NicolasG2523 commited on
Commit
a4f0fb0
verified
1 Parent(s): 6dde014

Upload gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +12 -17
gradio_app.py CHANGED
@@ -364,12 +364,12 @@ def shape_generation(
364
  model_viewer_html,
365
  stats,
366
  seed,
367
- model_viewer_html
368
  )
369
 
370
  def js_update(file):
371
  return f"<script>updateIframe('{file}');</script>"
372
-
373
  def build_app():
374
  title = 'Generaci贸n de modelo basado en im谩genes (de 1 a 4 vistas)'
375
 
@@ -481,21 +481,7 @@ def build_app():
481
  with gr.Tab('Generated Mesh', id='gen_mesh_panel'):
482
  html_gen_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
483
  file_output = gr.File(label="Generated GLB")
484
- iframe_html = """
485
- <iframe id="model_iframe" style="width:500px;height:500px;"></iframe>
486
- <script>
487
- function updateIframe(srcUrl) {
488
- document.getElementById('model_iframe').srcdoc = `
489
- <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
490
- <model-viewer src="${srcUrl}" camera-controls auto-rotate style="height:500px;width:500px;"></model-viewer>
491
- `;
492
- }
493
- </script>
494
- """
495
- iframe = gr.HTML(iframe_html)
496
- js_injection = gr.HTML()
497
- file_output.change(fn=js_update, inputs=file_output, outputs=js_injection)
498
-
499
 
500
  with gr.Tab('Exporting Mesh', id='export_mesh_panel'):
501
  html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
@@ -661,6 +647,15 @@ if __name__ == '__main__':
661
  <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;'>
662
  <div style='text-align: center; font-size: 16px; color: #6b7280;'>
663
  <p style="color: #8d8d8d;">Bienvenido a 3DMarket</p>
 
 
 
 
 
 
 
 
 
664
  </div>
665
  </div>
666
  """
 
364
  model_viewer_html,
365
  stats,
366
  seed,
367
+ gr.update(value=path)
368
  )
369
 
370
  def js_update(file):
371
  return f"<script>updateIframe('{file}');</script>"
372
+
373
  def build_app():
374
  title = 'Generaci贸n de modelo basado en im谩genes (de 1 a 4 vistas)'
375
 
 
481
  with gr.Tab('Generated Mesh', id='gen_mesh_panel'):
482
  html_gen_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
483
  file_output = gr.File(label="Generated GLB")
484
+ file_output.change(fn=js_update, inputs=file_output, outputs=html_gen_mesh)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
 
486
  with gr.Tab('Exporting Mesh', id='export_mesh_panel'):
487
  html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
 
647
  <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;'>
648
  <div style='text-align: center; font-size: 16px; color: #6b7280;'>
649
  <p style="color: #8d8d8d;">Bienvenido a 3DMarket</p>
650
+ <iframe id="model_iframe" style="width:500px;height:500px;">
651
+ <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>
652
+ <model-viewer id="model_viewer" src="" camera-controls auto-rotate style="height:500px;width:500px;"></model-viewer>
653
+ </iframe>
654
+ <script>
655
+ function updateIframe(srcUrl) {
656
+ document.getElementById('model_viewer').src = '${srcUrl}';
657
+ }
658
+ </script>
659
  </div>
660
  </div>
661
  """