anvilinteractiv commited on
Commit
cc4fd00
Β·
verified Β·
1 Parent(s): c454c02

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +54 -16
gradio_app.py CHANGED
@@ -133,12 +133,12 @@ def build_model_viewer_html(save_folder, height=660, width=790, textured=False):
133
  f.write(template_html)
134
 
135
  rel_path = os.path.relpath(output_html_path, SAVE_DIR)
136
- iframe_tag = f'<iframe src="/static/{rel_path}" height="{height}" width="100%" frameborder="0"></iframe>'
137
  print(
138
  f'Find html file {output_html_path}, {os.path.exists(output_html_path)}, relative HTML path is /static/{rel_path}')
139
 
140
  return f"""
141
- <div style='height: {height}; width: 100%;'>
142
  {iframe_tag}
143
  </div>
144
  """
@@ -372,7 +372,7 @@ def build_app():
372
  title = title.replace(':', '-Turbo: Fast ')
373
 
374
  title_html = f"""
375
- <div style="font-size: 2em; font-weight: bold; text-align: center; margin-bottom: 5px">
376
  {title}
377
  </div>
378
  <div align="center">
@@ -382,17 +382,55 @@ def build_app():
382
  """
383
  custom_css = """
384
  .app.svelte-wpkpf6.svelte-wpkpf6:not(.fill_width) {
385
- max-width: 1480px;
 
 
 
 
386
  }
387
  .mv-image button .wrap {
388
- font-size: 10px;
 
 
 
 
 
 
 
 
389
  }
390
  .mv-image .icon-wrap {
391
- width: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  }
393
  """
394
 
395
- with gr.Blocks(theme=gr.themes.Base(), title='Hunyuan-3D-2.0', analytics_enabled=False, css=custom_css) as demo:
396
  gr.HTML(title_html)
397
 
398
  with gr.Row():
@@ -501,22 +539,22 @@ def build_app():
501
  label=None, examples_per_page=6)
502
 
503
  gr.HTML(f"""
504
- <div align="center">
505
  Activated Model - Shape Generation ({args.model_path}/{args.subfolder}) ; Texture Generation ({'Hunyuan3D-2' if HAS_TEXTUREGEN else 'Unavailable'})
506
  </div>
507
  """)
508
  if not HAS_TEXTUREGEN:
509
  gr.HTML("""
510
- <div style="margin-top: 5px;" align="center">
511
- <b>Warning: </b>
512
  Texture synthesis is disable due to missing requirements,
513
  please install requirements following <a href="https://github.com/Tencent/Hunyuan3D-2?tab=readme-ov-file#install-requirements">README.md</a>to activate it.
514
  </div>
515
  """)
516
  if not args.enable_t23d:
517
  gr.HTML("""
518
- <div style="margin-top: 5px;" align="center">
519
- <b>Warning: </b>
520
  Text to 3D is disable. To activate it, please run `python gradio_app.py --enable_t23d`.
521
  </div>
522
  """)
@@ -676,10 +714,10 @@ if __name__ == '__main__':
676
  HTML_HEIGHT = 690 if MV_MODE else 650
677
  HTML_WIDTH = 500
678
  HTML_OUTPUT_PLACEHOLDER = f"""
679
- <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;'>
680
- <div style='text-align: center; font-size: 16px; color: #6b7280;'>
681
- <p style="color: #8d8d8d;">Welcome to Hunyuan3D!</p>
682
- <p style="color: #8d8d8d;">No mesh here.</p>
683
  </div>
684
  </div>
685
  """
 
133
  f.write(template_html)
134
 
135
  rel_path = os.path.relpath(output_html_path, SAVE_DIR)
136
+ iframe_tag = f'<iframe src="/static/{rel_path}" height="{height}" width="100%" frameborder="0" style="border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);"></iframe>'
137
  print(
138
  f'Find html file {output_html_path}, {os.path.exists(output_html_path)}, relative HTML path is /static/{rel_path}')
139
 
140
  return f"""
141
+ <div style='height: {height}px; width: 100%; display: flex; justify-content: center; align-items: center; padding: 10px; background: #f9f9f9; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);'>
142
  {iframe_tag}
143
  </div>
144
  """
 
372
  title = title.replace(':', '-Turbo: Fast ')
