Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -111,12 +111,12 @@ def generate(image, mc_resolution, formats=["obj", "glb"]):
111
  mesh.apply_scale([-1, 1, 1]) # Otherwise the visualized .obj will be flipped
112
  mesh.export(mesh_path_obj.name)
113
 
114
- return mesh_path_obj.name, mesh_path_glb.name
115
 
116
  def run_example(image_pil):
117
  preprocessed = preprocess(image_pil, False, 0.9)
118
- mesh_name_obj, mesh_name_glb = generate(preprocessed, 256, ["obj", "glb"])
119
- return preprocessed, mesh_name_obj, mesh_name_glb
120
 
121
  with gr.Blocks() as demo:
122
  gr.Markdown(HEADER)
@@ -158,12 +158,14 @@ with gr.Blocks() as demo:
158
  label="Output Model (OBJ Format)",
159
  interactive=False,
160
  )
 
161
  gr.Markdown("Note: Downloaded object will be flipped in case of .obj export. Export .glb instead or manually flip it before usage.")
162
  with gr.Tab("GLB"):
163
  output_model_glb = gr.Model3D(
164
  label="Output Model (GLB Format)",
165
  interactive=False,
166
  )
 
167
  gr.Markdown("Note: The model shown here has a darker appearance. Download to get correct results.")
168
  with gr.Row(variant="panel"):
169
  gr.Examples(
@@ -171,7 +173,7 @@ with gr.Blocks() as demo:
171
  os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
172
  ],
173
  inputs=[input_image],
174
- outputs=[processed_image, output_model_obj, output_model_glb],
175
  cache_examples=True,
176
  fn=partial(run_example),
177
  label="Examples",
@@ -184,7 +186,7 @@ with gr.Blocks() as demo:
184
  ).success(
185
  fn=generate,
186
  inputs=[processed_image, mc_resolution],
187
- outputs=[output_model_obj, output_model_glb],
188
  )
189
 
190
  demo.queue(max_size=10)
 
111
  mesh.apply_scale([-1, 1, 1]) # Otherwise the visualized .obj will be flipped
112
  mesh.export(mesh_path_obj.name)
113
 
114
+ return mesh_path_obj.name, mesh_path_glb.name, gr.update(value=mesh_path_obj.name, visible=True), gr.update(value=mesh_path_glb.name, visible=True)
115
 
116
  def run_example(image_pil):
117
  preprocessed = preprocess(image_pil, False, 0.9)
118
+ mesh_name_obj, mesh_name_glb, download_obj, download_glb = generate(preprocessed, 256, ["obj", "glb"])
119
+ return preprocessed, mesh_name_obj, mesh_name_glb, download_obj, download_glb
120
 
121
  with gr.Blocks() as demo:
122
  gr.Markdown(HEADER)
 
158
  label="Output Model (OBJ Format)",
159
  interactive=False,
160
  )
161
+ download_obj_button = gr.DownloadButton(label="Download .obj", visible=False)
162
  gr.Markdown("Note: Downloaded object will be flipped in case of .obj export. Export .glb instead or manually flip it before usage.")
163
  with gr.Tab("GLB"):
164
  output_model_glb = gr.Model3D(
165
  label="Output Model (GLB Format)",
166
  interactive=False,
167
  )
168
+ download_glb_button = gr.DownloadButton(label="Download .glb", visible=False)
169
  gr.Markdown("Note: The model shown here has a darker appearance. Download to get correct results.")
170
  with gr.Row(variant="panel"):
171
  gr.Examples(
 
173
  os.path.join("examples", img_name) for img_name in sorted(os.listdir("examples"))
174
  ],
175
  inputs=[input_image],
176
+ outputs=[processed_image, output_model_obj, output_model_glb, download_obj_button, download_glb_button],
177
  cache_examples=True,
178
  fn=partial(run_example),
179
  label="Examples",
 
186
  ).success(
187
  fn=generate,
188
  inputs=[processed_image, mc_resolution],
189
+ outputs=[output_model_obj, output_model_glb, download_obj_button, download_glb_button],
190
  )
191
 
192
  demo.queue(max_size=10)