Spaces:
Running on Zero
Running on Zero
Make mesh registration UI updates idempotent
Browse files
app.py
CHANGED
|
@@ -3883,17 +3883,26 @@ class InstructParticulateApp:
|
|
| 3883 |
warning_face_count = max(face_count, int(early_face_count or 0))
|
| 3884 |
mesh_face_warning = _mesh_face_warning_update_from_face_count(warning_face_count)
|
| 3885 |
cached_upright_previews = _cached_upright_preview_items(mesh_hash)
|
| 3886 |
-
rendering_orientation_previews = (
|
| 3887 |
-
_upright_preview_paths(cached_upright_previews)
|
| 3888 |
-
if cached_upright_previews is not None
|
| 3889 |
-
else _upright_rendering_preview_paths()
|
| 3890 |
-
)
|
| 3891 |
|
| 3892 |
try:
|
| 3893 |
prompt_mesh_data = _prompt_mesh_payload(mesh)
|
| 3894 |
except Exception:
|
| 3895 |
prompt_mesh_data = ""
|
| 3896 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3897 |
yield (
|
| 3898 |
str(mesh_path),
|
| 3899 |
mesh_hash,
|
|
@@ -3901,53 +3910,13 @@ class InstructParticulateApp:
|
|
| 3901 |
default_tree_json,
|
| 3902 |
default_point_prompt_json,
|
| 3903 |
prompt_mesh_data,
|
| 3904 |
-
*
|
| 3905 |
"",
|
| 3906 |
None,
|
| 3907 |
gr.update(interactive=False),
|
| 3908 |
gr.update(value=None, interactive=False),
|
| 3909 |
)
|
| 3910 |
|
| 3911 |
-
if cached_upright_previews is not None:
|
| 3912 |
-
return
|
| 3913 |
-
|
| 3914 |
-
try:
|
| 3915 |
-
upright_previews = _render_up_direction_previews(
|
| 3916 |
-
mesh_path=mesh_path,
|
| 3917 |
-
mesh=mesh,
|
| 3918 |
-
mesh_hash=mesh_hash,
|
| 3919 |
-
)
|
| 3920 |
-
except Exception:
|
| 3921 |
-
traceback.print_exc()
|
| 3922 |
-
yield (
|
| 3923 |
-
str(mesh_path),
|
| 3924 |
-
mesh_hash,
|
| 3925 |
-
mesh_face_warning,
|
| 3926 |
-
default_tree_json,
|
| 3927 |
-
default_point_prompt_json,
|
| 3928 |
-
prompt_mesh_data,
|
| 3929 |
-
*empty_orientation_previews,
|
| 3930 |
-
gr.skip(),
|
| 3931 |
-
gr.skip(),
|
| 3932 |
-
gr.skip(),
|
| 3933 |
-
gr.skip(),
|
| 3934 |
-
)
|
| 3935 |
-
return
|
| 3936 |
-
|
| 3937 |
-
yield (
|
| 3938 |
-
str(mesh_path),
|
| 3939 |
-
mesh_hash,
|
| 3940 |
-
mesh_face_warning,
|
| 3941 |
-
default_tree_json,
|
| 3942 |
-
default_point_prompt_json,
|
| 3943 |
-
prompt_mesh_data,
|
| 3944 |
-
*_upright_preview_paths(upright_previews),
|
| 3945 |
-
gr.skip(),
|
| 3946 |
-
gr.skip(),
|
| 3947 |
-
gr.skip(),
|
| 3948 |
-
gr.skip(),
|
| 3949 |
-
)
|
| 3950 |
-
|
| 3951 |
def select_example_mesh(self, selected_index_value: Any):
|
| 3952 |
examples = _example_meshes()
|
| 3953 |
selected_index = int(str(selected_index_value).strip())
|
|
|
|
| 3883 |
warning_face_count = max(face_count, int(early_face_count or 0))
|
| 3884 |
mesh_face_warning = _mesh_face_warning_update_from_face_count(warning_face_count)
|
| 3885 |
cached_upright_previews = _cached_upright_preview_items(mesh_hash)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3886 |
|
| 3887 |
try:
|
| 3888 |
prompt_mesh_data = _prompt_mesh_payload(mesh)
|
| 3889 |
except Exception:
|
| 3890 |
prompt_mesh_data = ""
|
| 3891 |
|
| 3892 |
+
if cached_upright_previews is not None:
|
| 3893 |
+
orientation_previews = _upright_preview_paths(cached_upright_previews)
|
| 3894 |
+
else:
|
| 3895 |
+
try:
|
| 3896 |
+
upright_previews = _render_up_direction_previews(
|
| 3897 |
+
mesh_path=mesh_path,
|
| 3898 |
+
mesh=mesh,
|
| 3899 |
+
mesh_hash=mesh_hash,
|
| 3900 |
+
)
|
| 3901 |
+
orientation_previews = _upright_preview_paths(upright_previews)
|
| 3902 |
+
except Exception:
|
| 3903 |
+
traceback.print_exc()
|
| 3904 |
+
orientation_previews = empty_orientation_previews
|
| 3905 |
+
|
| 3906 |
yield (
|
| 3907 |
str(mesh_path),
|
| 3908 |
mesh_hash,
|
|
|
|
| 3910 |
default_tree_json,
|
| 3911 |
default_point_prompt_json,
|
| 3912 |
prompt_mesh_data,
|
| 3913 |
+
*orientation_previews,
|
| 3914 |
"",
|
| 3915 |
None,
|
| 3916 |
gr.update(interactive=False),
|
| 3917 |
gr.update(value=None, interactive=False),
|
| 3918 |
)
|
| 3919 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3920 |
def select_example_mesh(self, selected_index_value: Any):
|
| 3921 |
examples = _example_meshes()
|
| 3922 |
selected_index = int(str(selected_index_value).strip())
|