diff --git a/supervision/tracker/byte_tracker/core.py b/supervision/tracker/byte_tracker/core.py index 34a90138..bf831daa 100644 --- a/supervision/tracker/byte_tracker/core.py +++ b/supervision/tracker/byte_tracker/core.py @@ -205,30 +205,29 @@ class ByteTrack: Detection: The updated detection results that now include tracking IDs. Example: ```python - >>> import supervision as sv - >>> from ultralytics import YOLO + import supervision as sv + from ultralytics import YOLO - >>> model = YOLO(...) - >>> byte_tracker = sv.ByteTrack() - >>> annotator = sv.BoxAnnotator() + model = YOLO(...) + byte_tracker = sv.ByteTrack() + annotator = sv.BoxAnnotator() - >>> def callback(frame: np.ndarray, index: int) -> np.ndarray: - ... results = model(frame)[0] - ... detections = sv.Detections.from_ultralytics(results) - ... detections = byte_tracker.update_with_detections(detections) - ... labels = [ - ... f"#{tracker_id} {model.model.names[class_id]} {confidence:0.2f}" - ... for _, _, confidence, class_id, tracker_id - ... in detections - ... ] - ... return annotator.annotate(scene=frame.copy(), - ... detections=detections, labels=labels) + def callback(frame: np.ndarray, index: int) -> np.ndarray: + results = model(frame)[0] + detections = sv.Detections.from_ultralytics(results) + detections = byte_tracker.update_with_detections(detections) + labels = [ + f"#{tracker_id} {model.model.names[class_id]} {confidence:0.2f}" + for _, _, confidence, class_id, tracker_id in detections + ] + return annotator.annotate(scene=frame.copy(), + detections=detections, labels=labels) - >>> sv.process_video( - ... source_path='...', - ... target_path='...', - ... callback=callback - ... ) + sv.process_video( + source_path='...', + target_path='...', + callback=callback + ) ``` """