pablo commited on
Commit
9b31e74
·
1 Parent(s): 35ffdbd
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -34,7 +34,7 @@ else:
34
 
35
 
36
  def estimate_depth(image: Image) -> Image:
37
- image= image.resize((384,384))
38
  image = np.array(image)
39
  input_batch = transform(image).to(device)
40
 
@@ -51,6 +51,11 @@ def estimate_depth(image: Image) -> Image:
51
  output = prediction.cpu().numpy()
52
 
53
  output= 255 * output/np.max(output)
 
 
 
 
 
54
 
55
  return Image.fromarray(output.astype("uint8"))
56
 
 
34
 
35
 
36
  def estimate_depth(image: Image) -> Image:
37
+ image= image.resize((384,384)).convert("RGB")
38
  image = np.array(image)
39
  input_batch = transform(image).to(device)
40
 
 
51
  output = prediction.cpu().numpy()
52
 
53
  output= 255 * output/np.max(output)
54
+
55
+ # If 3 channels convert to 1
56
+ if (len(output.shape) == 3):
57
+ if (output.shape[2] == 3):
58
+ output = output[:, :, 0]
59
 
60
  return Image.fromarray(output.astype("uint8"))
61