Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -37,16 +37,17 @@ color_map = cv2.applyColorMap(np.arange(256, dtype=np.uint8), cv2.COLORMAP_INFER
|
|
37 |
color_map = torch.from_numpy(color_map).to(device)
|
38 |
|
39 |
def preprocess_image(image):
|
40 |
-
image = cv2.resize(image, (
|
41 |
image = torch.from_numpy(image).permute(2, 0, 1).unsqueeze(0).float().to(device)
|
42 |
return image / 255.0
|
43 |
|
44 |
def plot_depth_map(depth_map):
|
45 |
-
fig = plt.figure()
|
46 |
ax = fig.add_subplot(111, projection='3d')
|
47 |
x, y = np.meshgrid(range(depth_map.shape[1]), range(depth_map.shape[0]))
|
48 |
ax.plot_surface(x, y, depth_map, cmap='viridis')
|
49 |
-
ax.
|
|
|
50 |
plt.close(fig)
|
51 |
return fig
|
52 |
|
|
|
37 |
color_map = torch.from_numpy(color_map).to(device)
|
38 |
|
39 |
def preprocess_image(image):
|
40 |
+
image = cv2.resize(image, (128, 72))
|
41 |
image = torch.from_numpy(image).permute(2, 0, 1).unsqueeze(0).float().to(device)
|
42 |
return image / 255.0
|
43 |
|
44 |
def plot_depth_map(depth_map):
|
45 |
+
fig = plt.figure(figsize=(16, 9)) # Set figure size to 16:9
|
46 |
ax = fig.add_subplot(111, projection='3d')
|
47 |
x, y = np.meshgrid(range(depth_map.shape[1]), range(depth_map.shape[0]))
|
48 |
ax.plot_surface(x, y, depth_map, cmap='viridis')
|
49 |
+
ax.view_init(azim=90, elev=0) # Rotate the view to face forward
|
50 |
+
ax.set_zlim(0, 1)
|
51 |
plt.close(fig)
|
52 |
return fig
|
53 |
|