Skip to content

Commit 7427057

Browse files
committed
refactor: Modify CLI arguments and camera data handling for gs-render and gs-extract-mesh
- Replace `--camera` with `--source_path` in extract_mesh.py - Modify source_path handling logic in extract_mesh.py and render_gs.py - Add dataset configuration and initialization in extract_mesh.py
1 parent dc9281a commit 7427057

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

gaustudio/scripts/extract_mesh.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def main():
2222
parser = argparse.ArgumentParser()
2323
parser.add_argument('--config', help='path to config file', default='vanilla')
2424
parser.add_argument('--gpu', default='0', help='GPU(s) to be used')
25-
parser.add_argument('--camera', '-c', default=None, help='path to cameras.json')
2625
parser.add_argument('--model', '-m', default=None, help='path to the model')
26+
parser.add_argument('--source_path', '-s', help='path to the dataset')
2727
parser.add_argument('--output-dir', '-o', default=None, help='path to the output dir')
2828
parser.add_argument('--load_iteration', default=-1, type=int, help='iteration to be rendered')
2929
parser.add_argument('--resolution', default=2, type=int, help='downscale resolution')
@@ -67,19 +67,23 @@ def main():
6767
print("Model not found at {}".format(model_path))
6868
pcd.to("cuda")
6969

70-
if args.camera is None:
71-
args.camera = os.path.join(model_path, "cameras.json")
72-
if os.path.exists(args.camera):
73-
print("Loading camera data from {}".format(args.camera))
74-
with open(args.camera, 'r') as f:
70+
if args.source_path is None:
71+
args.source_path = os.path.join(os.path.dirname(model_path), "cameras.json")
72+
73+
if args.source_path.endswith(".json"):
74+
print("Loading camera data from {}".format(args.source_path))
75+
with open(args.source_path, 'r') as f:
7576
camera_data = json.load(f)
7677
cameras = []
7778
for camera_json in camera_data:
7879
camera = JSON_to_camera(camera_json, "cuda")
7980
cameras.append(camera)
80-
vdb_volume = vdbfusion.VDBVolume(voxel_size=0.01, sdf_trunc=0.04, space_carving=False) # For Scene
8181
else:
82-
assert "Camera data not found at {}".format(args.camera)
82+
dataset_config = { "name":"colmap", "source_path": args.source_path,
83+
"images":"images", "resolution":-1, "data_device":"cuda", "eval": False}
84+
dataset = datasets.make(dataset_config)
85+
cameras = dataset.all_cameras
86+
vdb_volume = vdbfusion.VDBVolume(voxel_size=0.01, sdf_trunc=0.04, space_carving=False) # For Scene
8387

8488
bg_color = [1,1,1] if args.white_background else [0, 0, 0]
8589
background = torch.tensor(bg_color, dtype=torch.float32, device="cuda")
@@ -95,6 +99,7 @@ def main():
9599
render_pkg = renderer.render(camera, pcd)
96100
rendering = render_pkg["render"]
97101
rendered_final_opacity = render_pkg["rendered_final_opacity"][0]
102+
# rendered_depth = render_pkg["rendered_depth"][0] / rendered_final_opacity
98103
rendered_depth = render_pkg["rendered_median_depth"][0]
99104
invalid_mask = rendered_final_opacity < 0.5
100105

gaustudio/scripts/render_gs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def main():
2222
parser.add_argument('--config', help='path to config file', default='vanilla')
2323
parser.add_argument('--gpu', default='0', help='GPU(s) to be used')
2424
parser.add_argument('--model', '-m', default=None, help='path to the model')
25-
parser.add_argument('--source_path', '-s', required=True, help='path to the dataset')
25+
parser.add_argument('--source_path', '-s', help='path to the dataset')
2626
parser.add_argument('--flythrough', action='store_true', help='render a flythrough path')
2727
parser.add_argument('--output-dir', '-o', default=None, help='path to the output dir')
2828
parser.add_argument('--load_iteration', default=-1, type=int, help='iteration to be rendered')
@@ -64,7 +64,7 @@ def main():
6464
pcd.to("cuda")
6565

6666
if args.source_path is None:
67-
args.source_path = os.path.join(model_path, "cameras.json")
67+
args.source_path = os.path.join(os.path.dirname(model_path), "cameras.json")
6868

6969
if args.source_path.endswith(".json"):
7070
print("Loading camera data from {}".format(args.source_path))

0 commit comments

Comments
 (0)