mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-02 22:08:41 +08:00
Merge branch 'master' of github.com:ethanweber/mattport into eng/benchmarking
This commit is contained in:
commit
d9472e2fca
92 files changed
+277
-269
No files matched your search
@@ -25,10 +25,10 @@ jobs:
|
|||||||
pip install -r environment/requirements.txt
|
pip install -r environment/requirements.txt
|
||||||
pip install -e .
|
pip install -e .
|
||||||
- name: Run Black
|
- name: Run Black
|
||||||
run: black mattport/ notebooks/ --check
|
run: black radiance/ notebooks/ --check
|
||||||
- name: Python Pylint
|
- name: Python Pylint
|
||||||
run: |
|
run: |
|
||||||
pylint mattport tests
|
pylint radiance tests
|
||||||
- name: Test with pytest
|
- name: Test with pytest
|
||||||
run: |
|
run: |
|
||||||
pytest
|
pytest
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# MattPort
|
# Radiance
|
||||||
|
|
||||||
# Quickstart
|
# Quickstart
|
||||||
|
|
||||||
@@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
```
|
```
|
||||||
# Clone the repo
|
# Clone the repo
|
||||||
git clone --recurse-submodules git@github.com:ethanweber/mattport.git
|
git clone --recurse-submodules git@github.com:ethanweber/radiance.git
|
||||||
|
|
||||||
# Create the python environment
|
# Create the python environment
|
||||||
conda create --name mattport python=3.8.13
|
conda create --name radiance python=3.8.13
|
||||||
conda activate mattport
|
conda activate radiance
|
||||||
pip install -r environment/requirements.txt
|
pip install -r environment/requirements.txt
|
||||||
|
|
||||||
# Install mattport as a library
|
# Install radiance as a library
|
||||||
pip install -e .
|
pip install -e .
|
||||||
|
|
||||||
# Install library with CUDA support. Change setup.py to `USE_CUDA = True` and then
|
# Install library with CUDA support. Change setup.py to `USE_CUDA = True` and then
|
||||||
@@ -69,7 +69,7 @@ bash environments/run_jupyter.sh
|
|||||||
|
|
||||||
# Tooling
|
# Tooling
|
||||||
|
|
||||||
1. One can use [autoenv](https://github.com/hyperupcall/autoenv) to make setting up the environment and environment variables easier. This will run the `.envrc` file upon entering the `/path/to/mattport` folder. It will also remove the environment parameters upon leaving.
|
1. One can use [autoenv](https://github.com/hyperupcall/autoenv) to make setting up the environment and environment variables easier. This will run the `.envrc` file upon entering the `/path/to/radiance` folder. It will also remove the environment parameters upon leaving.
|
||||||
|
|
||||||
```
|
```
|
||||||
# Install direnv.
|
# Install direnv.
|
||||||
@@ -79,7 +79,7 @@ sudo apt install direnv
|
|||||||
eval "$(direnv hook bash)"
|
eval "$(direnv hook bash)"
|
||||||
|
|
||||||
# Populate your .envrc with commands you want to run. Then, run the following to allow updates.
|
# Populate your .envrc with commands you want to run. Then, run the following to allow updates.
|
||||||
cd /path/to/mattport
|
cd /path/to/radiance
|
||||||
direnv allow .
|
direnv allow .
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -125,12 +125,12 @@ python scripts/benchmarking/run_benchmark.py
|
|||||||
```
|
```
|
||||||
# nerf-pytorch
|
# nerf-pytorch
|
||||||
cd external
|
cd external
|
||||||
python run_nerf.py --config configs/chair.txt --datadir /path/to/mattport/data/blender/chair
|
python run_nerf.py --config configs/chair.txt --datadir /path/to/radiance/data/blender/chair
|
||||||
|
|
||||||
# jaxnerf
|
# jaxnerf
|
||||||
cd external
|
cd external
|
||||||
conda activate jaxnerf
|
conda activate jaxnerf
|
||||||
python -m jaxnerf.train --data_dir=/path/to/mattport/data/blender/chair --train_dir=/path/to/mattport/outputs/blender_chair_jaxnerf --config=/path/to/mattport/external/jaxnerf/configs/demo --render_every 100
|
python -m jaxnerf.train --data_dir=/path/to/radiance/data/blender/chair --train_dir=/path/to/radiance/outputs/blender_chair_jaxnerf --config=/path/to/radiance/external/jaxnerf/configs/demo --render_every 100
|
||||||
```
|
```
|
||||||
|
|
||||||
# Speeding up the code
|
# Speeding up the code
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
defaults:
|
defaults:
|
||||||
# This makes the logging module logs colorful
|
# This makes the logging module logs colorful
|
||||||
- data: default_data.yaml
|
- data: default_data.yaml
|
||||||
- graph: default_graph.yaml
|
|
||||||
- logging: default_logging.yaml
|
- logging: default_logging.yaml
|
||||||
- override hydra/job_logging: colorlog
|
- override hydra/job_logging: colorlog
|
||||||
- override hydra/hydra_logging: colorlog
|
- override hydra/hydra_logging: colorlog
|
||||||
- _self_
|
- _self_
|
||||||
|
|
||||||
seed: 0
|
seed: 42
|
||||||
|
|
||||||
hydra:
|
hydra:
|
||||||
run:
|
run:
|
||||||
@@ -15,12 +14,10 @@ hydra:
|
|||||||
# Example "outputs/mnist/classifier/baseline/2021-03-10-141516"
|
# Example "outputs/mnist/classifier/baseline/2021-03-10-141516"
|
||||||
dir: outputs/${experiment_name}/${method_name}/${now:%Y-%m-%d_%H%M%S}
|
dir: outputs/${experiment_name}/${method_name}/${now:%Y-%m-%d_%H%M%S}
|
||||||
|
|
||||||
experiment_name: blender_lego
|
|
||||||
method_name: vanilla_nerf
|
|
||||||
|
|
||||||
# machine options
|
# machine options
|
||||||
machine_config:
|
machine_config:
|
||||||
num_gpus: 1
|
num_gpus: 1
|
||||||
num_machines: 1
|
num_machines: 1
|
||||||
machine_rank: 0
|
machine_rank: 0
|
||||||
dist_url: auto
|
dist_url: auto
|
||||||
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# saving model specifications
|
|
||||||
model_dir: /tmp/mattport_models/
|
|
||||||
steps_per_save: null
|
|
||||||
steps_per_test: 100
|
|
||||||
max_num_iterations: 1000000
|
|
||||||
|
|
||||||
# pretrained loading options
|
|
||||||
resume_train:
|
|
||||||
load_dir: # pretrained model directory
|
|
||||||
load_step: # pretrained model's step number
|
|
||||||
|
|
||||||
network:
|
|
||||||
_target_: mattport.nerf.graph.vanilla_nerf.NeRFGraph
|
|
||||||
near_plane: 2.0
|
|
||||||
far_plane: 6.0
|
|
||||||
num_coarse_samples: 64
|
|
||||||
num_importance_samples: 128
|
|
||||||
|
|
||||||
loss_coefficients: # loss coefficients
|
|
||||||
rgb_loss_coarse: 1.0
|
|
||||||
rgb_loss_fine: 1.0
|
|
||||||
|
|
||||||
# optimizer options for network
|
|
||||||
param_groups:
|
|
||||||
fields:
|
|
||||||
optimizer:
|
|
||||||
_target_: torch.optim.RAdam
|
|
||||||
lr: 0.0005
|
|
||||||
scheduler:
|
|
||||||
_target_: mattport.nerf.optimizers.ExponentialDecaySchedule
|
|
||||||
lr_final: 0.000005
|
|
||||||
max_steps: 1000000
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
defaults:
|
|
||||||
- default_graph.yaml
|
|
||||||
- _self_
|
|
||||||
|
|
||||||
network:
|
|
||||||
_target_: mattport.nerf.graph.instant_ngp.NGPGraph
|
|
||||||
field_implementation: torch # torch, tcnn, ...
|
|
||||||
loss_coefficients: # loss coefficients
|
|
||||||
rgb_loss: 1.0
|
|
||||||
|
|
||||||
# optimizer options for network
|
|
||||||
param_groups:
|
|
||||||
fields:
|
|
||||||
optimizer:
|
|
||||||
lr: 1e-2
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
defaults:
|
|
||||||
- default_graph.yaml
|
|
||||||
- _self_
|
|
||||||
|
|
||||||
network:
|
|
||||||
_target_: mattport.nerf.graph.nerfw.NerfWGraph
|
|
||||||
loss_coefficients: # loss coefficients
|
|
||||||
rgb_loss_coarse: 1.0
|
|
||||||
rgb_loss_fine: 1.0
|
|
||||||
uncertainty_loss: 1.0
|
|
||||||
density_loss: 0.01
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
defaults:
|
|
||||||
- default_graph.yaml
|
|
||||||
- _self_
|
|
||||||
|
|
||||||
network:
|
|
||||||
_target_: mattport.nerf.graph.semantic_nerf.SemanticNerfGraph
|
|
||||||
loss_coefficients: # loss coefficients
|
|
||||||
rgb_loss_coarse: 1.0
|
|
||||||
rgb_loss_fine: 1.0
|
|
||||||
semantic_loss_fine: 0.05
|
|
||||||
@@ -1,7 +1,20 @@
|
|||||||
defaults:
|
defaults:
|
||||||
- default
|
- vanilla_nerf
|
||||||
- override graph: instant_ngp_graph
|
|
||||||
- _self_
|
- _self_
|
||||||
|
|
||||||
method_name: instant_ngp
|
method_name: instant_ngp
|
||||||
data.dataloader.num_rays_per_batch: 4096
|
data.dataloader.num_rays_per_batch: 4096
|
||||||
data.val_num_rays_per_chunk: 16384
|
data.val_num_rays_per_chunk: 16384
|
||||||
|
|
||||||
|
graph:
|
||||||
|
network:
|
||||||
|
_target_: radiance.nerf.graph.instant_ngp.NGPGraph
|
||||||
|
field_implementation: torch # torch, tcnn, ...
|
||||||
|
loss_coefficients: # loss coefficients
|
||||||
|
rgb_loss: 1.0
|
||||||
|
|
||||||
|
# optimizer options for network
|
||||||
|
param_groups:
|
||||||
|
fields:
|
||||||
|
optimizer:
|
||||||
|
lr: 1e-2
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
defaults:
|
defaults:
|
||||||
- default
|
- instant_ngp
|
||||||
- override graph: instant_ngp_graph
|
|
||||||
- _self_
|
- _self_
|
||||||
|
|
||||||
method_name: instant_ngp
|
method_name: instant_ngp
|
||||||
data:
|
data:
|
||||||
dataloader:
|
dataloader:
|
||||||
|
|||||||
+14
-7
@@ -1,14 +1,21 @@
|
|||||||
defaults:
|
defaults:
|
||||||
- default
|
- vanilla_nerf
|
||||||
- override data/dataset: friends_TBBT-big_living_room
|
- override data/dataset: friends_TBBT-big_living_room
|
||||||
- override graph: nerfw_graph
|
|
||||||
- _self_
|
- _self_
|
||||||
|
|
||||||
experiment_name: friends_TBBT-big_living_room
|
experiment_name: friends_TBBT-big_living_room
|
||||||
method_name: nerfw
|
method_name: nerfw
|
||||||
|
|
||||||
network:
|
graph:
|
||||||
near_plane: 0.1
|
network:
|
||||||
far_plane: 10.0
|
_target_: radiance.nerf.graph.nerfw.NerfWGraph
|
||||||
num_coarse_samples: 64
|
near_plane: 0.1
|
||||||
num_importance_samples: 64
|
far_plane: 10.0
|
||||||
|
num_coarse_samples: 64
|
||||||
|
num_importance_samples: 64
|
||||||
|
|
||||||
|
loss_coefficients: # loss coefficients
|
||||||
|
rgb_loss_coarse: 1.0
|
||||||
|
rgb_loss_fine: 1.0
|
||||||
|
uncertainty_loss: 1.0
|
||||||
|
density_loss: 0.01
|
||||||
@@ -1,14 +1,20 @@
|
|||||||
defaults:
|
defaults:
|
||||||
- default
|
- vanilla_nerf
|
||||||
- override data/dataset: friends_TBBT-big_living_room
|
- override data/dataset: friends_TBBT-big_living_room
|
||||||
- override graph: semantic_nerf_graph
|
|
||||||
- _self_
|
- _self_
|
||||||
|
|
||||||
experiment_name: friends_TBBT-big_living_room
|
experiment_name: friends_TBBT-big_living_room
|
||||||
method_name: semantic_nerf
|
method_name: semantic_nerf
|
||||||
|
|
||||||
network:
|
graph:
|
||||||
near_plane: 0.1
|
network:
|
||||||
far_plane: 10.0
|
_target_: radiance.nerf.graph.semantic_nerf.SemanticNerfGraph
|
||||||
num_coarse_samples: 64
|
near_plane: 0.1
|
||||||
num_importance_samples: 64
|
far_plane: 10.0
|
||||||
|
num_coarse_samples: 64
|
||||||
|
num_importance_samples: 64
|
||||||
|
|
||||||
|
loss_coefficients: # loss coefficients
|
||||||
|
rgb_loss_coarse: 1.0
|
||||||
|
rgb_loss_fine: 1.0
|
||||||
|
semantic_loss_fine: 0.05
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
defaults:
|
defaults:
|
||||||
- default
|
- vanilla_nerf
|
||||||
|
|
||||||
dry_run: true
|
dry_run: true
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
defaults:
|
||||||
|
- default_setup
|
||||||
|
- _self_
|
||||||
|
|
||||||
|
experiment_name: blender_lego
|
||||||
|
method_name: vanilla_nerf
|
||||||
|
|
||||||
|
graph:
|
||||||
|
# saving model specifications
|
||||||
|
model_dir: /tmp/radiance_models/
|
||||||
|
steps_per_save: null
|
||||||
|
steps_per_test: 100
|
||||||
|
max_num_iterations: 1000000
|
||||||
|
|
||||||
|
# pretrained loading options
|
||||||
|
resume_train:
|
||||||
|
load_dir: # pretrained model directory
|
||||||
|
load_step: # pretrained model's step number
|
||||||
|
|
||||||
|
network:
|
||||||
|
_target_: radiance.nerf.graph.vanilla_nerf.NeRFGraph
|
||||||
|
near_plane: 2.0
|
||||||
|
far_plane: 6.0
|
||||||
|
num_coarse_samples: 64
|
||||||
|
num_importance_samples: 128
|
||||||
|
|
||||||
|
loss_coefficients: # loss coefficients
|
||||||
|
rgb_loss_coarse: 1.0
|
||||||
|
rgb_loss_fine: 1.0
|
||||||
|
|
||||||
|
# optimizer options for network
|
||||||
|
param_groups:
|
||||||
|
fields:
|
||||||
|
optimizer:
|
||||||
|
_target_: torch.optim.RAdam
|
||||||
|
lr: 0.0005
|
||||||
|
scheduler:
|
||||||
|
_target_: radiance.nerf.optimizers.ExponentialDecaySchedule
|
||||||
|
lr_final: 0.000005
|
||||||
|
max_steps: 1000000
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import torch\n",
|
"import torch\n",
|
||||||
"from mattport.structures import cameras\n",
|
"from radiance.structures import cameras\n",
|
||||||
"import plotly.graph_objects as go\n",
|
"import plotly.graph_objects as go\n",
|
||||||
"import mediapy as media"
|
"import mediapy as media"
|
||||||
]
|
]
|
||||||
@@ -19597,7 +19597,7 @@
|
|||||||
"hash": "024fe9dea615e4e34961116ff517c7e9f5910440e3d2c8eb4560299f11aaf2e7"
|
"hash": "024fe9dea615e4e34961116ff517c7e9f5910440e3d2c8eb4560299f11aaf2e7"
|
||||||
},
|
},
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3.9.12 ('mattport')",
|
"display_name": "Python 3.9.12 ('radiance')",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,15 +20,15 @@
|
|||||||
"import torch\n",
|
"import torch\n",
|
||||||
"from torch.utils.data import DataLoader\n",
|
"from torch.utils.data import DataLoader\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from mattport.nerf.dataset.image_dataset import ImageDataset, collate_batch\n",
|
"from radiance.nerf.dataset.image_dataset import ImageDataset, collate_batch\n",
|
||||||
"from mattport.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one\n",
|
"from radiance.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one\n",
|
||||||
"from mattport.nerf.dataset.utils import get_dataset_inputs\n",
|
"from radiance.nerf.dataset.utils import get_dataset_inputs\n",
|
||||||
"from mattport.nerf.field_modules.ray_generator import RayGenerator\n",
|
"from radiance.nerf.field_modules.ray_generator import RayGenerator\n",
|
||||||
"from mattport.nerf.field_modules.scene_bounds_collider import SceneBoundsCollider\n",
|
"from radiance.nerf.field_modules.scene_bounds_collider import SceneBoundsCollider\n",
|
||||||
"from mattport.structures.rays import RayBundle\n",
|
"from radiance.structures.rays import RayBundle\n",
|
||||||
"from mattport.utils.io import get_absolute_path\n",
|
"from radiance.utils.io import get_absolute_path\n",
|
||||||
"from mattport.viewer.plotly import get_line_segments_from_lines\n",
|
"from radiance.viewer.plotly import get_line_segments_from_lines\n",
|
||||||
"from mattport.structures.cameras import get_camera_model\n",
|
"from radiance.structures.cameras import get_camera_model\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from hydra import compose, initialize\n",
|
"from hydra import compose, initialize\n",
|
||||||
@@ -361,9 +361,9 @@
|
|||||||
"hash": "4a749acc7d255f078aee52e0584cc77b3cb5aaed1b3a7407ec4262c1bf6cb526"
|
"hash": "4a749acc7d255f078aee52e0584cc77b3cb5aaed1b3a7407ec4262c1bf6cb526"
|
||||||
},
|
},
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "mattport",
|
"display_name": "radiance",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "mattport"
|
"name": "radiance"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 6;\n var nbb_unformatted_code = \"import torch\\nimport mediapy as media\\nfrom mattport.nerf.field_modules import encoding\";\n var nbb_formatted_code = \"import torch\\nimport mediapy as media\\nfrom mattport.nerf.field_modules import encoding\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ",
|
"application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 6;\n var nbb_unformatted_code = \"import torch\\nimport mediapy as media\\nfrom radiance.nerf.field_modules import encoding\";\n var nbb_formatted_code = \"import torch\\nimport mediapy as media\\nfrom radiance.nerf.field_modules import encoding\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ",
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"<IPython.core.display.Javascript object>"
|
"<IPython.core.display.Javascript object>"
|
||||||
]
|
]
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"import torch\n",
|
"import torch\n",
|
||||||
"import mediapy as media\n",
|
"import mediapy as media\n",
|
||||||
"from mattport.nerf.field_modules import encoding"
|
"from radiance.nerf.field_modules import encoding"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -434,7 +434,7 @@
|
|||||||
"hash": "024fe9dea615e4e34961116ff517c7e9f5910440e3d2c8eb4560299f11aaf2e7"
|
"hash": "024fe9dea615e4e34961116ff517c7e9f5910440e3d2c8eb4560299f11aaf2e7"
|
||||||
},
|
},
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 3.9.11 ('mattport')",
|
"display_name": "Python 3.9.11 ('radiance')",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python3"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -11,7 +11,7 @@ line-length = 120
|
|||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
generated-members = ["numpy.*", "torch.*", "cv2.*", "cv.*"]
|
generated-members = ["numpy.*", "torch.*", "cv2.*", "cv.*"]
|
||||||
good-names-rgxs = "^[_a-zA-Z][_a-z0-9]?$"
|
good-names-rgxs = "^[_a-zA-Z][_a-z0-9]?$"
|
||||||
ignore = ["mattport/cuda", "tests/cuda", "nerfw.py", "semantic_nerf.py"]
|
ignore = ["radiance/cuda", "tests/cuda", "nerfw.py", "semantic_nerf.py"]
|
||||||
|
|
||||||
disable = [
|
disable = [
|
||||||
"too-many-arguments",
|
"too-many-arguments",
|
||||||
@@ -23,7 +23,7 @@ disable = [
|
|||||||
|
|
||||||
#pytest
|
#pytest
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "--typeguard-packages=mattport --torchtyping-patch-typeguard --disable-warnings --ignore=tests/cuda"
|
addopts = "--typeguard-packages=radiance --torchtyping-patch-typeguard --disable-warnings --ignore=tests/cuda"
|
||||||
testpaths = [
|
testpaths = [
|
||||||
"tests",
|
"tests",
|
||||||
]
|
]
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,13 +7,13 @@ import math
|
|||||||
import torch
|
import torch
|
||||||
from torch import nn
|
from torch import nn
|
||||||
|
|
||||||
import mattport_cuda
|
import radiance_cuda
|
||||||
|
|
||||||
|
|
||||||
class LLTMFunction(torch.autograd.Function):
|
class LLTMFunction(torch.autograd.Function):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def forward(ctx, input, weights, bias, old_h, old_cell):
|
def forward(ctx, input, weights, bias, old_h, old_cell):
|
||||||
outputs = mattport_cuda.forward(input, weights, bias, old_h, old_cell)
|
outputs = radiance_cuda.forward(input, weights, bias, old_h, old_cell)
|
||||||
new_h, new_cell = outputs[:2]
|
new_h, new_cell = outputs[:2]
|
||||||
variables = outputs[1:] + [weights]
|
variables = outputs[1:] + [weights]
|
||||||
ctx.save_for_backward(*variables)
|
ctx.save_for_backward(*variables)
|
||||||
@@ -22,7 +22,7 @@ class LLTMFunction(torch.autograd.Function):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def backward(ctx, grad_h, grad_cell):
|
def backward(ctx, grad_h, grad_cell):
|
||||||
outputs = mattport_cuda.backward(grad_h.contiguous(), grad_cell.contiguous(), *ctx.saved_variables)
|
outputs = radiance_cuda.backward(grad_h.contiguous(), grad_cell.contiguous(), *ctx.saved_variables)
|
||||||
d_old_h, d_input, d_weights, d_bias, d_old_cell, d_gates = outputs
|
d_old_h, d_input, d_weights, d_bias, d_old_cell, d_gates = outputs
|
||||||
return d_input, d_weights, d_bias, d_old_h, d_old_cell
|
return d_input, d_weights, d_bias, d_old_h, d_old_cell
|
||||||
|
|
||||||
File renamed without changes.
@@ -4,8 +4,8 @@ Ray generator.
|
|||||||
import torch
|
import torch
|
||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
from mattport.nerf.dataset.structs import SceneBounds
|
from radiance.nerf.dataset.structs import SceneBounds
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
|
|
||||||
|
|
||||||
class SceneBoundsCollider(nn.Module):
|
class SceneBoundsCollider(nn.Module):
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -10,8 +10,8 @@ import numpy as np
|
|||||||
import torch
|
import torch
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.dataset.structs import DatasetInputs, SceneBounds
|
from radiance.nerf.dataset.structs import DatasetInputs, SceneBounds
|
||||||
from mattport.utils.io import load_from_json
|
from radiance.utils.io import load_from_json
|
||||||
|
|
||||||
|
|
||||||
def load_blender_data(
|
def load_blender_data(
|
||||||
@@ -7,10 +7,10 @@ import numpy as np
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mattport.nerf.dataset.colmap_utils import read_cameras_binary, read_images_binary, read_pointsTD_binary
|
from radiance.nerf.dataset.colmap_utils import read_cameras_binary, read_images_binary, read_pointsTD_binary
|
||||||
from mattport.nerf.dataset.structs import DatasetInputs, PointCloud, SceneBounds, Semantics
|
from radiance.nerf.dataset.structs import DatasetInputs, PointCloud, SceneBounds, Semantics
|
||||||
from mattport.utils import profiler
|
from radiance.utils import profiler
|
||||||
from mattport.utils.io import load_from_json
|
from radiance.utils.io import load_from_json
|
||||||
|
|
||||||
|
|
||||||
def get_aabb_and_transform(basedir):
|
def get_aabb_and_transform(basedir):
|
||||||
+2
-2
@@ -10,8 +10,8 @@ import imageio
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mattport.nerf.dataset.structs import DatasetInputs, SceneBounds
|
from radiance.nerf.dataset.structs import DatasetInputs, SceneBounds
|
||||||
from mattport.utils.io import load_from_json
|
from radiance.utils.io import load_from_json
|
||||||
|
|
||||||
|
|
||||||
def load_instant_ngp_data(
|
def load_instant_ngp_data(
|
||||||
File renamed without changes.
@@ -12,7 +12,7 @@ from PIL import Image
|
|||||||
from torch.utils.data import default_collate
|
from torch.utils.data import default_collate
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.dataset.structs import Semantics
|
from radiance.nerf.dataset.structs import Semantics
|
||||||
|
|
||||||
|
|
||||||
def collate_batch(batch_list, num_rays_per_batch, keep_full_image: bool = False):
|
def collate_batch(batch_list, num_rays_per_batch, keep_full_image: bool = False):
|
||||||
File renamed without changes.
@@ -6,12 +6,12 @@ from typing import Optional, Union
|
|||||||
|
|
||||||
from omegaconf import ListConfig
|
from omegaconf import ListConfig
|
||||||
|
|
||||||
from mattport.nerf.dataset.format.blender import load_blender_data
|
from radiance.nerf.dataset.format.blender import load_blender_data
|
||||||
from mattport.nerf.dataset.format.friends import load_friends_data
|
from radiance.nerf.dataset.format.friends import load_friends_data
|
||||||
from mattport.nerf.dataset.format.instant_ngp import load_instant_ngp_data
|
from radiance.nerf.dataset.format.instant_ngp import load_instant_ngp_data
|
||||||
from mattport.nerf.dataset.structs import DatasetInputs
|
from radiance.nerf.dataset.structs import DatasetInputs
|
||||||
from mattport.structures.colors import get_color
|
from radiance.structures.colors import get_color
|
||||||
from mattport.utils.io import get_absolute_path
|
from radiance.utils.io import get_absolute_path
|
||||||
|
|
||||||
|
|
||||||
def get_dataset_inputs(
|
def get_dataset_inputs(
|
||||||
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@ Code for embeddings.
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
from mattport.nerf.field_modules.base import FieldModule
|
from radiance.nerf.field_modules.base import FieldModule
|
||||||
|
|
||||||
|
|
||||||
class Embedding(FieldModule):
|
class Embedding(FieldModule):
|
||||||
@@ -9,8 +9,8 @@ import torch.nn.functional as F
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.field_modules.base import FieldModule
|
from radiance.nerf.field_modules.base import FieldModule
|
||||||
from mattport.utils.math import components_from_spherical_harmonics
|
from radiance.utils.math import components_from_spherical_harmonics
|
||||||
|
|
||||||
|
|
||||||
class Encoding(FieldModule):
|
class Encoding(FieldModule):
|
||||||
+1
-1
@@ -7,7 +7,7 @@ from typing import Optional
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.field_modules.base import FieldModule
|
from radiance.nerf.field_modules.base import FieldModule
|
||||||
|
|
||||||
|
|
||||||
class FieldHeadNames(Enum):
|
class FieldHeadNames(Enum):
|
||||||
File renamed without changes.
@@ -7,7 +7,7 @@ import torch
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.field_modules.base import FieldModule
|
from radiance.nerf.field_modules.base import FieldModule
|
||||||
|
|
||||||
|
|
||||||
class MLP(FieldModule):
|
class MLP(FieldModule):
|
||||||
File renamed without changes.
@@ -8,10 +8,10 @@ from typing import Dict, Optional, Tuple
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
import torch
|
import torch
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames
|
from radiance.nerf.field_modules.field_heads import FieldHeadNames
|
||||||
|
|
||||||
from mattport.structures.rays import PointSamples
|
from radiance.structures.rays import PointSamples
|
||||||
from mattport.utils.misc import is_not_none
|
from radiance.utils.misc import is_not_none
|
||||||
|
|
||||||
|
|
||||||
class Field(nn.Module):
|
class Field(nn.Module):
|
||||||
+6
-6
@@ -9,12 +9,12 @@ import torch
|
|||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
from torch.nn.parameter import Parameter
|
from torch.nn.parameter import Parameter
|
||||||
|
|
||||||
from mattport.nerf.field_modules.encoding import Encoding, HashEncoding, SHEncoding
|
from radiance.nerf.field_modules.encoding import Encoding, HashEncoding, SHEncoding
|
||||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames
|
from radiance.nerf.field_modules.field_heads import FieldHeadNames
|
||||||
from mattport.nerf.fields.base import Field
|
from radiance.nerf.fields.base import Field
|
||||||
from mattport.nerf.fields.nerf_field import NeRFField
|
from radiance.nerf.fields.nerf_field import NeRFField
|
||||||
from mattport.structures.rays import PointSamples
|
from radiance.structures.rays import PointSamples
|
||||||
from mattport.utils.misc import is_not_none
|
from radiance.utils.misc import is_not_none
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import tinycudann as tcnn
|
import tinycudann as tcnn
|
||||||
@@ -7,11 +7,11 @@ import torch
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.field_modules.encoding import Encoding, Identity
|
from radiance.nerf.field_modules.encoding import Encoding, Identity
|
||||||
from mattport.nerf.field_modules.field_heads import DensityFieldHead, FieldHead, FieldHeadNames, RGBFieldHead
|
from radiance.nerf.field_modules.field_heads import DensityFieldHead, FieldHead, FieldHeadNames, RGBFieldHead
|
||||||
from mattport.nerf.field_modules.mlp import MLP
|
from radiance.nerf.field_modules.mlp import MLP
|
||||||
from mattport.nerf.fields.base import Field
|
from radiance.nerf.fields.base import Field
|
||||||
from mattport.structures.rays import PointSamples
|
from radiance.structures.rays import PointSamples
|
||||||
|
|
||||||
|
|
||||||
class NeRFField(Field):
|
class NeRFField(Field):
|
||||||
@@ -11,13 +11,13 @@ from torch import nn
|
|||||||
from torch.nn import Parameter
|
from torch.nn import Parameter
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.dataset.structs import SceneBounds
|
from radiance.nerf.dataset.structs import SceneBounds
|
||||||
from mattport.nerf.ray_generator import RayGenerator
|
from radiance.nerf.ray_generator import RayGenerator
|
||||||
from mattport.nerf.colliders import AABBBoxCollider
|
from radiance.nerf.colliders import AABBBoxCollider
|
||||||
from mattport.structures.cameras import get_camera_model
|
from radiance.structures.cameras import get_camera_model
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
from mattport.utils.misc import get_masked_dict
|
from radiance.utils.misc import get_masked_dict
|
||||||
from mattport.utils.misc import is_not_none
|
from radiance.utils.misc import is_not_none
|
||||||
|
|
||||||
|
|
||||||
class AbstractGraph(nn.Module):
|
class AbstractGraph(nn.Module):
|
||||||
@@ -9,22 +9,22 @@ from torch.nn import Parameter
|
|||||||
from torchmetrics import PeakSignalNoiseRatio, StructuralSimilarityIndexMeasure
|
from torchmetrics import PeakSignalNoiseRatio, StructuralSimilarityIndexMeasure
|
||||||
from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
|
from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
|
||||||
|
|
||||||
from mattport.nerf.colliders import AABBBoxCollider
|
from radiance.nerf.colliders import AABBBoxCollider
|
||||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames
|
from radiance.nerf.field_modules.field_heads import FieldHeadNames
|
||||||
from mattport.nerf.fields.instant_ngp_field import field_implementation_to_class
|
from radiance.nerf.fields.instant_ngp_field import field_implementation_to_class
|
||||||
from mattport.nerf.graph.base import Graph
|
from radiance.nerf.graph.base import Graph
|
||||||
from mattport.nerf.loss import MSELoss
|
from radiance.nerf.loss import MSELoss
|
||||||
from mattport.nerf.occupancy_grid import OccupancyGrid
|
from radiance.nerf.occupancy_grid import OccupancyGrid
|
||||||
from mattport.nerf.renderers import AccumulationRenderer, DepthRenderer, RGBRenderer
|
from radiance.nerf.renderers import AccumulationRenderer, DepthRenderer, RGBRenderer
|
||||||
from mattport.nerf.sampler import PDFSampler, UniformSampler
|
from radiance.nerf.sampler import PDFSampler, UniformSampler
|
||||||
from mattport.structures import colors
|
from radiance.structures import colors
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
from mattport.utils import visualization, writer
|
from radiance.utils import visualization, writer
|
||||||
|
|
||||||
|
|
||||||
class NGPGraph(Graph):
|
class NGPGraph(Graph):
|
||||||
|
|
||||||
"""NeRF-W graph"""
|
"""Instant NGP graph"""
|
||||||
|
|
||||||
def __init__(self, field_implementation="torch", intrinsics=None, camera_to_world=None, **kwargs) -> None:
|
def __init__(self, field_implementation="torch", intrinsics=None, camera_to_world=None, **kwargs) -> None:
|
||||||
assert field_implementation in field_implementation_to_class
|
assert field_implementation in field_implementation_to_class
|
||||||
@@ -8,18 +8,18 @@ from typing import Tuple
|
|||||||
import torch
|
import torch
|
||||||
from torch import nn
|
from torch import nn
|
||||||
|
|
||||||
from mattport.nerf.field_modules.embedding import Embedding
|
from radiance.nerf.field_modules.embedding import Embedding
|
||||||
from mattport.nerf.field_modules.field_heads import (
|
from radiance.nerf.field_modules.field_heads import (
|
||||||
FieldHeadNames,
|
FieldHeadNames,
|
||||||
TransientDensityHead,
|
TransientDensityHead,
|
||||||
TransientRGBHead,
|
TransientRGBHead,
|
||||||
UncertaintyFieldHead,
|
UncertaintyFieldHead,
|
||||||
)
|
)
|
||||||
from mattport.nerf.field_modules.mlp import MLP
|
from radiance.nerf.field_modules.mlp import MLP
|
||||||
from mattport.nerf.graph.vanilla_nerf import NeRFField, NeRFGraph
|
from radiance.nerf.graph.vanilla_nerf import NeRFField, NeRFGraph
|
||||||
from mattport.nerf.renderers import UncertaintyRenderer
|
from radiance.nerf.renderers import UncertaintyRenderer
|
||||||
from mattport.structures.rays import RayBundle, RaySamples
|
from radiance.structures.rays import RayBundle, RaySamples
|
||||||
from mattport.utils import visualization, writer
|
from radiance.utils import visualization, writer
|
||||||
|
|
||||||
|
|
||||||
class NerfWField(Field):
|
class NerfWField(Field):
|
||||||
@@ -7,12 +7,12 @@ from typing import Tuple
|
|||||||
import torch
|
import torch
|
||||||
from torch import nn
|
from torch import nn
|
||||||
|
|
||||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames, SemanticStuffHead
|
from radiance.nerf.field_modules.field_heads import FieldHeadNames, SemanticStuffHead
|
||||||
from mattport.nerf.field_modules.mlp import MLP
|
from radiance.nerf.field_modules.mlp import MLP
|
||||||
from mattport.nerf.graph.vanilla_nerf import NeRFField, NeRFGraph
|
from radiance.nerf.graph.vanilla_nerf import NeRFField, NeRFGraph
|
||||||
from mattport.nerf.renderers import SemanticRenderer
|
from radiance.nerf.renderers import SemanticRenderer
|
||||||
from mattport.structures.rays import RayBundle, RaySamples
|
from radiance.structures.rays import RayBundle, RaySamples
|
||||||
from mattport.utils import visualization, writer
|
from radiance.utils import visualization, writer
|
||||||
|
|
||||||
|
|
||||||
class SemanticNerfField(NeRFField):
|
class SemanticNerfField(NeRFField):
|
||||||
File renamed without changes.
@@ -9,18 +9,18 @@ import torch
|
|||||||
from torch.nn import Parameter
|
from torch.nn import Parameter
|
||||||
from torchmetrics import PeakSignalNoiseRatio, StructuralSimilarityIndexMeasure
|
from torchmetrics import PeakSignalNoiseRatio, StructuralSimilarityIndexMeasure
|
||||||
from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
|
from torchmetrics.image.lpip import LearnedPerceptualImagePatchSimilarity
|
||||||
from mattport.nerf.field_modules.encoding import NeRFEncoding
|
from radiance.nerf.field_modules.encoding import NeRFEncoding
|
||||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames
|
from radiance.nerf.field_modules.field_heads import FieldHeadNames
|
||||||
|
|
||||||
from mattport.nerf.fields.nerf_field import NeRFField
|
from radiance.nerf.fields.nerf_field import NeRFField
|
||||||
from mattport.nerf.graph.base import Graph
|
from radiance.nerf.graph.base import Graph
|
||||||
from mattport.nerf.loss import MSELoss
|
from radiance.nerf.loss import MSELoss
|
||||||
from mattport.nerf.renderers import AccumulationRenderer, DepthRenderer, RGBRenderer
|
from radiance.nerf.renderers import AccumulationRenderer, DepthRenderer, RGBRenderer
|
||||||
from mattport.nerf.sampler import PDFSampler, UniformSampler
|
from radiance.nerf.sampler import PDFSampler, UniformSampler
|
||||||
from mattport.structures import colors
|
from radiance.structures import colors
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
from mattport.nerf.colliders import NearFarCollider
|
from radiance.nerf.colliders import NearFarCollider
|
||||||
from mattport.utils import visualization, writer
|
from radiance.utils import visualization, writer
|
||||||
|
|
||||||
|
|
||||||
class NeRFGraph(Graph):
|
class NeRFGraph(Graph):
|
||||||
File renamed without changes.
@@ -7,7 +7,7 @@ import torch.nn.functional as F
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.utils.misc import is_not_none
|
from radiance.utils.misc import is_not_none
|
||||||
|
|
||||||
|
|
||||||
class OccupancyGrid(nn.Module):
|
class OccupancyGrid(nn.Module):
|
||||||
@@ -10,7 +10,7 @@ from omegaconf import DictConfig
|
|||||||
from torch.nn import Parameter
|
from torch.nn import Parameter
|
||||||
from torch.optim.lr_scheduler import LambdaLR
|
from torch.optim.lr_scheduler import LambdaLR
|
||||||
|
|
||||||
from mattport.utils import writer
|
from radiance.utils import writer
|
||||||
|
|
||||||
|
|
||||||
class ExponentialDecaySchedule(LambdaLR):
|
class ExponentialDecaySchedule(LambdaLR):
|
||||||
@@ -3,8 +3,8 @@ Ray generator.
|
|||||||
"""
|
"""
|
||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
from mattport.structures.cameras import get_camera_model
|
from radiance.structures.cameras import get_camera_model
|
||||||
|
|
||||||
|
|
||||||
class RayGenerator(nn.Module):
|
class RayGenerator(nn.Module):
|
||||||
@@ -8,7 +8,7 @@ import torch
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.utils.math import components_from_spherical_harmonics
|
from radiance.utils.math import components_from_spherical_harmonics
|
||||||
|
|
||||||
|
|
||||||
class RGBRenderer(nn.Module):
|
class RGBRenderer(nn.Module):
|
||||||
@@ -17,7 +17,7 @@ class RGBRenderer(nn.Module):
|
|||||||
def __init__(self, background_color: Optional[TensorType[3]] = None) -> None:
|
def __init__(self, background_color: Optional[TensorType[3]] = None) -> None:
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
background_color (TensorType[3], optional): Background color as RGB. Defaults to black.
|
background_color (TensorType[3], optional): Background color as RGB. Defaults to random.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.background_color = background_color
|
self.background_color = background_color
|
||||||
@@ -34,14 +34,17 @@ class RGBRenderer(nn.Module):
|
|||||||
Args:
|
Args:
|
||||||
rgb (TensorType[..., "num_samples", -1]): RGB for each sample
|
rgb (TensorType[..., "num_samples", -1]): RGB for each sample
|
||||||
weights (TensorType[..., "num_samples"]): Weights for each sample
|
weights (TensorType[..., "num_samples"]): Weights for each sample
|
||||||
|
background_color (TensorType[3], optional): Background color as RGB. Defaults to random.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
TensorType[..., 3]: Outputs rgb values.
|
TensorType[..., 3]: Outputs rgb values.
|
||||||
"""
|
"""
|
||||||
rgb = torch.sum(weights[..., None] * rgb, dim=-2)
|
rgb = torch.sum(weights[..., None] * rgb, dim=-2)
|
||||||
|
|
||||||
if background_color is not None:
|
if background_color is None:
|
||||||
rgb = rgb + background_color.to(weights.device)[None, ...] * (1.0 - torch.sum(weights, dim=-1)[..., None])
|
background_color = torch.rand_like(rgb).to(rgb.device)
|
||||||
|
|
||||||
|
rgb = rgb + background_color.to(weights.device) * (1.0 - torch.sum(weights, dim=-1)[..., None])
|
||||||
|
|
||||||
return rgb
|
return rgb
|
||||||
|
|
||||||
@@ -74,7 +77,7 @@ class SHRenderer(nn.Module):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
background_color (TensorType[3], optional): Background color as RGB. Defaults to black.
|
background_color (TensorType[3], optional): Background color as RGB. Defaults to random.
|
||||||
activation (Optional[nn.Module], optional): Output activation. Defaults to Sigmoid().
|
activation (Optional[nn.Module], optional): Output activation. Defaults to Sigmoid().
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -9,8 +9,8 @@ import torch
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.nerf.occupancy_grid import OccupancyGrid
|
from radiance.nerf.occupancy_grid import OccupancyGrid
|
||||||
from mattport.structures.rays import RayBundle, RaySamples
|
from radiance.structures.rays import RayBundle, RaySamples
|
||||||
|
|
||||||
|
|
||||||
class Sampler(nn.Module):
|
class Sampler(nn.Module):
|
||||||
@@ -14,14 +14,14 @@ from omegaconf import DictConfig
|
|||||||
from torch.nn.parallel import DistributedDataParallel as DDP
|
from torch.nn.parallel import DistributedDataParallel as DDP
|
||||||
from torch.utils.data import DataLoader
|
from torch.utils.data import DataLoader
|
||||||
|
|
||||||
from mattport.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one
|
from radiance.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one
|
||||||
from mattport.nerf.dataset.image_dataset import ImageDataset, collate_batch
|
from radiance.nerf.dataset.image_dataset import ImageDataset, collate_batch
|
||||||
from mattport.nerf.dataset.utils import DatasetInputs, get_dataset_inputs
|
from radiance.nerf.dataset.utils import DatasetInputs, get_dataset_inputs
|
||||||
from mattport.nerf.optimizers import Optimizers
|
from radiance.nerf.optimizers import Optimizers
|
||||||
from mattport.utils import profiler, writer
|
from radiance.utils import profiler, writer
|
||||||
from mattport.utils.callbacks import update_occupancy
|
from radiance.utils.callbacks import update_occupancy
|
||||||
from mattport.utils.decorators import check_main_thread
|
from radiance.utils.decorators import check_main_thread
|
||||||
from mattport.utils.misc import get_dict_to_torch
|
from radiance.utils.misc import get_dict_to_torch
|
||||||
|
|
||||||
logging.getLogger("PIL").setLevel(logging.WARNING)
|
logging.getLogger("PIL").setLevel(logging.WARNING)
|
||||||
|
|
||||||
File renamed without changes.
File renamed without changes.
@@ -9,7 +9,7 @@ import torch
|
|||||||
from torch.nn.functional import normalize
|
from torch.nn.functional import normalize
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
File renamed without changes.
@@ -8,7 +8,7 @@ from typing import Optional
|
|||||||
import torch
|
import torch
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
from mattport.utils.misc import is_not_none
|
from radiance.utils.misc import is_not_none
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
File renamed without changes.
@@ -2,8 +2,8 @@
|
|||||||
Callback functions for training iterations
|
Callback functions for training iterations
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from mattport.nerf.graph.base import Graph
|
from radiance.nerf.graph.base import Graph
|
||||||
from mattport.nerf.occupancy_grid import OccupancyGrid
|
from radiance.nerf.occupancy_grid import OccupancyGrid
|
||||||
|
|
||||||
|
|
||||||
def update_occupancy(graph: Graph):
|
def update_occupancy(graph: Graph):
|
||||||
File renamed without changes.
@@ -3,7 +3,7 @@ Decorator definitions
|
|||||||
"""
|
"""
|
||||||
from typing import Callable, List
|
from typing import Callable, List
|
||||||
|
|
||||||
from mattport.utils import comms
|
from radiance.utils import comms
|
||||||
|
|
||||||
|
|
||||||
def decorate_all(decorators: List[Callable]) -> Callable:
|
def decorate_all(decorators: List[Callable]) -> Callable:
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,8 +7,8 @@ from typing import Callable
|
|||||||
|
|
||||||
from omegaconf import DictConfig
|
from omegaconf import DictConfig
|
||||||
|
|
||||||
from mattport.utils import comms
|
from radiance.utils import comms
|
||||||
from mattport.utils.decorators import check_main_thread, check_profiler_enabled, decorate_all
|
from radiance.utils.decorators import check_main_thread, check_profiler_enabled, decorate_all
|
||||||
|
|
||||||
PROFILER = []
|
PROFILER = []
|
||||||
|
|
||||||
File renamed without changes.
@@ -15,8 +15,8 @@ from omegaconf import DictConfig, ListConfig
|
|||||||
from torch.utils.tensorboard import SummaryWriter
|
from torch.utils.tensorboard import SummaryWriter
|
||||||
from torchtyping import TensorType
|
from torchtyping import TensorType
|
||||||
|
|
||||||
import mattport.utils.writer
|
import radiance.utils.writer
|
||||||
from mattport.utils.decorators import check_main_thread, decorate_all
|
from radiance.utils.decorators import check_main_thread, decorate_all
|
||||||
|
|
||||||
to8b = lambda x: (255 * torch.clamp(x, min=0, max=1)).to(torch.uint8)
|
to8b = lambda x: (255 * torch.clamp(x, min=0, max=1)).to(torch.uint8)
|
||||||
EVENT_WRITERS = []
|
EVENT_WRITERS = []
|
||||||
@@ -150,7 +150,7 @@ def setup_event_writers(config: DictConfig) -> None:
|
|||||||
"""Initialization of all event writers specified in config"""
|
"""Initialization of all event writers specified in config"""
|
||||||
logging_configs = config.logging.writer
|
logging_configs = config.logging.writer
|
||||||
for writer_type in logging_configs:
|
for writer_type in logging_configs:
|
||||||
writer_class = getattr(mattport.utils.writer, writer_type)
|
writer_class = getattr(radiance.utils.writer, writer_type)
|
||||||
writer_config = logging_configs[writer_type]
|
writer_config = logging_configs[writer_type]
|
||||||
if writer_type == "LocalWriter":
|
if writer_type == "LocalWriter":
|
||||||
curr_writer = writer_class(writer_config.save_dir, writer_config.stats_to_track, writer_config.max_log_size)
|
curr_writer = writer_class(writer_config.save_dir, writer_config.stats_to_track, writer_config.max_log_size)
|
||||||
File renamed without changes.
File renamed without changes.
@@ -6,7 +6,7 @@ import numpy as np
|
|||||||
import plotly.graph_objects as go
|
import plotly.graph_objects as go
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
|
|
||||||
|
|
||||||
def color_str(color):
|
def color_str(color):
|
||||||
@@ -43,7 +43,7 @@ for dataset in ${DATASETS[@]}; do
|
|||||||
data.dataset.data_directory=data/blender/${dataset} \
|
data.dataset.data_directory=data/blender/${dataset} \
|
||||||
data.dataset.downscale_factor=1 \
|
data.dataset.downscale_factor=1 \
|
||||||
experiment_name=blender_${dataset}_${tag} \
|
experiment_name=blender_${dataset}_${tag} \
|
||||||
graph.model_dir=mattport_models/ \
|
graph.model_dir=radiance_models/ \
|
||||||
graph.steps_per_save=25000 \
|
graph.steps_per_save=25000 \
|
||||||
graph.max_num_iterations=2000000 \
|
graph.max_num_iterations=2000000 \
|
||||||
logging.enable_profiler=False &
|
logging.enable_profiler=False &
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ from hydra.core.global_hydra import GlobalHydra
|
|||||||
from omegaconf import DictConfig
|
from omegaconf import DictConfig
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from mattport.nerf.trainer import Trainer
|
from radiance.nerf.trainer import Trainer
|
||||||
|
|
||||||
BENCH = {
|
BENCH = {
|
||||||
"method": "vanilla_nerf",
|
"method": "vanilla_nerf",
|
||||||
"hydra_base_dir": "outputs/",
|
"hydra_base_dir": "outputs/",
|
||||||
"benchmark_date": "05-24-2022",
|
"benchmark_date": "05-26-2022",
|
||||||
"object_list": ["mic", "ficus", "chair", "hotdog", "materials", "drums", "ship", "lego"],
|
"object_list": ["mic", "ficus", "chair", "hotdog", "materials", "drums", "ship", "lego"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-3
@@ -3,6 +3,7 @@ run_train_nerf.py
|
|||||||
"""
|
"""
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@@ -15,9 +16,10 @@ import torch
|
|||||||
import torch.distributed as dist
|
import torch.distributed as dist
|
||||||
import torch.multiprocessing as mp
|
import torch.multiprocessing as mp
|
||||||
from omegaconf import DictConfig
|
from omegaconf import DictConfig
|
||||||
|
import yaml
|
||||||
|
|
||||||
from mattport.nerf.trainer import Trainer
|
from radiance.nerf.trainer import Trainer
|
||||||
from mattport.utils import comms, profiler
|
from radiance.utils import comms, profiler
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.DEBUG)
|
logging.basicConfig(format="[%(filename)s:%(lineno)d] %(message)s", level=logging.DEBUG)
|
||||||
@@ -198,9 +200,17 @@ def launch(
|
|||||||
profiler.flush_profiler(config.logging)
|
profiler.flush_profiler(config.logging)
|
||||||
|
|
||||||
|
|
||||||
@hydra.main(config_path="../configs", config_name="default.yaml")
|
@hydra.main(config_path="../configs", config_name="vanilla_nerf.yaml")
|
||||||
def main(config: DictConfig):
|
def main(config: DictConfig):
|
||||||
"""Main function."""
|
"""Main function."""
|
||||||
|
unrolled_path = os.path.join(os.getcwd(), ".hydra/config.yaml")
|
||||||
|
if os.path.exists(unrolled_path):
|
||||||
|
with open(unrolled_path, "r", encoding="utf8") as f:
|
||||||
|
unrolled_config = yaml.safe_load(f)
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
logger.info("Printing current config setup")
|
||||||
|
print(yaml.dump(unrolled_config, sort_keys=False, default_flow_style=False))
|
||||||
|
|
||||||
launch(
|
launch(
|
||||||
_train,
|
_train,
|
||||||
config.machine_config.num_gpus,
|
config.machine_config.num_gpus,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = mattport
|
name = radiance
|
||||||
version = 0.0.0
|
version = 0.0.0
|
||||||
url = https://github.com/ethanweber/mattport.git
|
url = https://github.com/ethanweber/radiance.git
|
||||||
description = differentiable volume rendering package
|
description = differentiable volume rendering package
|
||||||
long_description = file: README.md
|
long_description = file: README.md
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ if USE_CUDA:
|
|||||||
|
|
||||||
ext_modules = [
|
ext_modules = [
|
||||||
CUDAExtension(
|
CUDAExtension(
|
||||||
name="mattport_cuda",
|
name="radiance_cuda",
|
||||||
sources=[
|
sources=[
|
||||||
"mattport/cuda/mattport_cuda.cpp",
|
"radiance/cuda/radiance_cuda.cpp",
|
||||||
"mattport/cuda/mattport_cuda_kernel.cu",
|
"radiance/cuda/radiance_cuda_kernel.cu",
|
||||||
],
|
],
|
||||||
include_dirs=[os.path.join("mattport", "cuda", "include")],
|
include_dirs=[os.path.join("radiance", "cuda", "include")],
|
||||||
extra_compile_args={
|
extra_compile_args={
|
||||||
"cxx": [],
|
"cxx": [],
|
||||||
"nvcc": [],
|
"nvcc": [],
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
Test the CUDA bindings.
|
Test the CUDA bindings.
|
||||||
"""
|
"""
|
||||||
import torch
|
import torch
|
||||||
from mattport.cuda.sampler import Sampler
|
from radiance.cuda.sampler import Sampler
|
||||||
import time
|
import time
|
||||||
import mattport_cuda
|
import radiance_cuda
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ def test_benchmark():
|
|||||||
print("PYTORCH_SAMPLE_TIME:", PYTORCH_SAMPLE_TIME)
|
print("PYTORCH_SAMPLE_TIME:", PYTORCH_SAMPLE_TIME)
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
time_steps_cu, samples_cu, time_steps_mask_cu = mattport_cuda.sample_uniformly_along_ray_bundle(
|
time_steps_cu, samples_cu, time_steps_mask_cu = radiance_cuda.sample_uniformly_along_ray_bundle(
|
||||||
origins, directions, nears, fars, offsets, max_num_samples
|
origins, directions, nears, fars, offsets, max_num_samples
|
||||||
)
|
)
|
||||||
CUDA_SAMPLE_TIME = time.time() - start
|
CUDA_SAMPLE_TIME = time.time() - start
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import torch
|
|||||||
from torch.utils.data import DataLoader
|
from torch.utils.data import DataLoader
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from mattport.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one
|
from radiance.nerf.dataset.collate import CollateIterDataset, collate_batch_size_one
|
||||||
from mattport.nerf.dataset.image_dataset import ImageDataset, collate_batch
|
from radiance.nerf.dataset.image_dataset import ImageDataset, collate_batch
|
||||||
from mattport.nerf.dataset.utils import get_dataset_inputs
|
from radiance.nerf.dataset.utils import get_dataset_inputs
|
||||||
from mattport.nerf.ray_generator import RayGenerator
|
from radiance.nerf.ray_generator import RayGenerator
|
||||||
from mattport.utils.io import get_absolute_path
|
from radiance.utils.io import get_absolute_path
|
||||||
from mattport.viewer.plotly import visualize_dataset
|
from radiance.viewer.plotly import visualize_dataset
|
||||||
|
|
||||||
|
|
||||||
def visualize_batch(batch):
|
def visualize_batch(batch):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Embedding tests
|
Embedding tests
|
||||||
"""
|
"""
|
||||||
from mattport.nerf.field_modules.embedding import Embedding
|
from radiance.nerf.field_modules.embedding import Embedding
|
||||||
|
|
||||||
|
|
||||||
def test_indexing():
|
def test_indexing():
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Encoding Tests
|
|||||||
"""
|
"""
|
||||||
import pytest
|
import pytest
|
||||||
import torch
|
import torch
|
||||||
from mattport.nerf.field_modules import encoding
|
from radiance.nerf.field_modules import encoding
|
||||||
|
|
||||||
|
|
||||||
def test_scaling_and_offset():
|
def test_scaling_and_offset():
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import torch
|
|||||||
from torch import nn
|
from torch import nn
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from mattport.nerf.field_modules.field_heads import (
|
from radiance.nerf.field_modules.field_heads import (
|
||||||
DensityFieldHead,
|
DensityFieldHead,
|
||||||
FieldHead,
|
FieldHead,
|
||||||
FieldHeadNames,
|
FieldHeadNames,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ MLP Test
|
|||||||
import torch
|
import torch
|
||||||
from torch import nn
|
from torch import nn
|
||||||
|
|
||||||
from mattport.nerf.field_modules import MLP
|
from radiance.nerf.field_modules import MLP
|
||||||
|
|
||||||
|
|
||||||
def test_mlp():
|
def test_mlp():
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ Test the fields
|
|||||||
"""
|
"""
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mattport.nerf.field_modules.field_heads import FieldHeadNames
|
from radiance.nerf.field_modules.field_heads import FieldHeadNames
|
||||||
from mattport.nerf.fields.instant_ngp_field import TCNNInstantNGPField
|
from radiance.nerf.fields.instant_ngp_field import TCNNInstantNGPField
|
||||||
from mattport.structures.rays import PointSamples
|
from radiance.structures.rays import PointSamples
|
||||||
|
|
||||||
|
|
||||||
def test_tcnn_instant_ngp_field():
|
def test_tcnn_instant_ngp_field():
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Code to test the occupancy grid.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from mattport.nerf.occupancy_grid import OccupancyGrid
|
from radiance.nerf.occupancy_grid import OccupancyGrid
|
||||||
|
|
||||||
|
|
||||||
def test_occupancy_grid():
|
def test_occupancy_grid():
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Test renderers
|
|||||||
import pytest
|
import pytest
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mattport.nerf import renderers
|
from radiance.nerf import renderers
|
||||||
|
|
||||||
|
|
||||||
def test_rgb_renderer():
|
def test_rgb_renderer():
|
||||||
@@ -21,7 +21,7 @@ def test_rgb_renderer():
|
|||||||
assert torch.max(rgb) > 0.9
|
assert torch.max(rgb) > 0.9
|
||||||
|
|
||||||
rgb = rgb_renderer(rgb=rgb_samples * 0, weights=weights)
|
rgb = rgb_renderer(rgb=rgb_samples * 0, weights=weights)
|
||||||
assert torch.max(rgb) == pytest.approx(0)
|
assert torch.max(rgb) == pytest.approx(0, abs=1e-6)
|
||||||
|
|
||||||
|
|
||||||
def test_sh_renderer():
|
def test_sh_renderer():
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
Test samplers
|
Test samplers
|
||||||
"""
|
"""
|
||||||
import torch
|
import torch
|
||||||
from mattport.nerf.sampler import PDFSampler, UniformSampler
|
from radiance.nerf.sampler import PDFSampler, UniformSampler
|
||||||
|
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
from mattport.nerf.colliders import NearFarCollider
|
from radiance.nerf.colliders import NearFarCollider
|
||||||
|
|
||||||
|
|
||||||
def test_uniform_sampler():
|
def test_uniform_sampler():
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ Test the camera classes.
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from mattport.structures.cameras import PinholeCamera
|
from radiance.structures.cameras import PinholeCamera
|
||||||
from mattport.structures.rays import RayBundle
|
from radiance.structures.rays import RayBundle
|
||||||
|
|
||||||
|
|
||||||
def test_pinhole_camera():
|
def test_pinhole_camera():
|
||||||
|
|||||||
Reference in new issue
Block a user