How jingh-ai/ultralytics-yolo-deepsort-bytetrack-pyqt-gui works
Project type and purpose
• This is a desktop GUI application (built with PyQt) for running ultralytics YOLO-based AI tasks (object detection, pose estimation, segmentation) and multi-object tracking (DeepSort, ByteTrack) on local files, camera feeds or RTSP streams.
File structure
• Top‐level files:
• main.py – entry point that launches the Qt application and wires up UI, video sources, AI workers
• download_weights.py – utility to fetch model weights into the weights/ folder
• environment.yml, requirements.txt – dependency definitions
• data/ – static assets (e.g. sample video, UI screenshot)
• weights/ – downloaded ONNX model files and class definitions
• src/ – core application code, subdivided into:
• data_type/ – frame buffering abstractions (VideoBuffer)
• models/ – AI inference modules, organized by functionality:
– base/yolo_base.py – common model loader and inference wrapper
– detection/… – YOLO‐ONNX detection classes
– pose/… – YOLO‐ONNX pose estimator
– segmentation/… – YOLO‐ONNX segmentation
– tracking/… – ByteTrack and DeepSort implementations with Kalman, matching, feature extractor, trackers
• qt/ – streaming and threading layers:
– stream/ai_worker.py – background worker that receives frames, runs inference, emits results
– stream/video_capture.py – captures frames from camera, file, RTSP
– video/video_worker.py – orchestrates reading video on worker thread
• tests/ – unit tests
README for additional insights
• Confirms supported AI tasks, model variants (YOLO11, YOLOv8 in ONNX), supported trackers and input sources
• Usage pattern: install dependencies → download weights → run main.py
Main components
a. User Interface (Qt GUI)
– MainWindow: menus/buttons for selecting tasks, input sources; display canvas
b. Input Source Manager
– VideoCaptureWorker: opens camera/file/RTSP, buffers frames
– VideoWorker: thread manager
c. AI Processing Layer
– AIWorker threads: receive frames → dispatch to selected pipeline
– Model Pipeline:
• Detection (YoloDetectorONNX)
• Pose (YoloPoseONNX)
• Segmentation (YoloSegONNX)
• Tracking (ByteTrack / DeepSort modules)
d. Data & Storage
– Weights directory with ONNX model files
– In‐memory VideoBuffer
e. Visualization & Output
– UI display canvas updates in real time
f. External Dependencies
– ONNX Runtime / PyTorch backend
– PyQt5
– System camera, file system, network (RTSP)
Relationships and interactions
• User→UI triggers “Open File/Camera/RTSP”
• UI requests VideoCaptureWorker to start
• Video frames flow → VideoWorker → VideoBuffer
• AIWorker pulls frames from VideoBuffer, runs inference via Model Pipeline
• Model Pipeline loads weights from weights/ when initialized
• Visualization module overlays results and emits Qt signals to update UI canvas
Architectural patterns & design principles
• MVC‐like separation:
• View: Qt UI definitions + visualization
• Controller: ai_worker, video_worker coordinating data flow
• Model: AI modules in src/models
• Producer–consumer queues for thread safety (VideoBuffer)
• Plug-in style model abstractions (base classes + ONNX implementations)
• Clear layering: UI ↔ streaming ↔ AI inference ↔ utils/visualization
Technologies, frameworks, libraries to annotate
• Python 3.x, PyQt5 (QtDesigner .ui files), ONNX Runtime
• ultralytics YOLO (exported to ONNX)
• ByteTrack, DeepSort algorithms in pure Python
• Conda or pip environment for dependencies