Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -432,21 +432,10 @@ edit_tool = gr.Interface(
|
|
| 432 |
|
| 433 |
|
| 434 |
# ============================================================
|
| 435 |
-
# MAIN
|
| 436 |
# ============================================================
|
| 437 |
|
| 438 |
-
|
| 439 |
-
.gradio-container { font-size: 18px !important; }
|
| 440 |
-
h1 { font-size: 2.5rem !important; }
|
| 441 |
-
h2 { font-size: 1.8rem !important; }
|
| 442 |
-
h3 { font-size: 1.4rem !important; }
|
| 443 |
-
label, .label-wrap { font-size: 1.1rem !important; }
|
| 444 |
-
textarea, input { font-size: 1.1rem !important; }
|
| 445 |
-
button { font-size: 1.1rem !important; }
|
| 446 |
-
.markdown-text { font-size: 1.1rem !important; }
|
| 447 |
-
"""
|
| 448 |
-
|
| 449 |
-
with gr.Blocks(title="Text to 3D | MCP Server", css=custom_css) as demo:
|
| 450 |
|
| 451 |
current_image_state = gr.State(None)
|
| 452 |
edit_count_state = gr.State(0)
|
|
@@ -460,65 +449,46 @@ with gr.Blocks(title="Text to 3D | MCP Server", css=custom_css) as demo:
|
|
| 460 |
⏱️ *Generation takes 1-2 minutes. First run may take longer as the model warms up.*
|
| 461 |
""")
|
| 462 |
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
| 502 |
-
|
| 503 |
-
glb_download = gr.File(label="GLB (mesh)")
|
| 504 |
-
ply_download = gr.File(label="PLY (splat)")
|
| 505 |
-
|
| 506 |
-
with gr.Tab("🔧 Generate Tool (MCP)"):
|
| 507 |
-
gr.Markdown("### MCP Tool: `generate_3d`")
|
| 508 |
-
gr.Markdown("This tool is exposed to MCP clients like Claude Desktop and Cursor.")
|
| 509 |
-
mcp_prompt = gr.Textbox(label="Prompt", placeholder="A red sports car")
|
| 510 |
-
mcp_generate_btn = gr.Button("Generate", variant="primary")
|
| 511 |
-
mcp_generate_output = gr.Textbox(label="Result (JSON)", lines=10)
|
| 512 |
-
mcp_generate_btn.click(fn=generate_3d_model, inputs=[mcp_prompt], outputs=[mcp_generate_output], api_name="generate_3d")
|
| 513 |
-
|
| 514 |
-
with gr.Tab("✏️ Edit Tool (MCP)"):
|
| 515 |
-
gr.Markdown("### MCP Tool: `edit_3d`")
|
| 516 |
-
gr.Markdown("This tool is exposed to MCP clients like Claude Desktop and Cursor.")
|
| 517 |
-
mcp_edit_prompt = gr.Textbox(label="Edit Prompt", placeholder="Remove the wings")
|
| 518 |
-
mcp_image_path = gr.Textbox(label="Transparent Image Path", placeholder="/path/to/transparent.png")
|
| 519 |
-
mcp_edit_btn = gr.Button("Edit", variant="primary")
|
| 520 |
-
mcp_edit_output = gr.Textbox(label="Result (JSON)", lines=10)
|
| 521 |
-
mcp_edit_btn.click(fn=edit_3d_model, inputs=[mcp_edit_prompt, mcp_image_path], outputs=[mcp_edit_output], api_name="edit_3d")
|
| 522 |
|
| 523 |
gr.Markdown("""
|
| 524 |
---
|
|
@@ -547,5 +517,16 @@ with gr.Blocks(title="Text to 3D | MCP Server", css=custom_css) as demo:
|
|
| 547 |
outputs=[nobg_output, mask_output, model_output, glb_download, ply_download, current_image_state, edit_count_state]
|
| 548 |
).then(fn=update_counter, inputs=[edit_count_state], outputs=[edit_counter])
|
| 549 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
if __name__ == "__main__":
|
| 551 |
demo.launch(mcp_server=True)
|
|
|
|
| 432 |
|
| 433 |
|
| 434 |
# ============================================================
|
| 435 |
+
# MAIN UI
|
| 436 |
# ============================================================
|
| 437 |
|
| 438 |
+
with gr.Blocks() as main_ui:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
current_image_state = gr.State(None)
|
| 441 |
edit_count_state = gr.State(0)
|
|
|
|
| 449 |
⏱️ *Generation takes 1-2 minutes. First run may take longer as the model warms up.*
|
| 450 |
""")
|
| 451 |
|
| 452 |
+
gr.Markdown("## 1️⃣ Generate Initial 3D Model")
|
| 453 |
+
|
| 454 |
+
with gr.Row():
|
| 455 |
+
with gr.Column(scale=2):
|
| 456 |
+
prompt_input = gr.Textbox(label="Text Prompt", placeholder="A plane with eagle wings", lines=2)
|
| 457 |
+
with gr.Column(scale=1):
|
| 458 |
+
generate_btn = gr.Button("🚀 Generate", variant="primary", size="lg")
|
| 459 |
+
|
| 460 |
+
gr.Examples(
|
| 461 |
+
examples=["A plane with eagle wings", "A wooden chair", "A red sports car", "A ceramic coffee mug", "A robot dog"],
|
| 462 |
+
inputs=prompt_input
|
| 463 |
+
)
|
| 464 |
+
|
| 465 |
+
gr.Markdown("## 2️⃣ Edit Your Model")
|
| 466 |
+
|
| 467 |
+
with gr.Row():
|
| 468 |
+
with gr.Column(scale=2):
|
| 469 |
+
edit_input = gr.Textbox(label="Edit Prompt", placeholder="Remove the wings", lines=2)
|
| 470 |
+
with gr.Column(scale=1):
|
| 471 |
+
edit_btn = gr.Button("✏️ Apply Edit", variant="secondary", size="lg")
|
| 472 |
+
edit_counter = gr.Markdown("*No edits yet*")
|
| 473 |
+
|
| 474 |
+
gr.Examples(
|
| 475 |
+
examples=["Remove the wings", "Change color to blue", "Add racing stripes", "Make it larger", "Add wheels"],
|
| 476 |
+
inputs=edit_input
|
| 477 |
+
)
|
| 478 |
+
|
| 479 |
+
gr.Markdown("## 📸 Images")
|
| 480 |
+
with gr.Row():
|
| 481 |
+
original_output = gr.Image(label="1. Original", type="filepath")
|
| 482 |
+
nobg_output = gr.Image(label="2. Transparent", type="filepath")
|
| 483 |
+
mask_output = gr.Image(label="3. Mask", type="filepath")
|
| 484 |
+
|
| 485 |
+
gr.Markdown("## 🎮 3D Model")
|
| 486 |
+
model_output = gr.Model3D(label="Interactive 3D Model (drag to rotate)", clear_color=[0.1, 0.1, 0.1, 1.0])
|
| 487 |
+
|
| 488 |
+
gr.Markdown("## 📥 Downloads")
|
| 489 |
+
with gr.Row():
|
| 490 |
+
glb_download = gr.File(label="GLB (mesh)")
|
| 491 |
+
ply_download = gr.File(label="PLY (splat)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
|
| 493 |
gr.Markdown("""
|
| 494 |
---
|
|
|
|
| 517 |
outputs=[nobg_output, mask_output, model_output, glb_download, ply_download, current_image_state, edit_count_state]
|
| 518 |
).then(fn=update_counter, inputs=[edit_count_state], outputs=[edit_counter])
|
| 519 |
|
| 520 |
+
|
| 521 |
+
# ============================================================
|
| 522 |
+
# COMBINE UI + MCP TOOLS
|
| 523 |
+
# ============================================================
|
| 524 |
+
|
| 525 |
+
demo = gr.TabbedInterface(
|
| 526 |
+
interface_list=[main_ui, generate_tool, edit_tool],
|
| 527 |
+
tab_names=["🎨 Interactive UI", "🔧 Generate Tool", "✏️ Edit Tool"],
|
| 528 |
+
title="Text to 3D | MCP Server"
|
| 529 |
+
)
|
| 530 |
+
|
| 531 |
if __name__ == "__main__":
|
| 532 |
demo.launch(mcp_server=True)
|