Nedo Vision Annotator Service for Automated Image Annotation
Project description
Nedo Vision Annotator Service
Overview
Python service that automatically annotates dataset images using AI models. Listens to RabbitMQ for image processing tasks, runs inference using YOLO/RF-DETR models with GPU acceleration, and sends annotations back to the manager via gRPC.
Features
- Automated Annotation: Process images from RabbitMQ queue automatically
- Multi-Model Support: YOLO and RF-DETR detection models
- GPU Acceleration: Automatic CUDA detection for faster inference
- Batch Processing: Efficient batch annotation submission
- Local Storage: SQLite-based annotation queue before sending
- Authentication: Token-based authentication with manager
- Configuration Management: Persistent configuration storage
- Status Reporting: Real-time status updates to manager
Architecture
Core Components
-
Configuration Management (
config/ConfigurationManager.py)- SQLite-based key-value storage
- Stores: server_host, server_port, token, annotator_id
- Convenience methods for common config keys
-
Database Management (
database/)- SQLAlchemy-based architecture with entity-repository pattern
- Local annotation storage with pending queue
- Entities:
DatasetAnnotation - Repositories:
DatasetAnnotationRepository - Session management with connection pooling
-
AI Models (
models/AIModel.py)- AI model entity representation
- Support for YOLO and RF-DETR models
- Class management for object detection
- Version tracking for model updates
-
Detection (
detection/)BaseDetector: Abstract base class for all detectorsYOLODetector: Ultralytics YOLO detection with GPU supportRFDETRDetector: RF-DETR detection with GPU support- Standardized output:
[{"label": str, "confidence": float, "bbox": [x1, y1, x2, y2]}] - Normalized bounding boxes (0-1 range)
-
Core Logic (
core/)DatasetManager: Dataset synchronization and managementModelLoader: AI model loading, caching, and version control
-
Background Tasks (
tasks/)AnnotationProcessor: Image download and detection processingAnnotationSender: Batch annotation submission to managerMessageHandler: RabbitMQ message routing and validationStatusReporter: Periodic status updates
-
Services (
services/)GrpcClientBase: Base gRPC client with authenticationAnnotatorGrpcClient: Manager communication for datasets, images, and annotationsRabbitMQConsumer: Message queue consumer with reconnection logic
Main Service (annotator_service.py)
- Entry point for the annotator service
- Manages service lifecycle (initialization, start, stop)
- Signal handling for graceful shutdown
- Configuration initialization and validation
- Coordinates all background tasks
CLI (cli.py)
Command-line interface with the following arguments:
--token(required): Authentication token for the annotator--server-host: Manager server host (default: be.vision.sindika.co.id)--server-port: gRPC port (default: 50051)--storage-path: Data storage path (default: data)--batch-size: Annotations per batch (default: 50)--send-interval: Send interval in seconds (default: 60)
Installation
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Install in development mode
pip install -e .
Usage
# Run annotator service
nedo-vision-annotator --token YOUR_TOKEN --server-host localhost
# Or with Python module
python -m nedo_vision_annotator.cli --token YOUR_TOKEN
# With custom settings
nedo-vision-annotator \
--token YOUR_TOKEN \
--server-host localhost \
--server-port 50051 \
--batch-size 100 \
--send-interval 30
Dependencies
- gRPC: Communication with manager (grpcio, grpcio-tools, protobuf)
- RabbitMQ: Message queue (pika)
- AI/ML: Model inference (torch, torchvision, ultralytics, rfdetr<=1.2.0, opencv-python, numpy)
- Database: Local storage (sqlalchemy)
- System: Resource monitoring (psutil)
gRPC Services
AnnotatorService
The annotator uses the following gRPC methods:
GetConnectionInfo: Fetch RabbitMQ connection details and annotator IDGetDatasetList: Get assigned datasets with AI model informationGetAIModelList: List AI models assigned to annotator's datasetsDownloadAIModel: Stream download AI model filesGetImage: Download image file from storageSendAnnotations: Submit batch of annotations to managerUpdateStatus: Report annotator status (connected/disconnected)
Data Flow
-
Initialization
- Connect to manager via gRPC using authentication token
- Fetch annotator ID and RabbitMQ connection information
- Retrieve assigned datasets with AI model configurations
- Download and load required AI models
-
Processing Loop
- Listen to dedicated RabbitMQ queue for annotation requests
- Receive message with dataset item ID and image path
- Download image from storage via gRPC
- Run inference using assigned AI model
- Store annotations locally with normalized bounding boxes (0-1 range)
- Batch annotations for efficient submission
-
Annotation Submission
- Collect pending annotations up to batch size
- Group annotations by dataset item
- Send batch to manager via gRPC
- Delete local annotations after successful submission
- Retry on failure with exponential backoff
-
Model Management
- Load AI models on demand when processing starts
- Cache loaded models in memory for reuse
- Monitor model versions and re-download on updates
- Support for YOLO and RF-DETR model types
-
Status Reporting
- Periodic status updates (connected/disconnected)
- System metrics: CPU usage, temperature, RAM usage, latency
- Automatic reconnection handling on network issues
Configuration
The annotator stores configuration in SQLite database at {storage_path}/config/config.db:
server_host: Manager server hostnameserver_port: Manager gRPC porttoken: Authentication tokenannotator_id: Unique annotator identifier (fetched from manager)
Logging
Logs are written to stdout with the following format:
YYYY-MM-DD HH:MM:SS [LEVEL] Message
Log levels:
- ERROR: Critical errors and failures
- WARNING: Non-critical issues
- INFO: Important events and status changes
- DEBUG: Detailed debugging information (disabled by default)
Error Handling
- Authentication Failures: Automatic shutdown on invalid token
- Network Issues: Automatic reconnection with exponential backoff
- Model Loading Errors: Logged and skipped, service continues
- RabbitMQ Disconnection: Automatic reconnection attempts
- gRPC Errors: Retry logic with timeout handling
Performance
- GPU Acceleration: Automatic CUDA detection and usage
- Batch Processing: Configurable batch size for efficient submission
- Connection Pooling: Database connection pool for concurrent operations
- Model Caching: In-memory model cache to avoid reloading
- Async Operations: Background threads for non-blocking tasks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nedo_vision_annotator-1.1.1.tar.gz.
File metadata
- Download URL: nedo_vision_annotator-1.1.1.tar.gz
- Upload date:
- Size: 63.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
171181a1faf4ccef7330260e6c8f13945d54789ef11a680b25f857e6f7694f71
|
|
| MD5 |
23615b7119f8e15021799546d58f2c86
|
|
| BLAKE2b-256 |
7ca0897e9ae336a1fcf83ba20cd5fc2a6b1c64ddac61fffe0ccd9efa2bf89c21
|
File details
Details for the file nedo_vision_annotator-1.1.1-py3-none-any.whl.
File metadata
- Download URL: nedo_vision_annotator-1.1.1-py3-none-any.whl
- Upload date:
- Size: 84.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
138f70f6ec0d57ac03b4974efc03218f8a51568087bee1b9460c19f3511b2fcd
|
|
| MD5 |
6ebc3b9a3d6bfb184ceb9c7525bc364b
|
|
| BLAKE2b-256 |
4b74007de4ca72a5f0a37b0c2ef937453c5fa5d8516c49f37c58fec73efb2e2d
|