373
 
374
  title_html = f"""
375
+ <div style="font-size: 2.5em; font-weight: bold; text-align: center; margin-bottom: 15px; background: linear-gradient(90deg, #4a90e2, #9013fe); -webkit-background-clip: text; color: transparent; padding: 10px; border-radius: 8px;">
376
  {title}
377
  </div>
378
  <div align="center">
 
382
  """
383
  custom_css = """
384
  .app.svelte-wpkpf6.svelte-wpkpf6:not(.fill_width) {
385
+ max-width: 1500px;
386
+ background-color: #f0f4f8;
387
+ padding: 20px;
388
+ border-radius: 12px;
389
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
390
  }
391
  .mv-image button .wrap {
392
+ font-size: 12px;
393
+ background-color: #ffffff;
394
+ border-radius: 6px;
395
+ padding: 5px;
396
+ transition: all 0.3s ease;
397
+ }
398
+ .mv-image button:hover .wrap {
399
+ background-color: #e0e7ff;
400
+ color: #4a90e2;
401
  }
402
  .mv-image .icon-wrap {
403
+ width: 22px;
404
+ background-color: #f0f4f8;
405
+ border-radius: 50%;
406
+ }
407
+ .gr-button {
408
+ background-color: #4a90e2;
409
+ color: white;
410
+ border-radius: 8px;
411
+ padding: 10px 20px;
412
+ transition: all 0.3s ease;
413
+ }
414
+ .gr-button:hover {
415
+ background-color: #357abd;
416
+ transform: translateY(-2px);
417
+ }
418
+ .gr-slider, .gr-dropdown, .gr-checkbox, .gr-number {
419
+ border-color: #d1d5db;
420
+ border-radius: 8px;
421
+ background-color: #ffffff;
422
+ }
423
+ .gr-tab {
424
+ background-color: #e5e7eb;
425
+ border-radius: 8px;
426
+ padding: 5px;
427
+ }
428
+ .gr-tab:hover, .gr-tab:active {
429
+ background-color: #d1d5db;
430
  }
431
  """
432
 
433
+ with gr.Blocks(theme=gr.themes.Soft(), title='Hunyuan-3D-2.0', analytics_enabled=False, css=custom_css) as demo:
434
  gr.HTML(title_html)
435
 
436
  with gr.Row():
 
539
  label=None, examples_per_page=6)
540
 
541
  gr.HTML(f"""
542
+ <div align="center" style="background-color: #e0e7ff; padding: 10px; border-radius: 8px; margin-top: 10px;">
543
  Activated Model - Shape Generation ({args.model_path}/{args.subfolder}) ; Texture Generation ({'Hunyuan3D-2' if HAS_TEXTUREGEN else 'Unavailable'})
544
  </div>
545
  """)
546
  if not HAS_TEXTUREGEN:
547
  gr.HTML("""
548
+ <div style="margin-top: 5px; background-color: #fff3f3; padding: 10px; border-radius: 8px; border: 1px solid #fee2e2;" align="center">
549
+ <b style="color: #dc2626;">Warning: </b>
550
  Texture synthesis is disable due to missing requirements,
551
  please install requirements following <a href="https://github.com/Tencent/Hunyuan3D-2?tab=readme-ov-file#install-requirements">README.md</a>to activate it.
552
  </div>
553
  """)
554
  if not args.enable_t23d:
555
  gr.HTML("""
556
+ <div style="margin-top: 5px; background-color: #fff3f3; padding: 10px; border-radius: 8px; border: 1px solid #fee2e2;" align="center">
557
+ <b style="color: #dc2626;">Warning: </b>
558
  Text to 3D is disable. To activate it, please run `python gradio_app.py --enable_t23d`.
559
  </div>
560
  """)
 
714
  HTML_HEIGHT = 690 if MV_MODE else 650
715
  HTML_WIDTH = 500
716
  HTML_OUTPUT_PLACEHOLDER = f"""
717
+ <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; background-color: #ffffff; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);'>
718
+ <div style='text-align: center; font-size: 18px; color: #4a5568;'>
719
+ <p style="color: #718096;">Welcome to Hunyuan3D!</p>
720
+ <p style="color: #718096;">No mesh here.</p>
721
  </div>
722
  </div>
723
  """