Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/time-in-zone-3' into time-in-zone-3
Browse files Browse the repository at this point in the history
  • Loading branch information
SkalskiP committed Mar 25, 2024
2 parents 577007d + 3434c06 commit 52c3a16
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions examples/time_in_zone/inference_file_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import cv2
import numpy as np
from inference import get_model
from utils.general import find_in_list, load_zones_config
from utils.timers import FPSBasedTimer

import supervision as sv
from utils.general import load_zones_config, find_in_list
from utils.timers import FPSBasedTimer

COLORS = sv.ColorPalette.from_hex(["#E6194B", "#3CB44B", "#FFE119", "#3C76D1"])
COLOR_ANNOTATOR = sv.ColorAnnotator(color=COLORS)
Expand Down
14 changes: 5 additions & 9 deletions examples/time_in_zone/inference_pipeline_stream_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import numpy as np
from inference import InferencePipeline
from inference.core.interfaces.camera.entities import VideoFrame
from utils.general import find_in_list, load_zones_config
from utils.timers import ClockBasedTimer

import supervision as sv
from utils.general import load_zones_config, find_in_list
from utils.timers import ClockBasedTimer

COLORS = sv.ColorPalette.from_hex(["#E6194B", "#3CB44B", "#FFE119", "#3C76D1"])
COLOR_ANNOTATOR = sv.ColorAnnotator(color=COLORS)
Expand Down Expand Up @@ -90,15 +90,14 @@ def main(
iou: float,
classes: List[int],
) -> None:

sink = CustomSink(zone_configuration_path=zone_configuration_path, classes=classes)

pipeline = InferencePipeline.init(
model_id=model_id,
video_reference=rtsp_url,
on_prediction=sink.on_prediction,
confidence=confidence,
iou_threshold=iou
iou_threshold=iou,
)

pipeline.start()
Expand Down Expand Up @@ -126,10 +125,7 @@ def main(
help="Complete RTSP URL for the video stream.",
)
parser.add_argument(
"--model_id",
type=str,
default="yolov8s-640",
help="Roboflow model ID."
"--model_id", type=str, default="yolov8s-640", help="Roboflow model ID."
)
parser.add_argument(
"--confidence_threshold",
Expand Down Expand Up @@ -159,4 +155,4 @@ def main(
confidence=args.confidence_threshold,
iou=args.iou_threshold,
classes=args.classes,
)
)
4 changes: 2 additions & 2 deletions examples/time_in_zone/inference_stream_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import cv2
import numpy as np
from inference import get_model
from utils.general import find_in_list, get_stream_frames_generator, load_zones_config
from utils.timers import ClockBasedTimer

import supervision as sv
from utils.general import load_zones_config, find_in_list, get_stream_frames_generator
from utils.timers import ClockBasedTimer

COLORS = sv.ColorPalette.from_hex(["#E6194B", "#3CB44B", "#FFE119", "#3C76D1"])
COLOR_ANNOTATOR = sv.ColorAnnotator(color=COLORS)
Expand Down
4 changes: 2 additions & 2 deletions examples/time_in_zone/ultralytics_file_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import cv2
import numpy as np
from ultralytics import YOLO
from utils.general import find_in_list, load_zones_config
from utils.timers import FPSBasedTimer

import supervision as sv
from utils.general import load_zones_config, find_in_list
from utils.timers import FPSBasedTimer

COLORS = sv.ColorPalette.from_hex(["#E6194B", "#3CB44B", "#FFE119", "#3C76D1"])
COLOR_ANNOTATOR = sv.ColorAnnotator(color=COLORS)
Expand Down
7 changes: 3 additions & 4 deletions examples/time_in_zone/ultralytics_pipeline_stream_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from inference import InferencePipeline
from inference.core.interfaces.camera.entities import VideoFrame
from ultralytics import YOLO
from utils.general import find_in_list, load_zones_config
from utils.timers import ClockBasedTimer

import supervision as sv
from utils.general import load_zones_config, find_in_list
from utils.timers import ClockBasedTimer

COLORS = sv.ColorPalette.from_hex(["#E6194B", "#3CB44B", "#FFE119", "#3C76D1"])
COLOR_ANNOTATOR = sv.ColorAnnotator(color=COLORS)
Expand Down Expand Up @@ -91,7 +91,6 @@ def main(
iou: float,
classes: List[int],
) -> None:

model = YOLO(weights)

def inference_callback(frame: VideoFrame) -> sv.Detections:
Expand Down Expand Up @@ -171,4 +170,4 @@ def inference_callback(frame: VideoFrame) -> sv.Detections:
confidence=args.confidence_threshold,
iou=args.iou_threshold,
classes=args.classes,
)
)
4 changes: 2 additions & 2 deletions examples/time_in_zone/ultralytics_stream_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import cv2
import numpy as np
from ultralytics import YOLO
from utils.general import find_in_list, get_stream_frames_generator, load_zones_config
from utils.timers import ClockBasedTimer

import supervision as sv
from utils.general import load_zones_config, find_in_list, get_stream_frames_generator
from utils.timers import ClockBasedTimer

COLORS = sv.ColorPalette.from_hex(["#E6194B", "#3CB44B", "#FFE119", "#3C76D1"])
COLOR_ANNOTATOR = sv.ColorAnnotator(color=COLORS)
Expand Down
1 change: 1 addition & 0 deletions examples/time_in_zone/utils/timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Dict

import numpy as np

import supervision as sv


Expand Down

0 comments on commit 52c3a16

Please sign in to comment.