Spaces:
Running on Zero
Running on Zero
Fix auto-kinematics queued mesh events
Browse files
app.py
CHANGED
|
@@ -1542,6 +1542,7 @@ UPRIGHT_PICKER_JS = r"""
|
|
| 1542 |
return;
|
| 1543 |
}
|
| 1544 |
window.__instructParticulateUprightPickerReady = true;
|
|
|
|
| 1545 |
|
| 1546 |
function selectedField() {
|
| 1547 |
return document.querySelector("#selected_up_dir textarea, #selected_up_dir input");
|
|
@@ -1552,6 +1553,7 @@ UPRIGHT_PICKER_JS = r"""
|
|
| 1552 |
}
|
| 1553 |
|
| 1554 |
function updateCards(selectedValue) {
|
|
|
|
| 1555 |
choices.forEach(([upDir, slug]) => {
|
| 1556 |
const card = cardForSlug(slug);
|
| 1557 |
if (!card) {
|
|
@@ -1601,7 +1603,11 @@ UPRIGHT_PICKER_JS = r"""
|
|
| 1601 |
|
| 1602 |
const syncFromField = () => {
|
| 1603 |
const field = selectedField();
|
| 1604 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1605 |
};
|
| 1606 |
const observer = new MutationObserver(syncFromField);
|
| 1607 |
observer.observe(document.body, {
|
|
@@ -4837,6 +4843,10 @@ def prepare_inference_ui():
|
|
| 4837 |
)
|
| 4838 |
|
| 4839 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4840 |
def _example_meshes() -> list[dict[str, str]]:
|
| 4841 |
examples_dir = REPO_ROOT / "examples"
|
| 4842 |
render_dir = examples_dir / "render"
|
|
@@ -5175,24 +5185,39 @@ def create_gradio_app(app: InstructParticulateApp) -> gr.Blocks:
|
|
| 5175 |
],
|
| 5176 |
)
|
| 5177 |
|
| 5178 |
-
|
| 5179 |
-
|
| 5180 |
-
|
| 5181 |
-
|
| 5182 |
-
|
| 5183 |
-
|
| 5184 |
-
|
| 5185 |
-
|
| 5186 |
-
|
| 5187 |
-
|
| 5188 |
-
|
| 5189 |
-
|
| 5190 |
-
|
| 5191 |
-
|
| 5192 |
-
|
| 5193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5194 |
)
|
| 5195 |
-
|
| 5196 |
fn=app.extract_kinematic_structure,
|
| 5197 |
inputs=[
|
| 5198 |
loaded_mesh_path,
|
|
|
|
| 1542 |
return;
|
| 1543 |
}
|
| 1544 |
window.__instructParticulateUprightPickerReady = true;
|
| 1545 |
+
let lastSelectedValue = "";
|
| 1546 |
|
| 1547 |
function selectedField() {
|
| 1548 |
return document.querySelector("#selected_up_dir textarea, #selected_up_dir input");
|
|
|
|
| 1553 |
}
|
| 1554 |
|
| 1555 |
function updateCards(selectedValue) {
|
| 1556 |
+
lastSelectedValue = selectedValue || "";
|
| 1557 |
choices.forEach(([upDir, slug]) => {
|
| 1558 |
const card = cardForSlug(slug);
|
| 1559 |
if (!card) {
|
|
|
|
| 1603 |
|
| 1604 |
const syncFromField = () => {
|
| 1605 |
const field = selectedField();
|
| 1606 |
+
if (!field) {
|
| 1607 |
+
updateCards(lastSelectedValue);
|
| 1608 |
+
return;
|
| 1609 |
+
}
|
| 1610 |
+
updateCards(field.value || "");
|
| 1611 |
};
|
| 1612 |
const observer = new MutationObserver(syncFromField);
|
| 1613 |
observer.observe(document.body, {
|
|
|
|
| 4843 |
)
|
| 4844 |
|
| 4845 |
|
| 4846 |
+
def prepare_auto_kinematics_ui():
|
| 4847 |
+
return "Starting auto-kinematic extraction..."
|
| 4848 |
+
|
| 4849 |
+
|
| 4850 |
def _example_meshes() -> list[dict[str, str]]:
|
| 4851 |
examples_dir = REPO_ROOT / "examples"
|
| 4852 |
render_dir = examples_dir / "render"
|
|
|
|
| 5185 |
],
|
| 5186 |
)
|
| 5187 |
|
| 5188 |
+
mesh_registration_outputs = [
|
| 5189 |
+
loaded_mesh_path,
|
| 5190 |
+
loaded_mesh_hash,
|
| 5191 |
+
mesh_face_warning,
|
| 5192 |
+
kinematic_tree,
|
| 5193 |
+
point_prompts,
|
| 5194 |
+
point_prompt_mesh_data,
|
| 5195 |
+
*upright_preview_images,
|
| 5196 |
+
selected_up_dir,
|
| 5197 |
+
latest_output_dir,
|
| 5198 |
+
export_urdf_button,
|
| 5199 |
+
urdf_zip,
|
| 5200 |
+
]
|
| 5201 |
+
mesh_upload_event = getattr(input_mesh, "upload", None)
|
| 5202 |
+
if callable(mesh_upload_event):
|
| 5203 |
+
mesh_upload_event(
|
| 5204 |
+
fn=app.register_mesh,
|
| 5205 |
+
inputs=[input_mesh, loaded_mesh_hash],
|
| 5206 |
+
outputs=mesh_registration_outputs,
|
| 5207 |
+
)
|
| 5208 |
+
else:
|
| 5209 |
+
input_mesh.change(
|
| 5210 |
+
fn=app.register_mesh,
|
| 5211 |
+
inputs=[input_mesh, loaded_mesh_hash],
|
| 5212 |
+
outputs=mesh_registration_outputs,
|
| 5213 |
+
)
|
| 5214 |
+
extract_start_event = extract_button.click(
|
| 5215 |
+
fn=prepare_auto_kinematics_ui,
|
| 5216 |
+
inputs=None,
|
| 5217 |
+
outputs=[auto_status],
|
| 5218 |
+
queue=False,
|
| 5219 |
)
|
| 5220 |
+
extract_start_event.then(
|
| 5221 |
fn=app.extract_kinematic_structure,
|
| 5222 |
inputs=[
|
| 5223 |
loaded_mesh_path,
|