mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 14:23:57 +08:00
1 parent
61c8c5b665
commit
5a76b955cd
12 files changed
+40
-31
No files matched your search
@@ -206,6 +206,9 @@ class Config(PrintableConfig):
|
||||
)
|
||||
"""optionally specify a pre-defined config to load from"""
|
||||
vis: Literal["viewer", "wandb", "tensorboard"] = "wandb"
|
||||
"""Which visualizer to use."""
|
||||
data: Optional[Path] = None
|
||||
"""Alias for --pipeline.datamanager.dataparser.data"""
|
||||
|
||||
def is_viewer_enabled(self) -> bool:
|
||||
"""Checks if a viewer is enabled."""
|
||||
@@ -226,7 +229,7 @@ class Config(PrintableConfig):
|
||||
def set_experiment_name(self) -> None:
|
||||
"""Dynamically set the experiment name"""
|
||||
if self.experiment_name is None:
|
||||
self.experiment_name = str(self.pipeline.datamanager.dataparser.data_directory).replace("/", "-")
|
||||
self.experiment_name = str(self.pipeline.datamanager.dataparser.data).replace("/", "-")
|
||||
|
||||
def get_base_dir(self) -> Path:
|
||||
"""Retrieve the base directory to set relative paths"""
|
||||
|
||||
@@ -27,6 +27,7 @@ from nerfstudio.data.datamanagers import VanillaDataManagerConfig
|
||||
from nerfstudio.data.dataparsers.blender_dataparser import BlenderDataParserConfig
|
||||
from nerfstudio.data.dataparsers.friends_dataparser import FriendsDataParserConfig
|
||||
from nerfstudio.data.dataparsers.mipnerf_dataparser import MipNerf360DataParserConfig
|
||||
from nerfstudio.data.dataparsers.nerfstudio_dataparser import NerfstudioDataParserConfig
|
||||
from nerfstudio.engine.optimizers import AdamOptimizerConfig, RAdamOptimizerConfig
|
||||
from nerfstudio.engine.schedulers import SchedulerConfig
|
||||
from nerfstudio.models.base_model import VanillaModelConfig
|
||||
@@ -59,7 +60,7 @@ model_configs["nerfacto"] = Config(
|
||||
trainer=TrainerConfig(steps_per_eval_batch=500, steps_per_save=2000, mixed_precision=True),
|
||||
pipeline=VanillaPipelineConfig(
|
||||
datamanager=VanillaDataManagerConfig(
|
||||
dataparser=BlenderDataParserConfig(), train_num_rays_per_batch=4096, eval_num_rays_per_batch=8192
|
||||
dataparser=NerfstudioDataParserConfig(), train_num_rays_per_batch=4096, eval_num_rays_per_batch=8192
|
||||
),
|
||||
model=NerfactoModelConfig(eval_num_rays_per_chunk=1 << 16),
|
||||
),
|
||||
@@ -81,7 +82,7 @@ model_configs["instant-ngp"] = Config(
|
||||
method_name="instant-ngp",
|
||||
trainer=TrainerConfig(steps_per_eval_batch=500, steps_per_save=2000, mixed_precision=True),
|
||||
pipeline=DynamicBatchPipelineConfig(
|
||||
datamanager=VanillaDataManagerConfig(dataparser=BlenderDataParserConfig(), train_num_rays_per_batch=8192),
|
||||
datamanager=VanillaDataManagerConfig(dataparser=NerfstudioDataParserConfig(), train_num_rays_per_batch=8192),
|
||||
model=InstantNGPModelConfig(eval_num_rays_per_chunk=8192),
|
||||
),
|
||||
optimizers={
|
||||
|
||||
@@ -80,6 +80,8 @@ class DataParserConfig(cfg.InstantiateConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: DataParser)
|
||||
"""_target: target class to instantiate"""
|
||||
data: Path = Path()
|
||||
"""Directory specifying location of data."""
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -40,8 +40,8 @@ class BlenderDataParserConfig(DataParserConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: Blender)
|
||||
"""target class to instantiate"""
|
||||
data_directory: Path = Path("data/blender/lego")
|
||||
"""directory specifying location of data"""
|
||||
data: Path = Path("data/blender/lego")
|
||||
"""Directory specifying location of data."""
|
||||
scale_factor: float = 1.0
|
||||
"""How much to scale the camera origins by."""
|
||||
alpha_color: str = "white"
|
||||
@@ -58,7 +58,7 @@ class Blender(DataParser):
|
||||
|
||||
def __init__(self, config: BlenderDataParserConfig):
|
||||
super().__init__(config=config)
|
||||
self.data_directory: Path = config.data_directory
|
||||
self.data: Path = config.data
|
||||
self.scale_factor: float = config.scale_factor
|
||||
self.alpha_color = config.alpha_color
|
||||
|
||||
@@ -68,11 +68,11 @@ class Blender(DataParser):
|
||||
else:
|
||||
alpha_color_tensor = None
|
||||
|
||||
meta = load_from_json(self.data_directory / f"transforms_{split}.json")
|
||||
meta = load_from_json(self.data / f"transforms_{split}.json")
|
||||
image_filenames = []
|
||||
poses = []
|
||||
for frame in meta["frames"]:
|
||||
fname = self.data_directory / Path(frame["file_path"].replace("./", "") + ".png")
|
||||
fname = self.data / Path(frame["file_path"].replace("./", "") + ".png")
|
||||
image_filenames.append(fname)
|
||||
poses.append(np.array(frame["transform_matrix"]))
|
||||
poses = np.array(poses).astype(np.float32)
|
||||
|
||||
@@ -63,8 +63,8 @@ class FriendsDataParserConfig(DataParserConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: Friends)
|
||||
"""target class to instantiate"""
|
||||
data_directory: Path = Path("data/friends/TBBT-big_living_room")
|
||||
"""directory specifying location of data"""
|
||||
data: Path = Path("data/friends/TBBT-big_living_room")
|
||||
"""Directory specifying location of data."""
|
||||
include_semantics: bool = True
|
||||
"""whether or not to include loading of semantics data"""
|
||||
downscale_factor: int = 8
|
||||
@@ -83,7 +83,7 @@ class Friends(DataParser):
|
||||
|
||||
def _generate_dataparser_outputs(self, split="train"): # pylint: disable=unused-argument,too-many-statements
|
||||
|
||||
cameras_json = load_from_json(self.config.data_directory / "cameras.json")
|
||||
cameras_json = load_from_json(self.config.data / "cameras.json")
|
||||
frames = cameras_json["frames"]
|
||||
bbox = torch.tensor(cameras_json["bbox"])
|
||||
|
||||
@@ -99,7 +99,7 @@ class Friends(DataParser):
|
||||
camera_to_worlds = []
|
||||
for frame in frames:
|
||||
# unpack data
|
||||
image_filename = self.config.data_directory / images_folder / frame["image_name"]
|
||||
image_filename = self.config.data / images_folder / frame["image_name"]
|
||||
intrinsics = torch.tensor(frame["intrinsics"])
|
||||
camtoworld = torch.tensor(frame["camtoworld"])[:3]
|
||||
# append data
|
||||
@@ -155,7 +155,7 @@ class Friends(DataParser):
|
||||
)
|
||||
for image_filename in image_filenames
|
||||
]
|
||||
panoptic_classes = load_from_json(self.config.data_directory / "panoptic_classes.json")
|
||||
panoptic_classes = load_from_json(self.config.data / "panoptic_classes.json")
|
||||
stuff_classes = panoptic_classes["stuff"]
|
||||
stuff_colors = torch.tensor(panoptic_classes["stuff_colors"], dtype=torch.float32) / 255.0
|
||||
thing_classes = panoptic_classes["thing"]
|
||||
|
||||
@@ -41,8 +41,8 @@ class InstantNGPDataParserConfig(DataParserConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: InstantNGP)
|
||||
"""target class to instantiate"""
|
||||
data_directory: Path = Path("data/ours/posterv2")
|
||||
"""directory specifying location of data"""
|
||||
data: Path = Path("data/ours/posterv2")
|
||||
"""Directory specifying location of data."""
|
||||
scale_factor: float = 1.0
|
||||
"""How much to scale the camera origins by."""
|
||||
scene_scale: float = 0.33
|
||||
@@ -57,12 +57,12 @@ class InstantNGP(DataParser):
|
||||
|
||||
def _generate_dataparser_outputs(self, split="train"):
|
||||
|
||||
meta = load_from_json(self.config.data_directory / "transforms.json")
|
||||
meta = load_from_json(self.config.data / "transforms.json")
|
||||
image_filenames = []
|
||||
poses = []
|
||||
num_skipped_image_filenames = 0
|
||||
for frame in meta["frames"]:
|
||||
fname = self.config.data_directory / Path(frame["file_path"])
|
||||
fname = self.config.data / Path(frame["file_path"])
|
||||
if not fname:
|
||||
num_skipped_image_filenames += 1
|
||||
else:
|
||||
|
||||
@@ -38,8 +38,8 @@ class MipNerf360DataParserConfig(DataParserConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: Mipnerf360)
|
||||
"""target class to instantiate"""
|
||||
data_directory: Path = Path("data/mipnerf_360/garden")
|
||||
"""directory specifying location of data"""
|
||||
data: Path = Path("data/mipnerf_360/garden")
|
||||
"""Directory specifying location of data."""
|
||||
downscale_factor: int = 1
|
||||
"""How much to downscale images."""
|
||||
val_skip: int = 8
|
||||
@@ -82,7 +82,7 @@ class Mipnerf360(DataParser):
|
||||
image_dir = "images"
|
||||
if self.config.downscale_factor > 1:
|
||||
image_dir += f"_{self.config.downscale_factor}"
|
||||
image_dir = self.config.data_directory / image_dir
|
||||
image_dir = self.config.data / image_dir
|
||||
if not image_dir.exists():
|
||||
raise ValueError(f"Image directory {image_dir} doesn't exist")
|
||||
|
||||
@@ -96,7 +96,7 @@ class Mipnerf360(DataParser):
|
||||
image_filenames = sorted(image_filenames)
|
||||
num_images = len(image_filenames)
|
||||
|
||||
poses_data = np.load(self.config.data_directory / "poses_bounds.npy")
|
||||
poses_data = np.load(self.config.data / "poses_bounds.npy")
|
||||
poses = poses_data[:, :-2].reshape([-1, 3, 5]).astype(np.float32)
|
||||
bounds = poses_data[:, -2:].transpose([1, 0])
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ class NerfstudioDataParserConfig(DataParserConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: Nerfstudio)
|
||||
"""target class to instantiate"""
|
||||
data_directory: Path = Path("data/nerfstudio/poster")
|
||||
"""directory specifying location of data"""
|
||||
data: Path = Path("data/nerfstudio/poster")
|
||||
"""Directory specifying location of data."""
|
||||
scale_factor: float = 1.0
|
||||
"""How much to scale the camera origins by."""
|
||||
downscale_factor: int = 1
|
||||
@@ -65,7 +65,7 @@ class Nerfstudio(DataParser):
|
||||
def _generate_dataparser_outputs(self, split="train"):
|
||||
# pylint: disable=too-many-statements
|
||||
|
||||
meta = load_from_json(self.config.data_directory / "transforms.json")
|
||||
meta = load_from_json(self.config.data / "transforms.json")
|
||||
image_filenames = []
|
||||
poses = []
|
||||
num_skipped_image_filenames = 0
|
||||
@@ -75,9 +75,9 @@ class Nerfstudio(DataParser):
|
||||
else:
|
||||
filepath = Path(frame["file_path"])
|
||||
if self.config.downscale_factor > 1:
|
||||
fname = self.config.data_directory / f"images_{self.config.downscale_factor}" / filepath.name
|
||||
fname = self.config.data / f"images_{self.config.downscale_factor}" / filepath.name
|
||||
else:
|
||||
fname = self.config.data_directory / filepath
|
||||
fname = self.config.data / filepath
|
||||
if not fname:
|
||||
num_skipped_image_filenames += 1
|
||||
else:
|
||||
|
||||
@@ -41,7 +41,7 @@ class Record3DDataParserConfig(DataParserConfig):
|
||||
|
||||
_target: Type = field(default_factory=lambda: Record3D)
|
||||
"""target class to instantiate"""
|
||||
data_directory: Path = Path("data/record3d/garden")
|
||||
data: Path = Path("data/record3d/garden")
|
||||
"""Location of data"""
|
||||
val_skip: int = 8
|
||||
"""1/val_skip images to use for validation."""
|
||||
@@ -61,7 +61,7 @@ class Record3D(DataParser):
|
||||
config: Record3DDataParserConfig
|
||||
|
||||
def _generate_dataparser_outputs(self, split: str = "train") -> DataparserOutputs:
|
||||
image_dir = self.config.data_directory / "rgb"
|
||||
image_dir = self.config.data / "rgb"
|
||||
|
||||
if not image_dir.exists():
|
||||
raise ValueError(f"Image directory {image_dir} doesn't exist")
|
||||
@@ -75,7 +75,7 @@ class Record3D(DataParser):
|
||||
image_filenames = np.array(image_filenames)
|
||||
num_images = len(image_filenames)
|
||||
|
||||
metadata_path = self.config.data_directory / "metadata.json"
|
||||
metadata_path = self.config.data / "metadata.json"
|
||||
metadata_dict = load_from_json(metadata_path)
|
||||
|
||||
poses_data = np.array(metadata_dict["poses"])
|
||||
|
||||
@@ -54,7 +54,7 @@ def run_viewer_bridge_server_as_subprocess(
|
||||
sock.bind(("", 0))
|
||||
zmq_port = sock.getsockname()[1]
|
||||
string = f"Using ZMQ port: {zmq_port}"
|
||||
CONSOLE.print(f"[bold red]{string}")
|
||||
CONSOLE.print(f"[bold yellow]{string}")
|
||||
|
||||
args.append("--zmq-port")
|
||||
args.append(str(zmq_port))
|
||||
|
||||
Reference in new issue
Block a user