gangweix commited on
Commit
ebeb031
·
verified ·
1 Parent(s): bb2a5ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -52,9 +52,9 @@ ckpt_path = hf_hub_download(
52
  )
53
  state_dict = torch.load(ckpt_path, map_location="cpu")
54
  model.load_state_dict(state_dict, strict=False)
55
- model = model.to(DEVICE).eval()
56
 
57
- moge_model = MoGeModel.from_pretrained("Ruicheng/moge-2-vitl-normal").to(DEVICE).eval()
58
 
59
 
60
  def main(share=True):
@@ -68,6 +68,7 @@ def main(share=True):
68
 
69
  @spaces.GPU
70
  def predict_depth(image, denoise_steps):
 
71
  depth, resize_image = model.infer_image(image, sampling_steps=denoise_steps)
72
  return depth, resize_image
73
 
@@ -75,6 +76,7 @@ def main(share=True):
75
  def predict_moge_depth(image):
76
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
77
  image = torch.tensor(image / 255, dtype=torch.float32, device=DEVICE).permute(2, 0, 1)
 
78
  metric_depth, mask, intrinsics = moge_model.infer(image)
79
  metric_depth[~mask] = metric_depth[mask].max()
80
  return metric_depth, mask, intrinsics
 
52
  )
53
  state_dict = torch.load(ckpt_path, map_location="cpu")
54
  model.load_state_dict(state_dict, strict=False)
55
+ model = model.eval()
56
 
57
+ moge_model = MoGeModel.from_pretrained("Ruicheng/moge-2-vitl-normal").eval()
58
 
59
 
60
  def main(share=True):
 
68
 
69
  @spaces.GPU
70
  def predict_depth(image, denoise_steps):
71
+ model = model.to(DEVICE)
72
  depth, resize_image = model.infer_image(image, sampling_steps=denoise_steps)
73
  return depth, resize_image
74
 
 
76
  def predict_moge_depth(image):
77
  image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
78
  image = torch.tensor(image / 255, dtype=torch.float32, device=DEVICE).permute(2, 0, 1)
79
+ moge_model = moge_model.to(DEVICE)
80
  metric_depth, mask, intrinsics = moge_model.infer(image)
81
  metric_depth[~mask] = metric_depth[mask].max()
82
  return metric_depth, mask, intrinsics