-
Notifications
You must be signed in to change notification settings - Fork 269
Implementation of custom bytetrack demo for real time stream analysis [GSoC'2026] #4420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Vishwa2684
wants to merge
14
commits into
openvinotoolkit:main
Choose a base branch
from
Vishwa2684:gsoc_bytetrack
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
58ae1cc
Use Vishwa2684/mediapipe_ovms for bytetrack demo
Vishwa2684 ed27dc3
Add ffmpeg_output width and height as client params for rtsp sink
Vishwa2684 1ad498f
Added bytetrack demo which can be used with RTSP
Vishwa2684 dc02a3a
Merge branch 'openvinotoolkit:main' into gsoc_bytetrack
Vishwa2684 4ec3459
Using input_video instead of transformed_input_video for overlay
Vishwa2684 89e096e
Update docs
Vishwa2684 f1615da
add logic to check timestamps
Vishwa2684 155f27e
formatting in client.py
Vishwa2684 fdb2dac
Write a custom calculator to process yolox tiny's ov tensors
Vishwa2684 a7a25d9
Move bytetrack logic from seperate mediapipe repo to OVMS
Vishwa2684 7524ee6
Add license headers to files
Vishwa2684 d2d0703
Updated spelling-whitelist.txt
Vishwa2684 a845c7b
Merge branch 'main' into gsoc_bytetrack
Vishwa2684 0369140
Update README
Vishwa2684 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # ByteTrack Demo Setup | ||
|
|
||
| ## 1. Download the YOLOX Tiny ONNX Model | ||
|
|
||
| Download the YOLOX Tiny ONNX model from the official release: | ||
|
|
||
| https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_tiny.onnx | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Convert the ONNX Model to TensorFlow Lite | ||
|
Vishwa2684 marked this conversation as resolved.
Outdated
|
||
|
|
||
| Open a Google Colab notebook and: | ||
|
|
||
| 1. Install `onnx2tf`. | ||
| 2. Upload `yolox_tiny.onnx` to the notebook. | ||
| 3. Run: | ||
|
|
||
| ```bash | ||
| !onnx2tf -i yolox_tiny.onnx -o yolox_tiny | ||
| ``` | ||
|
|
||
| This generates the TensorFlow Lite model. | ||
|
|
||
|
Vishwa2684 marked this conversation as resolved.
Outdated
|
||
| --- | ||
|
|
||
| ## 3. Download COCO Class Labels | ||
|
|
||
| Download the COCO 80-class label file: | ||
|
|
||
| https://raw.githubusercontent.com/openvinotoolkit/open_model_zoo/master/data/dataset_classes/coco_80cl.txt | ||
|
|
||
| --- | ||
|
|
||
| # Running the Demo | ||
|
|
||
| ## 1. Start the OpenVINO Model Server | ||
|
|
||
| ```bash | ||
| docker run -d \ | ||
| -v $PWD:/demo \ | ||
| -p 9000:9000 \ | ||
| openvino/model_server:latest \ | ||
| --config_path /demo/config.json \ | ||
| --port 9000 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Create an RTSP Input Stream | ||
|
|
||
| Use FFmpeg to publish your webcam as an RTSP stream. | ||
|
|
||
| ```bash | ||
| ffmpeg -f dshow -video_size 1280x720 \ | ||
| -i video="HP True Vision FHD Camera" \ | ||
| -f rtsp -rtsp_transport tcp \ | ||
| rtsp://localhost:8554/channel1 | ||
| ``` | ||
|
|
||
| > **Work in Progress:** The following H.264-based streaming command is still being evaluated and may not work correctly in all setups. | ||
|
|
||
| ```bash | ||
| ffmpeg -f dshow \ | ||
| -video_size 1280x720 \ | ||
| -framerate 30 \ | ||
| -i video="HP True Vision FHD Camera" \ | ||
| -c:v libx264 \ | ||
| -crf 18 \ | ||
| -preset veryfast \ | ||
| -f rtsp \ | ||
| -rtsp_transport tcp \ | ||
| rtsp://localhost:8554/channel1 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Run the Real-Time Stream Analysis Client | ||
|
|
||
| ```bash | ||
| python client.py \ | ||
| --grpc_address localhost:9000 \ | ||
| --input_stream rtsp://localhost:8554/channel1 \ | ||
| --output_stream rtsp://localhost:8554/channel2 \ | ||
| --model_name ByteTrack \ | ||
| --input_name input_video | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## 4. View the Output Stream | ||
|
|
||
| **Option 1 (recommended):** | ||
|
|
||
| ```bash | ||
| ffplay -rtsp_transport tcp \ | ||
| -vf "scale=704:704,format=yuv420p" \ | ||
| rtsp://localhost:8554/channel2 | ||
| ``` | ||
|
|
||
| **Option 2 (verbose logging):** | ||
|
|
||
| ```bash | ||
| ffplay -loglevel verbose \ | ||
| -rtsp_transport tcp \ | ||
| rtsp://localhost:8554/channel2 | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| input_stream: "IMAGE:input_video" | ||
| output_stream: "IMAGE:output" | ||
|
|
||
| node: { | ||
| calculator: "ImageTransformationCalculator" | ||
| input_stream: "IMAGE:input_video" | ||
| output_stream: "IMAGE:transformed_input_video" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.ImageTransformationCalculatorOptions] { | ||
| output_width: 416 | ||
| output_height: 416 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| node { | ||
| calculator: "OpenVINOConverterCalculator" | ||
| input_stream: "IMAGE:transformed_input_video" | ||
| output_stream: "TENSORS:image_tensor" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.OpenVINOConverterCalculatorOptions] { | ||
| enable_normalization: true | ||
| use_custom_normalization: true | ||
| custom_div: 1.0 | ||
| custom_sub: 0.0 | ||
| } | ||
| } | ||
| } | ||
| # Runs a TensorFlow Lite model on CPU that takes an image tensor and outputs a | ||
| # vector of tensors representing, for instance, detection boxes/keypoints and | ||
| # scores. | ||
| node { | ||
| calculator: "OpenVINOModelServerSessionCalculator" | ||
|
Vishwa2684 marked this conversation as resolved.
Outdated
|
||
| output_side_packet: "SESSION:session" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.OpenVINOModelServerSessionCalculatorOptions]: { | ||
| servable_name: "yoloxt_float32" # servable name inside OVMS | ||
| servable_version: "1" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| node { | ||
| calculator: "OpenVINOInferenceCalculator" | ||
| input_side_packet: "SESSION:session" | ||
| input_stream: "OVTENSORS:image_tensor" | ||
| output_stream: "OVTENSORS2:detection_tensors" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.OpenVINOInferenceCalculatorOptions]: { | ||
| input_order_list :["images"] | ||
| output_order_list :["output"] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ### WRITE YOLO SPECIFIC CALCULATORS | ||
|
|
||
| node{ | ||
| calculator: "OpenVINOYoloXTensorsToDetectionsCalculator" | ||
| input_stream: "TENSORS:detection_tensors" | ||
| output_stream: "DETECTIONS:detections" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.OpenVINOYoloXTensorsToDetectionsCalculatorOptions] { | ||
| conf_thresh: 0.1 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Performs non-max suppression to remove excessive detections. | ||
| node { | ||
| calculator: "NonMaxSuppressionCalculator" | ||
| input_stream: "detections" | ||
| output_stream: "filtered_detections" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.NonMaxSuppressionCalculatorOptions] { | ||
| min_suppression_threshold: 0.45 | ||
| max_num_detections: 100 | ||
| overlap_type: INTERSECTION_OVER_UNION | ||
| return_empty_detections: true | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| # Maps detection label IDs to the corresponding label text. The label map is | ||
| # provided in the label_map_path option. | ||
| node { | ||
| calculator: "DetectionLabelIdToTextCalculator" | ||
| input_stream: "filtered_detections" | ||
| output_stream: "output_detections" | ||
| node_options: { | ||
| [type.googleapis.com/mediapipe.DetectionLabelIdToTextCalculatorOptions] { | ||
| label_map_path: "/demo/coco_80cl.txt" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| node { | ||
| calculator: "ByteTrackCalculator" | ||
| input_stream: "DETECTIONS:output_detections" | ||
| output_stream: "DETECTIONS:tracked_detections" | ||
| options: { | ||
| [mediapipe.ByteTrackCalculatorOptions.ext] { | ||
| track_high_threshold:0.7 | ||
| track_low_threshold:0.55 | ||
| new_track_threshold:0.35 | ||
| matching_threshold: 0.8 | ||
| track_buffer: 60 | ||
| fuse_score: false | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Converts the detections to drawing primitives for annotation overlay. | ||
| node { | ||
| calculator: "DetectionColorByIdCalculator" | ||
| input_stream: "DETECTIONS:tracked_detections" | ||
| output_stream: "RENDER_DATA:detections_render_data" | ||
| } | ||
|
|
||
| # Draws annotations and overlays them on top of the input images. | ||
| node { | ||
| calculator: "AnnotationOverlayCalculator" | ||
| input_stream: "IMAGE:input_video" | ||
| input_stream: "detections_render_data" | ||
| output_stream: "IMAGE:output" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "model_config_list": [ | ||
| {"config": { | ||
| "name": "yoloxt_float32", | ||
| "base_path": "yolox_tiny_float32" | ||
| } | ||
| } | ||
| ], | ||
| "mediapipe_config_list": [ | ||
| { | ||
| "name":"ByteTrack", | ||
| "base_path":"./", | ||
| "graph_path":"bytetrack_ovms.pbtxt" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.