Spaces:
Running on Zero
Running on Zero
Callable ZeroGPU duration; move theme/css to launch() for Gradio 6
Browse files
app.py
CHANGED
|
@@ -242,7 +242,21 @@ def _parse_labels(labels_text: str):
|
|
| 242 |
return names
|
| 243 |
|
| 244 |
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
def segment(
|
| 247 |
shape_file: str,
|
| 248 |
labels_text: str = "back, seat, leg, arm",
|
|
@@ -331,7 +345,7 @@ EXAMPLES = [
|
|
| 331 |
["examples/bunny.obj", "ear, head, torso, foot"],
|
| 332 |
]
|
| 333 |
|
| 334 |
-
with gr.Blocks(
|
| 335 |
with gr.Column(elem_id="col-container"):
|
| 336 |
gr.Markdown(
|
| 337 |
"""
|
|
@@ -428,4 +442,4 @@ work best; the Bunny is there to show that arbitrary meshes go through the same
|
|
| 428 |
labels_text.submit(segment, inputs=inputs, outputs=outputs)
|
| 429 |
|
| 430 |
if __name__ == "__main__":
|
| 431 |
-
demo.launch(mcp_server=True)
|
|
|
|
| 242 |
return names
|
| 243 |
|
| 244 |
|
| 245 |
+
def _estimate_duration(shape_file=None, labels_text="", num_points=pa.DEFAULT_NPOINTS, *args, **kwargs):
|
| 246 |
+
"""GPU reservation. Measured worst case is ~1.2 s of compute at the heaviest settings; the rest is
|
| 247 |
+
headroom for loading / surface-sampling a large user-supplied mesh inside the same call."""
|
| 248 |
+
try:
|
| 249 |
+
mb = os.path.getsize(shape_file) / 1e6
|
| 250 |
+
except Exception:
|
| 251 |
+
mb = 0.0
|
| 252 |
+
try:
|
| 253 |
+
n = int(num_points)
|
| 254 |
+
except Exception:
|
| 255 |
+
n = pa.DEFAULT_NPOINTS
|
| 256 |
+
return int(min(90, 8 + 0.6 * mb + 2.0 * n / pa.DEFAULT_NPOINTS))
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
@spaces.GPU(duration=_estimate_duration)
|
| 260 |
def segment(
|
| 261 |
shape_file: str,
|
| 262 |
labels_text: str = "back, seat, leg, arm",
|
|
|
|
| 345 |
["examples/bunny.obj", "ear, head, torso, foot"],
|
| 346 |
]
|
| 347 |
|
| 348 |
+
with gr.Blocks(title="PatchAlign3D") as demo:
|
| 349 |
with gr.Column(elem_id="col-container"):
|
| 350 |
gr.Markdown(
|
| 351 |
"""
|
|
|
|
| 442 |
labels_text.submit(segment, inputs=inputs, outputs=outputs)
|
| 443 |
|
| 444 |
if __name__ == "__main__":
|
| 445 |
+
demo.launch(theme=gr.themes.Citrus(), css=CSS, mcp_server=True)
|