From 586c95b8a9a28c5151949510f0ccf965f3ee14a1 Mon Sep 17 00:00:00 2001 From: Neloy262 <42342914+Neloy262@users.noreply.github.com> Date: Mon, 3 Jul 2023 20:08:02 +0600 Subject: [PATCH] Add torch.Tensor results image saving (#3475) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- ultralytics/yolo/engine/predictor.py | 4 ---- ultralytics/yolo/engine/results.py | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ultralytics/yolo/engine/predictor.py b/ultralytics/yolo/engine/predictor.py index 2ea7a27..0f6eb0d 100644 --- a/ultralytics/yolo/engine/predictor.py +++ b/ultralytics/yolo/engine/predictor.py @@ -230,10 +230,6 @@ class BasePredictor: self.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz)) self.done_warmup = True - # Checks - if self.source_type.tensor and (self.args.save or self.args.save_txt or self.args.show): - LOGGER.warning("WARNING ⚠️ 'save', 'save_txt' and 'show' arguments not enabled for torch.Tensor inference.") - self.seen, self.windows, self.batch, profilers = 0, [], None, (ops.Profile(), ops.Profile(), ops.Profile()) self.run_callbacks('on_predict_start') for batch in self.dataset: diff --git a/ultralytics/yolo/engine/results.py b/ultralytics/yolo/engine/results.py index 085752e..c347da0 100644 --- a/ultralytics/yolo/engine/results.py +++ b/ultralytics/yolo/engine/results.py @@ -199,8 +199,7 @@ class Results(SimpleClass): (numpy.ndarray): A numpy array of the annotated image. """ if img is None and isinstance(self.orig_img, torch.Tensor): - LOGGER.warning('WARNING ⚠️ Results plotting is not supported for torch.Tensor image types.') - return + img = np.ascontiguousarray(self.orig_img[0].permute(1, 2, 0).cpu().detach().numpy()) * 255 # Deprecation warn TODO: remove in 8.2 if 'show_conf' in kwargs: