anvilinteractiv commited on
Commit
ab04635
·
verified ·
1 Parent(s): 78e5882

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +100 -65
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
- # 🔮 Image to 3D with [PolyGenixAI](https://www.anvilinteractive.com/polygenixai)
50
- ## Cutting-Edge Open Source 3D Generation Powered by AnvilInteractive Solutions
51
- <p style="font-size: 1.1em;">By <a href="https://www.anvilinteractive.com/" style="color: #1E90FF; text-decoration: none; font-weight: bold;">AnvilInteractive Solutions</a></p>
52
- ## 📋 Quick Start Guide:
53
- 1. **Upload an image** (single object works best)
54
- 2. Click **Generate Shape** to create the 3D mesh
55
- 3. Click **Apply Texture** to add textures
56
- 4. Use **Download GLB** to save your 3D model
57
- 5. Adjust parameters under **Generation Settings** for fine-tuning
58
- Best results come from clean, well-lit images with clear subject isolation. Try it now!
59
- <p style="font-size: 0.9em; margin-top: 10px;">Texture generation enhanced by advanced multi-view technology from AnvilInteractive Solutions. Explore more at <a href="https://www.anvilinteractive.com/polygenixai" style="color: #1E90FF; text-decoration: none;">PolyGenixAI</a>.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.Row():
377
- with gr.Column():
378
  with gr.Row():
379
- image_prompts = gr.Image(label="Input Image", type="filepath")
380
- seg_image = gr.Image(
381
- label="Segmentation Result", type="pil", format="png", interactive=False
382
- )
383
-
384
- with gr.Accordion("Generation Settings", open=True):
385
- seed = gr.Slider(
386
- label="Seed",
387
- minimum=0,
388
- maximum=MAX_SEED,
389
- step=0,
390
- value=0
391
- )
392
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
393
- num_inference_steps = gr.Slider(
394
- label="Number of inference steps",
395
- minimum=8,
396
- maximum=50,
397
- step=1,
398
- value=50,
399
- )
400
- guidance_scale = gr.Slider(
401
- label="CFG scale",
402
- minimum=0.0,
403
- maximum=20.0,
404
- step=0.1,
405
- value=7.0,
406
- )
407
-
408
- with gr.Row():
409
- reduce_face = gr.Checkbox(label="Simplify Mesh", value=True)
410
- target_face_num = gr.Slider(maximum=1000000, minimum=10000, value=DEFAULT_FACE_NUMBER, label="Target Face Number")
411
-
412
- gen_button = gr.Button("Generate Shape", variant="primary")
413
- gen_texture_button = gr.Button("Apply Texture", interactive=False)
414
-
415
- with gr.Column():
416
- model_output = gr.Model3D(label="PolyGenixAI GLB", interactive=False)
417
- textured_model_output = gr.Model3D(label="PolyGenixAI Textured GLB", interactive=False)
418
-
419
- with gr.Row():
420
- examples = gr.Examples(
421
- examples=[
422
- f"{TRIPOSG_CODE_DIR}/assets/example_data/{image}"
423
- for image in os.listdir(f"{TRIPOSG_CODE_DIR}/assets/example_data")
424
- ],
425
- fn=run_full,
426
- inputs=[image_prompts],
427
- outputs=[seg_image, model_output, textured_model_output],
428
- cache_examples=True,
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,