From 1bbfd2e29c2c64bcaadc50ef0b6147f7695dad7c Mon Sep 17 00:00:00 2001 From: Zhuofan Xi Date: Sun, 9 Nov 2025 21:53:08 -0500 Subject: [PATCH] Fix padding logic to avoid negative padding --- unidepth/models/unidepthv2/unidepthv2.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unidepth/models/unidepthv2/unidepthv2.py b/unidepth/models/unidepthv2/unidepthv2.py index c2a9453..a54c7b8 100644 --- a/unidepth/models/unidepthv2/unidepthv2.py +++ b/unidepth/models/unidepthv2/unidepthv2.py @@ -44,13 +44,13 @@ def get_paddings(original_shape, aspect_ratio_range): if orig_aspect_ratio > target_aspect_ratio: # Too wide W_new = W_ori - H_new = int(W_ori / target_aspect_ratio) + H_new = max(int(W_ori / target_aspect_ratio), H_ori) pad_top = (H_new - H_ori) // 2 pad_bottom = H_new - H_ori - pad_top pad_left, pad_right = 0, 0 else: # Too tall H_new = H_ori - W_new = int(H_ori * target_aspect_ratio) + W_new = max(int(H_ori * target_aspect_ratio), W_ori) pad_left = (W_new - W_ori) // 2 pad_right = W_new - W_ori - pad_left pad_top, pad_bottom = 0, 0