forked from nerfstudio-project/nerfstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 9808ebb Author: Matthew Tancik <[email protected]> Date: Sun Feb 12 11:14:12 2023 -0800 v0.1.17 (nerfstudio-project#1409) commit 2b52f51 Author: Matthew Tancik <[email protected]> Date: Sun Feb 12 11:05:59 2023 -0800 Downgrade nerfacc to 0.3.3 (nerfstudio-project#1408) reset nerfacc to 0.3.3 commit a37c73f Author: Pablo Vela <[email protected]> Date: Sun Feb 12 12:31:31 2023 -0600 sdfstudio dataparser/dataset (nerfstudio-project#1381) * add downloads for sdfstudio datasets * add sdfstudio parser to work with sdfstudio data * fix licensing and doc strings * fix linter errors * move depths/normals to metadata, create sdfdataset * remove extra scenebox parameters * more linting errors fix * fix wrong annotation * add in missing depth/normal files * minor fixes --------- commit 71eacd5 Author: Matthew Tancik <[email protected]> Date: Sat Feb 11 10:51:22 2023 -0800 Update reality capture doc (nerfstudio-project#1404) commit 259f3aa Author: Mark Colley <[email protected]> Date: Fri Feb 10 18:30:57 2023 -0500 Fix IPython error display (nerfstudio-project#1397) commit 3cf2bb0 Author: Matthew Tancik <[email protected]> Date: Thu Feb 9 18:26:13 2023 -0800 Update citation (nerfstudio-project#1392) commit 448e107 Author: Matthew Tancik <[email protected]> Date: Thu Feb 9 17:55:51 2023 -0800 Update doc link commit 6368340 Author: Jonáš Kulhánek <[email protected]> Date: Fri Feb 10 02:31:16 2023 +0100 Add ns-viewer command to run viewer only with model in eval mode (nerfstudio-project#1379) * Add ns-viewer command to run only viewer with model in eval mode * Remove profiler and logger * Fix ns-viewer * ns-viewer remove writer.setup_local_writer * ns-viewer add writer.setup_local_writer * ns-viewer: update docs * Delete outputs commit 27b7132 Author: Jonáš Kulhánek <[email protected]> Date: Fri Feb 10 02:23:33 2023 +0100 Add support for is_fisheye flag in ingp transforms.json (nerfstudio-project#1385) commit b653eef Author: LSong <[email protected]> Date: Thu Feb 9 16:43:21 2023 -0800 add time (nerfstudio-project#1391) * add time * fix black --------- Co-authored-by: LcDog <[email protected]>
- Loading branch information
1 parent
a12faff
commit 8c68a47
Showing
18 changed files
with
491 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# 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. | ||
"""Datapaser for sdfstudio formatted data""" | ||
|
||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass, field | ||
from pathlib import Path | ||
from typing import Type | ||
|
||
import torch | ||
from rich.console import Console | ||
|
||
from nerfstudio.cameras import camera_utils | ||
from nerfstudio.cameras.cameras import Cameras, CameraType | ||
from nerfstudio.data.dataparsers.base_dataparser import ( | ||
DataParser, | ||
DataParserConfig, | ||
DataparserOutputs, | ||
) | ||
from nerfstudio.data.scene_box import SceneBox | ||
from nerfstudio.utils.io import load_from_json | ||
|
||
CONSOLE = Console() | ||
|
||
|
||
@dataclass | ||
class SDFStudioDataParserConfig(DataParserConfig): | ||
"""Scene dataset parser config""" | ||
|
||
_target: Type = field(default_factory=lambda: SDFStudio) | ||
"""target class to instantiate""" | ||
data: Path = Path("data/DTU/scan65") | ||
"""Directory specifying location of data.""" | ||
include_mono_prior: bool = False | ||
"""whether or not to load monocular depth and normal """ | ||
include_foreground_mask: bool = False | ||
"""whether or not to load foreground mask""" | ||
downscale_factor: int = 1 | ||
scene_scale: float = 2.0 | ||
""" | ||
Sets the bounding cube to have edge length of this size. | ||
The longest dimension of the Friends axis-aligned bbox will be scaled to this value. | ||
""" | ||
skip_every_for_val_split: int = 1 | ||
"""sub sampling validation images""" | ||
auto_orient: bool = False | ||
|
||
|
||
@dataclass | ||
class SDFStudio(DataParser): | ||
"""SDFStudio Dataset""" | ||
|
||
config: SDFStudioDataParserConfig | ||
|
||
def _generate_dataparser_outputs(self, split="train"): # pylint: disable=unused-argument,too-many-statements | ||
# load meta data | ||
meta = load_from_json(self.config.data / "meta_data.json") | ||
|
||
indices = list(range(len(meta["frames"]))) | ||
# subsample to avoid out-of-memory for validation set | ||
if split != "train" and self.config.skip_every_for_val_split >= 1: | ||
indices = indices[:: self.config.skip_every_for_val_split] | ||
|
||
image_filenames = [] | ||
depth_filenames = [] | ||
normal_filenames = [] | ||
transform = None | ||
fx = [] | ||
fy = [] | ||
cx = [] | ||
cy = [] | ||
camera_to_worlds = [] | ||
for i, frame in enumerate(meta["frames"]): | ||
if i not in indices: | ||
continue | ||
|
||
image_filename = self.config.data / frame["rgb_path"] | ||
depth_filename = self.config.data / frame["mono_depth_path"] | ||
normal_filename = self.config.data / frame["mono_normal_path"] | ||
|
||
intrinsics = torch.tensor(frame["intrinsics"]) | ||
camtoworld = torch.tensor(frame["camtoworld"]) | ||
|
||
# append data | ||
image_filenames.append(image_filename) | ||
depth_filenames.append(depth_filename) | ||
normal_filenames.append(normal_filename) | ||
fx.append(intrinsics[0, 0]) | ||
fy.append(intrinsics[1, 1]) | ||
cx.append(intrinsics[0, 2]) | ||
cy.append(intrinsics[1, 2]) | ||
camera_to_worlds.append(camtoworld) | ||
|
||
fx = torch.stack(fx) | ||
fy = torch.stack(fy) | ||
cx = torch.stack(cx) | ||
cy = torch.stack(cy) | ||
camera_to_worlds = torch.stack(camera_to_worlds) | ||
|
||
# Convert from COLMAP's/OPENCV's camera coordinate system to nerfstudio | ||
camera_to_worlds[:, 0:3, 1:3] *= -1 | ||
|
||
if self.config.auto_orient: | ||
camera_to_worlds, transform = camera_utils.auto_orient_and_center_poses( | ||
camera_to_worlds, | ||
method="up", | ||
center_poses=False, | ||
) | ||
|
||
# scene box from meta data | ||
meta_scene_box = meta["scene_box"] | ||
aabb = torch.tensor(meta_scene_box["aabb"], dtype=torch.float32) | ||
scene_box = SceneBox( | ||
aabb=aabb, | ||
) | ||
|
||
height, width = meta["height"], meta["width"] | ||
cameras = Cameras( | ||
fx=fx, | ||
fy=fy, | ||
cx=cx, | ||
cy=cy, | ||
height=height, | ||
width=width, | ||
camera_to_worlds=camera_to_worlds[:, :3, :4], | ||
camera_type=CameraType.PERSPECTIVE, | ||
) | ||
|
||
# TODO supports downsample | ||
# cameras.rescale_output_resolution(scaling_factor=1.0 / self.config.downscale_factor) | ||
|
||
assert meta["has_mono_prior"] == self.config.include_mono_prior, f"no mono prior in {self.config.data}" | ||
|
||
dataparser_outputs = DataparserOutputs( | ||
image_filenames=image_filenames, | ||
cameras=cameras, | ||
scene_box=scene_box, | ||
metadata={ | ||
"depth_filenames": depth_filenames if len(depth_filenames) > 0 else None, | ||
"normal_filenames": normal_filenames if len(normal_filenames) > 0 else None, | ||
"transform": transform, | ||
"camera_to_worlds": camera_to_worlds if len(camera_to_worlds) > 0 else None, | ||
"include_mono_prior": self.config.include_mono_prior, | ||
}, | ||
) | ||
return dataparser_outputs |
Oops, something went wrong.