From 5be513e9688e1bb171907ab81d7536e7f1aa2976 Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Wed, 8 Jan 2025 17:10:43 +0800 Subject: [PATCH] Write camera path to output dir if saving to the data dir fails (#3476) * Update render_panel.py * Update render_panel.py * Update render_panel.py * Update render_panel.py * isort fix * Update render_panel.py --------- Co-authored-by: J.Y. <132313008+jb-ye@users.noreply.github.com> --- nerfstudio/viewer/render_panel.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nerfstudio/viewer/render_panel.py b/nerfstudio/viewer/render_panel.py index 10d263f8c..83e340757 100644 --- a/nerfstudio/viewer/render_panel.py +++ b/nerfstudio/viewer/render_panel.py @@ -30,6 +30,7 @@ import viser import viser.transforms as tf from scipy import interpolate +from nerfstudio.utils.rich_utils import CONSOLE from nerfstudio.viewer.control_panel import ControlPanel @@ -1130,8 +1131,15 @@ def populate_render_tab( } # now write the json file - json_outfile = datapath / "camera_paths" / f"{render_name_text.value}.json" - json_outfile.parent.mkdir(parents=True, exist_ok=True) + try: + json_outfile = datapath / "camera_paths" / f"{render_name_text.value}.json" + json_outfile.parent.mkdir(parents=True, exist_ok=True) + except Exception: + CONSOLE.print( + "[bold yellow]Warning: Failed to write the camera path to the data directory. Saving to the output directory instead." + ) + json_outfile = config_path.parent / "camera_paths" / f"{render_name_text.value}.json" + json_outfile.parent.mkdir(parents=True, exist_ok=True) with open(json_outfile.absolute(), "w") as outfile: json.dump(json_data, outfile) # now show the command