From e6f54c5b32340278474e922d456fa3eb7f74599d Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 23 Aug 2022 23:54:05 +0200 Subject: [PATCH] Fix numpy to torch cls streaming bug (#9112) * Fix numpy to torch cls streaming bug Resolves https://github.com/ultralytics/yolov5/issues/9111 Signed-off-by: Glenn Jocher * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Signed-off-by: Glenn Jocher Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- classify/predict.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classify/predict.py b/classify/predict.py index b430c0645f21..b33b5bcc9933 100644 --- a/classify/predict.py +++ b/classify/predict.py @@ -30,6 +30,7 @@ import sys from pathlib import Path +import torch import torch.backends.cudnn as cudnn import torch.nn.functional as F @@ -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