Skip to content

Commit 892c4cd

Browse files
AutoShape integer image-size fix (#10090)
Update common.py We have a division at line 694, and then a multiplication at line 695, so it makes `y*g` not an integer. And since `shape1` will be used at line 697 to ensure the size is divisible by the `stride`, this may lead to different image size. In my experiment, my image is [640, 640], it's divisible by the default stride 32, but I found that the result is changed to [672, 672] after line 697. So the final detection result is slightly different from that directly using the `detect.py` script, which does not call the AutoShape methods. Signed-off-by: janus-zheng <[email protected]> Signed-off-by: janus-zheng <[email protected]> Co-authored-by: Glenn Jocher <[email protected]>
1 parent 86decb3 commit 892c4cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

models/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ def forward(self, ims, size=640, augment=False, profile=False):
692692
s = im.shape[:2] # HWC
693693
shape0.append(s) # image shape
694694
g = max(size) / max(s) # gain
695-
shape1.append([y * g for y in s])
695+
shape1.append([int(y * g) for y in s])
696696
ims[i] = im if im.data.contiguous else np.ascontiguousarray(im) # update
697697
shape1 = [make_divisible(x, self.stride) for x in np.array(shape1).max(0)] if self.pt else size # inf shape
698698
x = [letterbox(im, shape1, auto=False)[0] for im in ims] # pad

0 commit comments

Comments
 (0)