Spaces:
Running
on
T4
Running
on
T4
Upload gradio_app.py
Browse files- gradio_app.py +32 -70
gradio_app.py
CHANGED
@@ -346,24 +346,21 @@ def build_app():
|
|
346 |
|
347 |
with gr.Row():
|
348 |
with gr.Column(scale=3):
|
349 |
-
with gr.
|
350 |
-
with gr.
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
|
|
360 |
|
361 |
with gr.Row():
|
362 |
-
btn = gr.Button(value='
|
363 |
-
btn_all = gr.Button(value='Gen Textured Shape',
|
364 |
-
variant='primary',
|
365 |
-
visible=HAS_TEXTUREGEN,
|
366 |
-
min_width=100)
|
367 |
|
368 |
with gr.Group():
|
369 |
file_out = gr.File(label="File", visible=False)
|
@@ -416,12 +413,12 @@ def build_app():
|
|
416 |
|
417 |
with gr.Column(scale=9):
|
418 |
with gr.Tabs(selected='gen_mesh_panel') as tabs_output:
|
419 |
-
with gr.Tab('
|
420 |
html_gen_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
|
421 |
-
with gr.Tab('Exporting Mesh', id='export_mesh_panel'):
|
422 |
-
|
423 |
-
with gr.Tab('Mesh Statistic', id='stats_panel'):
|
424 |
-
|
425 |
|
426 |
btn.click(
|
427 |
shape_generation,
|
@@ -448,31 +445,6 @@ def build_app():
|
|
448 |
outputs=[tabs_output],
|
449 |
)
|
450 |
|
451 |
-
btn_all.click(
|
452 |
-
generation_all,
|
453 |
-
inputs=[
|
454 |
-
mv_image_front,
|
455 |
-
mv_image_back,
|
456 |
-
mv_image_left,
|
457 |
-
mv_image_right,
|
458 |
-
num_steps,
|
459 |
-
cfg_scale,
|
460 |
-
seed,
|
461 |
-
octree_resolution,
|
462 |
-
check_box_rembg,
|
463 |
-
num_chunks,
|
464 |
-
randomize_seed,
|
465 |
-
],
|
466 |
-
outputs=[file_out, file_out2, html_gen_mesh, stats, seed]
|
467 |
-
).then(
|
468 |
-
lambda: (gr.update(visible=True, value=True), gr.update(interactive=False), gr.update(interactive=True),
|
469 |
-
gr.update(interactive=False)),
|
470 |
-
outputs=[export_texture, reduce_face, confirm_export, file_export],
|
471 |
-
).then(
|
472 |
-
lambda: gr.update(selected='gen_mesh_panel'),
|
473 |
-
outputs=[tabs_output],
|
474 |
-
)
|
475 |
-
|
476 |
def on_gen_mode_change(value):
|
477 |
if value == 'Turbo':
|
478 |
return gr.update(value=5)
|
@@ -499,30 +471,20 @@ def build_app():
|
|
499 |
|
500 |
print(f'exporting {file_out}')
|
501 |
print(f'reduce face to {target_face_num}')
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
if reduce_face:
|
517 |
-
mesh = face_reduce_worker(mesh, target_face_num)
|
518 |
-
save_folder = gen_save_folder()
|
519 |
-
path = export_mesh(mesh, save_folder, textured=False, type=file_type)
|
520 |
-
|
521 |
-
# for preview
|
522 |
-
save_folder = gen_save_folder()
|
523 |
-
_ = export_mesh(mesh, save_folder, textured=False)
|
524 |
-
model_viewer_html = build_model_viewer_html(save_folder, height=HTML_HEIGHT, width=HTML_WIDTH,
|
525 |
-
textured=False)
|
526 |
print(f'export to {path}')
|
527 |
return model_viewer_html, gr.update(value=path, interactive=True)
|
528 |
|
|
|
346 |
|
347 |
with gr.Row():
|
348 |
with gr.Column(scale=3):
|
349 |
+
with gr.Tabs(selected='tab_mv'):
|
350 |
+
with gr.Tab("Imágenes", id='tab_mv', visible=TURBO_MODE):
|
351 |
+
with gr.Row():
|
352 |
+
mv_image_front = gr.Image(label='Parte Frontal', type='pil', image_mode='RGBA', height=140,
|
353 |
+
min_width=100, elem_classes='mv-image')
|
354 |
+
mv_image_back = gr.Image(label='Parte Trasera', type='pil', image_mode='RGBA', height=140,
|
355 |
+
min_width=100, elem_classes='mv-image')
|
356 |
+
with gr.Row():
|
357 |
+
mv_image_left = gr.Image(label='Izquierda', type='pil', image_mode='RGBA', height=140,
|
358 |
+
min_width=100, elem_classes='mv-image')
|
359 |
+
mv_image_right = gr.Image(label='Derecha', type='pil', image_mode='RGBA', height=140,
|
360 |
+
min_width=100, elem_classes='mv-image')
|
361 |
|
362 |
with gr.Row():
|
363 |
+
btn = gr.Button(value='Generar Modelo', variant='primary', min_width=100)
|
|
|
|
|
|
|
|
|
364 |
|
365 |
with gr.Group():
|
366 |
file_out = gr.File(label="File", visible=False)
|
|
|
413 |
|
414 |
with gr.Column(scale=9):
|
415 |
with gr.Tabs(selected='gen_mesh_panel') as tabs_output:
|
416 |
+
with gr.Tab('Modelo Generado', id='gen_mesh_panel'):
|
417 |
html_gen_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
|
418 |
+
#with gr.Tab('Exporting Mesh', id='export_mesh_panel'):
|
419 |
+
# html_export_mesh = gr.HTML(HTML_OUTPUT_PLACEHOLDER, label='Output')
|
420 |
+
#with gr.Tab('Mesh Statistic', id='stats_panel'):
|
421 |
+
# stats = gr.Json({}, label='Mesh Stats')
|
422 |
|
423 |
btn.click(
|
424 |
shape_generation,
|
|
|
445 |
outputs=[tabs_output],
|
446 |
)
|
447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
def on_gen_mode_change(value):
|
449 |
if value == 'Turbo':
|
450 |
return gr.update(value=5)
|
|
|
471 |
|
472 |
print(f'exporting {file_out}')
|
473 |
print(f'reduce face to {target_face_num}')
|
474 |
+
|
475 |
+
mesh = trimesh.load(file_out)
|
476 |
+
mesh = floater_remove_worker(mesh)
|
477 |
+
mesh = degenerate_face_remove_worker(mesh)
|
478 |
+
if reduce_face:
|
479 |
+
mesh = face_reduce_worker(mesh, target_face_num)
|
480 |
+
save_folder = gen_save_folder()
|
481 |
+
path = export_mesh(mesh, save_folder, textured=False, type=file_type)
|
482 |
+
|
483 |
+
# for preview
|
484 |
+
save_folder = gen_save_folder()
|
485 |
+
_ = export_mesh(mesh, save_folder, textured=False)
|
486 |
+
model_viewer_html = build_model_viewer_html(save_folder, height=HTML_HEIGHT, width=HTML_WIDTH,
|
487 |
+
textured=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
print(f'export to {path}')
|
489 |
return model_viewer_html, gr.update(value=path, interactive=True)
|
490 |
|