mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-29 12:31:53 +08:00
fix instant-ngp while preserving robust for nerfacto
This commit is contained in:
1 parent
2575b532ab
commit
f3eb0bd193
3 files changed
+49
-7
No files matched your search
@@ -27,6 +27,7 @@ from nerfstudio.cameras.camera_optimizers import CameraOptimizerConfig
|
|||||||
from nerfstudio.configs.base_config import ViewerConfig
|
from nerfstudio.configs.base_config import ViewerConfig
|
||||||
from nerfstudio.data.datamanagers.base_datamanager import VanillaDataManagerConfig
|
from nerfstudio.data.datamanagers.base_datamanager import VanillaDataManagerConfig
|
||||||
from nerfstudio.data.datamanagers.depth_datamanager import DepthDataManagerConfig
|
from nerfstudio.data.datamanagers.depth_datamanager import DepthDataManagerConfig
|
||||||
|
from nerfstudio.data.datamanagers.patch_datamanager import PatchDataManagerConfig
|
||||||
from nerfstudio.data.datamanagers.semantic_datamanager import SemanticDataManagerConfig
|
from nerfstudio.data.datamanagers.semantic_datamanager import SemanticDataManagerConfig
|
||||||
from nerfstudio.data.datamanagers.variable_res_datamanager import (
|
from nerfstudio.data.datamanagers.variable_res_datamanager import (
|
||||||
VariableResDataManagerConfig,
|
VariableResDataManagerConfig,
|
||||||
@@ -89,10 +90,7 @@ method_configs["nerfacto"] = TrainerConfig(
|
|||||||
mode="SO3xR3", optimizer=AdamOptimizerConfig(lr=6e-4, eps=1e-8, weight_decay=1e-2)
|
mode="SO3xR3", optimizer=AdamOptimizerConfig(lr=6e-4, eps=1e-8, weight_decay=1e-2)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
model=NerfactoModelConfig(
|
model=NerfactoModelConfig(eval_num_rays_per_chunk=1 << 15),
|
||||||
eval_num_rays_per_chunk=1 << 15,
|
|
||||||
robust=False,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
optimizers={
|
optimizers={
|
||||||
"proposal_networks": {
|
"proposal_networks": {
|
||||||
@@ -115,7 +113,7 @@ method_configs["nerfacto-robust"] = TrainerConfig(
|
|||||||
max_num_iterations=30000,
|
max_num_iterations=30000,
|
||||||
mixed_precision=True,
|
mixed_precision=True,
|
||||||
pipeline=VanillaPipelineConfig(
|
pipeline=VanillaPipelineConfig(
|
||||||
datamanager=VanillaDataManagerConfig(
|
datamanager=PatchDataManagerConfig(
|
||||||
dataparser=NerfstudioDataParserConfig(),
|
dataparser=NerfstudioDataParserConfig(),
|
||||||
train_num_rays_per_batch=17000,
|
train_num_rays_per_batch=17000,
|
||||||
eval_num_rays_per_batch=4096,
|
eval_num_rays_per_batch=4096,
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ from nerfstudio.data.dataparsers.phototourism_dataparser import (
|
|||||||
PhototourismDataParserConfig,
|
PhototourismDataParserConfig,
|
||||||
)
|
)
|
||||||
from nerfstudio.data.datasets.base_dataset import InputDataset
|
from nerfstudio.data.datasets.base_dataset import InputDataset
|
||||||
from nerfstudio.data.pixel_samplers import EquirectangularPixelSampler, PixelSampler,PatchPixelSampler
|
from nerfstudio.data.pixel_samplers import EquirectangularPixelSampler, PixelSampler
|
||||||
from nerfstudio.data.utils.dataloaders import (
|
from nerfstudio.data.utils.dataloaders import (
|
||||||
CacheDataloader,
|
CacheDataloader,
|
||||||
FixedIndicesEvalDataloader,
|
FixedIndicesEvalDataloader,
|
||||||
@@ -351,7 +351,7 @@ class VanillaDataManager(DataManager): # pylint: disable=abstract-method
|
|||||||
# Otherwise, use the default pixel sampler
|
# Otherwise, use the default pixel sampler
|
||||||
if is_equirectangular.any():
|
if is_equirectangular.any():
|
||||||
CONSOLE.print("[bold yellow]Warning: Some cameras are equirectangular, but using default pixel sampler.")
|
CONSOLE.print("[bold yellow]Warning: Some cameras are equirectangular, but using default pixel sampler.")
|
||||||
return PatchPixelSampler(*args, **kwargs,patch_size=16)
|
return PixelSampler(*args, **kwargs)
|
||||||
|
|
||||||
def setup_train(self):
|
def setup_train(self):
|
||||||
"""Sets up the data loaders for training"""
|
"""Sets up the data loaders for training"""
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Copyright 2022 The Nerfstudio Team. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
#from abc import abstractmethod
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
from typing import Any, Type
|
||||||
|
|
||||||
|
from nerfstudio.cameras.cameras import CameraType
|
||||||
|
from nerfstudio.data.datamanagers import base_datamanager
|
||||||
|
from nerfstudio.data.datasets.base_dataset import InputDataset
|
||||||
|
from nerfstudio.data.pixel_samplers import EquirectangularPixelSampler, PatchPixelSampler
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PatchDataManagerConfig(base_datamanager.VanillaDataManagerConfig):
|
||||||
|
_target: Type = field(default_factory=lambda: PatchDataManager)
|
||||||
|
"""Target class to instantiate."""
|
||||||
|
|
||||||
|
class PatchDataManager(base_datamanager.VanillaDataManager): # pylint: disable=abstract-method
|
||||||
|
|
||||||
|
def _get_pixel_sampler( # pylint: disable=no-self-use
|
||||||
|
self, dataset: InputDataset, *args: Any, **kwargs: Any
|
||||||
|
) -> PixelSampler:
|
||||||
|
"""Infer pixel sampler to use."""
|
||||||
|
# If all images are equirectangular, use equirectangular pixel sampler
|
||||||
|
is_equirectangular = dataset.cameras.camera_type == CameraType.EQUIRECTANGULAR.value
|
||||||
|
if is_equirectangular.all():
|
||||||
|
return EquirectangularPixelSampler(*args, **kwargs)
|
||||||
|
# Otherwise, use the default pixel sampler
|
||||||
|
if is_equirectangular.any():
|
||||||
|
CONSOLE.print("[bold yellow]Warning: Some cameras are equirectangular, but using default pixel sampler.")
|
||||||
|
return PatchPixelSampler(*args, **kwargs,patch_size=16)
|
||||||
Reference in new issue
Block a user