NicolasG2523 commited on
Commit
3574502
·
verified ·
1 Parent(s): 08faf90

Upload gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +20 -82
gradio_app.py CHANGED
@@ -362,29 +362,13 @@ def shape_generation(
362
 
363
 
364
  def build_app():
365
- title = 'Hunyuan3D-2: High Resolution Textured 3D Assets Generation'
366
- if MV_MODE:
367
- title = 'Hunyuan3D-2mv: Image to 3D Generation with 1-4 Views'
368
- if 'mini' in args.subfolder:
369
- title = 'Hunyuan3D-2mini: Strong 0.6B Image to Shape Generator'
370
- if TURBO_MODE:
371
- title = title.replace(':', '-Turbo: Fast ')
372
 
373
  title_html = f"""
374
  <div style="font-size: 2em; font-weight: bold; text-align: center; margin-bottom: 5px">
375
 
376
  {title}
377
  </div>
378
- <div align="center">
379
- Tencent Hunyuan3D Team
380
- </div>
381
- <div align="center">
382
- <a href="https://github.com/tencent/Hunyuan3D-2">Github</a> &ensp;
383
- <a href="http://3d-models.hunyuan.tencent.com">Homepage</a> &ensp;
384
- <a href="https://3d.hunyuan.tencent.com">Hunyuan3D Studio</a> &ensp;
385
- <a href="#">Technical Report</a> &ensp;
386
- <a href="https://huggingface.co/Tencent/Hunyuan3D-2"> Pretrained Models</a> &ensp;
387
- </div>
388
  """
389
  custom_css = """
390
  .app.svelte-wpkpf6.svelte-wpkpf6:not(.fill_width) {
@@ -405,26 +389,17 @@ def build_app():
405
 
406
  with gr.Row():
407
  with gr.Column(scale=3):
408
- with gr.Tabs(selected='tab_img_prompt') as tabs_prompt:
409
- with gr.Tab('Image Prompt', id='tab_img_prompt', visible=not MV_MODE) as tab_ip:
410
- image = gr.Image(label='Image', type='pil', image_mode='RGBA', height=290)
411
-
412
- with gr.Tab('Text Prompt', id='tab_txt_prompt', visible=HAS_T2I and not MV_MODE) as tab_tp:
413
- caption = gr.Textbox(label='Text Prompt',
414
- placeholder='HunyuanDiT will be used to generate image.',
415
- info='Example: A 3D model of a cute cat, white background')
416
- with gr.Tab('MultiView Prompt', visible=MV_MODE) as tab_mv:
417
- # gr.Label('Please upload at least one front image.')
418
- with gr.Row():
419
- mv_image_front = gr.Image(label='Front', type='pil', image_mode='RGBA', height=140,
420
- min_width=100, elem_classes='mv-image')
421
- mv_image_back = gr.Image(label='Back', type='pil', image_mode='RGBA', height=140,
422
- min_width=100, elem_classes='mv-image')
423
- with gr.Row():
424
- mv_image_left = gr.Image(label='Left', type='pil', image_mode='RGBA', height=140,
425
- min_width=100, elem_classes='mv-image')
426
- mv_image_right = gr.Image(label='Right', type='pil', image_mode='RGBA', height=140,
427
- min_width=100, elem_classes='mv-image')
428
 
429
  with gr.Row():
430
  btn = gr.Button(value='Gen Shape', variant='primary', min_width=100)
@@ -482,7 +457,7 @@ def build_app():
482
  file_export = gr.DownloadButton(label="Download", variant='primary',
483
  interactive=False, min_width=100)
484
 
485
- with gr.Column(scale=6):
486
  with gr.Tabs(selected='gen_mesh_panel') as tabs_output:
487
  with gr.Tab('Generated Mesh', id='gen_mesh_panel'):
488
  html_gen_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
@@ -491,48 +466,6 @@ def build_app():
491
  with gr.Tab('Mesh Statistic', id='stats_panel'):
492
  stats = gr.Json({}, label='Mesh Stats')
493
 
494
- with gr.Column(scale=3 if MV_MODE else 2):
495
- with gr.Tabs(selected='tab_img_gallery') as gallery:
496
- with gr.Tab('Image to 3D Gallery', id='tab_img_gallery', visible=not MV_MODE) as tab_gi:
497
- with gr.Row():
498
- gr.Examples(examples=example_is, inputs=[image],
499
- label=None, examples_per_page=18)
500
-
501
- with gr.Tab('Text to 3D Gallery', id='tab_txt_gallery', visible=HAS_T2I and not MV_MODE) as tab_gt:
502
- with gr.Row():
503
- gr.Examples(examples=example_ts, inputs=[caption],
504
- label=None, examples_per_page=18)
505
- with gr.Tab('MultiView to 3D Gallery', id='tab_mv_gallery', visible=MV_MODE) as tab_mv:
506
- with gr.Row():
507
- gr.Examples(examples=example_mvs,
508
- inputs=[mv_image_front, mv_image_back, mv_image_left, mv_image_right],
509
- label=None, examples_per_page=6)
510
-
511
- gr.HTML(f"""
512
- <div align="center">
513
- Activated Model - Shape Generation ({args.model_path}/{args.subfolder}) ; Texture Generation ({'Hunyuan3D-2' if HAS_TEXTUREGEN else 'Unavailable'})
514
- </div>
515
- """)
516
- if not HAS_TEXTUREGEN:
517
- gr.HTML("""
518
- <div style="margin-top: 5px;" align="center">
519
- <b>Warning: </b>
520
- Texture synthesis is disable due to missing requirements,
521
- please install requirements following <a href="https://github.com/Tencent/Hunyuan3D-2?tab=readme-ov-file#install-requirements">README.md</a>to activate it.
522
- </div>
523
- """)
524
- if not args.enable_t23d:
525
- gr.HTML("""
526
- <div style="margin-top: 5px;" align="center">
527
- <b>Warning: </b>
528
- Text to 3D is disable. To activate it, please run `python gradio_app.py --enable_t23d`.
529
- </div>
530
- """)
531
-
532
- tab_ip.select(fn=lambda: gr.update(selected='tab_img_gallery'), outputs=gallery)
533
- if HAS_T2I:
534
- tab_tp.select(fn=lambda: gr.update(selected='tab_txt_gallery'), outputs=gallery)
535
-
536
  btn.click(
537
  shape_generation,
538
  inputs=[
@@ -671,6 +604,12 @@ if __name__ == '__main__':
671
  parser.add_argument('--low_vram_mode', action='store_true')
672
  args = parser.parse_args()
673
 
 
 
 
 
 
 
674
  args.enable_flashvdm = True
675
  SAVE_DIR = args.cache_path
676
  os.makedirs(SAVE_DIR, exist_ok=True)
@@ -684,8 +623,7 @@ if __name__ == '__main__':
684
  HTML_OUTPUT_PLACEHOLDER = f"""
685
  <div style='height: {650}px; width: 100%; border-radius: 8px; border-color: #e5e7eb; border-style: solid; border-width: 1px; display: flex; justify-content: center; align-items: center;'>
686
  <div style='text-align: center; font-size: 16px; color: #6b7280;'>
687
- <p style="color: #8d8d8d;">Welcome to Hunyuan3D!</p>
688
- <p style="color: #8d8d8d;">No mesh here.</p>
689
  </div>
690
  </div>
691
  """
 
362
 
363
 
364
  def build_app():
365
+ title = 'Generación de modelo basado en imágenes (de 1 a 4 vistas)'
 
 
 
 
 
 
366
 
367
  title_html = f"""
368
  <div style="font-size: 2em; font-weight: bold; text-align: center; margin-bottom: 5px">
369
 
370
  {title}
371
  </div>
 
 
 
 
 
 
 
 
 
 
372
  """
373
  custom_css = """
374
  .app.svelte-wpkpf6.svelte-wpkpf6:not(.fill_width) {
 
389
 
390
  with gr.Row():
391
  with gr.Column(scale=3):
392
+ with gr.Row():
393
+ with gr.Row():
394
+ mv_image_front = gr.Image(label='Front', type='pil', image_mode='RGBA', height=140,
395
+ min_width=100, elem_classes='mv-image')
396
+ mv_image_back = gr.Image(label='Back', type='pil', image_mode='RGBA', height=140,
397
+ min_width=100, elem_classes='mv-image')
398
+ with gr.Row():
399
+ mv_image_left = gr.Image(label='Left', type='pil', image_mode='RGBA', height=140,
400
+ min_width=100, elem_classes='mv-image')
401
+ mv_image_right = gr.Image(label='Right', type='pil', image_mode='RGBA', height=140,
402
+ min_width=100, elem_classes='mv-image')
 
 
 
 
 
 
 
 
 
403
 
404
  with gr.Row():
405
  btn = gr.Button(value='Gen Shape', variant='primary', min_width=100)
 
457
  file_export = gr.DownloadButton(label="Download", variant='primary',
458
  interactive=False, min_width=100)
459
 
460
+ with gr.Column(scale=9):
461
  with gr.Tabs(selected='gen_mesh_panel') as tabs_output:
462
  with gr.Tab('Generated Mesh', id='gen_mesh_panel'):
463
  html_gen_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
 
466
  with gr.Tab('Mesh Statistic', id='stats_panel'):
467
  stats = gr.Json({}, label='Mesh Stats')
468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
  btn.click(
470
  shape_generation,
471
  inputs=[
 
604
  parser.add_argument('--low_vram_mode', action='store_true')
605
  args = parser.parse_args()
606
 
607
+ try:
608
+ port = int(args.port)
609
+ except ValueError:
610
+ print(f"Invalid port argument detected: {args.port} — using default 7860")
611
+ port = 7860
612
+
613
  args.enable_flashvdm = True
614
  SAVE_DIR = args.cache_path
615
  os.makedirs(SAVE_DIR, exist_ok=True)
 
623
  HTML_OUTPUT_PLACEHOLDER = f"""
624
  <div style='height: {650}px; width: 100%; border-radius: 8px; border-color: #e5e7eb; border-style: solid; border-width: 1px; display: flex; justify-content: center; align-items: center;'>
625
  <div style='text-align: center; font-size: 16px; color: #6b7280;'>
626
+ <p style="color: #8d8d8d;">Bienvenido a 3D Market</p>
 
627
  </div>
628
  </div>
629
  """