How cvhub520/x-anylabeling works
Project Type and Purpose
• This is a monolithic desktop application written in Python.
• It follows an MVC-style separation:
• Views (anylabeling/views): Qt-based GUI components
• Controllers/Application Core (anylabeling/app.py): bootstraps the UI, routes events
• Services (anylabeling/services): AI inference engines, model management, business logic
• It integrates numerous AI models (YOLO, SAM, PP-OCR, etc.) for automatic labeling of images and videos.
Main Components
a. UI Layer
– anylabeling/views/...: Qt widgets, dialogs, canvases, chatbots, VQA interfaces
– anylabeling/mainwindow.py: top-level window
b. Application Core / Controller
– anylabeling/app.py & app_info.py: entry point, global app configuration, command-line arguments
– anylabeling/config.py: loads user preferences, defaults
c. Service Layer
– anylabeling/services/auto_labeling: model wrappers, inference pipelines
– anylabeling/services/model_manager.py: selects & instantiates model services based on YAML configs
– anylabeling/services/auto_labeling/engines: builds ONNX/DNN inference engines (GPU/CPU)
– anylabeling/services/auto_labeling/trackers: tracking algorithms (ByteTrack, BotSort)
d. Configuration & Resources
– anylabeling/configs/**/*.yaml: model definitions, hyperparameters
e. Data & Assets
– assets/: sample images/videos, annotation formats (COCO, MOT, VOC, etc.)
– examples/: use-case templates per task category
f. Tools & Scripts
– scripts/*.sh / *.py: build/publish, compile UI translations, format code
– tools/onnx_exporter: convert models to ONNX for inference engines
g. External Dependencies
– Python libs: PyQt5/PySide6, ONNXRuntime, PyTorch, OpenCV
– Hardware: GPU (CUDA/CUDNN) or CPU fallback
– Remote APIs: grounding_dino_api.py for cloud-based inference (optional)
Interactions & Data Flow
1. User Action (UI)
– Opens project / loads images/videos
– Picks a model & clicks “Auto-label”
2. Controller
– Receives UI event, reads config (anylabeling/config.py)
– Calls ModelManager to create a service instance
3. ModelManager
– Reads YAML (anylabeling/configs/…yaml) to identify model class
– Uses Factory pattern to load the corresponding service (base + engine)
4. Inference Engine Creation
– Builds ONNX or DNN engine via build_onnx_engine.py or build_dnn_engine.py
– Initializes runtime (device selection: GPU vs. CPU)
5. Model Execution
– Service.run(image/video) → ONNXRuntime / PyTorch model → raw predictions
6. Results to UI
– Controller receives predictions, wraps into annotation primitives
7. Export / Save
– UI triggers io modules (anylabeling/views/labeling/utils/export.py)
– Outputs in COCO, YOLO, VOC, etc.
Architectural Patterns & Principles
• MVC: clear separation of Views, Controllers, Services
• Plugin/Factory: new models or post-processors can be added by dropping in a YAML + service class
• Builder: engine builders for ONNX vs DNN runtime
• Single Responsibility: each folder has a well-defined concern (views, services, configs, resources)