Spaces:
Running on Zero
Running on Zero
Deploy from 3dvalley spaces/make-it-animatable
Browse files
app.py
CHANGED
|
@@ -30,6 +30,7 @@ import time
|
|
| 30 |
import types
|
| 31 |
|
| 32 |
import gradio as gr
|
|
|
|
| 33 |
from huggingface_hub import hf_hub_download
|
| 34 |
|
| 35 |
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -121,8 +122,16 @@ def rig(model_file, rest_pose="As it stands", fingers=True):
|
|
| 121 |
started = time.time()
|
| 122 |
# A folder of its own per run: handlers run at once, and upstream names its outputs after the input file.
|
| 123 |
work = tempfile.mkdtemp(prefix="rig-")
|
| 124 |
-
source = os.path.join(work, "model
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
db = mia.DB()
|
| 127 |
mia.fix_random()
|
| 128 |
mia.prepare_input(source, is_gs=False, opacity_threshold=0.0, db=db, export_temp=False)
|
|
|
|
| 30 |
import types
|
| 31 |
|
| 32 |
import gradio as gr
|
| 33 |
+
import trimesh
|
| 34 |
from huggingface_hub import hf_hub_download
|
| 35 |
|
| 36 |
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 122 |
started = time.time()
|
| 123 |
# A folder of its own per run: handlers run at once, and upstream names its outputs after the input file.
|
| 124 |
work = tempfile.mkdtemp(prefix="rig-")
|
| 125 |
+
source = os.path.join(work, "model.glb")
|
| 126 |
+
# The weights are matched to Blender's mesh vertex by vertex, and Blender's glTF import merges vertices that
|
| 127 |
+
# are exact duplicates (same place, normal and UV). A model with such duplicates (Quaternius' Casual,
|
| 128 |
+
# 2026-11-08) then had more weights than vertices and failed. They are merged first, the same way; vertices
|
| 129 |
+
# that differ in their UV or normal stay apart, so textures and hard edges are kept.
|
| 130 |
+
mesh = trimesh.load(path, force="mesh")
|
| 131 |
+
if not isinstance(mesh, trimesh.Trimesh) or len(mesh.faces) == 0:
|
| 132 |
+
raise gr.Error("Upload a 3D model with a surface: this file has no faces.")
|
| 133 |
+
mesh.merge_vertices(merge_tex=False, merge_norm=False)
|
| 134 |
+
mesh.export(source)
|
| 135 |
db = mia.DB()
|
| 136 |
mia.fix_random()
|
| 137 |
mia.prepare_input(source, is_gs=False, opacity_threshold=0.0, db=db, export_temp=False)
|