Tennineee commited on
Commit
520b0be
·
verified ·
1 Parent(s): 16f62f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -78,11 +78,11 @@ transforms = GOSNormalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
78
  def predict(image):
79
  H,W = image.shape[:2]
80
  depth = DAMV2.infer_image(image)
81
- image = cv2.resize(image, (1024,1024))
82
- depth = cv2.resize(depth, (1024,1024))
83
- image = torch.from_numpy(image).permute(2,0,1).float()/255
 
84
  image = transforms(image).unsqueeze(0)
85
- depth = torch.from_numpy(depth).unsqueeze(0).unsqueeze(0)/255
86
  DIS_map = model.inference(image.to(device),depth.to(device))[0][0][0].cpu()
87
  DIS_map = cv2.resize(np.array(DIS_map), (W,H))
88
  # return cv2.resize(np.array(depth[0][0]), (W,H))
 
78
  def predict(image):
79
  H,W = image.shape[:2]
80
  depth = DAMV2.infer_image(image)
81
+ image = torch.nn.functional.interpolate(torch.from_numpy(image).permute(2,0,1)[None,...],size=[1024,1024],mode='bilinear',align_corners=True)[0]
82
+ depth = torch.nn.functional.interpolate(torch.from_numpy(depth)[None,None,...],size=[1024,1024],mode='bilinear',align_corners=True)
83
+ image = torch.divide(image,255.0)
84
+ depth = torch.divide(depth,255.0)
85
  image = transforms(image).unsqueeze(0)
 
86
  DIS_map = model.inference(image.to(device),depth.to(device))[0][0][0].cpu()
87
  DIS_map = cv2.resize(np.array(DIS_map), (W,H))
88
  # return cv2.resize(np.array(depth[0][0]), (W,H))