mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-17 21:33:56 +08:00
Converted many @dataclass assignments for python 3.11 compatibility (#2630)
Converted many @dataclass assignments to field()s for python 3.11 compatibility
This commit is contained in:
1 parent
747dd557f6
commit
43a7da36a5
8 files changed
+15
-15
No files matched your search
@@ -17,7 +17,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Any, List, Literal, Optional, Tuple, Type
|
||||
|
||||
@@ -113,7 +113,7 @@ class LoggingConfig(PrintableConfig):
|
||||
max_buffer_size: int = 20
|
||||
"""maximum history size to keep for computing running averages of stats.
|
||||
e.g. if 20, averages will be computed over past 20 occurrences."""
|
||||
local_writer: LocalWriterConfig = LocalWriterConfig(enable=True)
|
||||
local_writer: LocalWriterConfig = field(default_factory=lambda: LocalWriterConfig(enable=True))
|
||||
"""if provided, will print stats locally. if None, will disable printing"""
|
||||
profiler: Literal["none", "basic", "pytorch"] = "basic"
|
||||
"""how to profile the code;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Literal, Optional
|
||||
@@ -51,13 +51,13 @@ class ExperimentConfig(InstantiateConfig):
|
||||
"""Project name."""
|
||||
timestamp: str = "{timestamp}"
|
||||
"""Experiment timestamp."""
|
||||
machine: MachineConfig = MachineConfig()
|
||||
machine: MachineConfig = field(default_factory=lambda: MachineConfig())
|
||||
"""Machine configuration"""
|
||||
logging: LoggingConfig = LoggingConfig()
|
||||
logging: LoggingConfig = field(default_factory=lambda: LoggingConfig())
|
||||
"""Logging configuration"""
|
||||
viewer: ViewerConfig = ViewerConfig()
|
||||
viewer: ViewerConfig = field(default_factory=lambda: ViewerConfig())
|
||||
"""Viewer configuration"""
|
||||
pipeline: VanillaPipelineConfig = VanillaPipelineConfig()
|
||||
pipeline: VanillaPipelineConfig = field(default_factory=lambda: VanillaPipelineConfig())
|
||||
"""Pipeline configuration"""
|
||||
optimizers: Dict[str, Any] = to_immutable_dict(
|
||||
{
|
||||
|
||||
@@ -317,7 +317,7 @@ class VanillaDataManagerConfig(DataManagerConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: VanillaDataManager)
|
||||
"""Target class to instantiate."""
|
||||
dataparser: AnnotatedDataParserUnion = BlenderDataParserConfig()
|
||||
dataparser: AnnotatedDataParserUnion = field(default_factory=lambda: BlenderDataParserConfig())
|
||||
"""Specifies the dataparser used to unpack the data."""
|
||||
train_num_rays_per_batch: int = 1024
|
||||
"""Number of rays per batch to use per training iteration."""
|
||||
@@ -345,7 +345,7 @@ class VanillaDataManagerConfig(DataManagerConfig):
|
||||
"""Size of patch to sample from. If > 1, patch-based sampling will be used."""
|
||||
camera_optimizer: Optional[CameraOptimizerConfig] = field(default=None)
|
||||
"""Deprecated, has been moved to the model config."""
|
||||
pixel_sampler: PixelSamplerConfig = PixelSamplerConfig()
|
||||
pixel_sampler: PixelSamplerConfig = field(default_factory=lambda: PixelSamplerConfig())
|
||||
"""Specifies the pixel sampler used to sample pixels from images."""
|
||||
|
||||
def __post_init__(self):
|
||||
|
||||
@@ -57,7 +57,7 @@ class DataparserOutputs:
|
||||
"""Camera object storing collection of camera information in dataset."""
|
||||
alpha_color: Optional[Float[Tensor, "3"]] = None
|
||||
"""Color of dataset background."""
|
||||
scene_box: SceneBox = SceneBox(aabb=torch.tensor([[-1, -1, -1], [1, 1, 1]]))
|
||||
scene_box: SceneBox = field(default_factory=lambda: SceneBox(aabb=torch.tensor([[-1, -1, -1], [1, 1, 1]])))
|
||||
"""Scene box of dataset. Used to bound the scene or provide the scene scale depending on model."""
|
||||
mask_filenames: Optional[List[Path]] = None
|
||||
"""Filenames for any masks that are required"""
|
||||
|
||||
@@ -79,7 +79,7 @@ class SurfaceModelConfig(ModelConfig):
|
||||
"""Monocular normal consistency loss multiplier."""
|
||||
mono_depth_loss_mult: float = 0.0
|
||||
"""Monocular depth consistency loss multiplier."""
|
||||
sdf_field: SDFFieldConfig = SDFFieldConfig()
|
||||
sdf_field: SDFFieldConfig = field(default_factory=lambda: SDFFieldConfig())
|
||||
"""Config for SDF Field"""
|
||||
background_model: Literal["grid", "mlp", "none"] = "mlp"
|
||||
"""background models"""
|
||||
|
||||
@@ -127,7 +127,7 @@ class NerfactoModelConfig(ModelConfig):
|
||||
"""Which implementation to use for the model."""
|
||||
appearance_embed_dim: int = 32
|
||||
"""Dimension of the appearance embedding."""
|
||||
camera_optimizer: CameraOptimizerConfig = CameraOptimizerConfig(mode="SO3xR3")
|
||||
camera_optimizer: CameraOptimizerConfig = field(default_factory=lambda: CameraOptimizerConfig(mode="SO3xR3"))
|
||||
"""Config of the camera optimizer to use"""
|
||||
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class TensoRFModelConfig(ModelConfig):
|
||||
tensorf_encoding: Literal["triplane", "vm", "cp"] = "vm"
|
||||
regularization: Literal["none", "l1", "tv"] = "l1"
|
||||
"""Regularization method used in tensorf paper"""
|
||||
camera_optimizer: CameraOptimizerConfig = CameraOptimizerConfig(mode="SO3xR3")
|
||||
camera_optimizer: CameraOptimizerConfig = field(default_factory=lambda: CameraOptimizerConfig(mode="SO3xR3"))
|
||||
"""Config of the camera optimizer to use"""
|
||||
use_gradient_scaling: bool = False
|
||||
"""Use gradient scaler where the gradients are lower for points closer to the camera."""
|
||||
|
||||
@@ -224,9 +224,9 @@ class VanillaPipelineConfig(cfg.InstantiateConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: VanillaPipeline)
|
||||
"""target class to instantiate"""
|
||||
datamanager: DataManagerConfig = DataManagerConfig()
|
||||
datamanager: DataManagerConfig = field(default_factory=lambda: DataManagerConfig())
|
||||
"""specifies the datamanager config"""
|
||||
model: ModelConfig = ModelConfig()
|
||||
model: ModelConfig = field(default_factory=lambda: ModelConfig())
|
||||
"""specifies the model config"""
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user