mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-16 04:43:52 +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])
|
||||
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(
|
||||
server: viser.ViserServer,
|
||||
control_panel: ControlPanel,
|
||||
@@ -117,14 +100,11 @@ def populate_point_cloud_tab(
|
||||
@export_button.on_click
|
||||
def _(event: viser.GuiEvent) -> None:
|
||||
assert event.client is not None
|
||||
notif = server.add_notification(
|
||||
notif = server.gui.add_notification(
|
||||
title="Exporting point cloud",
|
||||
body="File will be saved under " + str(output_dir.value),
|
||||
withCloseButton=True,
|
||||
loading=True,
|
||||
autoClose=False,
|
||||
)
|
||||
notif.show()
|
||||
|
||||
if control_panel.crop_obb is not None and control_panel.crop_viewport:
|
||||
posstring, rpystring, scalestring = get_crop_string(
|
||||
@@ -147,10 +127,12 @@ def populate_point_cloud_tab(
|
||||
obb_scale=scalestring,
|
||||
)
|
||||
export.main()
|
||||
|
||||
show_notification(export_complete=export.complete,
|
||||
server=server,
|
||||
output_dir=str(output_dir.value))
|
||||
|
||||
if export.complete:
|
||||
notif.update(
|
||||
title="Export complete!",
|
||||
body="File saved under " + str(output_dir.value),
|
||||
)
|
||||
|
||||
else:
|
||||
server.add_gui_markdown(
|
||||
@@ -195,11 +177,8 @@ def populate_mesh_tab(
|
||||
notif = server.add_notification(
|
||||
title="Exporting poisson mesh",
|
||||
body="File will be saved under " + str(output_dir.value),
|
||||
withCloseButton=True,
|
||||
loading=True,
|
||||
autoClose=False,
|
||||
)
|
||||
notif.show()
|
||||
|
||||
if control_panel.crop_obb is not None and control_panel.crop_viewport:
|
||||
posstring, rpystring, scalestring = get_crop_string(
|
||||
@@ -224,9 +203,11 @@ def populate_mesh_tab(
|
||||
)
|
||||
export.main()
|
||||
|
||||
show_notification(export_complete=export.complete,
|
||||
server=server,
|
||||
output_dir=str(output_dir.value))
|
||||
if export.complete:
|
||||
notif.update(
|
||||
title="Export complete!",
|
||||
body="File saved under " + str(output_dir.value),
|
||||
)
|
||||
|
||||
else:
|
||||
server.add_gui_markdown(
|
||||
@@ -255,9 +236,7 @@ def populate_splat_tab(
|
||||
notif = server.add_notification(
|
||||
title="Exporting gaussian splat",
|
||||
body="File will be saved under " + str(output_dir.value),
|
||||
withCloseButton=True,
|
||||
loading=True,
|
||||
autoClose=False,
|
||||
)
|
||||
notif.show()
|
||||
|
||||
@@ -279,9 +258,11 @@ def populate_splat_tab(
|
||||
)
|
||||
export.main()
|
||||
|
||||
show_notification(export_complete=export.complete,
|
||||
server=server,
|
||||
output_dir=str(output_dir.value))
|
||||
if export.complete:
|
||||
notif.update(
|
||||
title="Export complete!",
|
||||
body="File saved under " + str(output_dir.value),
|
||||
)
|
||||
|
||||
else:
|
||||
server.add_gui_markdown(
|
||||
|
||||
@@ -1123,14 +1123,11 @@ def populate_render_tab(
|
||||
def _(event: viser.GuiEvent) -> None:
|
||||
assert event.client is not None
|
||||
render_path = f"renders/{datapath.name}/{render_name_text.value}.mp4"
|
||||
notif = server.add_notification(
|
||||
notif = server.gui.add_notification(
|
||||
title="Rendering trajectory",
|
||||
body="Saving rendered video as " + render_path,
|
||||
withCloseButton=True,
|
||||
loading=True,
|
||||
autoClose=False,
|
||||
)
|
||||
notif.show()
|
||||
num_frames = int(framerate_number.value * duration_number.value)
|
||||
json_data = {}
|
||||
|
||||
@@ -1245,34 +1242,10 @@ def populate_render_tab(
|
||||
render.main()
|
||||
|
||||
if render.complete:
|
||||
server.clear_notification()
|
||||
notif = server.add_notification(
|
||||
title="Render complete!",
|
||||
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()
|
||||
notif.update(
|
||||
title="Render complete!",
|
||||
body="Video saved as " + render_path,
|
||||
)
|
||||
|
||||
if control_panel is not None:
|
||||
camera_path = CameraPath(server, duration_number, control_panel._time_enabled)
|
||||
|
||||
Reference in new issue
Block a user