alexnasa commited on
Commit
c4a18a0
·
verified ·
1 Parent(s): 9221b07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -271,14 +271,16 @@ def run_triposg(image_path: str,
271
 
272
  # Merge and color
273
  merged = get_colored_mesh_composition(outputs)
 
274
 
275
 
276
- glb_path = os.path.join(export_dir, "object.glb")
277
- merged.export(glb_path)
278
 
279
- mesh_file = first_file_from_dir(export_dir, "glb")
280
-
281
- return mesh_file, export_dir, zip_path
 
282
 
283
  def cleanup(request: gr.Request):
284
 
@@ -295,7 +297,7 @@ def build_demo():
295
  css = """
296
  #col-container {
297
  margin: 0 auto;
298
- max-width: 1024px;
299
  }
300
  """
301
  theme = gr.themes.Ocean()
@@ -345,6 +347,7 @@ def build_demo():
345
  )
346
  with gr.Row(scale=2):
347
  output_model = gr.Model3D(label="Merged 3D Object")
 
348
  output_dir = gr.Textbox(label="Export Directory", visible=False)
349
  with gr.Row(scale=1):
350
  download_zip = gr.File(label="Download All Parts (zip)")
@@ -367,7 +370,7 @@ def build_demo():
367
 
368
  ],
369
  inputs=[input_image, num_parts],
370
- outputs=[output_model, output_dir, download_zip],
371
  fn=run_triposg,
372
  cache_examples=True,
373
  )
@@ -375,7 +378,7 @@ def build_demo():
375
  run_button.click(fn=run_triposg,
376
  inputs=[input_image, num_parts, seed, num_tokens, num_steps,
377
  guidance, flash_decoder, remove_bg, session_state],
378
- outputs=[output_model, output_dir, download_zip])
379
  return demo
380
 
381
  if __name__ == "__main__":
 
271
 
272
  # Merge and color
273
  merged = get_colored_mesh_composition(outputs)
274
+ split_mesh = explode_mesh(merged)
275
 
276
 
277
+ merged_path = os.path.join(export_dir, "object.glb")
278
+ merged.export(merged_path)
279
 
280
+ split_preview_path = os.path.join(export_dir, "object.glb")
281
+ split_mesh.export(split_preview_path)
282
+
283
+ return merged_path, split_preview_path, export_dir, zip_path
284
 
285
  def cleanup(request: gr.Request):
286
 
 
297
  css = """
298
  #col-container {
299
  margin: 0 auto;
300
+ max-width: 1280px;
301
  }
302
  """
303
  theme = gr.themes.Ocean()
 
347
  )
348
  with gr.Row(scale=2):
349
  output_model = gr.Model3D(label="Merged 3D Object")
350
+ split_model = gr.Model3D(label="Split Preview")
351
  output_dir = gr.Textbox(label="Export Directory", visible=False)
352
  with gr.Row(scale=1):
353
  download_zip = gr.File(label="Download All Parts (zip)")
 
370
 
371
  ],
372
  inputs=[input_image, num_parts],
373
+ outputs=[output_model, split_model, output_dir, download_zip],
374
  fn=run_triposg,
375
  cache_examples=True,
376
  )
 
378
  run_button.click(fn=run_triposg,
379
  inputs=[input_image, num_parts, seed, num_tokens, num_steps,
380
  guidance, flash_decoder, remove_bg, session_state],
381
+ outputs=[output_model, split_model, output_dir, download_zip])
382
  return demo
383
 
384
  if __name__ == "__main__":