Add a Download button to help users to understand they can retrieve the 3D model

#12
Files changed (1) hide show
  1. gradio_app/gradio_3dgen.py +15 -14
gradio_app/gradio_3dgen.py CHANGED
@@ -39,7 +39,7 @@ def generate3dv2(preview_img, input_processing, seed, render_video=True, do_refi
39
  new_meshes = Meshes(verts=[vertices], faces=new_meshes.faces_list(), textures=new_meshes.textures)
40
 
41
  ret_mesh, video = save_glb_and_video("/tmp/gradio/generated", new_meshes, with_timestamp=True, dist=3.5, fov_in_degrees=2 / 1.35, cam_type="ortho", export_video=render_video)
42
- return ret_mesh, video
43
 
44
  #######################################
45
  def create_ui(concurrency_id="wkl"):
@@ -47,6 +47,18 @@ def create_ui(concurrency_id="wkl"):
47
  with gr.Column(scale=1):
48
  input_image = gr.Image(type='pil', image_mode='RGBA', label='Frontview')
49
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  example_folder = os.path.join(os.path.dirname(__file__), "./examples")
51
  example_fns = sorted([os.path.join(example_folder, example) for example in os.listdir(example_folder)])
52
  gr.Examples(
@@ -61,24 +73,13 @@ def create_ui(concurrency_id="wkl"):
61
  with gr.Column(scale=1):
62
  # export mesh display
63
  output_mesh = gr.Model3D(value=None, label="Mesh Model", show_label=True, height=320, camera_position=(90, 90, 2))
 
64
  output_video = gr.Video(label="Preview", show_label=True, show_share_button=True, height=320, visible=False)
65
 
66
- input_processing = gr.Checkbox(
67
- value=True,
68
- label='Remove Background',
69
- visible=True,
70
- )
71
- do_refine = gr.Checkbox(value=True, label="Refine Multiview Details", visible=False)
72
- expansion_weight = gr.Slider(minimum=-1., maximum=1.0, value=0.1, step=0.1, label="Expansion Weight", visible=False)
73
- init_type = gr.Dropdown(choices=["std", "thin"], label="Mesh Initialization", value="std", visible=False)
74
- setable_seed = gr.Slider(-1, 1000000000, -1, step=1, visible=True, label="Seed")
75
- render_video = gr.Checkbox(value=False, visible=False, label="generate video")
76
- fullrunv2_btn = gr.Button('Generate 3D', variant = "primary", interactive=True)
77
-
78
  fullrunv2_btn.click(
79
  fn = generate3dv2,
80
  inputs=[input_image, input_processing, setable_seed, render_video, do_refine, expansion_weight, init_type],
81
- outputs=[output_mesh, output_video],
82
  concurrency_id=concurrency_id,
83
  api_name="generate3dv2",
84
  ).success(clean_up, api_name=False)
 
39
  new_meshes = Meshes(verts=[vertices], faces=new_meshes.faces_list(), textures=new_meshes.textures)
40
 
41
  ret_mesh, video = save_glb_and_video("/tmp/gradio/generated", new_meshes, with_timestamp=True, dist=3.5, fov_in_degrees=2 / 1.35, cam_type="ortho", export_video=render_video)
42
+ return ret_mesh, video, gr.update(value=ret_mesh, visible=True)
43
 
44
  #######################################
45
  def create_ui(concurrency_id="wkl"):
 
47
  with gr.Column(scale=1):
48
  input_image = gr.Image(type='pil', image_mode='RGBA', label='Frontview')
49
 
50
+ input_processing = gr.Checkbox(
51
+ value=True,
52
+ label='Remove Background',
53
+ visible=True,
54
+ )
55
+ do_refine = gr.Checkbox(value=True, label="Refine Multiview Details", visible=False)
56
+ expansion_weight = gr.Slider(minimum=-1., maximum=1.0, value=0.1, step=0.1, label="Expansion Weight", visible=False)
57
+ init_type = gr.Dropdown(choices=["std", "thin"], label="Mesh Initialization", value="std", visible=False)
58
+ setable_seed = gr.Slider(-1, 1000000000, -1, step=1, visible=True, label="Seed")
59
+ render_video = gr.Checkbox(value=False, visible=False, label="generate video")
60
+ fullrunv2_btn = gr.Button('Generate 3D', variant = "primary", interactive=True)
61
+
62
  example_folder = os.path.join(os.path.dirname(__file__), "./examples")
63
  example_fns = sorted([os.path.join(example_folder, example) for example in os.listdir(example_folder)])
64
  gr.Examples(
 
73
  with gr.Column(scale=1):
74
  # export mesh display
75
  output_mesh = gr.Model3D(value=None, label="Mesh Model", show_label=True, height=320, camera_position=(90, 90, 2))
76
+ download_button = gr.DownloadButton(label="Download 3D", visible=False)
77
  output_video = gr.Video(label="Preview", show_label=True, show_share_button=True, height=320, visible=False)
78
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  fullrunv2_btn.click(
80
  fn = generate3dv2,
81
  inputs=[input_image, input_processing, setable_seed, render_video, do_refine, expansion_weight, init_type],
82
+ outputs=[output_mesh, output_video, download_button],
83
  concurrency_id=concurrency_id,
84
  api_name="generate3dv2",
85
  ).success(clean_up, api_name=False)