Retain Results.speed attribute during ops (#12774)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Rick-v-E 2024-05-17 18:55:34 +02:00 committed by GitHub
parent e26036d965
commit 303579c35e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -94,7 +94,9 @@ class Results(SimpleClass):
tojson(normalize=False): Converts detection results to JSON format. 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. Initialize the Results class.
@ -115,7 +117,7 @@ class Results(SimpleClass):
self.probs = Probs(probs) if probs is not None else None 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.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.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.names = names
self.path = path self.path = path
self.save_dir = None self.save_dir = None
@ -180,8 +182,8 @@ class Results(SimpleClass):
return self._apply("to", *args, **kwargs) return self._apply("to", *args, **kwargs)
def new(self): def new(self):
"""Return a new Results object with the same image, path, and 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) return Results(orig_img=self.orig_img, path=self.path, names=self.names, speed=self.speed)
def plot( def plot(
self, self,