Spaces:
Running on Zero
Running on Zero
Fix OBJ auto-kinematics render coordinate frame
Browse files- app.py +7 -2
- scripts/render_auto_kinematics_blender.py +2 -0
app.py
CHANGED
|
@@ -111,6 +111,7 @@ OUTPUT_ROOT = Path(os.environ.get("INSTRUCT_PARTICULATE_OUTPUT_ROOT", str(DEFAUL
|
|
| 111 |
UP_DIR_CHOICES = ["+X", "-X", "+Y", "-Y", "+Z", "-Z"]
|
| 112 |
AUTO_KINEMATICS_MODEL_ID = "gemini-3.5-flash"
|
| 113 |
AUTO_KINEMATICS_REASONING_EFFORT = "medium"
|
|
|
|
| 114 |
|
| 115 |
DEFAULT_KINEMATIC_TREE = {
|
| 116 |
"links": [
|
|
@@ -2651,7 +2652,11 @@ def _auto_kinematics_cache_complete_path(cache_dir: Path) -> Path:
|
|
| 2651 |
def _cached_auto_kinematics(
|
| 2652 |
cache_dir: Path,
|
| 2653 |
) -> tuple[str, str, list[tuple[str, str]]] | None:
|
| 2654 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2655 |
return None
|
| 2656 |
tree_path = cache_dir / "demo_kinematic_tree.json"
|
| 2657 |
prompt_path = cache_dir / "demo_point_prompts.json"
|
|
@@ -2703,7 +2708,7 @@ def _store_auto_kinematics_cache(source_dir: Path, cache_dir: Path) -> None:
|
|
| 2703 |
_auto_kinematics_cache_complete_path(temp_dir).write_text(
|
| 2704 |
json.dumps(
|
| 2705 |
{
|
| 2706 |
-
"version":
|
| 2707 |
"created_at": datetime.now().isoformat(timespec="seconds"),
|
| 2708 |
"render_count": len(render_paths),
|
| 2709 |
},
|
|
|
|
| 111 |
UP_DIR_CHOICES = ["+X", "-X", "+Y", "-Y", "+Z", "-Z"]
|
| 112 |
AUTO_KINEMATICS_MODEL_ID = "gemini-3.5-flash"
|
| 113 |
AUTO_KINEMATICS_REASONING_EFFORT = "medium"
|
| 114 |
+
AUTO_KINEMATICS_CACHE_VERSION = 2
|
| 115 |
|
| 116 |
DEFAULT_KINEMATIC_TREE = {
|
| 117 |
"links": [
|
|
|
|
| 2652 |
def _cached_auto_kinematics(
|
| 2653 |
cache_dir: Path,
|
| 2654 |
) -> tuple[str, str, list[tuple[str, str]]] | None:
|
| 2655 |
+
complete_path = _auto_kinematics_cache_complete_path(cache_dir)
|
| 2656 |
+
if not complete_path.exists():
|
| 2657 |
+
return None
|
| 2658 |
+
complete_payload = json.loads(complete_path.read_text(encoding="utf-8"))
|
| 2659 |
+
if int(complete_payload.get("version", 0)) != AUTO_KINEMATICS_CACHE_VERSION:
|
| 2660 |
return None
|
| 2661 |
tree_path = cache_dir / "demo_kinematic_tree.json"
|
| 2662 |
prompt_path = cache_dir / "demo_point_prompts.json"
|
|
|
|
| 2708 |
_auto_kinematics_cache_complete_path(temp_dir).write_text(
|
| 2709 |
json.dumps(
|
| 2710 |
{
|
| 2711 |
+
"version": AUTO_KINEMATICS_CACHE_VERSION,
|
| 2712 |
"created_at": datetime.now().isoformat(timespec="seconds"),
|
| 2713 |
"render_count": len(render_paths),
|
| 2714 |
},
|
scripts/render_auto_kinematics_blender.py
CHANGED
|
@@ -106,6 +106,8 @@ def load_object(mesh_path: Path) -> None:
|
|
| 106 |
result = importer(filepath=str(mesh_path), merge_vertices=False)
|
| 107 |
except TypeError:
|
| 108 |
result = importer(filepath=str(mesh_path))
|
|
|
|
|
|
|
| 109 |
else:
|
| 110 |
result = importer(filepath=str(mesh_path))
|
| 111 |
if "FINISHED" not in result:
|
|
|
|
| 106 |
result = importer(filepath=str(mesh_path), merge_vertices=False)
|
| 107 |
except TypeError:
|
| 108 |
result = importer(filepath=str(mesh_path))
|
| 109 |
+
elif suffix == "obj":
|
| 110 |
+
result = importer(filepath=str(mesh_path), forward_axis="Y", up_axis="Z")
|
| 111 |
else:
|
| 112 |
result = importer(filepath=str(mesh_path))
|
| 113 |
if "FINISHED" not in result:
|