From 99a620f50063257eabb918b072dfc52cad6347fc Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 23 Aug 2022 23:51:09 +0200 Subject: [PATCH 1/2] Fix numpy to torch cls streaming bug Resolves https://github.com/ultralytics/yolov5/issues/9111 Signed-off-by: Glenn Jocher --- classify/predict.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classify/predict.py b/classify/predict.py index b430c0645f21..bb9477bb604c 100644 --- a/classify/predict.py +++ b/classify/predict.py @@ -28,6 +28,7 @@ import os import platform import sys +import torch from pathlib import Path import torch.backends.cudnn as cudnn @@ -101,7 +102,7 @@ def run( seen, windows, dt = 0, [], (Profile(), Profile(), Profile()) for path, im, im0s, vid_cap, s in dataset: with dt[0]: - im = im.to(device) + im = torch.Tensor(im).to(device) im = im.half() if model.fp16 else im.float() # uint8 to fp16/32 if len(im.shape) == 3: im = im[None] # expand for batch dim From 75bf2bb04f379de7c3c1f5d59f1c24d5533f327b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 23 Aug 2022 21:51:29 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- classify/predict.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classify/predict.py b/classify/predict.py index bb9477bb604c..b33b5bcc9933 100644 --- a/classify/predict.py +++ b/classify/predict.py @@ -28,9 +28,9 @@ import os import platform import sys -import torch from pathlib import Path +import torch import torch.backends.cudnn as cudnn import torch.nn.functional as F