TorchScript single-output fix (#7261)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-04-03 22:51:11 +02:00
1 parent 05cf0d1a44
commit 8bc839ed8e
2 files changed
+16 -9

No files matched your search

+4 -3
View File
@@ -406,9 +406,10 @@ class DetectMultiBackend(nn.Module):
def forward(self, im, augment=False, visualize=False, val=False):
# YOLOv5 MultiBackend inference
b, ch, h, w = im.shape # batch, channel, height, width
if self.pt or self.jit: # PyTorch
y = self.model(im) if self.jit else self.model(im, augment=augment, visualize=visualize)
return y if val else y[0]
if self.pt: # PyTorch
y = self.model(im, augment=augment, visualize=visualize)[0]
elif self.jit: # TorchScript
y = self.model(im)[0]
elif self.dnn: # ONNX OpenCV DNN
im = im.cpu().numpy() # torch to numpy
self.net.setInput(im)