From 597e12d723ca176335541622dd9fb3da4073cc83 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:13:06 +0000 Subject: [PATCH] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20form?= =?UTF-8?q?at=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/tracking/README.md | 2 +- examples/tracking/requirements.txt | 2 +- examples/tracking/script.py | 59 ++++++++++++++++++------------ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/examples/tracking/README.md b/examples/tracking/README.md index c664f517..95ee9cf7 100644 --- a/examples/tracking/README.md +++ b/examples/tracking/README.md @@ -5,4 +5,4 @@ - `sv.get_video_frames_generator` - `sv.VideoInfo` - `sv.VideoSink` -- `sv.Detections` \ No newline at end of file +- `sv.Detections` diff --git a/examples/tracking/requirements.txt b/examples/tracking/requirements.txt index d4df1702..bf05e300 100644 --- a/examples/tracking/requirements.txt +++ b/examples/tracking/requirements.txt @@ -1,3 +1,3 @@ supervision tqdm -ultralytics \ No newline at end of file +ultralytics diff --git a/examples/tracking/script.py b/examples/tracking/script.py index a524c8fb..4b7d51ed 100644 --- a/examples/tracking/script.py +++ b/examples/tracking/script.py @@ -1,9 +1,9 @@ import argparse -import supervision as sv - -from ultralytics import YOLO from tqdm import tqdm +from ultralytics import YOLO + +import supervision as sv def process_video( @@ -11,7 +11,7 @@ def process_video( source_video_path: str, target_video_path: str, confidence_threshold: float = 0.3, - iou_threshold: float = 0.7 + iou_threshold: float = 0.7, ) -> None: model = YOLO(source_weights_path) @@ -22,43 +22,55 @@ def process_video( with sv.VideoSink(target_path=target_video_path, video_info=video_info) as sink: for frame in tqdm(frame_generator, total=video_info.total_frames): - results = model( - frame, verbose=False, conf=confidence_threshold, iou=iou_threshold)[0] + frame, verbose=False, conf=confidence_threshold, iou=iou_threshold + )[0] detections = sv.Detections.from_ultralytics(results) detections = tracker.update_with_detections(detections) labels = [ f"#{tracker_id} {model.model.names[class_id]}" - for _, _, _, class_id, tracker_id - in detections] + for _, _, _, class_id, tracker_id in detections + ] annotated_frame = box_annotator.annotate( - scene=frame.copy(), - detections=detections, - labels=labels) + scene=frame.copy(), detections=detections, labels=labels + ) sink.write_frame(frame=annotated_frame) if __name__ == "__main__": parser = argparse.ArgumentParser( - description="Video Processing with YOLO and ByteTrack") + description="Video Processing with YOLO and ByteTrack" + ) parser.add_argument( - "--source_weights_path", required=True, - help="Path to the source weights file", type=str) + "--source_weights_path", + required=True, + help="Path to the source weights file", + type=str, + ) parser.add_argument( - "--source_video_path", required=True, - help="Path to the source video file", type=str) + "--source_video_path", + required=True, + help="Path to the source video file", + type=str, + ) parser.add_argument( - "--target_video_path", required=True, - help="Path to the target video file (output)", type=str) + "--target_video_path", + required=True, + help="Path to the target video file (output)", + type=str, + ) parser.add_argument( - "--confidence_threshold", default=0.3, - help="Confidence threshold for the model", type=float) + "--confidence_threshold", + default=0.3, + help="Confidence threshold for the model", + type=float, + ) parser.add_argument( - "--iou_threshold", default=0.7, - help="IOU threshold for the model", type=float) + "--iou_threshold", default=0.7, help="IOU threshold for the model", type=float + ) args = parser.parse_args() @@ -67,4 +79,5 @@ if __name__ == "__main__": source_video_path=args.source_video_path, target_video_path=args.target_video_path, confidence_threshold=args.confidence_threshold, - iou_threshold=args.iou_threshold) + iou_threshold=args.iou_threshold, + )