Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 82 additions & 32 deletions examples/time_in_zone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,10 @@ window where you can draw polygons on the source image or video file. The polygo
be saved as a JSON file.

- `--source_path`: Path to the source image or video file for drawing polygons.

- `--zone_configuration_path`: Path where the polygon annotations will be saved as a JSON file.

- `enter` - finish drawing the current polygon.

- `escape` - cancel drawing the current polygon.

- `q` - quit the drawing window.

- `s` - save zone configuration to a JSON file.

```bash
Expand Down Expand Up @@ -128,8 +123,8 @@ Script to run object detection on a video file using the Roboflow Inference mode
python inference_file_example.py \
--zone_configuration_path "data/checkout/config.json" \
--source_video_path "data/checkout/video.mp4" \
--model_id "yolov8x-640" \
--classes 0 \
--model_id "rfdetr-medium" \
--classes 1 \
--confidence_threshold 0.3 \
--iou_threshold 0.7
```
Expand All @@ -140,8 +135,8 @@ https://github.com/roboflow/supervision/assets/26109316/d051cc8a-dd15-41d4-aa36-
python inference_file_example.py \
--zone_configuration_path "data/traffic/config.json" \
--source_video_path "data/traffic/video.mp4" \
--model_id "yolov8x-640" \
--classes 2 5 6 7 \
--model_id "rfdetr-medium" \
--classes 3 6 7 8 \
--confidence_threshold 0.3 \
--iou_threshold 0.7
```
Expand All @@ -150,7 +145,7 @@ https://github.com/roboflow/supervision/assets/26109316/5ec896d7-4b39-4426-8979-

### `inference_stream_example`

Script to run object detection on a video stream using the Roboflow Inference model.
Script to run object detection on an RTSP stream using Roboflow Inference model.

- `--zone_configuration_path`: Path to the zone configuration JSON file.
- `--rtsp_url`: Complete RTSP URL for the video stream.
Expand All @@ -163,8 +158,8 @@ Script to run object detection on a video stream using the Roboflow Inference mo
python inference_stream_example.py \
--zone_configuration_path "data/checkout/config.json" \
--rtsp_url "rtsp://localhost:8554/live0.stream" \
--model_id "yolov8x-640" \
--classes 0 \
--model_id "rfdetr-medium" \
--classes 1 \
--confidence_threshold 0.3 \
--iou_threshold 0.7
```
Expand All @@ -173,14 +168,85 @@ python inference_stream_example.py \
python inference_stream_example.py \
--zone_configuration_path "data/traffic/config.json" \
--rtsp_url "rtsp://localhost:8554/live0.stream" \
--model_id "yolov8x-640" \
--classes 2 5 6 7 \
--model_id "rfdetr-medium" \
--classes 3 6 7 8 \
--confidence_threshold 0.3 \
--iou_threshold 0.7
```

<details>
<summary>👉 show ultralytics examples</summary>
### `rfdeter_file_example`

Script to run object detection on a video file using the RF-DETR model.

- `--zone_configuration_path`: Path to the zone configuration JSON file.
- `--source_video_path`: Path to the source video file.
- `--model_size`: Size of RF-DETR model ('nano', 'small', 'medium', 'base' or 'large'). Default is 'medium'.
- `--device`: Computation device ('cpu', 'mps' or 'cuda'). Default is 'cpu'.
- `--classes`: List of class IDs to track. If empty, all classes are tracked.
- `--confidence_threshold`: Confidence level for detections (`0` to `1`). Default is `0.3`.
- `--iou_threshold`: IOU threshold for non-max suppression. Default is `0.7`.
- `--resolution`: Resolution for the model input. Default is `640`.

```bash
python rfdetr_file_example.py \
--zone_configuration_path "data/checkout/config.json" \
--source_video_path "data/checkout/video.mp4" \
--model_size "medium" \
--device="cpu" \
--classes 1 \
--confidence_threshold 0.3 \
--iou_threshold 0.7 \
--resolution 640
```

```bash
python rfdetr_file_example.py \
--zone_configuration_path "data/traffic/config.json" \
--source_video_path "data/traffic/video.mp4" \
--model_size "medium" \
--device="cpu" \
--classes 3 6 7 8 \
--confidence_threshold 0.3 \
--iou_threshold 0.7 \
--resolution 640
```

### `rfdeter_stream_example`

Script to run object detection on an RTSP stream using the RF-DETR model.

- `--zone_configuration_path`: Path to the zone-configuration JSON file defining the polygons.
- `--rtsp_url`: Complete RTSP URL of the live video stream.
- `--model_size`: RF-DETR backbone size to load — choose from 'nano', 'small', 'medium', 'base', or 'large' (default 'medium').
- `--device`: Compute device to run the model on ('cpu', 'mps', or 'cuda'; default 'cpu').
- `--classes`: Space-separated list of class IDs to track. Leave empty to track all classes.
- `--confidence_threshold`: Minimum confidence score for a detection to be kept, range 0–1 (default 0.3).
- `--iou_threshold`: IOU threshold applied during non-max suppression (default 0.7).
- `--resolution`: Shortest-side input resolution supplied to the model. The script will round it to the nearest valid multiple (default 640).

```bash
python rfdetr_stream_example.py \
--zone_configuration_path "data/checkout/config.json" \
--rtsp_url "rtsp://localhost:8554/live0.stream" \
--model_size "medium" \
--device "cpu" \
--classes 1 \
--confidence_threshold 0.3 \
--iou_threshold 0.7 \
--resolution 640
```

```bash
python rfdetr_stream_example.py \
--zone_configuration_path "data/traffic/config.json" \
--rtsp_url "rtsp://localhost:8554/live0.stream" \
--model_size "medium" \
--device "cpu" \
--classes 3 6 7 8 \
--confidence_threshold 0.3 \
--iou_threshold 0.7 \
--resolution 640
```

### `ultralytics_file_example`

Expand Down Expand Up @@ -249,19 +315,3 @@ python ultralytics_stream_example.py \
--confidence_threshold 0.3 \
--iou_threshold 0.7
```

</details>

## © license

This demo integrates two main components, each with its own licensing:

- ultralytics: The object detection model used in this demo, YOLOv8, is distributed
under the [AGPL-3.0 license](https://github.com/ultralytics/ultralytics/blob/main/LICENSE).
You can find more details about this license here.

- supervision: The analytics code that powers the zone-based analysis in this demo is
based on the Supervision library, which is licensed under the
[MIT license](https://github.com/roboflow/supervision/blob/develop/LICENSE.md). This
makes the Supervision part of the code fully open source and freely usable in your
projects.
2 changes: 1 addition & 1 deletion examples/time_in_zone/inference_file_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def main(
help="Path to the source video file.",
)
parser.add_argument(
"--model_id", type=str, default="yolov8s-640", help="Roboflow model ID."
"--model_id", type=str, default="rfdetr-medium", help="Roboflow model ID."
)
parser.add_argument(
"--confidence_threshold",
Expand Down
2 changes: 1 addition & 1 deletion examples/time_in_zone/inference_naive_stream_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,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="rfdetr-medium", help="Roboflow model ID."
)
parser.add_argument(
"--confidence_threshold",
Expand Down
2 changes: 1 addition & 1 deletion examples/time_in_zone/inference_stream_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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="rfdetr-medium", help="Roboflow model ID."
)
parser.add_argument(
"--confidence_threshold",
Expand Down
5 changes: 2 additions & 3 deletions examples/time_in_zone/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
supervision
ultralytics
inference
# https://github.com/pytube/pytube/issues/2044
# pytube
pytubefix
rfdetr
yt_dlp
Loading
Loading