44 Commits

Author SHA1 Message Date
Jeremy Reizenstein
e20cbe9b0e test fixes and lints
Summary:
- followup recent pyre change D63415925
- make tests remove temporary files
- weights_only=True in torch.load
- lint fixes

3 test fixes from VRehnberg in https://github.com/facebookresearch/pytorch3d/issues/1914
- imageio channels fix
- frozen decorator in test_config
- load_blobs positional

Reviewed By: MichaelRamamonjisoa

Differential Revision: D66162167

fbshipit-source-id: 7737e174691b62f1708443a4fae07343cec5bfeb
2024-11-20 09:15:51 -08:00
Amethyst Reese
3da7703c5a apply Black 2024 style in fbcode (4/16)
Summary:
Formats the covered files with pyfmt.

paintitblack

Reviewed By: aleivag

Differential Revision: D54447727

fbshipit-source-id: 8844b1caa08de94d04ac4df3c768dbf8c865fd2f
2024-03-02 17:31:19 -08:00
Jeremy Reizenstein
009a3d3b3c projects/nerf subsampling fix for newish pytorch #1441
Summary: Fix for https://github.com/facebookresearch/pytorch3d/issues/1441 where we were indexing with a tensor on the wrong device.

Reviewed By: shapovalov

Differential Revision: D46276449

fbshipit-source-id: 7750ed45ffecefa5d291fd1eadfe515310c2cf0d
2023-06-16 04:33:24 -07:00
Sergii Dymchenko
1530a66469 Update deprecated torch.symeig in vision/fair/pytorch3d/projects/nerf/nerf/eval_video_utils.py
Summary:
torch.symeig is deprecated for a long time and is being removed by https://github.com/pytorch/pytorch/pull/70988.

Created from CodeHub with https://fburl.com/edit-in-codehub

Reviewed By: bottler

Differential Revision: D39153103

