mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-12 10:55:57 +08:00
Add background_color config to keep consistent with other models (#2455)
* add backgorund_color config * removed unused color import
This commit is contained in:
1 parent
c87ebe34ba
commit
2fd8b59d20
4 files changed
+14
-9
No files matched your search
@@ -57,7 +57,7 @@ from nerfstudio.model_components.renderers import (
|
||||
from nerfstudio.model_components.scene_colliders import AABBBoxCollider, SphereCollider
|
||||
from nerfstudio.model_components.shaders import LambertianShader, NormalsShader
|
||||
from nerfstudio.models.base_model import Model, ModelConfig
|
||||
from nerfstudio.utils import colormaps, colors, math, misc
|
||||
from nerfstudio.utils import colormaps, math, misc
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -68,7 +68,8 @@ class GenerfactoModelConfig(ModelConfig):
|
||||
"""target class to instantiate"""
|
||||
prompt: str = "a high quality photo of a ripe pineapple"
|
||||
"""prompt for stable dreamfusion"""
|
||||
|
||||
background_color: Literal["random", "last_sample", "black", "white"] = "white"
|
||||
"""Whether to randomize the background color."""
|
||||
orientation_loss_mult: Tuple[float, float] = (0.001, 10.0)
|
||||
"""Orientation loss multipier on computed normals."""
|
||||
orientation_loss_mult_range: Tuple[int, int] = (0, 15000)
|
||||
@@ -251,7 +252,7 @@ class GenerfactoModel(Model):
|
||||
)
|
||||
|
||||
# renderers
|
||||
self.renderer_rgb = RGBRenderer(background_color=colors.WHITE)
|
||||
self.renderer_rgb = RGBRenderer(background_color=self.config.background_color)
|
||||
self.renderer_accumulation = AccumulationRenderer()
|
||||
self.renderer_depth = DepthRenderer()
|
||||
self.renderer_normals = NormalsRenderer()
|
||||
|
||||
@@ -38,7 +38,7 @@ from nerfstudio.model_components.renderers import (
|
||||
)
|
||||
from nerfstudio.models.base_model import Model
|
||||
from nerfstudio.models.vanilla_nerf import VanillaModelConfig
|
||||
from nerfstudio.utils import colormaps, colors, misc
|
||||
from nerfstudio.utils import colormaps, misc
|
||||
|
||||
|
||||
class MipNerfModel(Model):
|
||||
@@ -81,7 +81,7 @@ class MipNerfModel(Model):
|
||||
self.sampler_pdf = PDFSampler(num_samples=self.config.num_importance_samples, include_original=False)
|
||||
|
||||
# renderers
|
||||
self.renderer_rgb = RGBRenderer(background_color=colors.WHITE)
|
||||
self.renderer_rgb = RGBRenderer(background_color=self.config.background_color)
|
||||
self.renderer_accumulation = AccumulationRenderer()
|
||||
self.renderer_depth = DepthRenderer()
|
||||
|
||||
|
||||
@@ -89,6 +89,8 @@ class TensoRFModelConfig(ModelConfig):
|
||||
tensorf_encoding: Literal["triplane", "vm", "cp"] = "vm"
|
||||
regularization: Literal["none", "l1", "tv"] = "l1"
|
||||
"""Regularization method used in tensorf paper"""
|
||||
background_color: Literal["random", "last_sample", "black", "white"] = "white"
|
||||
"""Whether to randomize the background color."""
|
||||
|
||||
|
||||
class TensoRFModel(Model):
|
||||
@@ -234,7 +236,7 @@ class TensoRFModel(Model):
|
||||
self.sampler_pdf = PDFSampler(num_samples=self.config.num_samples, single_jitter=True, include_original=False)
|
||||
|
||||
# renderers
|
||||
self.renderer_rgb = RGBRenderer(background_color=colors.WHITE)
|
||||
self.renderer_rgb = RGBRenderer(background_color=self.config.background_color)
|
||||
self.renderer_accumulation = AccumulationRenderer()
|
||||
self.renderer_depth = DepthRenderer()
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ Implementation of vanilla nerf.
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Tuple, Type
|
||||
from typing import Any, Dict, List, Tuple, Type, Literal
|
||||
|
||||
import torch
|
||||
from torch.nn import Parameter
|
||||
@@ -41,7 +41,7 @@ from nerfstudio.model_components.renderers import (
|
||||
RGBRenderer,
|
||||
)
|
||||
from nerfstudio.models.base_model import Model, ModelConfig
|
||||
from nerfstudio.utils import colormaps, colors, misc
|
||||
from nerfstudio.utils import colormaps, misc
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -58,6 +58,8 @@ class VanillaModelConfig(ModelConfig):
|
||||
"""Specifies whether or not to include ray warping based on time."""
|
||||
temporal_distortion_params: Dict[str, Any] = to_immutable_dict({"kind": TemporalDistortionKind.DNERF})
|
||||
"""Parameters to instantiate temporal distortion with"""
|
||||
background_color: Literal["random", "last_sample", "black", "white"] = "white"
|
||||
"""Whether to randomize the background color."""
|
||||
|
||||
|
||||
class NeRFModel(Model):
|
||||
@@ -110,7 +112,7 @@ class NeRFModel(Model):
|
||||
self.sampler_pdf = PDFSampler(num_samples=self.config.num_importance_samples)
|
||||
|
||||
# renderers
|
||||
self.renderer_rgb = RGBRenderer(background_color=colors.WHITE)
|
||||
self.renderer_rgb = RGBRenderer(background_color=self.config.background_color)
|
||||
self.renderer_accumulation = AccumulationRenderer()
|
||||
self.renderer_depth = DepthRenderer()
|
||||
|
||||
|
||||
Reference in new issue
Block a user