vibs08 commited on
Commit
c09a068
·
verified ·
1 Parent(s): 81572b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -1
app.py CHANGED
@@ -170,8 +170,9 @@ def preprocess(input_image, do_remove_background, foreground_ratio):
170
 
171
  # @spaces.GPU
172
  def generate(image, mc_resolution, formats=["obj", "glb"]):
173
- # torch.cuda.empty_cache()
174
  scene_codes = model(image, device=device)
 
175
  mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
176
  mesh = to_gradio_3d_orientation(mesh)
177
 
@@ -181,6 +182,7 @@ def generate(image, mc_resolution, formats=["obj", "glb"]):
181
  mesh_path_obj = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False)
182
  mesh.apply_scale([-1, 1, 1]) # Otherwise the visualized .obj will be flipped
183
  mesh.export(mesh_path_obj.name)
 
184
  return mesh_path_obj.name, mesh_path_glb.name
185
 
186
  def upload_file_to_s3(file_path, bucket_name, object_name=None):
 
170
 
171
  # @spaces.GPU
172
  def generate(image, mc_resolution, formats=["obj", "glb"]):
173
+ torch.cuda.synchronize()
174
  scene_codes = model(image, device=device)
175
+ torch.cuda.synchronize()
176
  mesh = model.extract_mesh(scene_codes, resolution=mc_resolution)[0]
177
  mesh = to_gradio_3d_orientation(mesh)
178
 
 
182
  mesh_path_obj = tempfile.NamedTemporaryFile(suffix=f".obj", delete=False)
183
  mesh.apply_scale([-1, 1, 1]) # Otherwise the visualized .obj will be flipped
184
  mesh.export(mesh_path_obj.name)
185
+ torch.cuda.synchronize()
186
  return mesh_path_obj.name, mesh_path_glb.name
187
 
188
  def upload_file_to_s3(file_path, bucket_name, object_name=None):