fbshipit-source-id: 3a1397b6d86fb3e45e4777e06a4da3ee76591b32
2022-08-30 17:15:11 -07:00
Luca Di Grazia
a91f15f24e Incompatible variable type fixed (#1288)
Summary:
**"filename"**: "projects/nerf/nerf/implicit_function.py"
**"warning_type"**: "Incompatible variable type [9]",
**"warning_message"**: " input_skips is declared to have type `Tuple[int]` but is used as type `Tuple[]`.",
**"warning_line"**: 256,
**"fix"**: input_skips: Tuple[int,...] = ()

Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/1288

Reviewed By: kjchalup

Differential Revision: D38615188

Pulled By: bottler

fbshipit-source-id: a014344dd6cf2125f564f948a3c905ceb84cf994
2022-08-11 08:54:37 -07:00
John Reese
bef959c755 formatting changes from black 22.3.0
Summary:
Applies the black-fbsource codemod with the new build of pyfmt.

paintitblack

Reviewed By: lisroach

Differential Revision: D36324783

fbshipit-source-id: 280c09e88257e5e569ab729691165d8dedd767bc
2022-05-11 19:55:56 -07:00
Tim Hatch
34bbb3ad32 apply import merging for fbcode/vision/fair (2 of 2)
Summary:
Applies new import merging and sorting from µsort v1.0.

When merging imports, µsort will make a best-effort to move associated
comments to match merged elements, but there are known limitations due to
the diynamic nature of Python and developer tooling. These changes should
not produce any dangerous runtime changes, but may require touch-ups to
satisfy linters and other tooling.

Note that µsort uses case-insensitive, lexicographical sorting, which
results in a different ordering compared to isort. This provides a more
consistent sorting order, matching the case-insensitive order used when
sorting import statements by module name, and ensures that "frog", "FROG",
and "Frog" always sort next to each other.

For details on µsort's sorting and merging semantics, see the user guide:
https://usort.readthedocs.io/en/stable/guide.html#sorting

Reviewed By: bottler

Differential Revision: D35553814

fbshipit-source-id: be49bdb6a4c25264ff8d4db3a601f18736d17be1
2022-04-13 06:51:33 -07:00
Jeremy Reizenstein
2a1de3b610 move LinearWithRepeat to pytorch3d
Summary: Move this simple layer from the NeRF project into pytorch3d.

Reviewed By: shapovalov

Differential Revision: D34126972

fbshipit-source-id: a9c6d6c3c1b662c1b844ea5d1b982007d4df83e6
2022-02-14 04:52:30 -08:00
Jeremy Reizenstein
67778caee8 avoid deprecated raysamplers
Summary: Migrate away from NDCGridRaysampler and GridRaysampler to their more flexible replacements.

Reviewed By: patricklabatut

Differential Revision: D33281584

fbshipit-source-id: 65f8702e700a32d38f7cd6bda3924bb1707a0633
2022-01-24 10:52:23 -08:00
Jeremy Reizenstein
3eb4233844 New raysamplers
Summary: New MultinomialRaysampler succeeds GridRaysampler bringing masking and subsampling. Correspondingly, NDCMultinomialRaysampler succeeds NDCGridRaysampler.

Reviewed By: nikhilaravi, shapovalov

Differential Revision: D33256897

fbshipit-source-id: cd80ec6f35b110d1d20a75c62f4e889ba8fa5d45
2022-01-24 10:52:23 -08:00
Jeremy Reizenstein
9eeb456e82 Update license for company name
Summary: Update all FB license strings to the new format.

Reviewed By: patricklabatut

Differential Revision: D33403538

fbshipit-source-id: 97a4596c5c888f3c54f44456dc07e718a387a02c
2022-01-04 11:43:38 -08:00
Nikhila Ravi
52c71b8816 Update Harmonic embedding in NeRF
Summary: Removed harmonic embedding function from projects/nerf and changed import to be from core pytorch3d.

Reviewed By: patricklabatut

Differential Revision: D33142358

fbshipit-source-id: 3004247d50392dbd04ea72e9cd4bace0dc03606b
2021-12-21 15:05:33 -08:00
Jeremy Reizenstein
53d99671bd remove PyTorch 1.5 builds
Summary: PyTorch 1.6.0 came out on 28 Jul 2020. Stop builds for 1.5.0 and 1.5.1. Also update the news section of the README for recent releases.

Reviewed By: nikhilaravi

Differential Revision: D31442830

fbshipit-source-id: 20bdd8a07090776d0461240e71c6536d874615f6
2021-10-11 06:13:01 -07:00
Jeremy Reizenstein
c3d7808868 register_buffer compatibility
Summary: In D30349234 (1b8d86a104) we introduced persistent=False to some register_buffer calls, which depend on PyTorch 1.6. We go back to the old behaviour for PyTorch 1.5.

Reviewed By: nikhilaravi

Differential Revision: D30731327

fbshipit-source-id: ab02ef98ee87440ef02479b72f4872b562ab85b5
2021-09-09 07:37:57 -07:00
Jeremy Reizenstein
1b8d86a104 (breaking) image_size-agnostic GridRaySampler
Summary:
As suggested in #802. By not persisting the _xy_grid buffer, we can allow (in some cases) a model with one image_size to be loaded from a saved model which was trained at a different resolution.

Also avoid persisting _frequencies in HarmonicEmbedding for similar reasons.

BC-break: This will cause load_state_dict, in strict mode, to complain if you try to load an old model with the new code.

Reviewed By: patricklabatut

Differential Revision: D30349234

fbshipit-source-id: d6061d1e51c9f79a78d61a9f732c9a5dfadbbb47
2021-08-31 14:30:24 -07:00
Jeremy Reizenstein
1251446383 Use sample_pdf from PyTorch3D in NeRF
Summary:
Use PyTorch3D's new faster sample_pdf function instead of local Python implementation.

Also clarify deps for the Python implementation.

Reviewed By: gkioxari

Differential Revision: D30512109

fbshipit-source-id: 84cfdc00313fada37a6b29837de96f6a4646434f
2021-08-31 11:26:26 -07:00
Jeremy Reizenstein
b0dd0c8821 rename master branch to main
Summary: Change doc references to master branch to its new name main.

Reviewed By: nikhilaravi

Differential Revision: D30303018

fbshipit-source-id: cfdbb207dfe3366de7e0ca759ed56f4b8dd894d1
2021-08-16 04:06:53 -07:00
Yida Wang
5eec5e289e remove type error suppressions in nerf_data_module
Summary: Remove `pyre-fixme` and `pyre-ignore` and fix the type errors.

Reviewed By: kandluis

Differential Revision: D29899546

fbshipit-source-id: dc8314f314bbc8acc002b8dbf21013cf3bafe65d
2021-07-27 17:32:41 -07:00
Patrick Labatut
f593bfd3c2 More type annotations
Summary: More type annotations: device, shaders, pluggable I/O, stats in NeRF project, cameras, textures, etc...

Reviewed By: nikhilaravi

Differential Revision: D29327396

fbshipit-source-id: cdf0ceaaa010e22423088752688c8dd81f1acc3c
2021-06-25 19:56:25 -07:00
Patrick Labatut
64289a491d Annotate dunder functions
Summary: Annotate the (return type of the) following dunder functions across the codebase: `__init__()`, `__len__()`, `__getitem__()`

Reviewed By: nikhilaravi

Differential Revision: D29001801

fbshipit-source-id: 928d9e1c417ffe01ab8c0445311287786e997c7c
2021-06-24 15:19:16 -07:00
Patrick Labatut
af93f34834 License lint codebase
Summary: License lint codebase

Reviewed By: theschnitz

Differential Revision: D29001799

fbshipit-source-id: 5c59869911785b0181b1663bbf430bc8b7fb2909
2021-06-22 03:45:27 -07:00
Jeremy Reizenstein
f00ef66727 NeRF training: avoid caching unused visualization data.
Summary: If we are not visualizing the training with visdom, then there are a couple of outputs of the coarse rendering step which are not small and are returned by the renderer but never used. We don't need to bother transferring them to the CPU.

Reviewed By: nikhilaravi

Differential Revision: D28939958

fbshipit-source-id: 7e0d6681d6524f7fb57b6b20164580006120de80
2021-06-08 04:35:22 -07:00
Patrick Labatut
d76c00721c Remove explicit inheritance from object
Summary:
All classes implicitly inherit from `object` since Python 3, so remove unnecessary explicit inheritance.

From the [official documentation](https://docs.python.org/3/library/functions.html#object):

> `object` is a base for all classes.

Reviewed By: nikhilaravi

Differential Revision: D28942595

fbshipit-source-id: 466c0d19d8a93a6263e7ad734c3e87160cfa6066
2021-06-08 02:15:50 -07:00
Jeremy Reizenstein
280fed3c76 cuda streams for color/density in NeRF
Summary:
Inside the implicit function, the color and density calculations are independent and time is saved by putting them on separate streams.

(In fact, colors is slower than densities, and the raymarcher does some calculation with the densities before the colors. So theoretically we could go further and not join the streams together until the colors are actually needed. The code would be more complicated. But the profile suggests that the raymarcher is quick and so this wouldn't be expected to make a big difference.)

In inference, this might increase memory usage, so it isn't an obvious win. That is why I have added a flag.

Reviewed By: nikhilaravi

Differential Revision: D28648549

fbshipit-source-id: c087de80d8ccfce1dad3a13e71df2f305a36952e
2021-06-02 05:43:13 -07:00
Jeremy Reizenstein
f63e49d245 Let harmonic embedding layer include input (NeRF)
Summary: When harmonic embedding is used, we always cat its input onto its output before proceeding. Avoid an intermediate tensor by making the module do that for itself.

Reviewed By: davnov134

Differential Revision: D28185791

fbshipit-source-id: 98d92c94a918dd42e16cdadcaac71dabbc7de5c3
2021-06-02 05:43:13 -07:00
Jeremy Reizenstein
ab73f8c3fd LinearWithRepeat layer for NeRF
Summary:
Add custom layer to avoid repeating copied data for every ray position.

This should also save time in the backward pass because there are fewer multiplies with the weights.

Reviewed By: theschnitz

Differential Revision: D28382412

fbshipit-source-id: 1ba7356cd8520ebd598568ae503e47d31d3989eb
2021-06-02 05:43:13 -07:00
Jeremy Reizenstein
c9dea62162 gitignore for NeRF
Summary: Add gitignore file to ignore data and checkpoints in the NeRF project.

Reviewed By: nikhilaravi

Differential Revision: D28382413

fbshipit-source-id: 747d69f4353a76a28acde8ba26a896cb2278f976
2021-05-13 04:27:12 -07:00
Jeremy Reizenstein
097b0ef2c6 use no_grad for sample_pdf in NeRF project
Summary: We don't use gradents of sample_pdf. Here we disable gradient calculation around calling it, instead of calling detach later. There's a theoretical speedup, but mainly this enables using sample_pdf implementations which don't support gradients.

Reviewed By: nikhilaravi

Differential Revision: D28057284

fbshipit-source-id: 8a9d5e73f18b34e1e4291028008e02973023638d
2021-04-28 09:34:50 -07:00
David Novotny
4a9e294436 Updated readme with NeRF metrics, added a nicer gif
Summary: See title.

Reviewed By: nikhilaravi

Differential Revision: D27658290

fbshipit-source-id: 232550f04df4951f7f3d712047b39e510a2f4209
2021-04-14 09:20:47 -07:00
Jeremy Reizenstein
124bb5e391 spelling
Summary: Collection of spelling things, mostly in docs / tutorials.

Reviewed By: gkioxari

Differential Revision: D26101323

fbshipit-source-id: 652f62bc9d71a4ff872efa21141225e43191353a
2021-04-09 09:58:54 -07:00
Jeremy Reizenstein
5ac2f42184 test & compilation fixes
Summary:
Fixes mostly related to the "main" build on circleci.
-Avoid error to do with tuple copy from initializer_list which is `explicit` on old compiler.
-Add better reporting to copyright test.
-Move to PackedTensorAccessor64 from the deprecated PackedTensorAccessor
-Avoid some warnings about mismatched comparisons.

The "main" build is the only one that runs the test_build stuff. In that area
-Fix my bad copyright fix D26275931 (3463f418b8) / 965c9c
-Add test that all tutorials are valid json.

Reviewed By: nikhilaravi

Differential Revision: D26366466

fbshipit-source-id: c4ab8b7e6647987069f7cb7144aa6ab7c24bcdac
2021-02-11 11:06:08 -08:00
Jeremy Reizenstein
3463f418b8 Missing copyright
Summary: Fix missing copyright header in __init__.py file.

Reviewed By: davnov134

Differential Revision: D26275931

fbshipit-source-id: 965c9cf17383aa27d35d549754ebd99ae7c25f47
2021-02-05 05:28:20 -08:00
David Novotny
3c0b31a2b8 Readme fixes + pytorch3d nerf logo gif
Summary: Fixes to Readme in NeRF

Reviewed By: nikhilaravi

Differential Revision: D26205882

fbshipit-source-id: 73e4d727f6e6c96fa7af7d2b917acdeaf990091c
2021-02-03 15:37:37 -08:00
David Novotny
51de308b80 Readme
Summary: Adds the readme file.

Reviewed By: nikhilaravi

Differential Revision: D25684459

fbshipit-source-id: f1aaa621a2a67c98d5fcfe33fe9bbfea8f95b537
2021-02-02 05:45:41 -08:00
David Novotny
2628fb56f2 Testing script
Summary: Implements the test script of NeRF.

Reviewed By: nikhilaravi

Differential Revision: D25684450

fbshipit-source-id: 739169d9df706795814912bb9a15e2e65ac92df8
2021-02-02 05:45:41 -08:00
David Novotny
dc28b615ae Generation of test camera trajectories
Summary: Implements methods for generating trajectories of test cameras.

Reviewed By: nikhilaravi

Differential Revision: D26100869

fbshipit-source-id: cf2b61a34d4c749cd8cba881e97f6c388e57d1f8
2021-02-02 05:45:41 -08:00
David Novotny
9751f1f185 Main training script
Summary: Implements the training script of NeRF.

Reviewed By: nikhilaravi

Differential Revision: D25684439

fbshipit-source-id: 8b19b6dc282eb6bf6e46ec4476bb0f13a84c90dd
2021-02-02 05:45:40 -08:00
David Novotny
5b74911881 NeRF training stats logger.
Summary: Implements the `Stats` class that handles logging of the training statistics.

Reviewed By: nikhilaravi

Differential Revision: D25684430

fbshipit-source-id: 920a1c65917ab5d047988494d92173da60cfd64b
2021-02-02 05:45:40 -08:00
David Novotny
0666848338 NeRF dataloader.
Summary: Implements the dataloader for NeRF.

Reviewed By: nikhilaravi

Differential Revision: D25684424

fbshipit-source-id: 4f7092ce23135bd418186833a087e243433babc7
2021-02-02 05:45:40 -08:00
David Novotny
eb908487b8 Radiance field renderer
Summary: Implements the main NeRF model class that controls the radiance field and its renderer

Reviewed By: nikhilaravi

Differential Revision: D25684419

fbshipit-source-id: fae45572daa6748c6234bd212f3e68110f778238
2021-02-02 05:45:39 -08:00
David Novotny
bf633ab556 Implicit function
Summary: Implements the radiance field function of NeRF

Reviewed By: nikhilaravi

Differential Revision: D25684413

fbshipit-source-id: 4bf6dd5d22e6134a09f7b9f314536ec16670f737
2021-02-02 05:45:39 -08:00
David Novotny
1e82341da7 Harmonic embedding
Summary: Implements the positional embedding of NeRF

Reviewed By: nikhilaravi

Differential Revision: D25684406

fbshipit-source-id: 9f3b657babacff48bd6a0497d7a859607ffa5f89
2021-02-02 05:45:39 -08:00
David Novotny
7cbda3ec17 NeRF Raysampler
Summary: Implements the NeRF raysampler.

Reviewed By: nikhilaravi

Differential Revision: D25684403

fbshipit-source-id: 616a60f047c79479f60a6a75d214f87cbfb06d28
2021-02-02 05:45:39 -08:00
David Novotny
fba419b7f7 NeRF Raymarcher
Summary: An initial NeRF diff which sets up the folder structure and implements the raymarching algorithm of NeRF.

Reviewed By: nikhilaravi

Differential Revision: D25623990

fbshipit-source-id: ac6b05a9b866358bd4bbf44858f06859d8a6ebd1
2021-02-02 05:45:39 -08:00