Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -46,17 +46,40 @@ sys.path.append(MV_ADAPTER_CODE_DIR)
|
|
46 |
sys.path.append(os.path.join(MV_ADAPTER_CODE_DIR, "scripts"))
|
47 |
|
48 |
HEADER = """
|
49 |
-
#
|
50 |
-
##
|
51 |
-
<p style="font-size: 1.1em;">By <a href="https://www.anvilinteractive.com/" style="color: #
|
52 |
-
##
|
53 |
-
1. **Upload an
|
54 |
-
2.
|
55 |
-
3. Click **
|
56 |
-
4.
|
57 |
-
5.
|
58 |
-
|
59 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
"""
|
61 |
|
62 |
# triposg
|
@@ -370,63 +393,75 @@ def run_texture(image: Image, mesh_path: str, seed: int, req: gr.Request):
|
|
370 |
return textured_glb_path
|
371 |
|
372 |
|
373 |
-
with gr.Blocks(title="PolyGenixAI") as demo:
|
374 |
gr.Markdown(HEADER)
|
375 |
|
376 |
-
with gr.
|
377 |
-
with gr.
|
378 |
with gr.Row():
|
379 |
-
|
380 |
-
|
381 |
-
label="Segmentation
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
|
431 |
gen_button.click(
|
432 |
run_segmentation,
|
|
|
46 |
sys.path.append(os.path.join(MV_ADAPTER_CODE_DIR, "scripts"))
|
47 |
|
48 |
HEADER = """
|
49 |
+
# 🎨 PolyGenixAI: Transform Ideas into 3D Masterpieces
|
50 |
+
## Unleash Your Creativity with AI-Powered 3D Generation by AnvilInteractive Solutions
|
51 |
+
<p style="font-size: 1.1em;">By <a href="https://www.anvilinteractive.com/" style="color: #3B82F6; text-decoration: none; font-weight: bold;">AnvilInteractive Solutions</a></p>
|
52 |
+
## 🚀 Get Started:
|
53 |
+
1. **Upload an Image** (clear, single-object images work best)
|
54 |
+
2. **Select Filters** to customize styles
|
55 |
+
3. Click **Generate 3D Model** to create your mesh
|
56 |
+
4. Click **Apply Texture** to enhance with realistic textures
|
57 |
+
5. **Download GLB** to save your creation
|
58 |
+
<p style="font-size: 0.9em; margin-top: 10px;">Powered by advanced AI and multi-view technology from AnvilInteractive Solutions. Join our community at <a href="https://www.anvilinteractive.com/polygenixai" style="color: #3B82F6; text-decoration: none;">PolyGenixAI</a> for tips and inspiration.</p>
|
59 |
+
<style>
|
60 |
+
.gr-button-primary {
|
61 |
+
background-color: #3B82F6 !important;
|
62 |
+
color: white !important;
|
63 |
+
border-radius: 8px !important;
|
64 |
+
padding: 10px 20px !important;
|
65 |
+
font-weight: 600 !important;
|
66 |
+
}
|
67 |
+
.gr-button-secondary {
|
68 |
+
background-color: #E5E7EB !important;
|
69 |
+
color: #1F2937 !important;
|
70 |
+
border-radius: 8px !important;
|
71 |
+
padding: 10px 20px !important;
|
72 |
+
}
|
73 |
+
.gr-panel {
|
74 |
+
border-radius: 12px !important;
|
75 |
+
box-shadow: 0 4px 6px rgba(0,0,0,0.1) !important;
|
76 |
+
padding: 20px !important;
|
77 |
+
}
|
78 |
+
.gr-accordion {
|
79 |
+
background-color: #F9FAFB !important;
|
80 |
+
border-radius: 8px !important;
|
81 |
+
}
|
82 |
+
</style>
|
83 |
"""
|
84 |
|
85 |
# triposg
|
|
|
393 |
return textured_glb_path
|
394 |
|
395 |
|
396 |
+
with gr.Blocks(title="PolyGenixAI", css="body { background-color: #F3F4F6; } .gr-panel { background-color: white; }") as demo:
|
397 |
gr.Markdown(HEADER)
|
398 |
|
399 |
+
with gr.Tabs():
|
400 |
+
with gr.Tab("Create 3D Model"):
|
401 |
with gr.Row():
|
402 |
+
with gr.Column(scale=1):
|
403 |
+
image_prompts = gr.Image(label="Upload Image", type="filepath", height=300)
|
404 |
+
seg_image = gr.Image(label="Preview Segmentation", type="pil", format="png", interactive=False, height=300)
|
405 |
+
with gr.Accordion("Style & Settings", open=True):
|
406 |
+
style_filter = gr.Dropdown(
|
407 |
+
choices=["None", "Realistic", "Fantasy", "Cartoon", "Sci-Fi", "Vintage"],
|
408 |
+
label="Style Filter",
|
409 |
+
value="None",
|
410 |
+
info="Select a style to enhance your 3D model (optional)"
|
411 |
+
)
|
412 |
+
seed = gr.Slider(
|
413 |
+
label="Seed",
|
414 |
+
minimum=0,
|
415 |
+
maximum=MAX_SEED,
|
416 |
+
step=1,
|
417 |
+
value=0
|
418 |
+
)
|
419 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
|
420 |
+
num_inference_steps = gr.Slider(
|
421 |
+
label="Inference Steps",
|
422 |
+
minimum=8,
|
423 |
+
maximum=50,
|
424 |
+
step=1,
|
425 |
+
value=50,
|
426 |
+
info="Higher steps improve quality but take longer"
|
427 |
+
)
|
428 |
+
guidance_scale = gr.Slider(
|
429 |
+
label="Guidance Scale",
|
430 |
+
minimum=0.0,
|
431 |
+
maximum=20.0,
|
432 |
+
step=0.1,
|
433 |
+
value=7.0,
|
434 |
+
info="Controls how closely the model follows the input"
|
435 |
+
)
|
436 |
+
reduce_face = gr.Checkbox(label="Simplify Mesh", value=True)
|
437 |
+
target_face_num = gr.Slider(
|
438 |
+
maximum=1000000,
|
439 |
+
minimum=10000,
|
440 |
+
value=DEFAULT_FACE_NUMBER,
|
441 |
+
label="Target Face Number",
|
442 |
+
info="Adjust mesh complexity"
|
443 |
+
)
|
444 |
+
gen_button = gr.Button("Generate 3D Model", variant="primary")
|
445 |
+
gen_texture_button = gr.Button("Apply Texture", variant="secondary", interactive=False)
|
446 |
+
|
447 |
+
with gr.Column(scale=1):
|
448 |
+
model_output = gr.Model3D(label="3D Model Preview", interactive=False, height=400)
|
449 |
+
textured_model_output = gr.Model3D(label="Textured 3D Model", interactive=False, height=400)
|
450 |
+
download_button = gr.Button("Download GLB", variant="secondary")
|
451 |
+
|
452 |
+
with gr.Tab("Gallery & Community"):
|
453 |
+
gr.Markdown("### Explore Creations")
|
454 |
+
gr.Examples(
|
455 |
+
examples=[
|
456 |
+
f"{TRIPOSG_CODE_DIR}/assets/example_data/{image}"
|
457 |
+
for image in os.listdir(f"{TRIPOSG_CODE_DIR}/assets/example_data")
|
458 |
+
],
|
459 |
+
fn=run_full,
|
460 |
+
inputs=[image_prompts],
|
461 |
+
outputs=[seg_image, model_output, textured_model_output],
|
462 |
+
cache_examples=True,
|
463 |
+
)
|
464 |
+
gr.Markdown("Join our [PolyGenixAI Community](https://www.anvilinteractive.com/community) to share your creations and get inspired!")
|
465 |
|
466 |
gen_button.click(
|
467 |
run_segmentation,
|