Skip to content

Commit f09f507

Browse files
zehuichen123RogerChern
authored andcommitted
fix pad2D potential error (tusen-ai#250)
1 parent 67c79f5 commit f09f507

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

core/detection_input.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ def apply(self, input_record):
304304
image = input_record["image"]
305305
gt_bbox = input_record["gt_bbox"]
306306

307+
origin_h, origin_w = input_record["h"], input_record["w"]
307308
h, w = image.shape[:2]
308-
shape = (p.long, p.short, 3) if h >= w \
309+
shape = (p.long, p.short, 3) if origin_h >= origin_w \
309310
else (p.short, p.long, 3)
310311

311312
padded_image = np.zeros(shape, dtype=np.float32)
@@ -334,8 +335,9 @@ def apply(self, input_record):
334335

335336
image = input_record["image"]
336337

338+
origin_h, origin_w = input_record["h"], input_record["w"]
337339
h, w = image.shape[:2]
338-
shape = (p.long, p.short, 3) if h >= w \
340+
shape = (p.long, p.short, 3) if origin_h >= origin_w \
339341
else (p.short, p.long, 3)
340342

341343
padded_image = np.zeros(shape, dtype=np.float32)

0 commit comments

Comments
 (0)