freealise commited on
Commit
a0e06d8
1 Parent(s): d9c6302

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -11,6 +11,7 @@ from torchvision.transforms import Compose
11
  import trimesh
12
  from geometry import create_triangles
13
  import tempfile
 
14
  import spaces
15
  from zipfile import ZipFile
16
 
@@ -209,6 +210,7 @@ def pano_depth_to_world_points(depth):
209
  def get_mesh(image, depth, keep_edges=False):
210
  image.thumbnail((1024,1024)) # limit the size of the image
211
  pts3d = pano_depth_to_world_points(depth)
 
212
 
213
  # Create a trimesh mesh from the points
214
  # Each pixel is connected to its 4 neighbors
@@ -220,13 +222,16 @@ def get_mesh(image, depth, keep_edges=False):
220
  triangles = create_triangles(image.shape[0], image.shape[1])
221
  else:
222
  triangles = create_triangles(image.shape[0], image.shape[1], mask=~depth_edges_mask(depth))
 
223
  colors = image.reshape(-1, 3)
224
  mesh = trimesh.Trimesh(vertices=verts, faces=triangles, vertex_colors=colors)
 
225
 
226
  # Save as glb
227
  glb_file = tempfile.NamedTemporaryFile(suffix='.glb', delete=False)
228
  glb_path = glb_file.name
229
  mesh.export(glb_path)
 
230
  return glb_path
231
 
232
  def loadurl(url):
@@ -299,7 +304,7 @@ with gr.Blocks(css=css) as demo:
299
  return output_video_path
300
 
301
  submit.click(on_submit, inputs=[input_video, model_type], outputs=[processed_video, processed_zip, output_frame, output_depth])
302
- render.click(get_mesh, inputs=[output_frame, output_depth, checkbox], outputs=[result])
303
 
304
  example_files = os.listdir('examples')
305
  example_files.sort()
 
11
  import trimesh
12
  from geometry import create_triangles
13
  import tempfile
14
+ from functools import partial
15
  import spaces
16
  from zipfile import ZipFile
17
 
 
210
  def get_mesh(image, depth, keep_edges=False):
211
  image.thumbnail((1024,1024)) # limit the size of the image
212
  pts3d = pano_depth_to_world_points(depth)
213
+ print('radius from depth - ok')
214
 
215
  # Create a trimesh mesh from the points
216
  # Each pixel is connected to its 4 neighbors
 
222
  triangles = create_triangles(image.shape[0], image.shape[1])
223
  else:
224
  triangles = create_triangles(image.shape[0], image.shape[1], mask=~depth_edges_mask(depth))
225
+ print('triangles - ok')
226
  colors = image.reshape(-1, 3)
227
  mesh = trimesh.Trimesh(vertices=verts, faces=triangles, vertex_colors=colors)
228
+ print('mesh - ok')
229
 
230
  # Save as glb
231
  glb_file = tempfile.NamedTemporaryFile(suffix='.glb', delete=False)
232
  glb_path = glb_file.name
233
  mesh.export(glb_path)
234
+ print('file - ok')
235
  return glb_path
236
 
237
  def loadurl(url):
 
304
  return output_video_path
305
 
306
  submit.click(on_submit, inputs=[input_video, model_type], outputs=[processed_video, processed_zip, output_frame, output_depth])
307
+ render.click(partial(get_mesh), inputs=[output_frame, output_depth, checkbox], outputs=[result])
308
 
309
  example_files = os.listdir('examples')
310
  example_files.sort()