Bladeren bron

Fix PyTorch Hub export inference shapes (#6949)

May resolve https://github.com/ultralytics/yolov5/issues/6947
modifyDataloader
Glenn Jocher GitHub 2 jaren geleden
bovenliggende
commit
84efa62b2d
Geen bekende sleutel gevonden voor deze handtekening in de database GPG sleutel-ID: 4AEE18F83AFDEB23
1 gewijzigde bestanden met toevoegingen van 3 en 4 verwijderingen
  1. +3
    -4
      models/common.py

+ 3
- 4
models/common.py Bestand weergeven

@@ -544,10 +544,9 @@ class AutoShape(nn.Module):
g = (size / max(s)) # gain
shape1.append([y * g for y in s])
imgs[i] = im if im.data.contiguous else np.ascontiguousarray(im) # update
shape1 = [make_divisible(x, self.stride) for x in np.stack(shape1, 0).max(0)] # inference shape
x = [letterbox(im, new_shape=shape1 if self.pt else size, auto=False)[0] for im in imgs] # pad
x = np.stack(x, 0) if n > 1 else x[0][None] # stack
x = np.ascontiguousarray(x.transpose((0, 3, 1, 2))) # BHWC to BCHW
shape1 = [make_divisible(x, self.stride) if self.pt else size for x in np.array(shape1).max(0)] # inf shape
x = [letterbox(im, new_shape=shape1, auto=False)[0] for im in imgs] # pad
x = np.ascontiguousarray(np.array(x).transpose((0, 3, 1, 2))) # stack and BHWC to BCHW
x = torch.from_numpy(x).to(p.device).type_as(p) / 255 # uint8 to fp16/32
t.append(time_sync())


Laden…
Annuleren
Opslaan