Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -271,11 +271,11 @@ def run_triposg(image_path: str,
|
|
| 271 |
|
| 272 |
# Merge and color
|
| 273 |
merged = get_colored_mesh_composition(outputs)
|
| 274 |
-
split_mesh = explode_mesh(merged)
|
| 275 |
-
|
| 276 |
|
| 277 |
merged_path = os.path.join(export_dir, "object.glb")
|
| 278 |
merged.export(merged_path)
|
|
|
|
|
|
|
| 279 |
|
| 280 |
split_preview_path = os.path.join(export_dir, "object.glb")
|
| 281 |
split_mesh.export(split_preview_path)
|
|
@@ -325,7 +325,7 @@ def build_demo():
|
|
| 325 |
)
|
| 326 |
with gr.Row():
|
| 327 |
with gr.Column(scale=1):
|
| 328 |
-
input_image = gr.Image(type="filepath", label="Input Image")
|
| 329 |
num_parts = gr.Slider(1, MAX_NUM_PARTS, value=4, step=1, label="Number of Parts")
|
| 330 |
run_button = gr.Button("Generate 3D Parts", variant="primary")
|
| 331 |
|
|
@@ -345,35 +345,34 @@ def build_demo():
|
|
| 345 |
</p>
|
| 346 |
"""
|
| 347 |
)
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
"assets/images/np7_1c004909dedb4ebe8db69b4d7b077434.png",
|
| 364 |
-
7,
|
| 365 |
-
],
|
| 366 |
-
[
|
| 367 |
-
"assets/images/np2_tree.png",
|
| 368 |
-
2,
|
| 369 |
-
],
|
| 370 |
-
|
| 371 |
-
],
|
| 372 |
-
inputs=[input_image, num_parts],
|
| 373 |
-
outputs=[output_model, split_model, output_dir, download_zip],
|
| 374 |
-
fn=run_triposg,
|
| 375 |
-
cache_examples=True,
|
| 376 |
-
)
|
| 377 |
|
| 378 |
run_button.click(fn=run_triposg,
|
| 379 |
inputs=[input_image, num_parts, seed, num_tokens, num_steps,
|
|
|
|
| 271 |
|
| 272 |
# Merge and color
|
| 273 |
merged = get_colored_mesh_composition(outputs)
|
|
|
|
|
|
|
| 274 |
|
| 275 |
merged_path = os.path.join(export_dir, "object.glb")
|
| 276 |
merged.export(merged_path)
|
| 277 |
+
|
| 278 |
+
split_mesh = explode_mesh(merged)
|
| 279 |
|
| 280 |
split_preview_path = os.path.join(export_dir, "object.glb")
|
| 281 |
split_mesh.export(split_preview_path)
|
|
|
|
| 325 |
)
|
| 326 |
with gr.Row():
|
| 327 |
with gr.Column(scale=1):
|
| 328 |
+
input_image = gr.Image(type="filepath", label="Input Image", height=256)
|
| 329 |
num_parts = gr.Slider(1, MAX_NUM_PARTS, value=4, step=1, label="Number of Parts")
|
| 330 |
run_button = gr.Button("Generate 3D Parts", variant="primary")
|
| 331 |
|
|
|
|
| 345 |
</p>
|
| 346 |
"""
|
| 347 |
)
|
| 348 |
+
output_model = gr.Model3D(label="Merged 3D Object")
|
| 349 |
+
split_model = gr.Model3D(label="Split Preview")
|
| 350 |
+
output_dir = gr.Textbox(label="Export Directory", visible=False)
|
| 351 |
+
download_zip = gr.File(label="Download All Parts (zip)")
|
| 352 |
+
with gr.Row():
|
| 353 |
+
with gr.Column():
|
| 354 |
+
examples = gr.Examples(
|
| 355 |
+
|
| 356 |
+
examples=[
|
| 357 |
+
[
|
| 358 |
+
"assets/images/np5_b81f29e567ea4db48014f89c9079e403.png",
|
| 359 |
+
5,
|
| 360 |
+
],
|
| 361 |
+
[
|
| 362 |
+
"assets/images/np7_1c004909dedb4ebe8db69b4d7b077434.png",
|
| 363 |
+
7,
|
| 364 |
+
],
|
| 365 |
+
[
|
| 366 |
+
"assets/images/np2_tree.png",
|
| 367 |
+
3,
|
| 368 |
+
],
|
| 369 |
|
| 370 |
+
],
|
| 371 |
+
inputs=[input_image, num_parts],
|
| 372 |
+
outputs=[output_model, split_model, output_dir, download_zip],
|
| 373 |
+
fn=run_triposg,
|
| 374 |
+
cache_examples=True,
|
| 375 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
|
| 377 |
run_button.click(fn=run_triposg,
|
| 378 |
inputs=[input_image, num_parts, seed, num_tokens, num_steps,
|