Add files using upload-large-folder tool
Browse files- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/.github/ISSUE_TEMPLATE/bugs.md +30 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/.github/ISSUE_TEMPLATE/config.yml +1 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/base.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/decoding_functions.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/idr_feature_field.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/index.rst +13 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/neural_radiance_field.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/scene_representation_networks.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/voxel_grid.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/voxel_grid_implicit_function.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/renderer/raymarcher.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/renderer/rgb_net.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/renderer/sdf_renderer.rst +9 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/.clang-format +85 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/README.md +183 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/README.md +455 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/__init__.py +7 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/experiment.py +304 -0
- project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/visualize_reconstruction.py +160 -0
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/.github/ISSUE_TEMPLATE/bugs.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: "🐛 Bugs / Unexpected behaviors"
|
| 3 |
+
about: Please report unexpected behaviors or bugs in PyTorch3D.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
If you do not know the root cause of the problem / bug, and wish someone to help you, please
|
| 8 |
+
post according to this template:
|
| 9 |
+
|
| 10 |
+
## 🐛 Bugs / Unexpected behaviors
|
| 11 |
+
<!-- A clear and concise description of the issue -->
|
| 12 |
+
|
| 13 |
+
NOTE: Please look at the existing list of Issues tagged with the label ['bug`](https://github.com/facebookresearch/pytorch3d/issues?q=label%3Abug). **Only open a new issue if this bug has not already been reported. If an issue already exists, please comment there instead.**.
|
| 14 |
+
|
| 15 |
+
## Instructions To Reproduce the Issue:
|
| 16 |
+
|
| 17 |
+
Please include the following (depending on what the issue is):
|
| 18 |
+
|
| 19 |
+
1. Any changes you made (`git diff`) or code you wrote
|
| 20 |
+
```
|
| 21 |
+
<put diff or code here>
|
| 22 |
+
```
|
| 23 |
+
2. The exact command(s) you ran:
|
| 24 |
+
3. What you observed (including the full logs):
|
| 25 |
+
```
|
| 26 |
+
<put logs here>
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
Please also simplify the steps as much as possible so they do not require additional resources to
|
| 30 |
+
run, such as a private dataset.
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: false
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/.github/ISSUE_TEMPLATE/feature_request.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: "\U0001F680 Feature Request"
|
| 3 |
+
about: Submit a proposal/request for a new PyTorch3D feature
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 🚀 Feature
|
| 8 |
+
<!-- A clear and concise description of the feature proposal -->
|
| 9 |
+
|
| 10 |
+
NOTE: Please look at the existing list of Issues tagged with the label ['enhancement`](https://github.com/facebookresearch/pytorch3d/issues?q=label%3Aenhancement). **Only open a new issue if you do not see your feature request there**.
|
| 11 |
+
|
| 12 |
+
## Motivation
|
| 13 |
+
|
| 14 |
+
<!-- Please outline the motivation for the proposal.
|
| 15 |
+
e.g. It would be great if I could do [...], I'm always frustrated when [...]. If this is related to another GitHub issue, please link here too -->
|
| 16 |
+
|
| 17 |
+
## Pitch
|
| 18 |
+
|
| 19 |
+
<!-- A clear and concise description, optionally with code examples showing the functionality you want. -->
|
| 20 |
+
|
| 21 |
+
NOTE: we only consider adding new features if they are useful for many users.
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/base.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.base
|
| 2 |
+
===================================================
|
| 3 |
+
|
| 4 |
+
base
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.base
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/decoding_functions.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.decoding_functions
|
| 2 |
+
=================================================================
|
| 3 |
+
|
| 4 |
+
decoding_functions
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.decoding_functions
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/idr_feature_field.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.idr_feature_field
|
| 2 |
+
================================================================
|
| 3 |
+
|
| 4 |
+
idr_feature_field
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.idr_feature_field
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/index.rst
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function
|
| 2 |
+
==============================================
|
| 3 |
+
|
| 4 |
+
.. toctree::
|
| 5 |
+
|
| 6 |
+
base
|
| 7 |
+
decoding_functions
|
| 8 |
+
idr_feature_field
|
| 9 |
+
neural_radiance_field
|
| 10 |
+
scene_representation_networks
|
| 11 |
+
utils
|
| 12 |
+
voxel_grid
|
| 13 |
+
voxel_grid_implicit_function
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/neural_radiance_field.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.neural_radiance_field
|
| 2 |
+
====================================================================
|
| 3 |
+
|
| 4 |
+
neural_radiance_field
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.neural_radiance_field
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/scene_representation_networks.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.scene_representation_networks
|
| 2 |
+
============================================================================
|
| 3 |
+
|
| 4 |
+
scene_representation_networks
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.scene_representation_networks
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/voxel_grid.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.voxel_grid
|
| 2 |
+
=========================================================
|
| 3 |
+
|
| 4 |
+
voxel_grid
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.voxel_grid
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/implicit_function/voxel_grid_implicit_function.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.implicit_function.voxel_grid_implicit_function
|
| 2 |
+
===========================================================================
|
| 3 |
+
|
| 4 |
+
voxel_grid_implicit_function
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.implicit_function.voxel_grid_implicit_function
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/renderer/raymarcher.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.renderer.raymarcher
|
| 2 |
+
================================================
|
| 3 |
+
|
| 4 |
+
raymarcher
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.renderer.raymarcher
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/renderer/rgb_net.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.renderer.rgb_net
|
| 2 |
+
=============================================
|
| 3 |
+
|
| 4 |
+
rgb_net
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.renderer.rgb_net
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/extern/pytorch3d/docs/modules/implicitron/models/renderer/sdf_renderer.rst
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pytorch3d.implicitron.models.renderer.sdf_renderer
|
| 2 |
+
==================================================
|
| 3 |
+
|
| 4 |
+
sdf_renderer
|
| 5 |
+
|
| 6 |
+
.. automodule:: pytorch3d.implicitron.models.renderer.sdf_renderer
|
| 7 |
+
:members:
|
| 8 |
+
:undoc-members:
|
| 9 |
+
:show-inheritance:
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/.clang-format
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AccessModifierOffset: -1
|
| 2 |
+
AlignAfterOpenBracket: AlwaysBreak
|
| 3 |
+
AlignConsecutiveAssignments: false
|
| 4 |
+
AlignConsecutiveDeclarations: false
|
| 5 |
+
AlignEscapedNewlinesLeft: true
|
| 6 |
+
AlignOperands: false
|
| 7 |
+
AlignTrailingComments: false
|
| 8 |
+
AllowAllParametersOfDeclarationOnNextLine: false
|
| 9 |
+
AllowShortBlocksOnASingleLine: false
|
| 10 |
+
AllowShortCaseLabelsOnASingleLine: false
|
| 11 |
+
AllowShortFunctionsOnASingleLine: Empty
|
| 12 |
+
AllowShortIfStatementsOnASingleLine: false
|
| 13 |
+
AllowShortLoopsOnASingleLine: false
|
| 14 |
+
AlwaysBreakAfterReturnType: None
|
| 15 |
+
AlwaysBreakBeforeMultilineStrings: true
|
| 16 |
+
AlwaysBreakTemplateDeclarations: true
|
| 17 |
+
BinPackArguments: false
|
| 18 |
+
BinPackParameters: false
|
| 19 |
+
BraceWrapping:
|
| 20 |
+
AfterClass: false
|
| 21 |
+
AfterControlStatement: false
|
| 22 |
+
AfterEnum: false
|
| 23 |
+
AfterFunction: false
|
| 24 |
+
AfterNamespace: false
|
| 25 |
+
AfterObjCDeclaration: false
|
| 26 |
+
AfterStruct: false
|
| 27 |
+
AfterUnion: false
|
| 28 |
+
BeforeCatch: false
|
| 29 |
+
BeforeElse: false
|
| 30 |
+
IndentBraces: false
|
| 31 |
+
BreakBeforeBinaryOperators: None
|
| 32 |
+
BreakBeforeBraces: Attach
|
| 33 |
+
BreakBeforeTernaryOperators: true
|
| 34 |
+
BreakConstructorInitializersBeforeComma: false
|
| 35 |
+
BreakAfterJavaFieldAnnotations: false
|
| 36 |
+
BreakStringLiterals: false
|
| 37 |
+
ColumnLimit: 80
|
| 38 |
+
CommentPragmas: '^ IWYU pragma:'
|
| 39 |
+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
| 40 |
+
ConstructorInitializerIndentWidth: 4
|
| 41 |
+
ContinuationIndentWidth: 4
|
| 42 |
+
Cpp11BracedListStyle: true
|
| 43 |
+
DerivePointerAlignment: false
|
| 44 |
+
DisableFormat: false
|
| 45 |
+
ForEachMacros: [ FOR_EACH, FOR_EACH_R, FOR_EACH_RANGE, ]
|
| 46 |
+
IncludeCategories:
|
| 47 |
+
- Regex: '^<.*\.h(pp)?>'
|
| 48 |
+
Priority: 1
|
| 49 |
+
- Regex: '^<.*'
|
| 50 |
+
Priority: 2
|
| 51 |
+
- Regex: '.*'
|
| 52 |
+
Priority: 3
|
| 53 |
+
IndentCaseLabels: true
|
| 54 |
+
IndentWidth: 2
|
| 55 |
+
IndentWrappedFunctionNames: false
|
| 56 |
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
| 57 |
+
MacroBlockBegin: ''
|
| 58 |
+
MacroBlockEnd: ''
|
| 59 |
+
MaxEmptyLinesToKeep: 1
|
| 60 |
+
NamespaceIndentation: None
|
| 61 |
+
ObjCBlockIndentWidth: 2
|
| 62 |
+
ObjCSpaceAfterProperty: false
|
| 63 |
+
ObjCSpaceBeforeProtocolList: false
|
| 64 |
+
PenaltyBreakBeforeFirstCallParameter: 1
|
| 65 |
+
PenaltyBreakComment: 300
|
| 66 |
+
PenaltyBreakFirstLessLess: 120
|
| 67 |
+
PenaltyBreakString: 1000
|
| 68 |
+
PenaltyExcessCharacter: 1000000
|
| 69 |
+
PenaltyReturnTypeOnItsOwnLine: 200
|
| 70 |
+
PointerAlignment: Left
|
| 71 |
+
ReflowComments: true
|
| 72 |
+
SortIncludes: true
|
| 73 |
+
SpaceAfterCStyleCast: false
|
| 74 |
+
SpaceBeforeAssignmentOperators: true
|
| 75 |
+
SpaceBeforeParens: ControlStatements
|
| 76 |
+
SpaceInEmptyParentheses: false
|
| 77 |
+
SpacesBeforeTrailingComments: 1
|
| 78 |
+
SpacesInAngles: false
|
| 79 |
+
SpacesInContainerLiterals: true
|
| 80 |
+
SpacesInCStyleCastParentheses: false
|
| 81 |
+
SpacesInParentheses: false
|
| 82 |
+
SpacesInSquareBrackets: false
|
| 83 |
+
Standard: Cpp11
|
| 84 |
+
TabWidth: 8
|
| 85 |
+
UseTab: Never
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/pytorch3dlogo.png" width="900"/>
|
| 2 |
+
|
| 3 |
+
[](https://circleci.com/gh/facebookresearch/pytorch3d)
|
| 4 |
+
[](https://anaconda.org/pytorch3d/pytorch3d)
|
| 5 |
+
|
| 6 |
+
# Introduction
|
| 7 |
+
|
| 8 |
+
PyTorch3D provides efficient, reusable components for 3D Computer Vision research with [PyTorch](https://pytorch.org).
|
| 9 |
+
|
| 10 |
+
Key features include:
|
| 11 |
+
|
| 12 |
+
- Data structure for storing and manipulating triangle meshes
|
| 13 |
+
- Efficient operations on triangle meshes (projective transformations, graph convolution, sampling, loss functions)
|
| 14 |
+
- A differentiable mesh renderer
|
| 15 |
+
- Implicitron, see [its README](projects/implicitron_trainer), a framework for new-view synthesis via implicit representations. ([blog post](https://ai.facebook.com/blog/implicitron-a-new-modular-extensible-framework-for-neural-implicit-representations-in-pytorch3d/))
|
| 16 |
+
|
| 17 |
+
PyTorch3D is designed to integrate smoothly with deep learning methods for predicting and manipulating 3D data.
|
| 18 |
+
For this reason, all operators in PyTorch3D:
|
| 19 |
+
|
| 20 |
+
- Are implemented using PyTorch tensors
|
| 21 |
+
- Can handle minibatches of hetereogenous data
|
| 22 |
+
- Can be differentiated
|
| 23 |
+
- Can utilize GPUs for acceleration
|
| 24 |
+
|
| 25 |
+
Within FAIR, PyTorch3D has been used to power research projects such as [Mesh R-CNN](https://arxiv.org/abs/1906.02739).
|
| 26 |
+
|
| 27 |
+
See our [blog post](https://ai.facebook.com/blog/-introducing-pytorch3d-an-open-source-library-for-3d-deep-learning/) to see more demos and learn about PyTorch3D.
|
| 28 |
+
|
| 29 |
+
## Installation
|
| 30 |
+
|
| 31 |
+
For detailed instructions refer to [INSTALL.md](INSTALL.md).
|
| 32 |
+
|
| 33 |
+
## License
|
| 34 |
+
|
| 35 |
+
PyTorch3D is released under the [BSD License](LICENSE).
|
| 36 |
+
|
| 37 |
+
## Tutorials
|
| 38 |
+
|
| 39 |
+
Get started with PyTorch3D by trying one of the tutorial notebooks.
|
| 40 |
+
|
| 41 |
+
|<img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/dolphin_deform.gif" width="310"/>|<img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/bundle_adjust.gif" width="310"/>|
|
| 42 |
+
|:-----------------------------------------------------------------------------------------------------------:|:--------------------------------------------------:|
|
| 43 |
+
| [Deform a sphere mesh to dolphin](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb)| [Bundle adjustment](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/bundle_adjustment.ipynb) |
|
| 44 |
+
|
| 45 |
+
| <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/render_textured_mesh.gif" width="310"/> | <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/camera_position_teapot.gif" width="310" height="310"/>
|
| 46 |
+
|:------------------------------------------------------------:|:--------------------------------------------------:|
|
| 47 |
+
| [Render textured meshes](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/render_textured_meshes.ipynb)| [Camera position optimization](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb)|
|
| 48 |
+
|
| 49 |
+
| <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/pointcloud_render.png" width="310"/> | <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/cow_deform.gif" width="310" height="310"/>
|
| 50 |
+
|:------------------------------------------------------------:|:--------------------------------------------------:|
|
| 51 |
+
| [Render textured pointclouds](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/render_colored_points.ipynb)| [Fit a mesh with texture](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/fit_textured_mesh.ipynb)|
|
| 52 |
+
|
| 53 |
+
| <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/densepose_render.png" width="310"/> | <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/shapenet_render.png" width="310" height="310"/>
|
| 54 |
+
|:------------------------------------------------------------:|:--------------------------------------------------:|
|
| 55 |
+
| [Render DensePose data](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/render_densepose.ipynb)| [Load & Render ShapeNet data](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb)|
|
| 56 |
+
|
| 57 |
+
| <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/fit_textured_volume.gif" width="310"/> | <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/fit_nerf.gif" width="310" height="310"/>
|
| 58 |
+
|:------------------------------------------------------------:|:--------------------------------------------------:|
|
| 59 |
+
| [Fit Textured Volume](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/fit_textured_volume.ipynb)| [Fit A Simple Neural Radiance Field](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/fit_simple_neural_radiance_field.ipynb)|
|
| 60 |
+
|
| 61 |
+
| <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/fit_textured_volume.gif" width="310"/> | <img src="https://raw.githubusercontent.com/facebookresearch/pytorch3d/main/.github/implicitron_config.gif" width="310" height="310"/>
|
| 62 |
+
|:------------------------------------------------------------:|:--------------------------------------------------:|
|
| 63 |
+
| [Fit Textured Volume in Implicitron](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/implicitron_volumes.ipynb)| [Implicitron Config System](https://github.com/facebookresearch/pytorch3d/blob/main/docs/tutorials/implicitron_config_system.ipynb)|
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
## Documentation
|
| 70 |
+
|
| 71 |
+
Learn more about the API by reading the PyTorch3D [documentation](https://pytorch3d.readthedocs.org/).
|
| 72 |
+
|
| 73 |
+
We also have deep dive notes on several API components:
|
| 74 |
+
|
| 75 |
+
- [Heterogeneous Batching](https://github.com/facebookresearch/pytorch3d/tree/main/docs/notes/batching.md)
|
| 76 |
+
- [Mesh IO](https://github.com/facebookresearch/pytorch3d/tree/main/docs/notes/meshes_io.md)
|
| 77 |
+
- [Differentiable Rendering](https://github.com/facebookresearch/pytorch3d/tree/main/docs/notes/renderer_getting_started.md)
|
| 78 |
+
|
| 79 |
+
### Overview Video
|
| 80 |
+
|
| 81 |
+
We have created a short (~14 min) video tutorial providing an overview of the PyTorch3D codebase including several code examples. Click on the image below to watch the video on YouTube:
|
| 82 |
+
|
| 83 |
+
<a href="http://www.youtube.com/watch?v=Pph1r-x9nyY"><img src="http://img.youtube.com/vi/Pph1r-x9nyY/0.jpg" height="225" ></a>
|
| 84 |
+
|
| 85 |
+
## Development
|
| 86 |
+
|
| 87 |
+
We welcome new contributions to PyTorch3D and we will be actively maintaining this library! Please refer to [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for full instructions on how to run the code, tests and linter, and submit your pull requests.
|
| 88 |
+
|
| 89 |
+
## Development and Compatibility
|
| 90 |
+
|
| 91 |
+
- `main` branch: actively developed, without any guarantee, Anything can be broken at any time
|
| 92 |
+
- REMARK: this includes nightly builds which are built from `main`
|
| 93 |
+
- HINT: the commit history can help locate regressions or changes
|
| 94 |
+
- backward-compatibility between releases: no guarantee. Best efforts to communicate breaking changes and facilitate migration of code or data (incl. models).
|
| 95 |
+
|
| 96 |
+
## Contributors
|
| 97 |
+
|
| 98 |
+
PyTorch3D is written and maintained by the Facebook AI Research Computer Vision Team.
|
| 99 |
+
|
| 100 |
+
In alphabetical order:
|
| 101 |
+
|
| 102 |
+
* Amitav Baruah
|
| 103 |
+
* Steve Branson
|
| 104 |
+
* Krzysztof Chalupka
|
| 105 |
+
* Jiali Duan
|
| 106 |
+
* Luya Gao
|
| 107 |
+
* Georgia Gkioxari
|
| 108 |
+
* Taylor Gordon
|
| 109 |
+
* Justin Johnson
|
| 110 |
+
* Patrick Labatut
|
| 111 |
+
* Christoph Lassner
|
| 112 |
+
* Wan-Yen Lo
|
| 113 |
+
* David Novotny
|
| 114 |
+
* Nikhila Ravi
|
| 115 |
+
* Jeremy Reizenstein
|
| 116 |
+
* Dave Schnizlein
|
| 117 |
+
* Roman Shapovalov
|
| 118 |
+
* Olivia Wiles
|
| 119 |
+
|
| 120 |
+
## Citation
|
| 121 |
+
|
| 122 |
+
If you find PyTorch3D useful in your research, please cite our tech report:
|
| 123 |
+
|
| 124 |
+
```bibtex
|
| 125 |
+
@article{ravi2020pytorch3d,
|
| 126 |
+
author = {Nikhila Ravi and Jeremy Reizenstein and David Novotny and Taylor Gordon
|
| 127 |
+
and Wan-Yen Lo and Justin Johnson and Georgia Gkioxari},
|
| 128 |
+
title = {Accelerating 3D Deep Learning with PyTorch3D},
|
| 129 |
+
journal = {arXiv:2007.08501},
|
| 130 |
+
year = {2020},
|
| 131 |
+
}
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
If you are using the pulsar backend for sphere-rendering (the `PulsarPointRenderer` or `pytorch3d.renderer.points.pulsar.Renderer`), please cite the tech report:
|
| 135 |
+
|
| 136 |
+
```bibtex
|
| 137 |
+
@article{lassner2020pulsar,
|
| 138 |
+
author = {Christoph Lassner and Michael Zollh\"ofer},
|
| 139 |
+
title = {Pulsar: Efficient Sphere-based Neural Rendering},
|
| 140 |
+
journal = {arXiv:2004.07484},
|
| 141 |
+
year = {2020},
|
| 142 |
+
}
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
## News
|
| 146 |
+
|
| 147 |
+
Please see below for a timeline of the codebase updates in reverse chronological order. We are sharing updates on the releases as well as research projects which are built with PyTorch3D. The changelogs for the releases are available under [`Releases`](https://github.com/facebookresearch/pytorch3d/releases), and the builds can be installed using `conda` as per the instructions in [INSTALL.md](INSTALL.md).
|
| 148 |
+
|
| 149 |
+
**[Oct 31st 2023]:** PyTorch3D [v0.7.5](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.7.5) released.
|
| 150 |
+
|
| 151 |
+
**[May 10th 2023]:** PyTorch3D [v0.7.4](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.7.4) released.
|
| 152 |
+
|
| 153 |
+
**[Apr 5th 2023]:** PyTorch3D [v0.7.3](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.7.3) released.
|
| 154 |
+
|
| 155 |
+
**[Dec 19th 2022]:** PyTorch3D [v0.7.2](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.7.2) released.
|
| 156 |
+
|
| 157 |
+
**[Oct 23rd 2022]:** PyTorch3D [v0.7.1](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.7.1) released.
|
| 158 |
+
|
| 159 |
+
**[Aug 10th 2022]:** PyTorch3D [v0.7.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.7.0) released with Implicitron and MeshRasterizerOpenGL.
|
| 160 |
+
|
| 161 |
+
**[Apr 28th 2022]:** PyTorch3D [v0.6.2](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.6.2) released
|
| 162 |
+
|
| 163 |
+
**[Dec 16th 2021]:** PyTorch3D [v0.6.1](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.6.1) released
|
| 164 |
+
|
| 165 |
+
**[Oct 6th 2021]:** PyTorch3D [v0.6.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.6.0) released
|
| 166 |
+
|
| 167 |
+
**[Aug 5th 2021]:** PyTorch3D [v0.5.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.5.0) released
|
| 168 |
+
|
| 169 |
+
**[Feb 9th 2021]:** PyTorch3D [v0.4.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.4.0) released with support for implicit functions, volume rendering and a [reimplementation of NeRF](https://github.com/facebookresearch/pytorch3d/tree/main/projects/nerf).
|
| 170 |
+
|
| 171 |
+
**[November 2nd 2020]:** PyTorch3D [v0.3.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.3.0) released, integrating the pulsar backend.
|
| 172 |
+
|
| 173 |
+
**[Aug 28th 2020]:** PyTorch3D [v0.2.5](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.2.5) released
|
| 174 |
+
|
| 175 |
+
**[July 17th 2020]:** PyTorch3D tech report published on ArXiv: https://arxiv.org/abs/2007.08501
|
| 176 |
+
|
| 177 |
+
**[April 24th 2020]:** PyTorch3D [v0.2.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.2.0) released
|
| 178 |
+
|
| 179 |
+
**[March 25th 2020]:** [SynSin](https://arxiv.org/abs/1912.08804) codebase released using PyTorch3D: https://github.com/facebookresearch/synsin
|
| 180 |
+
|
| 181 |
+
**[March 8th 2020]:** PyTorch3D [v0.1.1](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.1.1) bug fix release
|
| 182 |
+
|
| 183 |
+
**[Jan 23rd 2020]:** PyTorch3D [v0.1.0](https://github.com/facebookresearch/pytorch3d/releases/tag/v0.1.0) released. [Mesh R-CNN](https://arxiv.org/abs/1906.02739) codebase released: https://github.com/facebookresearch/meshrcnn
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/README.md
ADDED
|
@@ -0,0 +1,455 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Introduction
|
| 2 |
+
|
| 3 |
+
Implicitron is a PyTorch3D-based framework for new-view synthesis via modeling the neural-network based representations.
|
| 4 |
+
|
| 5 |
+
# License
|
| 6 |
+
|
| 7 |
+
Implicitron is distributed as part of PyTorch3D under the [BSD license](https://github.com/facebookresearch/pytorch3d/blob/main/LICENSE).
|
| 8 |
+
It includes code from the [NeRF](https://github.com/bmild/nerf), [SRN](http://github.com/vsitzmann/scene-representation-networks) and [IDR](http://github.com/lioryariv/idr) repos.
|
| 9 |
+
See [LICENSE-3RD-PARTY](https://github.com/facebookresearch/pytorch3d/blob/main/LICENSE-3RD-PARTY) for their licenses.
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# Installation
|
| 13 |
+
|
| 14 |
+
There are three ways to set up Implicitron, depending on the flexibility level required.
|
| 15 |
+
If you only want to train or evaluate models as they are implemented changing only the parameters, you can just install the package.
|
| 16 |
+
Implicitron also provides a flexible API that supports user-defined plug-ins;
|
| 17 |
+
if you want to re-implement some of the components without changing the high-level pipeline, you need to create a custom launcher script.
|
| 18 |
+
The most flexible option, though, is cloning PyTorch3D repo and building it from sources, which allows changing the code in arbitrary ways.
|
| 19 |
+
Below, we descibe all three options in more details.
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
## [Option 1] Running an executable from the package
|
| 23 |
+
|
| 24 |
+
This option allows you to use the code as is without changing the implementations.
|
| 25 |
+
Only configuration can be changed (see [Configuration system](#configuration-system)).
|
| 26 |
+
|
| 27 |
+
For this setup, install the dependencies and PyTorch3D from conda following [the guide](https://github.com/facebookresearch/pytorch3d/blob/master/INSTALL.md#1-install-with-cuda-support-from-anaconda-cloud-on-linux-only). Then, install implicitron-specific dependencies:
|
| 28 |
+
|
| 29 |
+
```shell
|
| 30 |
+
pip install "hydra-core>=1.1" visdom lpips matplotlib accelerate
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
Runner executable is available as `pytorch3d_implicitron_runner` shell command.
|
| 34 |
+
See [Running](#running) section below for examples of training and evaluation commands.
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
## [Option 2] Supporting custom implementations
|
| 38 |
+
|
| 39 |
+
To plug in custom implementations, for example, of renderer or implicit-function protocols, you need to create your own runner script and import the plug-in implementations there.
|
| 40 |
+
First, install PyTorch3D and Implicitron dependencies as described in the previous section.
|
| 41 |
+
Then, implement the custom script; copying `pytorch3d/projects/implicitron_trainer` is a good place to start.
|
| 42 |
+
See [Custom plugins](#custom-plugins) for more information on how to import implementations and enable them in the configs.
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
## [Option 3] Cloning PyTorch3D repo
|
| 46 |
+
|
| 47 |
+
This is the most flexible way to set up Implicitron as it allows changing the code directly.
|
| 48 |
+
It allows modifying the high-level rendering pipeline or implementing yet-unsupported loss functions.
|
| 49 |
+
Please follow the instructions to [install PyTorch3D from a local clone](https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md#2-install-from-a-local-clone).
|
| 50 |
+
Then, install Implicitron-specific dependencies:
|
| 51 |
+
|
| 52 |
+
```shell
|
| 53 |
+
pip install "hydra-core>=1.1" visdom lpips matplotlib accelerate
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
You are still encouraged to implement custom plugins as above where possible as it makes reusing the code easier.
|
| 57 |
+
The executable is located in `pytorch3d/projects/implicitron_trainer`.
|
| 58 |
+
|
| 59 |
+
> **_NOTE:_** Both `pytorch3d_implicitron_runner` and `pytorch3d_implicitron_visualizer`
|
| 60 |
+
executables (mentioned below) are not available when using local clone.
|
| 61 |
+
Instead users should use the python scripts `experiment.py` and `visualize_reconstruction.py` (see the [Running](Running) section below).
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
# Running
|
| 65 |
+
|
| 66 |
+
This section assumes that you use the executable provided by the installed package
|
| 67 |
+
(Option 1 / Option 2 in [#Installation](Installation) above),
|
| 68 |
+
i.e. `pytorch3d_implicitron_runner` and `pytorch3d_implicitron_visualizer` are available.
|
| 69 |
+
|
| 70 |
+
> **_NOTE:_** If the executables are not available (e.g. when using a local clone - Option 3 in [#Installation](Installation)),
|
| 71 |
+
users should directly use the `experiment.py` and `visualize_reconstruction.py` python scripts
|
| 72 |
+
which correspond to the executables as follows:
|
| 73 |
+
- `pytorch3d_implicitron_runner` corresponds to `<pytorch3d_root>/projects/implicitron_trainer/experiment.py`
|
| 74 |
+
- `pytorch3d_implicitron_visualizer` corresponds to `<pytorch3d_root>/projects/implicitron_trainer/visualize_reconstruction.py`
|
| 75 |
+
|
| 76 |
+
For instance, in order to directly execute training with the python script, users can call:
|
| 77 |
+
```shell
|
| 78 |
+
cd <pytorch3d_root>/projects/
|
| 79 |
+
python -m implicitron_trainer.experiment <args>`
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
If you have a custom `experiment.py` or `visualize_reconstruction.py` script
|
| 83 |
+
(as in the Option 2 [above](#Installation)), replace the executable with the path to your script.
|
| 84 |
+
|
| 85 |
+
## Training
|
| 86 |
+
|
| 87 |
+
To run training, pass a yaml config file, followed by a list of overridden arguments.
|
| 88 |
+
For example, to train NeRF on the first skateboard sequence from CO3D dataset, you can run:
|
| 89 |
+
```shell
|
| 90 |
+
dataset_args=data_source_ImplicitronDataSource_args.dataset_map_provider_JsonIndexDatasetMapProvider_args
|
| 91 |
+
pytorch3d_implicitron_runner --config-path ./configs/ --config-name repro_singleseq_nerf \
|
| 92 |
+
$dataset_args.dataset_root=<DATASET_ROOT> $dataset_args.category='skateboard' \
|
| 93 |
+
$dataset_args.test_restrict_sequence_id=0 test_when_finished=True exp_dir=<CHECKPOINT_DIR>
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
Here, `--config-path` points to the config path relative to `pytorch3d_implicitron_runner` location;
|
| 97 |
+
`--config-name` picks the config (in this case, `repro_singleseq_nerf.yaml`);
|
| 98 |
+
`test_when_finished` will launch evaluation script once training is finished.
|
| 99 |
+
Replace `<DATASET_ROOT>` with the location where the dataset in Implicitron format is stored
|
| 100 |
+
and `<CHECKPOINT_DIR>` with a directory where checkpoints will be dumped during training.
|
| 101 |
+
Other configuration parameters can be overridden in the same way.
|
| 102 |
+
See [Configuration system](#configuration-system) section for more information on this.
|
| 103 |
+
|
| 104 |
+
### Visdom logging
|
| 105 |
+
|
| 106 |
+
Note that the training script logs its progress to Visdom. Make sure to start a visdom server before the training commences:
|
| 107 |
+
```
|
| 108 |
+
python -m visdom.server
|
| 109 |
+
```
|
| 110 |
+
> In case a Visdom server is not started, the console will get flooded with `requests.exceptions.ConnectionError` errors signalling that a Visdom server is not available. Note that these errors <b>will NOT interrupt</b> the program and the training will still continue without issues.
|
| 111 |
+
|
| 112 |
+
## Evaluation
|
| 113 |
+
|
| 114 |
+
To run evaluation on the latest checkpoint after (or during) training, simply add `eval_only=True` to your training command.
|
| 115 |
+
|
| 116 |
+
E.g. for executing the evaluation on the NeRF skateboard sequence, you can run:
|
| 117 |
+
```shell
|
| 118 |
+
dataset_args=data_source_ImplicitronDataSource_args.dataset_map_provider_JsonIndexDatasetMapProvider_args
|
| 119 |
+
pytorch3d_implicitron_runner --config-path ./configs/ --config-name repro_singleseq_nerf \
|
| 120 |
+
$dataset_args.dataset_root=<CO3D_DATASET_ROOT> $dataset_args.category='skateboard' \
|
| 121 |
+
$dataset_args.test_restrict_sequence_id=0 exp_dir=<CHECKPOINT_DIR> eval_only=True
|
| 122 |
+
```
|
| 123 |
+
Evaluation prints the metrics to `stdout` and dumps them to a json file in `exp_dir`.
|
| 124 |
+
|
| 125 |
+
## Visualisation
|
| 126 |
+
|
| 127 |
+
The script produces a video of renders by a trained model assuming a pre-defined camera trajectory.
|
| 128 |
+
In order for it to work, `ffmpeg` needs to be installed:
|
| 129 |
+
|
| 130 |
+
```shell
|
| 131 |
+
conda install ffmpeg
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
Here is an example of calling the script:
|
| 135 |
+
```shell
|
| 136 |
+
pytorch3d_implicitron_visualizer exp_dir=<CHECKPOINT_DIR> \
|
| 137 |
+
visdom_show_preds=True n_eval_cameras=40 render_size="[64,64]" video_size="[256,256]"
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
The argument `n_eval_cameras` sets the number of renderring viewpoints sampled on a trajectory, which defaults to a circular fly-around;
|
| 141 |
+
`render_size` sets the size of a render passed to the model, which can be resized to `video_size` before writing.
|
| 142 |
+
|
| 143 |
+
Rendered videos of images, masks, and depth maps will be saved to `<CHECKPOINT_DIR>/video`.
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
# Configuration system
|
| 147 |
+
|
| 148 |
+
We use hydra and OmegaConf to parse the configs.
|
| 149 |
+
The config schema and default values are defined by the dataclasses implementing the modules.
|
| 150 |
+
More specifically, if a class derives from `Configurable`, its fields can be set in config yaml files or overridden in CLI.
|
| 151 |
+
For example, `GenericModel` has a field `render_image_width` with the default value 400.
|
| 152 |
+
If it is specified in the yaml config file or in CLI command, the new value will be used.
|
| 153 |
+
|
| 154 |
+
Configurables can form hierarchies.
|
| 155 |
+
For example, `GenericModel` has a field `raysampler: RaySampler`, which is also Configurable.
|
| 156 |
+
In the config, inner parameters can be propagated using `_args` postfix, e.g. to change `raysampler.n_pts_per_ray_training` (the number of sampled points per ray), the node `raysampler_args.n_pts_per_ray_training` should be specified.
|
| 157 |
+
|
| 158 |
+
### Top-level configuration class: `Experiment`
|
| 159 |
+
|
| 160 |
+
<b>The root of the hierarchy is defined by `Experiment` Configurable in `<pytorch3d_root>/projects/implicitron_trainer/experiment.py`.</b>
|
| 161 |
+
|
| 162 |
+
It has top-level fields like `seed`, which seeds the random number generator.
|
| 163 |
+
Additionally, it has non-leaf nodes like `model_factory_ImplicitronModelFactory_args.model_GenericModel_args`, which dispatches the config parameters to `GenericModel`.
|
| 164 |
+
Thus, changing the model parameters may be achieved in two ways: either by editing the config file, e.g.
|
| 165 |
+
```yaml
|
| 166 |
+
model_factory_ImplicitronModelFactory_args:
|
| 167 |
+
model_GenericModel_args:
|
| 168 |
+
render_image_width: 800
|
| 169 |
+
raysampler_args:
|
| 170 |
+
n_pts_per_ray_training: 128
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
or, equivalently, by adding the following to `pytorch3d_implicitron_runner` arguments:
|
| 174 |
+
|
| 175 |
+
```shell
|
| 176 |
+
model_args=model_factory_ImplicitronModelFactory_args.model_GenericModel_args
|
| 177 |
+
$model_args.render_image_width=800 $model_args.raysampler_args.n_pts_per_ray_training=128
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
See the documentation in `pytorch3d/implicitron/tools/config.py` for more details.
|
| 181 |
+
|
| 182 |
+
## Replaceable implementations
|
| 183 |
+
|
| 184 |
+
Sometimes changing the model parameters does not provide enough flexibility, and you want to provide a new implementation for a building block.
|
| 185 |
+
The configuration system also supports it!
|
| 186 |
+
Abstract classes like `BaseRenderer` derive from `ReplaceableBase` instead of `Configurable`.
|
| 187 |
+
This means that other Configurables can refer to them using the base type, while the specific implementation is chosen in the config using `_class_type`-postfixed node.
|
| 188 |
+
In that case, `_args` node name has to include the implementation type.
|
| 189 |
+
More specifically, to change renderer settings, the config will look like this:
|
| 190 |
+
```yaml
|
| 191 |
+
model_factory_ImplicitronModelFactory_args:
|
| 192 |
+
model_GenericModel_args:
|
| 193 |
+
renderer_class_type: LSTMRenderer
|
| 194 |
+
renderer_LSTMRenderer_args:
|
| 195 |
+
num_raymarch_steps: 10
|
| 196 |
+
hidden_size: 16
|
| 197 |
+
```
|
| 198 |
+
|
| 199 |
+
See the documentation in `pytorch3d/implicitron/tools/config.py` for more details on the configuration system.
|
| 200 |
+
|
| 201 |
+
## Custom plugins
|
| 202 |
+
|
| 203 |
+
If you have an idea for another implementation of a replaceable component, it can be plugged in without changing the core code.
|
| 204 |
+
For that, you need to set up Implicitron through option 2 or 3 above.
|
| 205 |
+
Let's say you want to implement a renderer that accumulates opacities similar to an X-ray machine.
|
| 206 |
+
First, create a module `x_ray_renderer.py` with a class deriving from `BaseRenderer`:
|
| 207 |
+
|
| 208 |
+
```python
|
| 209 |
+
from pytorch3d.implicitron.tools.config import registry
|
| 210 |
+
|
| 211 |
+
@registry.register
|
| 212 |
+
class XRayRenderer(BaseRenderer, torch.nn.Module):
|
| 213 |
+
n_pts_per_ray: int = 64
|
| 214 |
+
|
| 215 |
+
def __post_init__(self):
|
| 216 |
+
# custom initialization
|
| 217 |
+
|
| 218 |
+
def forward(
|
| 219 |
+
self,
|
| 220 |
+
ray_bundle,
|
| 221 |
+
implicit_functions=[],
|
| 222 |
+
evaluation_mode: EvaluationMode = EvaluationMode.EVALUATION,
|
| 223 |
+
**kwargs,
|
| 224 |
+
) -> RendererOutput:
|
| 225 |
+
...
|
| 226 |
+
```
|
| 227 |
+
|
| 228 |
+
Please note `@registry.register` decorator that registers the plug-in as an implementation of `Renderer`.
|
| 229 |
+
IMPORTANT: In order for it to run, the class (or its enclosing module) has to be imported in your launch script.
|
| 230 |
+
Additionally, this has to be done before parsing the root configuration class `ExperimentConfig`.
|
| 231 |
+
Simply add `import .x_ray_renderer` in the beginning of `experiment.py`.
|
| 232 |
+
|
| 233 |
+
After that, you should be able to change the config with:
|
| 234 |
+
```yaml
|
| 235 |
+
model_factory_ImplicitronModelFactory_args:
|
| 236 |
+
model_GenericModel_args:
|
| 237 |
+
renderer_class_type: XRayRenderer
|
| 238 |
+
renderer_XRayRenderer_args:
|
| 239 |
+
n_pts_per_ray: 128
|
| 240 |
+
```
|
| 241 |
+
|
| 242 |
+
to replace the implementation and potentially override the parameters.
|
| 243 |
+
|
| 244 |
+
# Code and config structure
|
| 245 |
+
|
| 246 |
+
The main object for this trainer loop is `Experiment`. It has four top-level replaceable components.
|
| 247 |
+
|
| 248 |
+
* `data_source`: This is a `DataSourceBase` which defaults to `ImplicitronDataSource`.
|
| 249 |
+
It constructs the data sets and dataloaders.
|
| 250 |
+
* `model_factory`: This is a `ModelFactoryBase` which defaults to `ImplicitronModelFactory`.
|
| 251 |
+
It constructs the model, which is usually an instance of `OverfitModel` (for NeRF-style training with overfitting to one scene) or `GenericModel` (that is able to generalize to multiple scenes by NeRFormer-style conditioning on other scene views), and can load its weights from a checkpoint.
|
| 252 |
+
* `optimizer_factory`: This is an `OptimizerFactoryBase` which defaults to `ImplicitronOptimizerFactory`.
|
| 253 |
+
It constructs the optimizer and can load its weights from a checkpoint.
|
| 254 |
+
* `training_loop`: This is a `TrainingLoopBase` which defaults to `ImplicitronTrainingLoop` and defines the main training loop.
|
| 255 |
+
|
| 256 |
+
As per above, the config structure is parsed automatically from the module hierarchy.
|
| 257 |
+
In particular, for ImplicitronModelFactory with generic model, model parameters are contained in the `model_factory_ImplicitronModelFactory_args.model_GenericModel_args` node, and dataset parameters in `data_source_ImplicitronDataSource_args` node.
|
| 258 |
+
|
| 259 |
+
Here is the class structure of GenericModel (single-line edges show aggregation, while double lines show available implementations):
|
| 260 |
+
```
|
| 261 |
+
model_GenericModel_args: GenericModel
|
| 262 |
+
└-- global_encoder_*_args: GlobalEncoderBase
|
| 263 |
+
╘== SequenceAutodecoder
|
| 264 |
+
└-- autodecoder_args: Autodecoder
|
| 265 |
+
╘== HarmonicTimeEncoder
|
| 266 |
+
└-- raysampler_*_args: RaySampler
|
| 267 |
+
╘== AdaptiveRaysampler
|
| 268 |
+
╘== NearFarRaysampler
|
| 269 |
+
└-- renderer_*_args: BaseRenderer
|
| 270 |
+
╘== MultiPassEmissionAbsorptionRenderer
|
| 271 |
+
╘== LSTMRenderer
|
| 272 |
+
╘== SignedDistanceFunctionRenderer
|
| 273 |
+
└-- ray_tracer_args: RayTracing
|
| 274 |
+
└-- ray_normal_coloring_network_args: RayNormalColoringNetwork
|
| 275 |
+
└-- implicit_function_*_args: ImplicitFunctionBase
|
| 276 |
+
╘== NeuralRadianceFieldImplicitFunction
|
| 277 |
+
╘== SRNImplicitFunction
|
| 278 |
+
└-- raymarch_function_args: SRNRaymarchFunction
|
| 279 |
+
└-- pixel_generator_args: SRNPixelGenerator
|
| 280 |
+
╘== SRNHyperNetImplicitFunction
|
| 281 |
+
└-- hypernet_args: SRNRaymarchHyperNet
|
| 282 |
+
└-- pixel_generator_args: SRNPixelGenerator
|
| 283 |
+
╘== IdrFeatureField
|
| 284 |
+
└-- image_feature_extractor_*_args: FeatureExtractorBase
|
| 285 |
+
╘== ResNetFeatureExtractor
|
| 286 |
+
└-- view_pooler_args: ViewPooler
|
| 287 |
+
└-- view_sampler_args: ViewSampler
|
| 288 |
+
└-- feature_aggregator_*_args: FeatureAggregatorBase
|
| 289 |
+
╘== IdentityFeatureAggregator
|
| 290 |
+
╘== AngleWeightedIdentityFeatureAggregator
|
| 291 |
+
╘== AngleWeightedReductionFeatureAggregator
|
| 292 |
+
╘== ReductionFeatureAggregator
|
| 293 |
+
```
|
| 294 |
+
|
| 295 |
+
Here is the class structure of OverfitModel:
|
| 296 |
+
|
| 297 |
+
```
|
| 298 |
+
model_OverfitModel_args: OverfitModel
|
| 299 |
+
└-- raysampler_*_args: RaySampler
|
| 300 |
+
╘== AdaptiveRaysampler
|
| 301 |
+
╘== NearFarRaysampler
|
| 302 |
+
└-- renderer_*_args: BaseRenderer
|
| 303 |
+
╘== MultiPassEmissionAbsorptionRenderer
|
| 304 |
+
╘== LSTMRenderer
|
| 305 |
+
╘== SignedDistanceFunctionRenderer
|
| 306 |
+
└-- ray_tracer_args: RayTracing
|
| 307 |
+
└-- ray_normal_coloring_network_args: RayNormalColoringNetwork
|
| 308 |
+
└-- implicit_function_*_args: ImplicitFunctionBase
|
| 309 |
+
╘== NeuralRadianceFieldImplicitFunction
|
| 310 |
+
╘== SRNImplicitFunction
|
| 311 |
+
└-- raymarch_function_args: SRNRaymarchFunction
|
| 312 |
+
└-- pixel_generator_args: SRNPixelGenerator
|
| 313 |
+
╘== SRNHyperNetImplicitFunction
|
| 314 |
+
└-- hypernet_args: SRNRaymarchHyperNet
|
| 315 |
+
└-- pixel_generator_args: SRNPixelGenerator
|
| 316 |
+
╘== IdrFeatureField
|
| 317 |
+
└-- coarse_implicit_function_*_args: ImplicitFunctionBase
|
| 318 |
+
╘== NeuralRadianceFieldImplicitFunction
|
| 319 |
+
╘== SRNImplicitFunction
|
| 320 |
+
└-- raymarch_function_args: SRNRaymarchFunction
|
| 321 |
+
└-- pixel_generator_args: SRNPixelGenerator
|
| 322 |
+
╘== SRNHyperNetImplicitFunction
|
| 323 |
+
└-- hypernet_args: SRNRaymarchHyperNet
|
| 324 |
+
└-- pixel_generator_args: SRNPixelGenerator
|
| 325 |
+
╘== IdrFeatureField
|
| 326 |
+
```
|
| 327 |
+
|
| 328 |
+
OverfitModel has been introduced to create a simple class to disantagle Nerfs which the overfit pattern
|
| 329 |
+
from the GenericModel.
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
Please look at the annotations of the respective classes or functions for the lists of hyperparameters.
|
| 333 |
+
`tests/experiment.yaml` shows every possible option if you have no user-defined classes.
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
# Implementations of existing methods
|
| 337 |
+
|
| 338 |
+
We provide configuration files that implement several existing works.
|
| 339 |
+
|
| 340 |
+
<b>The configuration files live in `pytorch3d/projects/implicitron_trainer/configs`.</b>
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
## NeRF
|
| 344 |
+
|
| 345 |
+
The following config file corresponds to training of a vanilla NeRF on Blender Synthetic dataset
|
| 346 |
+
(see https://arxiv.org/abs/2003.08934 for details of the method):
|
| 347 |
+
|
| 348 |
+
`./configs/repro_singleseq_nerf_blender.yaml`
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
### Downloading Blender-Synthetic
|
| 352 |
+
Training requires the Blender Synthetic dataset.
|
| 353 |
+
To download the dataset, visit the [gdrive bucket](https://drive.google.com/file/d/18JxhpWD-4ZmuFKLzKlAw-w5PpzZxXOcG/view?usp=share_link)
|
| 354 |
+
and click Download.
|
| 355 |
+
Then unpack the downloaded .zip file to a folder which we call `<BLENDER_DATASET_ROOT_FOLDER>`.
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
### Launching NeRF training
|
| 359 |
+
In order to train NeRF on the "drums" scene, execute the following command:
|
| 360 |
+
```shell
|
| 361 |
+
export BLENDER_DATASET_ROOT="<BLENDER_DATASET_ROOT_FOLDER>" \
|
| 362 |
+
export BLENDER_SINGLESEQ_CLASS="drums" \
|
| 363 |
+
pytorch3d_implicitron_runner --config-path ./configs/ --config-name repro_singleseq_nerf_blender
|
| 364 |
+
```
|
| 365 |
+
|
| 366 |
+
Note that the training scene is selected by setting the environment variable `BLENDER_SINGLESEQ_CLASS`
|
| 367 |
+
appropriately (one of `"chair"`, `"drums"`, `"ficus"`, `"hotdog"`, `"lego"`, `"materials"`, `"mic"`, `"ship"`).
|
| 368 |
+
|
| 369 |
+
By default, the training outputs will be stored to `"./data/nerf_blender_repro/$BLENDER_SINGLESEQ_CLASS/"`
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
### Visualizing trained NeRF
|
| 373 |
+
```shell
|
| 374 |
+
pytorch3d_implicitron_visualizer exp_dir=<CHECKPOINT_DIR> \
|
| 375 |
+
visdom_show_preds=True n_eval_cameras=40 render_size="[64,64]" video_size="[256,256]"
|
| 376 |
+
```
|
| 377 |
+
where `<CHECKPOINT_DIR>` corresponds to the directory with the training outputs (defaults to `"./data/nerf_blender_repro/$BLENDER_SINGLESEQ_CLASS/"`).
|
| 378 |
+
|
| 379 |
+
The script will output a rendered video of the learned radiance field to `"./data/nerf_blender_repro/$BLENDER_SINGLESEQ_CLASS/"` (requires `ffmpeg`).
|
| 380 |
+
|
| 381 |
+
> **_NOTE:_** Recall that, if `pytorch3d_implicitron_runner`/`pytorch3d_implicitron_visualizer` are not available, replace the calls
|
| 382 |
+
with `cd <pytorch3d_root>/projects/; python -m implicitron_trainer.[experiment|visualize_reconstruction]`
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
## CO3D experiments
|
| 386 |
+
|
| 387 |
+
Common Objects in 3D (CO3D) is a large-scale dataset of videos of rigid objects grouped into 50 common categories.
|
| 388 |
+
Implicitron provides implementations and config files to reproduce the results from [the paper](https://arxiv.org/abs/2109.00512).
|
| 389 |
+
Please follow [the link](https://github.com/facebookresearch/co3d#automatic-batch-download) for the instructions to download the dataset.
|
| 390 |
+
In training and evaluation scripts, use the download location as `<DATASET_ROOT>`.
|
| 391 |
+
It is also possible to define environment variable `CO3D_DATASET_ROOT` instead of specifying it.
|
| 392 |
+
To reproduce the experiments from the paper, use the following configs.
|
| 393 |
+
|
| 394 |
+
For single-sequence experiments:
|
| 395 |
+
|
| 396 |
+
| Method | config file |
|
| 397 |
+
|-----------------|-------------------------------------|
|
| 398 |
+
| NeRF | repro_singleseq_nerf.yaml |
|
| 399 |
+
| NeRF + WCE | repro_singleseq_nerf_wce.yaml |
|
| 400 |
+
| NerFormer | repro_singleseq_nerformer.yaml |
|
| 401 |
+
| IDR | repro_singleseq_idr.yaml |
|
| 402 |
+
| SRN | repro_singleseq_srn_noharm.yaml |
|
| 403 |
+
| SRN + γ | repro_singleseq_srn.yaml |
|
| 404 |
+
| SRN + WCE | repro_singleseq_srn_wce_noharm.yaml |
|
| 405 |
+
| SRN + WCE + γ | repro_singleseq_srn_wce_noharm.yaml |
|
| 406 |
+
|
| 407 |
+
For multi-sequence autodecoder experiments (without generalization to new sequences):
|
| 408 |
+
|
| 409 |
+
| Method | config file |
|
| 410 |
+
|-----------------|--------------------------------------------|
|
| 411 |
+
| NeRF + AD | repro_multiseq_nerf_ad.yaml |
|
| 412 |
+
| SRN + AD | repro_multiseq_srn_ad_hypernet_noharm.yaml |
|
| 413 |
+
| SRN + γ + AD | repro_multiseq_srn_ad_hypernet.yaml |
|
| 414 |
+
|
| 415 |
+
For multi-sequence experiments (with generalization to new sequences):
|
| 416 |
+
|
| 417 |
+
| Method | config file |
|
| 418 |
+
|-----------------|--------------------------------------|
|
| 419 |
+
| NeRF + WCE | repro_multiseq_nerf_wce.yaml |
|
| 420 |
+
| NerFormer | repro_multiseq_nerformer.yaml |
|
| 421 |
+
| SRN + WCE | repro_multiseq_srn_wce_noharm.yaml |
|
| 422 |
+
| SRN + WCE + γ | repro_multiseq_srn_wce.yaml |
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
## CO3Dv2 experiments
|
| 426 |
+
|
| 427 |
+
The following config files implement training on the second version of CO3D, `CO3Dv2`.
|
| 428 |
+
|
| 429 |
+
In order to launch trainings, set the `CO3DV2_DATASET_ROOT` environment variable
|
| 430 |
+
to the root folder of the dataset (note that the name of the env. variable differs from the CO3Dv1 version).
|
| 431 |
+
|
| 432 |
+
Single-sequence experiments:
|
| 433 |
+
|
| 434 |
+
| Method | config file |
|
| 435 |
+
|-----------------|-------------------------------------|
|
| 436 |
+
| NeRF | repro_singleseq_v2_nerf.yaml |
|
| 437 |
+
| NerFormer | repro_singleseq_v2_nerformer.yaml |
|
| 438 |
+
| IDR | repro_singleseq_v2_idr.yaml |
|
| 439 |
+
| SRN | repro_singleseq_v2_srn_noharm.yaml |
|
| 440 |
+
|
| 441 |
+
Multi-sequence autodecoder experiments (without generalization to new sequences):
|
| 442 |
+
|
| 443 |
+
| Method | config file |
|
| 444 |
+
|-----------------|--------------------------------------------|
|
| 445 |
+
| NeRF + AD | repro_multiseq_v2_nerf_ad.yaml |
|
| 446 |
+
| SRN + γ + AD | repro_multiseq_v2_srn_ad_hypernet.yaml |
|
| 447 |
+
|
| 448 |
+
Multi-sequence experiments (with generalization to new sequences):
|
| 449 |
+
|
| 450 |
+
| Method | config file |
|
| 451 |
+
|-----------------|----------------------------------------|
|
| 452 |
+
| NeRF + WCE | repro_multiseq_v2_nerf_wce.yaml |
|
| 453 |
+
| NerFormer | repro_multiseq_v2_nerformer.yaml |
|
| 454 |
+
| SRN + WCE | repro_multiseq_v2_srn_wce_noharm.yaml |
|
| 455 |
+
| SRN + WCE + γ | repro_multiseq_v2_srn_wce.yaml |
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/__init__.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This source code is licensed under the BSD-style license found in the
|
| 5 |
+
# LICENSE file in the root directory of this source tree.
|
| 6 |
+
|
| 7 |
+
# pyre-unsafe
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/experiment.py
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 3 |
+
# All rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# This source code is licensed under the BSD-style license found in the
|
| 6 |
+
# LICENSE file in the root directory of this source tree.
|
| 7 |
+
|
| 8 |
+
# pyre-unsafe
|
| 9 |
+
|
| 10 |
+
""" "
|
| 11 |
+
This file is the entry point for launching experiments with Implicitron.
|
| 12 |
+
|
| 13 |
+
Launch Training
|
| 14 |
+
---------------
|
| 15 |
+
Experiment config .yaml files are located in the
|
| 16 |
+
`projects/implicitron_trainer/configs` folder. To launch an experiment,
|
| 17 |
+
specify the name of the file. Specific config values can also be overridden
|
| 18 |
+
from the command line, for example:
|
| 19 |
+
|
| 20 |
+
```
|
| 21 |
+
./experiment.py --config-name base_config.yaml override.param.one=42 override.param.two=84
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
Main functions
|
| 25 |
+
---------------
|
| 26 |
+
- The Experiment class defines `run` which creates the model, optimizer, and other
|
| 27 |
+
objects used in training, then starts TrainingLoop's `run` function.
|
| 28 |
+
- TrainingLoop takes care of the actual training logic: forward and backward passes,
|
| 29 |
+
evaluation and testing, as well as model checkpointing, visualization, and metric
|
| 30 |
+
printing.
|
| 31 |
+
|
| 32 |
+
Outputs
|
| 33 |
+
--------
|
| 34 |
+
The outputs of the experiment are saved and logged in multiple ways:
|
| 35 |
+
- Checkpoints:
|
| 36 |
+
Model, optimizer and stats are stored in the directory
|
| 37 |
+
named by the `exp_dir` key from the config file / CLI parameters.
|
| 38 |
+
- Stats
|
| 39 |
+
Stats are logged and plotted to the file "train_stats.pdf" in the
|
| 40 |
+
same directory. The stats are also saved as part of the checkpoint file.
|
| 41 |
+
- Visualizations
|
| 42 |
+
Predictions are plotted to a visdom server running at the
|
| 43 |
+
port specified by the `visdom_server` and `visdom_port` keys in the
|
| 44 |
+
config file.
|
| 45 |
+
|
| 46 |
+
"""
|
| 47 |
+
|
| 48 |
+
import logging
|
| 49 |
+
import os
|
| 50 |
+
import warnings
|
| 51 |
+
|
| 52 |
+
from dataclasses import field
|
| 53 |
+
|
| 54 |
+
import hydra
|
| 55 |
+
|
| 56 |
+
import torch
|
| 57 |
+
from accelerate import Accelerator
|
| 58 |
+
from omegaconf import DictConfig, OmegaConf
|
| 59 |
+
from packaging import version
|
| 60 |
+
|
| 61 |
+
from pytorch3d.implicitron.dataset.data_source import (
|
| 62 |
+
DataSourceBase,
|
| 63 |
+
ImplicitronDataSource,
|
| 64 |
+
)
|
| 65 |
+
from pytorch3d.implicitron.models.base_model import ImplicitronModelBase
|
| 66 |
+
|
| 67 |
+
from pytorch3d.implicitron.models.renderer.multipass_ea import (
|
| 68 |
+
MultiPassEmissionAbsorptionRenderer,
|
| 69 |
+
)
|
| 70 |
+
from pytorch3d.implicitron.models.renderer.ray_sampler import AdaptiveRaySampler
|
| 71 |
+
from pytorch3d.implicitron.tools.config import (
|
| 72 |
+
Configurable,
|
| 73 |
+
expand_args_fields,
|
| 74 |
+
remove_unused_components,
|
| 75 |
+
run_auto_creation,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
from .impl.model_factory import ModelFactoryBase
|
| 79 |
+
from .impl.optimizer_factory import OptimizerFactoryBase
|
| 80 |
+
from .impl.training_loop import TrainingLoopBase
|
| 81 |
+
from .impl.utils import seed_all_random_engines
|
| 82 |
+
|
| 83 |
+
logger = logging.getLogger(__name__)
|
| 84 |
+
|
| 85 |
+
# workaround for https://github.com/facebookresearch/hydra/issues/2262
|
| 86 |
+
_RUN = hydra.types.RunMode.RUN
|
| 87 |
+
|
| 88 |
+
if version.parse(hydra.__version__) < version.Version("1.1"):
|
| 89 |
+
raise ValueError(
|
| 90 |
+
f"Hydra version {hydra.__version__} is too old."
|
| 91 |
+
" (Implicitron requires version 1.1 or later.)"
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
try:
|
| 95 |
+
# only makes sense in FAIR cluster
|
| 96 |
+
import pytorch3d.implicitron.fair_cluster.slurm # noqa: F401
|
| 97 |
+
except ModuleNotFoundError:
|
| 98 |
+
pass
|
| 99 |
+
|
| 100 |
+
no_accelerate = os.environ.get("PYTORCH3D_NO_ACCELERATE") is not None
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
class Experiment(Configurable):
|
| 104 |
+
"""
|
| 105 |
+
This class is at the top level of Implicitron's config hierarchy. Its
|
| 106 |
+
members are high-level components necessary for training an implicit rende-
|
| 107 |
+
ring network.
|
| 108 |
+
|
| 109 |
+
Members:
|
| 110 |
+
data_source: An object that produces datasets and dataloaders.
|
| 111 |
+
model_factory: An object that produces an implicit rendering model as
|
| 112 |
+
well as its corresponding Stats object.
|
| 113 |
+
optimizer_factory: An object that produces the optimizer and lr
|
| 114 |
+
scheduler.
|
| 115 |
+
training_loop: An object that runs training given the outputs produced
|
| 116 |
+
by the data_source, model_factory and optimizer_factory.
|
| 117 |
+
seed: A random seed to ensure reproducibility.
|
| 118 |
+
detect_anomaly: Whether torch.autograd should detect anomalies. Useful
|
| 119 |
+
for debugging, but might slow down the training.
|
| 120 |
+
exp_dir: Root experimentation directory. Checkpoints and training stats
|
| 121 |
+
will be saved here.
|
| 122 |
+
"""
|
| 123 |
+
|
| 124 |
+
# pyre-fixme[13]: Attribute `data_source` is never initialized.
|
| 125 |
+
data_source: DataSourceBase
|
| 126 |
+
data_source_class_type: str = "ImplicitronDataSource"
|
| 127 |
+
# pyre-fixme[13]: Attribute `model_factory` is never initialized.
|
| 128 |
+
model_factory: ModelFactoryBase
|
| 129 |
+
model_factory_class_type: str = "ImplicitronModelFactory"
|
| 130 |
+
# pyre-fixme[13]: Attribute `optimizer_factory` is never initialized.
|
| 131 |
+
optimizer_factory: OptimizerFactoryBase
|
| 132 |
+
optimizer_factory_class_type: str = "ImplicitronOptimizerFactory"
|
| 133 |
+
# pyre-fixme[13]: Attribute `training_loop` is never initialized.
|
| 134 |
+
training_loop: TrainingLoopBase
|
| 135 |
+
training_loop_class_type: str = "ImplicitronTrainingLoop"
|
| 136 |
+
|
| 137 |
+
seed: int = 42
|
| 138 |
+
detect_anomaly: bool = False
|
| 139 |
+
exp_dir: str = "./data/default_experiment/"
|
| 140 |
+
|
| 141 |
+
hydra: dict = field(
|
| 142 |
+
default_factory=lambda: {
|
| 143 |
+
"run": {"dir": "."}, # Make hydra not change the working dir.
|
| 144 |
+
"output_subdir": None, # disable storing the .hydra logs
|
| 145 |
+
"mode": _RUN,
|
| 146 |
+
}
|
| 147 |
+
)
|
| 148 |
+
|
| 149 |
+
def __post_init__(self):
|
| 150 |
+
seed_all_random_engines(
|
| 151 |
+
self.seed
|
| 152 |
+
) # Set all random engine seeds for reproducibility
|
| 153 |
+
|
| 154 |
+
run_auto_creation(self)
|
| 155 |
+
|
| 156 |
+
def run(self) -> None:
|
| 157 |
+
# Initialize the accelerator if desired.
|
| 158 |
+
if no_accelerate:
|
| 159 |
+
accelerator = None
|
| 160 |
+
device = torch.device("cuda:0")
|
| 161 |
+
else:
|
| 162 |
+
accelerator = Accelerator(device_placement=False)
|
| 163 |
+
logger.info(accelerator.state)
|
| 164 |
+
device = accelerator.device
|
| 165 |
+
|
| 166 |
+
logger.info(f"Running experiment on device: {device}")
|
| 167 |
+
os.makedirs(self.exp_dir, exist_ok=True)
|
| 168 |
+
|
| 169 |
+
# set the debug mode
|
| 170 |
+
if self.detect_anomaly:
|
| 171 |
+
logger.info("Anomaly detection!")
|
| 172 |
+
torch.autograd.set_detect_anomaly(self.detect_anomaly)
|
| 173 |
+
|
| 174 |
+
# Initialize the datasets and dataloaders.
|
| 175 |
+
datasets, dataloaders = self.data_source.get_datasets_and_dataloaders()
|
| 176 |
+
|
| 177 |
+
# Init the model and the corresponding Stats object.
|
| 178 |
+
model = self.model_factory(
|
| 179 |
+
accelerator=accelerator,
|
| 180 |
+
exp_dir=self.exp_dir,
|
| 181 |
+
)
|
| 182 |
+
|
| 183 |
+
stats = self.training_loop.load_stats(
|
| 184 |
+
log_vars=model.log_vars,
|
| 185 |
+
exp_dir=self.exp_dir,
|
| 186 |
+
resume=self.model_factory.resume,
|
| 187 |
+
resume_epoch=self.model_factory.resume_epoch, # pyre-ignore [16]
|
| 188 |
+
)
|
| 189 |
+
start_epoch = stats.epoch + 1
|
| 190 |
+
|
| 191 |
+
model.to(device)
|
| 192 |
+
|
| 193 |
+
# Init the optimizer and LR scheduler.
|
| 194 |
+
optimizer, scheduler = self.optimizer_factory(
|
| 195 |
+
accelerator=accelerator,
|
| 196 |
+
exp_dir=self.exp_dir,
|
| 197 |
+
last_epoch=start_epoch,
|
| 198 |
+
model=model,
|
| 199 |
+
resume=self.model_factory.resume,
|
| 200 |
+
resume_epoch=self.model_factory.resume_epoch,
|
| 201 |
+
)
|
| 202 |
+
|
| 203 |
+
# Wrap all modules in the distributed library
|
| 204 |
+
# Note: we don't pass the scheduler to prepare as it
|
| 205 |
+
# doesn't need to be stepped at each optimizer step
|
| 206 |
+
train_loader = dataloaders.train
|
| 207 |
+
val_loader = dataloaders.val
|
| 208 |
+
test_loader = dataloaders.test
|
| 209 |
+
if accelerator is not None:
|
| 210 |
+
(
|
| 211 |
+
model,
|
| 212 |
+
optimizer,
|
| 213 |
+
train_loader,
|
| 214 |
+
val_loader,
|
| 215 |
+
) = accelerator.prepare(model, optimizer, train_loader, val_loader)
|
| 216 |
+
|
| 217 |
+
# Enter the main training loop.
|
| 218 |
+
self.training_loop.run(
|
| 219 |
+
train_loader=train_loader,
|
| 220 |
+
val_loader=val_loader,
|
| 221 |
+
test_loader=test_loader,
|
| 222 |
+
# pyre-ignore[6]
|
| 223 |
+
train_dataset=datasets.train,
|
| 224 |
+
model=model,
|
| 225 |
+
optimizer=optimizer,
|
| 226 |
+
scheduler=scheduler,
|
| 227 |
+
accelerator=accelerator,
|
| 228 |
+
device=device,
|
| 229 |
+
exp_dir=self.exp_dir,
|
| 230 |
+
stats=stats,
|
| 231 |
+
seed=self.seed,
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def _setup_envvars_for_cluster() -> bool:
|
| 236 |
+
"""
|
| 237 |
+
Prepares to run on cluster if relevant.
|
| 238 |
+
Returns whether FAIR cluster in use.
|
| 239 |
+
"""
|
| 240 |
+
# TODO: How much of this is needed in general?
|
| 241 |
+
|
| 242 |
+
try:
|
| 243 |
+
import submitit
|
| 244 |
+
except ImportError:
|
| 245 |
+
return False
|
| 246 |
+
|
| 247 |
+
try:
|
| 248 |
+
# Only needed when launching on cluster with slurm and submitit
|
| 249 |
+
job_env = submitit.JobEnvironment()
|
| 250 |
+
except RuntimeError:
|
| 251 |
+
return False
|
| 252 |
+
|
| 253 |
+
os.environ["LOCAL_RANK"] = str(job_env.local_rank)
|
| 254 |
+
os.environ["RANK"] = str(job_env.global_rank)
|
| 255 |
+
os.environ["WORLD_SIZE"] = str(job_env.num_tasks)
|
| 256 |
+
os.environ["MASTER_ADDR"] = "localhost"
|
| 257 |
+
os.environ["MASTER_PORT"] = "42918"
|
| 258 |
+
logger.info(
|
| 259 |
+
"Num tasks %s, global_rank %s"
|
| 260 |
+
% (str(job_env.num_tasks), str(job_env.global_rank))
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
return True
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def dump_cfg(cfg: DictConfig) -> None:
|
| 267 |
+
remove_unused_components(cfg)
|
| 268 |
+
# dump the exp config to the exp dir
|
| 269 |
+
os.makedirs(cfg.exp_dir, exist_ok=True)
|
| 270 |
+
try:
|
| 271 |
+
cfg_filename = os.path.join(cfg.exp_dir, "expconfig.yaml")
|
| 272 |
+
OmegaConf.save(config=cfg, f=cfg_filename)
|
| 273 |
+
except PermissionError:
|
| 274 |
+
warnings.warn("Can't dump config due to insufficient permissions!")
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
expand_args_fields(Experiment)
|
| 278 |
+
cs = hydra.core.config_store.ConfigStore.instance()
|
| 279 |
+
cs.store(name="default_config", node=Experiment)
|
| 280 |
+
|
| 281 |
+
|
| 282 |
+
@hydra.main(config_path="./configs/", config_name="default_config")
|
| 283 |
+
def experiment(cfg: DictConfig) -> None:
|
| 284 |
+
# CUDA_VISIBLE_DEVICES must have been set.
|
| 285 |
+
|
| 286 |
+
if "CUDA_DEVICE_ORDER" not in os.environ:
|
| 287 |
+
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
|
| 288 |
+
|
| 289 |
+
if not _setup_envvars_for_cluster():
|
| 290 |
+
logger.info("Running locally")
|
| 291 |
+
|
| 292 |
+
# TODO: The following may be needed for hydra/submitit it to work
|
| 293 |
+
expand_args_fields(ImplicitronModelBase)
|
| 294 |
+
expand_args_fields(AdaptiveRaySampler)
|
| 295 |
+
expand_args_fields(MultiPassEmissionAbsorptionRenderer)
|
| 296 |
+
expand_args_fields(ImplicitronDataSource)
|
| 297 |
+
|
| 298 |
+
experiment = Experiment(**cfg)
|
| 299 |
+
dump_cfg(cfg)
|
| 300 |
+
experiment.run()
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
if __name__ == "__main__":
|
| 304 |
+
experiment()
|
project/ManiSkill3/src/maniskill2_benchmark/cfdp_experiment/cfdp/pytorch3d/projects/implicitron_trainer/visualize_reconstruction.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
| 3 |
+
# All rights reserved.
|
| 4 |
+
#
|
| 5 |
+
# This source code is licensed under the BSD-style license found in the
|
| 6 |
+
# LICENSE file in the root directory of this source tree.
|
| 7 |
+
|
| 8 |
+
# pyre-unsafe
|
| 9 |
+
|
| 10 |
+
"""
|
| 11 |
+
Script to visualize a previously trained model. Example call:
|
| 12 |
+
|
| 13 |
+
pytorch3d_implicitron_visualizer \
|
| 14 |
+
exp_dir='./exps/checkpoint_dir' visdom_show_preds=True visdom_port=8097 \
|
| 15 |
+
n_eval_cameras=40 render_size="[64,64]" video_size="[256,256]"
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
import os
|
| 19 |
+
import sys
|
| 20 |
+
from typing import Optional, Tuple
|
| 21 |
+
|
| 22 |
+
import numpy as np
|
| 23 |
+
import torch
|
| 24 |
+
from omegaconf import DictConfig, OmegaConf
|
| 25 |
+
from pytorch3d.implicitron.models.visualization.render_flyaround import render_flyaround
|
| 26 |
+
from pytorch3d.implicitron.tools.config import enable_get_default_args, get_default_args
|
| 27 |
+
|
| 28 |
+
from .experiment import Experiment
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def visualize_reconstruction(
|
| 32 |
+
exp_dir: str = "",
|
| 33 |
+
restrict_sequence_name: Optional[str] = None,
|
| 34 |
+
output_directory: Optional[str] = None,
|
| 35 |
+
render_size: Tuple[int, int] = (512, 512),
|
| 36 |
+
video_size: Optional[Tuple[int, int]] = None,
|
| 37 |
+
split: str = "train",
|
| 38 |
+
n_source_views: int = 9,
|
| 39 |
+
n_eval_cameras: int = 40,
|
| 40 |
+
visdom_show_preds: bool = False,
|
| 41 |
+
visdom_server: str = "http://127.0.0.1",
|
| 42 |
+
visdom_port: int = 8097,
|
| 43 |
+
visdom_env: Optional[str] = None,
|
| 44 |
+
**render_flyaround_kwargs,
|
| 45 |
+
) -> None:
|
| 46 |
+
"""
|
| 47 |
+
Given an `exp_dir` containing a trained Implicitron model, generates videos consisting
|
| 48 |
+
of renderes of sequences from the dataset used to train and evaluate the trained
|
| 49 |
+
Implicitron model.
|
| 50 |
+
|
| 51 |
+
Args:
|
| 52 |
+
exp_dir: Implicitron experiment directory.
|
| 53 |
+
restrict_sequence_name: If set, defines the list of sequences to visualize.
|
| 54 |
+
output_directory: If set, defines a custom directory to output visualizations to.
|
| 55 |
+
render_size: The size (HxW) of the generated renders.
|
| 56 |
+
video_size: The size (HxW) of the output video.
|
| 57 |
+
split: The dataset split to use for visualization.
|
| 58 |
+
Can be "train" / "val" / "test".
|
| 59 |
+
n_source_views: The number of source views added to each rendered batch. These
|
| 60 |
+
views are required inputs for models such as NeRFormer / NeRF-WCE.
|
| 61 |
+
n_eval_cameras: The number of cameras each fly-around trajectory.
|
| 62 |
+
visdom_show_preds: If `True`, outputs visualizations to visdom.
|
| 63 |
+
visdom_server: The address of the visdom server.
|
| 64 |
+
visdom_port: The port of the visdom server.
|
| 65 |
+
visdom_env: If set, defines a custom name for the visdom environment.
|
| 66 |
+
render_flyaround_kwargs: Keyword arguments passed to the invoked `render_flyaround`
|
| 67 |
+
function (see `pytorch3d.implicitron.models.visualization.render_flyaround`).
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
# In case an output directory is specified use it. If no output_directory
|
| 71 |
+
# is specified create a vis folder inside the experiment directory
|
| 72 |
+
if output_directory is None:
|
| 73 |
+
output_directory = os.path.join(exp_dir, "vis")
|
| 74 |
+
os.makedirs(output_directory, exist_ok=True)
|
| 75 |
+
|
| 76 |
+
# Set the random seeds
|
| 77 |
+
torch.manual_seed(0)
|
| 78 |
+
np.random.seed(0)
|
| 79 |
+
|
| 80 |
+
# Get the config from the experiment_directory,
|
| 81 |
+
# and overwrite relevant fields
|
| 82 |
+
config = _get_config_from_experiment_directory(exp_dir)
|
| 83 |
+
config.exp_dir = exp_dir
|
| 84 |
+
# important so that the CO3D dataset gets loaded in full
|
| 85 |
+
data_source_args = config.data_source_ImplicitronDataSource_args
|
| 86 |
+
if "dataset_map_provider_JsonIndexDatasetMapProvider_args" in data_source_args:
|
| 87 |
+
dataset_args = (
|
| 88 |
+
data_source_args.dataset_map_provider_JsonIndexDatasetMapProvider_args
|
| 89 |
+
)
|
| 90 |
+
dataset_args.test_on_train = False
|
| 91 |
+
if restrict_sequence_name is not None:
|
| 92 |
+
dataset_args.restrict_sequence_name = restrict_sequence_name
|
| 93 |
+
|
| 94 |
+
# Set the rendering image size
|
| 95 |
+
model_factory_args = config.model_factory_ImplicitronModelFactory_args
|
| 96 |
+
model_factory_args.force_resume = True
|
| 97 |
+
model_args = model_factory_args.model_GenericModel_args
|
| 98 |
+
model_args.render_image_width = render_size[0]
|
| 99 |
+
model_args.render_image_height = render_size[1]
|
| 100 |
+
|
| 101 |
+
# Load the previously trained model
|
| 102 |
+
experiment = Experiment(**config)
|
| 103 |
+
model = experiment.model_factory(exp_dir=exp_dir)
|
| 104 |
+
device = torch.device("cuda")
|
| 105 |
+
model.to(device)
|
| 106 |
+
model.eval()
|
| 107 |
+
|
| 108 |
+
# Setup the dataset
|
| 109 |
+
data_source = experiment.data_source
|
| 110 |
+
dataset_map, _ = data_source.get_datasets_and_dataloaders()
|
| 111 |
+
dataset = dataset_map[split]
|
| 112 |
+
if dataset is None:
|
| 113 |
+
raise ValueError(f"{split} dataset not provided")
|
| 114 |
+
|
| 115 |
+
if visdom_env is None:
|
| 116 |
+
visdom_env = (
|
| 117 |
+
"visualizer_" + config.training_loop_ImplicitronTrainingLoop_args.visdom_env
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# iterate over the sequences in the dataset
|
| 121 |
+
for sequence_name in dataset.sequence_names():
|
| 122 |
+
with torch.no_grad():
|
| 123 |
+
render_kwargs = {
|
| 124 |
+
"dataset": dataset,
|
| 125 |
+
"sequence_name": sequence_name,
|
| 126 |
+
"model": model,
|
| 127 |
+
"output_video_path": os.path.join(output_directory, "video"),
|
| 128 |
+
"n_source_views": n_source_views,
|
| 129 |
+
"visdom_show_preds": visdom_show_preds,
|
| 130 |
+
"n_flyaround_poses": n_eval_cameras,
|
| 131 |
+
"visdom_server": visdom_server,
|
| 132 |
+
"visdom_port": visdom_port,
|
| 133 |
+
"visdom_environment": visdom_env,
|
| 134 |
+
"video_resize": video_size,
|
| 135 |
+
"device": device,
|
| 136 |
+
**render_flyaround_kwargs,
|
| 137 |
+
}
|
| 138 |
+
render_flyaround(**render_kwargs)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
enable_get_default_args(visualize_reconstruction)
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def _get_config_from_experiment_directory(experiment_directory) -> DictConfig:
|
| 145 |
+
cfg_file = os.path.join(experiment_directory, "expconfig.yaml")
|
| 146 |
+
config = OmegaConf.load(cfg_file)
|
| 147 |
+
# pyre-ignore[7]
|
| 148 |
+
return OmegaConf.merge(get_default_args(Experiment), config)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def main(argv=sys.argv) -> None:
|
| 152 |
+
# automatically parses arguments of visualize_reconstruction
|
| 153 |
+
cfg = OmegaConf.create(get_default_args(visualize_reconstruction))
|
| 154 |
+
cfg.update(OmegaConf.from_cli(argv))
|
| 155 |
+
with torch.no_grad():
|
| 156 |
+
visualize_reconstruction(**cfg)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
if __name__ == "__main__":
|
| 160 |
+
main()
|