DepthAnything / Depth-Anything-V2

Depth Anything V2. A More Capable Foundation Model for Monocular Depth Estimation
https://depth-anything-v2.github.io
Apache License 2.0
3.32k stars 266 forks source link

Sharper depth when interpolating to image size #118

Open felipecadar opened 1 month ago

felipecadar commented 1 month ago

Hi! Congrats on the work!

I was testing the models and I noticed some distortions in my point clouds caused (probably) by the interpolation back to the image shape. It happens in sharp corners, where the interpolation sometimes places points between two (very distant) depth levels, instead of leaving it as a "sharp edge".

Mainly, I wanted to know why the authors decided on the bilinear interpolation, and if there's a better solution then just using a simpler interpolation.

My temporary fix was just to modify this line to get a sharper depth image on the original image resolution.

from

        depth = F.interpolate(depth[:, None], (h, w), mode="bilinear", align_corners=True)[0, 0]

to

        depth = F.interpolate(depth[:, None], (h, w), mode="nearest")[0, 0]
LiheYoung commented 6 days ago

Hi @felipecadar, thank you for raising this! We agree that the 'nearest' interpolation should be a better practice. We will use this interpolation probably in our future versions.