AI-powered aviation photography review API built with FastAPI.
- Quality Assessment: Sharpness, exposure, composition, noise, color evaluation
- Aircraft Classification: Aircraft type identification with top-k predictions
- Airline Recognition: Airline livery identification
- Registration OCR: Aircraft registration number recognition with bounding boxes
- Aggregated Review: Combined review endpoint that calls all atomic services
- Batch Processing: All endpoints support batch operations (up to 50 images)
Aerovision-V1-Server/
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI application entry point
│ ├── api/
│ │ ├── __init__.py # Router aggregation
│ │ ├── deps.py # Dependencies & request stats
│ │ └── routes/
│ │ ├── health.py # Health check & statistics
│ │ ├── quality.py # Quality assessment API
│ │ ├── aircraft.py # Aircraft classification API
│ │ ├── airline.py # Airline recognition API
│ │ ├── registration.py # Registration OCR API
│ │ └── review.py # Aggregated review API
│ ├── services/
│ │ ├── base.py # Service base class
│ │ ├── quality_service.py
│ │ ├── aircraft_service.py
│ │ ├── airline_service.py
│ │ ├── registration_service.py
│ │ └── review_service.py # Aggregated service
│ ├── schemas/
│ │ ├── common.py # Common models
│ │ ├── quality.py
│ │ ├── aircraft.py
│ │ ├── airline.py
│ │ ├── registration.py
│ │ └── review.py
│ ├── core/
│ │ ├── config.py # Configuration management
│ │ ├── logging.py # Logging configuration
│ │ └── exceptions.py # Custom exceptions
│ └── inference/
│ ├── factory.py # Inference model factory
│ └── wrappers.py # Result wrappers
├── tests/
│ ├── conftest.py # Pytest fixtures
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── fixtures/
│ └── images/ # Test images
└── requirements/
├── base.txt
├── test.txt
└── dev.txt
cd Aerovision-V1-Server
# Install dependencies
pip install -r requirements/base.txt
# Install test dependencies
pip install -r requirements/test.txtCreate a .env file or set environment variables:
# Model Configuration
MODEL_DIR=models # Model directory
DEVICE=cuda # Inference device (cuda/cpu)
PRELOAD_MODELS=true # Preload models on startup
# OCR Configuration
OCR_MODE=local # OCR mode (local/api)
OCR_LANG=ch # OCR language
USE_ANGLE_CLS=true # Use angle classifier
# Server Configuration
HOST=0.0.0.0
PORT=8000
WORKERS=1
DEBUG=true# Development mode
python -m app.main
# Or using uvicorn
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Production mode
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/history/push |
Push historical audit records to vector database |
GET |
/api/v1/history/stats |
Get vector database statistics |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/quality |
Quality assessment |
POST |
/api/v1/quality/batch |
Batch quality assessment |
POST |
/api/v1/aircraft |
Aircraft classification |
POST |
/api/v1/aircraft/batch |
Batch aircraft classification |
POST |
/api/v1/airline |
Airline recognition |
POST |
/api/v1/airline/batch |
Batch airline recognition |
POST |
/api/v1/registration |
Registration OCR |
POST |
/api/v1/registration/batch |
Batch registration OCR |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/v1/review |
Full review (all services) |
POST |
/api/v1/review/batch |
Batch full review |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/v1/health |
Health check |
GET |
/api/v1/stats |
Request statistics |
curl -X POST "http://localhost:8000/api/v1/history/push" \
-H "Content-Type: application/json" \
-d '{
"records": [
{
"id": "record_001",
"image_url": "https://example.com/image1.jpg",
"aircraft_type": "A320",
"airline": "CEA",
"aircraft_confidence": 0.85,
"airline_confidence": 0.75,
"timestamp": "2025-01-28T10:00:00Z",
"metadata": {
"image_data": "data:image/jpeg;base64,/9j/4AAQ..."
}
}
]
}'Response:
{
"success": true,
"total": 1,
"added": 1,
"failed": 0
}curl -X GET "http://localhost:8000/api/v1/history/stats"Response:
{
"available": true,
"total_records": 1000,
"aircraft_types": {
"A320": 350,
"B738": 450,
"A321": 200
},
"airlines": {
"CEA": 500,
"CSN": 300,
"CAC": 200
}
}curl -X POST "http://localhost:8000/api/v1/quality" \
-H "Content-Type: application/json" \
-d '{
"image": "data:image/jpeg;base64,/9j/4AAQ..."
}'Response:
{
"success": true,
"pass": true,
"score": 0.85,
"details": {
"sharpness": 0.90,
"exposure": 0.80,
"composition": 0.85,
"noise": 0.88,
"color": 0.82
},
"meta": {
"processing_time_ms": 123.45,
"timestamp": "2025-01-28T10:00:00Z"
}
}curl -X POST "http://localhost:8000/api/v1/aircraft?top_k=5" \
-H "Content-Type: application/json" \
-d '{
"image": "data:image/jpeg;base64,/9j/4AAQ..."
}'Response:
{
"success": true,
"top1": {
"class": "A320",
"confidence": 0.85
},
"top_k": 5,
"predictions": [
{"class": "A320", "confidence": 0.85},
{"class": "B738", "confidence": 0.10},
{"class": "A321", "confidence": 0.05}
],
"meta": {
"processing_time_ms": 89.2,
"timestamp": "2025-01-28T10:00:00Z"
}
}curl -X POST "http://localhost:8000/api/v1/registration" \
-H "Content-Type: application/json" \
-d '{
"image": "data:image/jpeg;base64,/9j/4AAQ..."
}'Response:
{
"success": true,
"registration": "B-1234",
"confidence": 0.95,
"raw_text": "B-1234",
"all_matches": [
{"text": "B-1234", "confidence": 0.95}
],
"yolo_boxes": [
{
"class_id": 0,
"x_center": 0.5,
"y_center": 0.3,
"width": 0.2,
"height": 0.1,
"text": "B-1234",
"confidence": 0.95
}
],
"meta": {
"processing_time_ms": 156.7,
"timestamp": "2025-01-28T10:00:00Z"
}
}curl -X POST "http://localhost:8000/api/v1/review?include_quality=true&include_aircraft=true&include_airline=true&include_registration=true" \
-H "Content-Type: application/json" \
-d '{
"image": "data:image/jpeg;base64,/9j/4AAQ..."
}'Response:
{
"success": true,
"quality": {
"score": 0.85,
"pass": true,
"details": {
"sharpness": 0.90,
"exposure": 0.80,
"composition": 0.85,
"noise": 0.88,
"color": 0.82
}
},
"aircraft": {
"type_code": "A320",
"confidence": 0.85
},
"airline": {
"airline_code": "CEA",
"confidence": 0.75
},
"registration": {
"registration": "B-1234",
"confidence": 0.95,
"clarity": 0.95
},
"meta": {
"processing_time_ms": 369.1,
"timestamp": "2025-01-28T10:00:00Z"
}
}curl -X POST "http://localhost:8000/api/v1/quality/batch" \
-H "Content-Type: application/json" \
-d '{
"images": [
"data:image/jpeg;base64,/9j/4AAQ...",
"data:image/jpeg;base64,/9j/4AAQ..."
]
}'Response:
{
"total": 2,
"successful": 2,
"failed": 0,
"results": [
{
"index": 0,
"success": true,
"data": {
"pass": true,
"score": 0.85,
"details": {...}
},
"error": null
},
{
"index": 1,
"success": true,
"data": {
"pass": true,
"score": 0.78,
"details": {...}
},
"error": null
}
]
}# Run all tests
pytest
# Run unit tests only
pytest tests/unit/
# Run with coverage
pytest --cov=app --cov-report=html
# Run specific test file
pytest tests/unit/schemas/test_schemas.py -vCurrent coverage: 52% (418/865 lines)
The app/inference/factory.py provides a unified interface for loading models from aerovision_inference:
InferenceFactory.get_aircraft_classifier()InferenceFactory.get_airline_classifier()InferenceFactory.get_registration_ocr()InferenceFactory.get_quality_assessor()
Models are lazy-loaded on first request and cached for subsequent use.
Each atomic API has a corresponding service class:
QualityService- Image quality assessmentAircraftService- Aircraft type classificationAirlineService- Airline recognitionRegistrationService- Registration OCRReviewService- Aggregated review (calls all services)
Single Image Request:
{
"image": "base64 or URL"
}Batch Request:
{
"images": ["base64 or URL", "..."]
}Response Format:
{
"success": true,
"data": { /* result */ },
"meta": {
"processing_time_ms": 123,
"timestamp": "2025-01-28T10:00:00Z"
}
}fastapi>=0.104.1- Web frameworkuvicorn[standard]>=0.24.0- ASGI serverpydantic>=2.5.0- Data validationpydantic-settings>=2.1.0- Configuration managementhttpx>=0.25.0- HTTP clientpillow>=10.1.0- Image processing
pytest>=7.4.0- Testing frameworkpytest-asyncio>=0.21.0- Async supportpytest-cov>=4.1.0- Coverage reporting
aerovision_inference- Inference backend (local package)
This server is designed to work with aerovision_inference package. The inference layer provides:
- Lazy-loading of models
- Graceful degradation when inference package is not available
- Result wrapping for consistent API responses
See project root for license information.