From 303579c35ee2b30bdba15dfc2f37be6f62e99efd Mon Sep 17 00:00:00 2001 From: Rick-v-E <78429257+Rick-v-E@users.noreply.github.com> Date: Fri, 17 May 2024 18:55:34 +0200 Subject: [PATCH] Retain `Results.speed` attribute during ops (#12774) Co-authored-by: UltralyticsAssistant Co-authored-by: Glenn Jocher --- ultralytics/engine/results.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ultralytics/engine/results.py b/ultralytics/engine/results.py index 5cfd9c5a..0c2161b4 100644 --- a/ultralytics/engine/results.py +++ b/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,