CharlieAmalet commited on
Commit
c08d09e
·
verified ·
1 Parent(s): c283f36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -33,7 +33,8 @@ model = torch.hub.load('isl-org/ZoeDepth', "ZoeD_N", pretrained=True).to("cpu").
33
  @spaces.GPU(enable_queue=True)
34
  def save_raw_16bit(depth, fpath="raw.png"):
35
  if isinstance(depth, torch.Tensor):
36
- depth = depth.squeeze().cpu().numpy()
 
37
 
38
  assert isinstance(depth, np.ndarray), "Depth must be a torch tensor or numpy array"
39
  assert depth.ndim == 2, "Depth must be 2D"
@@ -73,7 +74,7 @@ def depth_edges_mask(depth):
73
  return mask
74
 
75
  @spaces.GPU(enable_queue=True)
76
- def predict_depth(model, image):
77
  global model
78
  model.to(DEVICE)
79
  depth = model.infer_pil(image)
@@ -81,10 +82,9 @@ def predict_depth(model, image):
81
 
82
  @spaces.GPU(enable_queue=True)
83
  def get_mesh(image: Image.Image, keep_edges=True):
84
- global model
85
  image.thumbnail((1024,1024)) # limit the size of the input image
86
 
87
- depth = predict_depth(model, image)
88
  pts3d = depth_to_points(depth[None])
89
  pts3d = pts3d.reshape(-1, 3)
90
 
 
33
  @spaces.GPU(enable_queue=True)
34
  def save_raw_16bit(depth, fpath="raw.png"):
35
  if isinstance(depth, torch.Tensor):
36
+ depth
37
+ = depth.squeeze().cpu().numpy()
38
 
39
  assert isinstance(depth, np.ndarray), "Depth must be a torch tensor or numpy array"
40
  assert depth.ndim == 2, "Depth must be 2D"
 
74
  return mask
75
 
76
  @spaces.GPU(enable_queue=True)
77
+ def predict_depth(image):
78
  global model
79
  model.to(DEVICE)
80
  depth = model.infer_pil(image)
 
82
 
83
  @spaces.GPU(enable_queue=True)
84
  def get_mesh(image: Image.Image, keep_edges=True):
 
85
  image.thumbnail((1024,1024)) # limit the size of the input image
86
 
87
+ depth = predict_depth(image)
88
  pts3d = depth_to_points(depth[None])
89
  pts3d = pts3d.reshape(-1, 3)
90