mattpoggi / depthstillation

Demo code for paper "Learning optical flow from still images", CVPR 2021.
MIT License
152 stars 11 forks source link

The generation process of depth image #2

Closed Victarry closed 3 years ago

Victarry commented 3 years ago

I use MiDaS and follow the instructions in https://pytorch.org/hub/intelisl_midas_v2/ to get the depth image, white the depth of the demo image I get is as follows: demo

It seems very different from the depth image provided in this repo: demo2

the code I use is like this:

midas = torch.hub.load("intel-isl/MiDaS", "MiDaS").cuda()
midas_transforms = torch.hub.load("intel-isl/MiDaS", "transforms")
transform = midas_transforms.default_transform

image = np.asarray(Image.open(input_image))
img = transform(image)
with torch.no_grad():
    prediction = midas(img.cuda())
    # prediction = torch.nn.functional.interpolate(
    #     prediction.unsqueeze(1),
    #     size=image.shape[:2],
    #     mode="bicubic",
    #     align_corners=False,
    # ).squeeze()
depth_image = prediction.cpu().numpy().squeeze()
depth_image = cv2.convertScaleAbs(depth_image, alpha=255/np.max(depth_image))
Image.fromarray(img, mode="L").save("demo.png")

Could you please give some details about how to get the depth image?

mattpoggi commented 3 years ago

Hi @Victarry, we generated depth maps using the run.py script from the MiDaS repo (https://github.com/intel-isl/MiDaS) as it was in August 2020, using model-f46da743.pt weights. Maybe you are using a different model?