gangweix commited on
Commit
b9944aa
·
verified ·
1 Parent(s): 8a61297

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -82,19 +82,19 @@ def main(share=True):
82
 
83
  @(spaces.GPU if HUGGINFACE_SPACES_INSTALLED else (lambda x: x))
84
  def predict_depth(image, denoise_steps):
85
- DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
86
- global model
87
- model = model.to(DEVICE)
88
  depth, resize_image = model.infer_image(image, sampling_steps=denoise_steps)
89
  return depth, resize_image
90
 
91
  @(spaces.GPU if HUGGINFACE_SPACES_INSTALLED else (lambda x: x))
92
  def predict_moge_depth(image):
93
- DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
94
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
95
  image = torch.tensor(image / 255, dtype=torch.float32, device=DEVICE).permute(2, 0, 1)
96
- global moge_model
97
- moge_model = moge_model.to(DEVICE)
98
  metric_depth, mask, intrinsics = moge_model.infer(image)
99
  metric_depth[~mask] = metric_depth[mask].max()
100
  return metric_depth, mask, intrinsics
 
82
 
83
  @(spaces.GPU if HUGGINFACE_SPACES_INSTALLED else (lambda x: x))
84
  def predict_depth(image, denoise_steps):
85
+ # DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
86
+ # global model
87
+ # model = model.to(DEVICE)
88
  depth, resize_image = model.infer_image(image, sampling_steps=denoise_steps)
89
  return depth, resize_image
90
 
91
  @(spaces.GPU if HUGGINFACE_SPACES_INSTALLED else (lambda x: x))
92
  def predict_moge_depth(image):
93
+ # DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")
94
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
95
  image = torch.tensor(image / 255, dtype=torch.float32, device=DEVICE).permute(2, 0, 1)
96
+ # global moge_model
97
+ # moge_model = moge_model.to(DEVICE)
98
  metric_depth, mask, intrinsics = moge_model.infer(image)
99
  metric_depth[~mask] = metric_depth[mask].max()
100
  return metric_depth, mask, intrinsics