color is gray white, How can I obtain the colored depth map
Hello, I successfully ran your instance code, but the depth map I generated is gray white. How can I obtain the colored depth map you displayed
field_of_view = post_processed_output[0]["field_of_view"]
focal_length = post_processed_output[0]["focal_length"]
depth = post_processed_output[0]["predicted_depth"]
depth = (depth - depth.min()) / (depth.max() - depth.min())
depth = depth * 255. # 600,800
depth = depth.detach().cpu().numpy()
depth = Image.fromarray(depth.astype("uint8"))
THANKS !
The depth map generated is actually on a gray scale in nature, if you want to color that, you have to use matplotlib colormaps. The images in the model card were actually displayed using matplotlib, therefore color map was applied automatically.
Quick way to get colored image is to display the final depth using matplotlib (automatically applies color map)
import matplotlib.pyplot as plt
plt.imshow(depth)
Or if you want to apply custom color maps, you can use the following code on the final depth
import numpy as np
depth_array = np.array(depth)
# Choose a colormap from https://matplotlib.org/stable/users/explain/colors/colormaps.html
colormap = plt.get_cmap("inferno")
depth_colored = colormap(depth_array / 255.0)
depth_colored = (depth_colored * 255).astype(np.uint8)
depth_colored = Image.fromarray(depth_colored)
depth_colored # applied color map
You can find the full code with outputs under the heading "Create Color Map" in this colab notebook