mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
update to match viser notification api
This commit is contained in:
1 parent
6fbccf1603
commit
006f5f3aa0
2 files changed
+22
-68
No files matched your search
@@ -63,23 +63,6 @@ def get_crop_string(obb: OrientedBox, crop_viewport: bool) -> List[str]:
|
|||||||
scalestring = " ".join([f"{x:.10f}" for x in scale])
|
scalestring = " ".join([f"{x:.10f}" for x in scale])
|
||||||
return [posstring, rpystring, scalestring]
|
return [posstring, rpystring, scalestring]
|
||||||
|
|
||||||
|
|
||||||
def show_notification(
|
|
||||||
export_complete: bool,
|
|
||||||
server: viser.ViserServer,
|
|
||||||
output_dir: str) -> None:
|
|
||||||
if export_complete:
|
|
||||||
server.clear_notification()
|
|
||||||
notif = server.add_notification(
|
|
||||||
title="Export complete!",
|
|
||||||
body="File saved under " + output_dir,
|
|
||||||
withCloseButton=True,
|
|
||||||
loading=False,
|
|
||||||
autoClose=5000,
|
|
||||||
)
|
|
||||||
notif.show()
|
|
||||||
|
|
||||||
|
|
||||||
def populate_point_cloud_tab(
|
def populate_point_cloud_tab(
|
||||||
server: viser.ViserServer,
|
server: viser.ViserServer,
|
||||||
control_panel: ControlPanel,
|
control_panel: ControlPanel,
|
||||||
@@ -117,14 +100,11 @@ def populate_point_cloud_tab(
|
|||||||
@export_button.on_click
|
@export_button.on_click
|
||||||
def _(event: viser.GuiEvent) -> None:
|
def _(event: viser.GuiEvent) -> None:
|
||||||
assert event.client is not None
|
assert event.client is not None
|
||||||
notif = server.add_notification(
|
notif = server.gui.add_notification(
|
||||||
title="Exporting point cloud",
|
title="Exporting point cloud",
|
||||||
body="File will be saved under " + str(output_dir.value),
|
body="File will be saved under " + str(output_dir.value),
|
||||||
withCloseButton=True,
|
|
||||||
loading=True,
|
loading=True,
|
||||||
autoClose=False,
|
|
||||||
)
|
)
|
||||||
notif.show()
|
|
||||||
|
|
||||||
if control_panel.crop_obb is not None and control_panel.crop_viewport:
|
if control_panel.crop_obb is not None and control_panel.crop_viewport:
|
||||||
posstring, rpystring, scalestring = get_crop_string(
|
posstring, rpystring, scalestring = get_crop_string(
|
||||||
@@ -147,10 +127,12 @@ def populate_point_cloud_tab(
|
|||||||
obb_scale=scalestring,
|
obb_scale=scalestring,
|
||||||
)
|
)
|
||||||
export.main()
|
export.main()
|
||||||
|
|
||||||
show_notification(export_complete=export.complete,
|
if export.complete:
|
||||||
server=server,
|
notif.update(
|
||||||
output_dir=str(output_dir.value))
|
title="Export complete!",
|
||||||
|
body="File saved under " + str(output_dir.value),
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
server.add_gui_markdown(
|
server.add_gui_markdown(
|
||||||
@@ -195,11 +177,8 @@ def populate_mesh_tab(
|
|||||||
notif = server.add_notification(
|
notif = server.add_notification(
|
||||||
title="Exporting poisson mesh",
|
title="Exporting poisson mesh",
|
||||||
body="File will be saved under " + str(output_dir.value),
|
body="File will be saved under " + str(output_dir.value),
|
||||||
withCloseButton=True,
|
|
||||||
loading=True,
|
loading=True,
|
||||||
autoClose=False,
|
|
||||||
)
|
)
|
||||||
notif.show()
|
|
||||||
|
|
||||||
if control_panel.crop_obb is not None and control_panel.crop_viewport:
|
if control_panel.crop_obb is not None and control_panel.crop_viewport:
|
||||||
posstring, rpystring, scalestring = get_crop_string(
|
posstring, rpystring, scalestring = get_crop_string(
|
||||||
@@ -224,9 +203,11 @@ def populate_mesh_tab(
|
|||||||
)
|
)
|
||||||
export.main()
|
export.main()
|
||||||
|
|
||||||
show_notification(export_complete=export.complete,
|
if export.complete:
|
||||||
server=server,
|
notif.update(
|
||||||
output_dir=str(output_dir.value))
|
title="Export complete!",
|
||||||
|
body="File saved under " + str(output_dir.value),
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
server.add_gui_markdown(
|
server.add_gui_markdown(
|
||||||
@@ -255,9 +236,7 @@ def populate_splat_tab(
|
|||||||
notif = server.add_notification(
|
notif = server.add_notification(
|
||||||
title="Exporting gaussian splat",
|
title="Exporting gaussian splat",
|
||||||
body="File will be saved under " + str(output_dir.value),
|
body="File will be saved under " + str(output_dir.value),
|
||||||
withCloseButton=True,
|
|
||||||
loading=True,
|
loading=True,
|
||||||
autoClose=False,
|
|
||||||
)
|
)
|
||||||
notif.show()
|
notif.show()
|
||||||
|
|
||||||
@@ -279,9 +258,11 @@ def populate_splat_tab(
|
|||||||
)
|
)
|
||||||
export.main()
|
export.main()
|
||||||
|
|
||||||
show_notification(export_complete=export.complete,
|
if export.complete:
|
||||||
server=server,
|
notif.update(
|
||||||
output_dir=str(output_dir.value))
|
title="Export complete!",
|
||||||
|
body="File saved under " + str(output_dir.value),
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
server.add_gui_markdown(
|
server.add_gui_markdown(
|
||||||
|
|||||||
@@ -1123,14 +1123,11 @@ def populate_render_tab(
|
|||||||
def _(event: viser.GuiEvent) -> None:
|
def _(event: viser.GuiEvent) -> None:
|
||||||
assert event.client is not None
|
assert event.client is not None
|
||||||
render_path = f"renders/{datapath.name}/{render_name_text.value}.mp4"
|
render_path = f"renders/{datapath.name}/{render_name_text.value}.mp4"
|
||||||
notif = server.add_notification(
|
notif = server.gui.add_notification(
|
||||||
title="Rendering trajectory",
|
title="Rendering trajectory",
|
||||||
body="Saving rendered video as " + render_path,
|
body="Saving rendered video as " + render_path,
|
||||||
withCloseButton=True,
|
|
||||||
loading=True,
|
loading=True,
|
||||||
autoClose=False,
|
|
||||||
)
|
)
|
||||||
notif.show()
|
|
||||||
num_frames = int(framerate_number.value * duration_number.value)
|
num_frames = int(framerate_number.value * duration_number.value)
|
||||||
json_data = {}
|
json_data = {}
|
||||||
|
|
||||||
@@ -1245,34 +1242,10 @@ def populate_render_tab(
|
|||||||
render.main()
|
render.main()
|
||||||
|
|
||||||
if render.complete:
|
if render.complete:
|
||||||
server.clear_notification()
|
notif.update(
|
||||||
notif = server.add_notification(
|
title="Render complete!",
|
||||||
title="Render complete!",
|
body="Video saved as " + render_path,
|
||||||
body="Video saved as " + render_path,
|
)
|
||||||
withCloseButton=True,
|
|
||||||
loading=False,
|
|
||||||
autoClose=5000,
|
|
||||||
)
|
|
||||||
notif.show()
|
|
||||||
|
|
||||||
with server.gui.add_modal("Render download") as modal:
|
|
||||||
server.gui.add_markdown("Download the rendered video to your local machine:")
|
|
||||||
|
|
||||||
download_button = server.gui.add_button("Download")
|
|
||||||
|
|
||||||
@downlaod_button.on_click
|
|
||||||
def _(_) -> None:
|
|
||||||
import imageio.v3 as iio
|
|
||||||
|
|
||||||
server.send_file_download(
|
|
||||||
f"{render_name_text.value}.mp4", iio.imwrite("<bytes>", images, extension=".gif")
|
|
||||||
)
|
|
||||||
|
|
||||||
close_button = server.gui.add_button("Close")
|
|
||||||
|
|
||||||
@close_button.on_click
|
|
||||||
def _(_) -> None:
|
|
||||||
modal.close()
|
|
||||||
|
|
||||||
if control_panel is not None:
|
if control_panel is not None:
|
||||||
camera_path = CameraPath(server, duration_number, control_panel._time_enabled)
|
camera_path = CameraPath(server, duration_number, control_panel._time_enabled)
|
||||||
|
|||||||
Reference in new issue
Block a user