Retain `Results.speed` attribute during ops (#12774)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
pull/11779/head^2
Rick-v-E 6 months ago committed by GitHub
parent e26036d965
commit 303579c35e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      ultralytics/engine/results.py

@ -94,7 +94,9 @@ class Results(SimpleClass):
tojson(normalize=False): Converts detection results to JSON format.
"""
def __init__(self, orig_img, path, names, boxes=None, masks=None, probs=None, keypoints=None, obb=None) -> None:
def __init__(
self, orig_img, path, names, boxes=None, masks=None, probs=None, keypoints=None, obb=None, speed=None
) -> None:
"""
Initialize the Results class.
@ -115,7 +117,7 @@ class Results(SimpleClass):
self.probs = Probs(probs) if probs is not None else None
self.keypoints = Keypoints(keypoints, self.orig_shape) if keypoints is not None else None
self.obb = OBB(obb, self.orig_shape) if obb is not None else None
self.speed = {"preprocess": None, "inference": None, "postprocess": None} # milliseconds per image
self.speed = speed if speed is not None else {"preprocess": None, "inference": None, "postprocess": None}
self.names = names
self.path = path
self.save_dir = None
@ -180,8 +182,8 @@ class Results(SimpleClass):
return self._apply("to", *args, **kwargs)
def new(self):
"""Return a new Results object with the same image, path, and names."""
return Results(orig_img=self.orig_img, path=self.path, names=self.names)
"""Return a new Results object with the same image, path, names and speed."""
return Results(orig_img=self.orig_img, path=self.path, names=self.names, speed=self.speed)
def plot(
self,

Loading…
Cancel
Save