Merge branch 'main' into generative

This commit is contained in:
Terrance Wang authored and GitHub committed 2023-06-01 10:18:33 -07:00
commit c7e92920f3
6 files changed
+417 -7

No files matched your search

+5 -5
View File
@@ -7,7 +7,7 @@
"colab_type": "text" "colab_type": "text"
}, },
"source": [ "source": [
"<a href=\"https://colab.research.google.com/github/nerfstudio-project/nerfstudio/blob/alex%2Frender_colab_fix/colab/demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" "<a href=\"https://colab.research.google.com/github/nerfstudio-project/nerfstudio/blob/alex%2Fcolab310/colab/demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
] ]
}, },
{ {
@@ -74,12 +74,12 @@
"\n", "\n",
"%cd /content/\n", "%cd /content/\n",
"!pip install --upgrade pip\n", "!pip install --upgrade pip\n",
"!pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html\n", "!pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118\n",
"\n", "\n",
"# Installing TinyCuda\n", "# Installing TinyCuda\n",
"%cd /content/\n", "%cd /content/\n",
"!gdown \"https://drive.google.com/u/1/uc?id=1LlL2ofrViALsqE789MFGZeJyxkNu84cT&confirm=t\" \n", "!gdown \"https://drive.google.com/u/1/uc?id=1-7x7qQfB7bIw2zV4Lr6-yhvMpjXC84Q5&confirm=t\"\n",
"!pip install tinycudann-1.7-cp39-cp39-linux_x86_64.whl\n", "!pip install tinycudann-1.7-cp310-cp310-linux_x86_64.whl\n",
"\n", "\n",
"# Installing COLMAP\n", "# Installing COLMAP\n",
"%cd /content/\n", "%cd /content/\n",
@@ -371,4 +371,4 @@
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 0
} }
@@ -20,6 +20,7 @@ from __future__ import annotations
import functools import functools
from abc import abstractmethod from abc import abstractmethod
from collections import defaultdict
from dataclasses import dataclass, field from dataclasses import dataclass, field
from pathlib import Path from pathlib import Path
from typing import ( from typing import (
@@ -33,6 +34,7 @@ from typing import (
Tuple, Tuple,
Type, Type,
Union, Union,
cast,
) )
import torch import torch
@@ -64,7 +66,6 @@ from nerfstudio.engine.callbacks import TrainingCallback, TrainingCallbackAttrib
from nerfstudio.model_components.ray_generators import RayGenerator from nerfstudio.model_components.ray_generators import RayGenerator
from nerfstudio.utils.misc import IterableWrapper from nerfstudio.utils.misc import IterableWrapper
from nerfstudio.utils.rich_utils import CONSOLE from nerfstudio.utils.rich_utils import CONSOLE
from collections import defaultdict
def variable_res_collate(batch: List[Dict]) -> Dict: def variable_res_collate(batch: List[Dict]) -> Dict:
@@ -331,7 +332,7 @@ class VanillaDataManagerConfig(DataManagerConfig):
camera_optimizer: CameraOptimizerConfig = CameraOptimizerConfig() camera_optimizer: CameraOptimizerConfig = CameraOptimizerConfig()
"""Specifies the camera pose optimizer used during training. Helpful if poses are noisy, such as for data from """Specifies the camera pose optimizer used during training. Helpful if poses are noisy, such as for data from
Record3D.""" Record3D."""
collate_fn: Callable[[Any], Any] = nerfstudio_collate collate_fn: Callable[[Any], Any] = cast(Any, staticmethod(nerfstudio_collate))
"""Specifies the collate function to use for the train and eval dataloaders.""" """Specifies the collate function to use for the train and eval dataloaders."""
camera_res_scale_factor: float = 1.0 camera_res_scale_factor: float = 1.0
"""The scale factor for scaling spatial data such as images, mask, semantics """The scale factor for scaling spatial data such as images, mask, semantics
@@ -162,6 +162,13 @@ def nerfstudio_collate(batch: Any, extra_mappings: Union[Dict[type, Callable], N
else: else:
op = torch.cat op = torch.cat
# Create metadata dictionary
metadata_keys = batch[0].metadata.keys()
assert all(
(cam.metadata.keys() == metadata_keys for cam in batch)
), "All cameras must have the same metadata keys."
metadata = {key: op([cam.metadata[key] for cam in batch], dim=0) for key in metadata_keys}
return Cameras( return Cameras(
op([cameras.camera_to_worlds for cameras in batch], dim=0), op([cameras.camera_to_worlds for cameras in batch], dim=0),
op([cameras.fx for cameras in batch], dim=0), op([cameras.fx for cameras in batch], dim=0),
@@ -184,6 +191,7 @@ def nerfstudio_collate(batch: Any, extra_mappings: Union[Dict[type, Callable], N
[cameras.times if cameras.times is not None else -torch.ones_like(cameras.times) for cameras in batch], [cameras.times if cameras.times is not None else -torch.ones_like(cameras.times) for cameras in batch],
dim=0, dim=0,
), ),
metadata=metadata,
) )
for type_key in extra_mappings: for type_key in extra_mappings:
+194
View File
@@ -0,0 +1,194 @@
!!python/object:nerfstudio.engine.trainer.TrainerConfig
_target: !!python/name:nerfstudio.engine.trainer.Trainer ''
data: null
experiment_name: unnamed
load_checkpoint: !!python/object/apply:pathlib.PosixPath
- outputs
- unnamed
- nerfacto
- 2023-05-24_204526
- config.yml
load_config: null
load_dir: null
load_step: null
log_gradients: false
logging: !!python/object:nerfstudio.configs.base_config.LoggingConfig
local_writer: !!python/object:nerfstudio.configs.base_config.LocalWriterConfig
_target: !!python/name:nerfstudio.utils.writer.LocalWriter ''
enable: true
max_log_size: 10
stats_to_track: !!python/tuple
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Train Iter (time)
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Train Rays / Sec
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Test PSNR
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Vis Rays / Sec
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Test Rays / Sec
- !!python/object/apply:nerfstudio.utils.writer.EventName
- ETA (time)
max_buffer_size: 20
profiler: basic
relative_log_dir: !!python/object/apply:pathlib.PosixPath []
steps_per_log: 10
machine: !!python/object:nerfstudio.configs.base_config.MachineConfig
dist_url: auto
machine_rank: 0
num_gpus: 1
num_machines: 1
seed: 42
max_num_iterations: 30000
method_name: nerfacto
mixed_precision: true
optimizers:
fields:
optimizer: !!python/object:nerfstudio.engine.optimizers.AdamOptimizerConfig
_target: &id001 !!python/name:torch.optim.adam.Adam ''
eps: 1.0e-15
lr: 0.01
max_norm: null
weight_decay: 0
scheduler: !!python/object:nerfstudio.engine.schedulers.ExponentialDecaySchedulerConfig
_target: &id002 !!python/name:nerfstudio.engine.schedulers.ExponentialDecayScheduler ''
lr_final: 0.0001
lr_pre_warmup: 1.0e-08
max_steps: 200000
ramp: cosine
warmup_steps: 0
proposal_networks:
optimizer: !!python/object:nerfstudio.engine.optimizers.AdamOptimizerConfig
_target: *id001
eps: 1.0e-15
lr: 0.01
max_norm: null
weight_decay: 0
scheduler: !!python/object:nerfstudio.engine.schedulers.ExponentialDecaySchedulerConfig
_target: *id002
lr_final: 0.0001
lr_pre_warmup: 1.0e-08
max_steps: 200000
ramp: cosine
warmup_steps: 0
output_dir: !!python/object/apply:pathlib.PosixPath
- outputs
pipeline: !!python/object:nerfstudio.pipelines.base_pipeline.VanillaPipelineConfig
_target: !!python/name:nerfstudio.pipelines.base_pipeline.VanillaPipeline ''
datamanager: !!python/object:nerfstudio.data.datamanagers.base_datamanager.VanillaDataManagerConfig
_target: !!python/name:nerfstudio.data.datamanagers.base_datamanager.VanillaDataManager ''
camera_optimizer: !!python/object:nerfstudio.cameras.camera_optimizers.CameraOptimizerConfig
_target: !!python/name:nerfstudio.cameras.camera_optimizers.CameraOptimizer ''
mode: 'off'
optimizer: !!python/object:nerfstudio.engine.optimizers.AdamOptimizerConfig
_target: *id001
eps: 1.0e-08
lr: 0.0006
max_norm: null
weight_decay: 0.01
orientation_noise_std: 0.0
param_group: camera_opt
position_noise_std: 0.0
scheduler: !!python/object:nerfstudio.engine.schedulers.ExponentialDecaySchedulerConfig
_target: *id002
lr_final: 6.0e-06
lr_pre_warmup: 1.0e-08
max_steps: 200000
ramp: cosine
warmup_steps: 0
camera_res_scale_factor: 1.0
collate_fn: !!python/name:nerfstudio.data.utils.nerfstudio_collate.nerfstudio_collate ''
data: null
dataparser: !!python/object:nerfstudio.data.dataparsers.minimal_dataparser.MinimalDataParserConfig
_target: !!python/name:nerfstudio.data.dataparsers.minimal_dataparser.MinimalDataParser ''
data: !!python/object/apply:pathlib.PosixPath
- /
- home
- kulhajon
- projects
- nerf-playground
- data
- varun
- cheezit-scaled
eval_image_indices: !!python/tuple
- 0
eval_num_images_to_sample_from: -1
eval_num_rays_per_batch: 4096
eval_num_times_to_repeat_images: -1
patch_size: 1
train_num_images_to_sample_from: -1
train_num_rays_per_batch: 4096
train_num_times_to_repeat_images: -1
model: !!python/object:nerfstudio.models.nerfacto.NerfactoModelConfig
_target: !!python/name:nerfstudio.models.nerfacto.NerfactoModel ''
background_color: last_sample
collider_params:
far_plane: 6.0
near_plane: 2.0
disable_scene_contraction: false
distortion_loss_mult: 0.002
enable_collider: true
eval_num_rays_per_chunk: 32768
far_plane: 1000.0
hidden_dim: 64
hidden_dim_color: 64
hidden_dim_transient: 64
interlevel_loss_mult: 1.0
log2_hashmap_size: 19
loss_coefficients:
rgb_loss_coarse: 1.0
rgb_loss_fine: 1.0
max_res: 2048
near_plane: 0.05
num_levels: 16
num_nerf_samples_per_ray: 48
num_proposal_iterations: 2
num_proposal_samples_per_ray: !!python/tuple
- 256
- 96
orientation_loss_mult: 0.0001
pred_normal_loss_mult: 0.001
predict_normals: false
proposal_initial_sampler: piecewise
proposal_net_args_list:
- hidden_dim: 16
log2_hashmap_size: 17
max_res: 128
num_levels: 5
use_linear: false
- hidden_dim: 16
log2_hashmap_size: 17
max_res: 256
num_levels: 5
use_linear: false
proposal_update_every: 5
proposal_warmup: 5000
proposal_weights_anneal_max_num_iters: 1000
proposal_weights_anneal_slope: 10.0
use_average_appearance_embedding: true
use_gradient_scaling: false
use_proposal_weight_anneal: true
use_same_proposal_network: false
use_single_jitter: true
project_name: nerfstudio-project
relative_model_dir: !!python/object/apply:pathlib.PosixPath
- nerfstudio_models
save_only_latest_checkpoint: true
steps_per_eval_all_images: 25000
steps_per_eval_batch: 500
steps_per_eval_image: 500
steps_per_save: 2000
timestamp: 2023-05-24_205104
use_grad_scaler: false
viewer: !!python/object:nerfstudio.configs.base_config.ViewerConfig
image_format: jpeg
jpeg_quality: 90
max_num_display_images: 512
num_rays_per_chunk: 32768
quit_on_train_completion: false
relative_log_filename: viewer_log_filename.txt
websocket_host: 0.0.0.0
websocket_port: null
websocket_port_default: 7007
vis: viewer+wandb
+188
View File
@@ -0,0 +1,188 @@
!!python/object:nerfstudio.engine.trainer.TrainerConfig
_target: !!python/name:nerfstudio.engine.trainer.Trainer ''
data: null
experiment_name: unnamed
load_checkpoint: null
load_config: null
load_dir: null
load_step: null
log_gradients: false
logging: !!python/object:nerfstudio.configs.base_config.LoggingConfig
local_writer: !!python/object:nerfstudio.configs.base_config.LocalWriterConfig
_target: !!python/name:nerfstudio.utils.writer.LocalWriter ''
enable: true
max_log_size: 10
stats_to_track: !!python/tuple
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Train Iter (time)
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Train Rays / Sec
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Test PSNR
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Vis Rays / Sec
- !!python/object/apply:nerfstudio.utils.writer.EventName
- Test Rays / Sec
- !!python/object/apply:nerfstudio.utils.writer.EventName
- ETA (time)
max_buffer_size: 20
profiler: basic
relative_log_dir: !!python/object/apply:pathlib.PosixPath []
steps_per_log: 10
machine: !!python/object:nerfstudio.configs.base_config.MachineConfig
dist_url: auto
machine_rank: 0
num_gpus: 1
num_machines: 1
seed: 42
max_num_iterations: 30000
method_name: nerfacto
mixed_precision: true
optimizers:
fields:
optimizer: !!python/object:nerfstudio.engine.optimizers.AdamOptimizerConfig
_target: &id001 !!python/name:torch.optim.adam.Adam ''
eps: 1.0e-15
lr: 0.01
max_norm: null
weight_decay: 0
scheduler: !!python/object:nerfstudio.engine.schedulers.ExponentialDecaySchedulerConfig
_target: &id002 !!python/name:nerfstudio.engine.schedulers.ExponentialDecayScheduler ''
lr_final: 0.0001
lr_pre_warmup: 1.0e-08
max_steps: 200000
ramp: cosine
warmup_steps: 0
proposal_networks:
optimizer: !!python/object:nerfstudio.engine.optimizers.AdamOptimizerConfig
_target: *id001
eps: 1.0e-15
lr: 0.01
max_norm: null
weight_decay: 0
scheduler: !!python/object:nerfstudio.engine.schedulers.ExponentialDecaySchedulerConfig
_target: *id002
lr_final: 0.0001
lr_pre_warmup: 1.0e-08
max_steps: 200000
ramp: cosine
warmup_steps: 0
output_dir: !!python/object/apply:pathlib.PosixPath
- outputs
pipeline: !!python/object:nerfstudio.pipelines.base_pipeline.VanillaPipelineConfig
_target: !!python/name:nerfstudio.pipelines.base_pipeline.VanillaPipeline ''
datamanager: !!python/object:nerfstudio.data.datamanagers.base_datamanager.VanillaDataManagerConfig
_target: !!python/name:nerfstudio.data.datamanagers.base_datamanager.VanillaDataManager ''
camera_optimizer: !!python/object:nerfstudio.cameras.camera_optimizers.CameraOptimizerConfig
_target: !!python/name:nerfstudio.cameras.camera_optimizers.CameraOptimizer ''
mode: 'off'
optimizer: !!python/object:nerfstudio.engine.optimizers.AdamOptimizerConfig
_target: *id001
eps: 1.0e-08
lr: 0.0006
max_norm: null
weight_decay: 0.01
orientation_noise_std: 0.0
param_group: camera_opt
position_noise_std: 0.0
scheduler: !!python/object:nerfstudio.engine.schedulers.ExponentialDecaySchedulerConfig
_target: *id002
lr_final: 6.0e-06
lr_pre_warmup: 1.0e-08
max_steps: 200000
ramp: cosine
warmup_steps: 0
camera_res_scale_factor: 1.0
data: null
dataparser: !!python/object:nerfstudio.data.dataparsers.minimal_dataparser.MinimalDataParserConfig
_target: !!python/name:nerfstudio.data.dataparsers.minimal_dataparser.MinimalDataParser ''
data: !!python/object/apply:pathlib.PosixPath
- /
- home
- kulhajon
- projects
- nerf-playground
- data
- varun
- cheezit-scaled
eval_image_indices: !!python/tuple
- 0
eval_num_images_to_sample_from: -1
eval_num_rays_per_batch: 4096
eval_num_times_to_repeat_images: -1
patch_size: 1
train_num_images_to_sample_from: -1
train_num_rays_per_batch: 4096
train_num_times_to_repeat_images: -1
model: !!python/object:nerfstudio.models.nerfacto.NerfactoModelConfig
_target: !!python/name:nerfstudio.models.nerfacto.NerfactoModel ''
background_color: last_sample
collider_params:
far_plane: 6.0
near_plane: 2.0
disable_scene_contraction: false
distortion_loss_mult: 0.002
enable_collider: true
eval_num_rays_per_chunk: 32768
far_plane: 1000.0
hidden_dim: 64
hidden_dim_color: 64
hidden_dim_transient: 64
interlevel_loss_mult: 1.0
log2_hashmap_size: 19
loss_coefficients:
rgb_loss_coarse: 1.0
rgb_loss_fine: 1.0
max_res: 2048
near_plane: 0.05
num_levels: 16
num_nerf_samples_per_ray: 48
num_proposal_iterations: 2
num_proposal_samples_per_ray: !!python/tuple
- 256
- 96
orientation_loss_mult: 0.0001
pred_normal_loss_mult: 0.001
predict_normals: false
proposal_initial_sampler: piecewise
proposal_net_args_list:
- hidden_dim: 16
log2_hashmap_size: 17
max_res: 128
num_levels: 5
use_linear: false
- hidden_dim: 16
log2_hashmap_size: 17
max_res: 256
num_levels: 5
use_linear: false
proposal_update_every: 5
proposal_warmup: 5000
proposal_weights_anneal_max_num_iters: 1000
proposal_weights_anneal_slope: 10.0
use_average_appearance_embedding: true
use_gradient_scaling: false
use_proposal_weight_anneal: true
use_same_proposal_network: false
use_single_jitter: true
project_name: nerfstudio-project
relative_model_dir: !!python/object/apply:pathlib.PosixPath
- nerfstudio_models
save_only_latest_checkpoint: true
steps_per_eval_all_images: 25000
steps_per_eval_batch: 500
steps_per_eval_image: 500
steps_per_save: 2000
timestamp: 2023-05-24_204526
use_grad_scaler: false
viewer: !!python/object:nerfstudio.configs.base_config.ViewerConfig
image_format: jpeg
jpeg_quality: 90
max_num_display_images: 512
num_rays_per_chunk: 32768
quit_on_train_completion: false
relative_log_filename: viewer_log_filename.txt
websocket_host: 0.0.0.0
websocket_port: null
websocket_port_default: 7007
vis: viewer+wandb
+19
View File
@@ -1,3 +1,4 @@
from pathlib import Path
from typing import Any from typing import Any
import pytest import pytest
@@ -102,3 +103,21 @@ def test_data_manager_type_can_be_serialized(config):
assert isinstance(obj, tmp2) assert isinstance(obj, tmp2)
finally: finally:
globals().pop("tmp2") globals().pop("tmp2")
def _dummy_function():
return True
def test_deserialize_config1():
with open(Path(__file__).parent / "configs" / "test_config1.yml", "r") as f:
config_str = f.read()
obj = yaml.load(config_str, Loader=yaml.Loader)
obj.pipeline.datamanager.collate_fn([1, 2, 3])
def test_deserialize_config2():
with open(Path(__file__).parent / "configs" / "test_config2.yml", "r") as f:
config_str = f.read()
obj = yaml.load(config_str, Loader=yaml.Loader)
obj.pipeline.datamanager.collate_fn([1, 2, 3])