A comprehensive backend API for managing active learning annotation projects, built with Django REST Framework, PostgreSQL, and modern Python development practices.
The complete documentation for this project is available at:
https://jerzyszyjut.github.io/active-annotate/
The documentation includes:
- API reference and endpoints
- Installation instructions
- Development setup guide
- Testing procedures
- Project architecture overview
- Active Learning: Intelligent data point selection using entropy-based uncertainty sampling
- Model Management: Integration with ML backends for model training and inference
- Label Studio Integration: Seamless integration with Label Studio for annotation tasks
- Webhook Support: Real-time annotation updates via webhooks
- S3-Compatible Storage: MinIO integration for media file storage
- Async Task Management: Celery for background tasks and periodic scheduling
- Docker Support: Full Docker Compose setup for local development and deployment
- REST API: Well-documented RESTful API with DRF
- Clone the repository:
git clone https://github.com/jerzyszyjut/active-annotate.git
cd active-annotate- Set up environment variables:
cp .envs/.local/.django.example .envs/.local/.django
cp .envs/.local/.postgres.example .envs/.local/.postgres- Start the development environment:
just up- Run database migrations:
just manage migrate- Create a superuser:
just manage createsuperuserThe services will be available at:
- API:
http://localhost:8000 - API Docs (Swagger):
http://localhost:8000/api/docs/ - API Docs (ReDoc):
http://localhost:8000/api/schema/redoc/ - Admin Panel:
http://localhost:8000/admin - MinIO Console:
http://localhost:9001(minioadmin / minioadmin) - Label Studio:
http://localhost:8080 - Flower (Celery):
http://localhost:5555
If you prefer local development without Docker:
- Python 3.13+
- PostgreSQL 15+
- Redis 7+
uv(for dependency management)
- Clone the repository:
git clone https://github.com/jerzyszyjut/active-annotate.git
cd active-annotate- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate- Install dependencies:
uv sync- Set up environment variables:
cp .envs/.local/.django.example .envs/.local/.django
cp .envs/.local/.postgres.example .envs/.local/.postgres- Run migrations:
python manage.py migrate- Create a superuser:
python manage.py createsuperuser- Start the development server:
python manage.py runserverThe API will be available at http://localhost:8000
active-annotate/
├── active_annotate/
│ ├── config/ # Django configuration
│ ├── datasets/ # Dataset management app
│ ├── integrations/ # External service integrations (Label Studio, ML Backend)
│ ├── users/ # User management app
│ └── manage.py
├── ml_backend/ # ML backend service (separate microservice)
├── compose/ # Docker compose configurations
├── docs/ # Sphinx documentation
├── tests/ # Test suite
└── docker-compose.local.yml
- Framework: Django 4.2+ with Django REST Framework
- Database: PostgreSQL 15+
- Cache/Message Queue: Redis 7+
- Task Queue: Celery with Celery Beat
- File Storage: MinIO (S3-compatible)
- Annotation Tool: Label Studio
- Package Manager:
uv - Code Quality: Ruff, mypy, djLint
- Testing: pytest with pytest-django
- Documentation: Sphinx with ReadTheDocs
just --list # List all available commands
just build # Build Docker images
just up # Start containers
just down # Stop containers
just prune # Remove containers and volumes
just logs [service] # View container logs
just manage [cmd] # Run Django management commandsuv run python manage.py [command] # Run management commands
uv run pytest # Run tests
uv run coverage run -m pytest # Run tests with coverage-
To create a normal user account, go to the Sign Up endpoint and fill out the form. Once submitted, you'll receive an email verification link.
-
To create a superuser account, use:
just manage createsuperuser
# or for local development
uv run python manage.py createsuperuserFor convenience during development, you can keep your normal user logged in on one browser tab and your superuser logged in on another tab to see how the site behaves for different user types.
Run all tests:
just manage test# Run all tests
uv run pytest
# Run tests with coverage report
uv run coverage run -m pytest
uv run coverage html
uv run open htmlcov/index.html
# Run specific test file
uv run pytest tests/test_specific.py
# Run with verbose output
uv run pytest -vRunning type checks with mypy:
uv run mypy active_annotateThe project uses Ruff for linting and code style. Configuration is in pyproject.toml.
# Check code style
uv run ruff check active_annotate
# Format code
uv run ruff format active_annotateuv run djlint --check active_annotate/templates/
uv run djlint --reformat active_annotate/templates/This app comes with Celery for background task management and scheduled jobs.
uv run celery -A config.celery_app worker -l infouv run celery -A config.celery_app beatuv run celery -A config.celery_app worker -B -l infouv run celery -A config.celery_app flowerAccess Flower at http://localhost:5555
To build the documentation locally:
cd docs
uv run make htmlThe built documentation will be available in docs/_build/html/index.html
The system receives webhook events from Label Studio when annotations are created or updated. Webhooks are automatically configured when creating an active learning project.
Webhook Event Types:
ANNOTATION_CREATED- New annotation addedANNOTATION_UPDATED- Annotation modified
The system can integrate with ML backends for:
- Model Status Checks: Monitor model training and inference readiness
- Predictions: Generate predictions for unlabeled data points
- Model Training: Train models on labeled data
The system implements entropy-based uncertainty sampling to select the most informative data points for annotation:
# Uncertainty is calculated based on prediction entropy
# Higher entropy = more uncertain = higher priority for annotation
uncertainty = -sum(p * log(p) for p in normalized_confidences)# Core
DEBUG=True
SECRET_KEY=your-secret-key
ALLOWED_HOSTS=localhost,127.0.0.1
# Database
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=active_annotate
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
# Redis
REDIS_URL=redis://redis:6379
# AWS/MinIO
AWS_STORAGE_BUCKET_NAME=media
AWS_S3_ACCESS_KEY_ID=minioadmin
AWS_S3_SECRET_ACCESS_KEY=minioadmin
AWS_S3_ENDPOINT_URL=http://minio:9000
AWS_S3_FRONTEND_URL=http://localhost:9000
# Label Studio
LABEL_STUDIO_URL=http://label_studio:8080
LABEL_STUDIO_API_KEY=your-label-studio-api-key
# Email (for production)
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USE_TLS=True
EMAIL_HOST_USER=your-email@example.com
EMAIL_HOST_PASSWORD=your-app-passwordPlease refer to our development documentation for detailed contribution guidelines.
We welcome contributions! Please feel free to submit issues and pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
- Jerzy Szyjut - Initial development and architecture
- Hubert Malinowski - Contributions and development
Built with:
- Cookiecutter Django - Project template
- Django REST Framework - API framework
- Label Studio - Annotation tool
- MinIO - S3-compatible object storage
- Celery - Distributed task queue
- The amazing Python and Django communities
For issues, questions, or suggestions, please open an issue on GitHub.
Last Updated: November 2024