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,