michaelj commited on
Commit
f9d21de
·
verified ·
1 Parent(s): 3feaa5a

, mc_resolution

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -69,15 +69,16 @@ def preprocess(input_image, do_remove_background, foreground_ratio):
69
  return image
70
 
71
 
72
- def generate(image, mc_resolution):
73
  scene_codes = model(image, device=device)
74
  mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
75
  mesh = to_gradio_3d_orientation(mesh)
76
- mesh_path = tempfile.NamedTemporaryFile(suffix=".obj", delete=False)
77
- mesh_path2 = tempfile.NamedTemporaryFile(suffix=".glb", delete=False)
78
- mesh.export(mesh_path.name)
79
- mesh.export(mesh_path2.name)
80
- return mesh_path.name, mesh_path2.name
 
81
 
82
  def run_example(image_pil):
83
  preprocessed = preprocess(image_pil, False, 0.9)
@@ -112,7 +113,7 @@ with gr.Blocks() as demo:
112
  mc_resolution = gr.Slider(
113
  label="Marching Cubes Resolution",
114
  minimum=32,
115
- maximum=320,
116
  value=256,
117
  step=32
118
  )
@@ -147,7 +148,7 @@ with gr.Blocks() as demo:
147
  outputs=[processed_image],
148
  ).success(
149
  fn=generate,
150
- inputs=[processed_image],
151
  outputs=[output_model, output_model2],
152
  )
153
 
 
69
  return image
70
 
71
 
72
+ def generate(image, mc_resolution, formats=["obj", "glb"]):
73
  scene_codes = model(image, device=device)
74
  mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
75
  mesh = to_gradio_3d_orientation(mesh)
76
+ rv = []
77
+ for format in formats:
78
+ mesh_path = tempfile.NamedTemporaryFile(suffix=f".{format}", delete=False)
79
+ mesh.export(mesh_path.name)
80
+ rv.append(mesh_path.name)
81
+ return rv
82
 
83
  def run_example(image_pil):
84
  preprocessed = preprocess(image_pil, False, 0.9)
 
113
  mc_resolution = gr.Slider(
114
  label="Marching Cubes Resolution",
115
  minimum=32,
116
+ maximum=1024,
117
  value=256,
118
  step=32
119
  )
 
148
  outputs=[processed_image],
149
  ).success(
150
  fn=generate,
151
+ inputs=[processed_image, mc_resolution],
152
  outputs=[output_model, output_model2],
153
  )
154