From 87d2f96c5c84c2ad5db2a41f19e27a9adef7ec39 Mon Sep 17 00:00:00 2001 From: alexchwong <80015046+alexchwong@users.noreply.github.com> Date: Mon, 27 Dec 2021 09:58:46 +1100 Subject: [PATCH] Update general.py See https://github.com/ultralytics/yolov5/issues/2106 --- utils/general.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/general.py b/utils/general.py index a104eff..48f1a0c 100644 --- a/utils/general.py +++ b/utils/general.py @@ -1089,6 +1089,9 @@ def output_to_target(output, width, height): targets = [] for i, o in enumerate(output): if o is not None: + # sometimes output can be a list of tensor, so here ensure the type again, this fixes the error. + if isinstance(o, torch.Tensor): + o = o.cpu().numpy() for pred in o: box = pred[:4] w = (box[2] - box[0]) / width