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 <glenn.jocher@ultralytics.com>
single_channel
Neloy262 1 year ago committed by GitHub
parent cd0bf05aa4
commit 586c95b8a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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.model.warmup(imgsz=(1 if self.model.pt or self.model.triton else self.dataset.bs, 3, *self.imgsz))
self.done_warmup = True 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.seen, self.windows, self.batch, profilers = 0, [], None, (ops.Profile(), ops.Profile(), ops.Profile())
self.run_callbacks('on_predict_start') self.run_callbacks('on_predict_start')
for batch in self.dataset: for batch in self.dataset:

@ -199,8 +199,7 @@ class Results(SimpleClass):
(numpy.ndarray): A numpy array of the annotated image. (numpy.ndarray): A numpy array of the annotated image.
""" """
if img is None and isinstance(self.orig_img, torch.Tensor): if img is None and isinstance(self.orig_img, torch.Tensor):
LOGGER.warning('WARNING ⚠️ Results plotting is not supported for torch.Tensor image types.') img = np.ascontiguousarray(self.orig_img[0].permute(1, 2, 0).cpu().detach().numpy()) * 255
return
# Deprecation warn TODO: remove in 8.2 # Deprecation warn TODO: remove in 8.2
if 'show_conf' in kwargs: if 'show_conf' in kwargs:

Loading…
Cancel
Save