fabio-sim / Depth-Anything-ONNX

ONNX-compatible Depth Anything: Unleashing the Power of Large-Scale Unlabeled Data
Apache License 2.0
234 stars 23 forks source link

Not Identical Output B/w ONNX and Original Version #6

Closed TouqeerAhmad closed 6 months ago

TouqeerAhmad commented 6 months ago

Hello,

Thank you for providing the ONNX models for DepthAnything. I have compared the inferred depth maps from original DepthAnything models and your provided ONNX converted models. To my surprise the outputs are not identical. There are a lot of details missing in the ONNX based prediction. Specifically, I have used the ViT-L for both inferences, I attach the zipped folder containing comparison for couple of demo images. comparison.zip

Can you please clarify why there is so much difference?

Thank you!

TouqeerAhmad commented 6 months ago

Please find below another zipped folder with comparison for more images; details are definitely being compromised in ONNX version. comparison_more.zip

TouqeerAhmad commented 6 months ago

I figured out the issue, the aspect ratio was not maintained in this repo i.e., https://github.com/fabio-sim/Depth-Anything-ONNX/blob/d6cc8e1e6713a2129683496b328bde675a66370d/depth_anything/util/transform.py#L256

whereas it is maintained in the original DepthAnything i.e., https://github.com/LiheYoung/Depth-Anything/blob/6e780749e7772e911754a4eb00965727987f92f7/app.py#L39

Fixing aspect ratio flag in this repo addresses the visual mismatch that I noticed between ONNX and original version.