The Character Classification System is an AI-based image recognition tool specifically designed to identify characters from games and anime.
1
stars
597
commits
Python
primary language
Aug 21, 2026
updated
An AI-powered image recognition system designed to identify characters from games and anime.
Layered topology: Access (API Gateway) โ Business services (API / Model / Multimedia / Search) โ Async workers (Inference / Search Worker) โ Core AI (Classification / Detection / Recognition / Tagging / Keypoint) โ Infrastructure (Redis / MySQL / RabbitMQ / Fluent-bit / Grafana) โ Deployment (Supervisord / Docker Compose / Kubernetes).
# Clone the repository
git clone https://github.com/ard-team/anime_role_detect.git
cd anime_role_detect
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements-base.txt
pip install -r requirements-ml.txt # For model training/inference
pip install -r requirements-dev.txt # For development
pip install supervisor # For process management
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Start Redis (required for caching)
redis-server &
# Start all services using supervisord
supervisord -c supervisord.conf
# Check service status
supervisorctl status
# Stop all services
supervisorctl stop all
# linux
nohup ./src/run/sh/run_with_supervisor.sh start >/dev/null 2>&1 &
# Build and start all services
docker-compose up --build -d
# Check container status
docker-compose ps
# View logs
docker-compose logs -f <service_name>
# Stop services
docker-compose down
# k8s deployment
# 1. ๆๅปบๆๆ้ๅ
./scripts/k8s/build_k8s_images.sh
# 2. ้จ็ฝฒๅฐ K8s๏ผๆๅจๆบ๏ผk8s/base/๏ผ่ฏฆ่ง k8s/README.md๏ผ
kubectl apply -k k8s/base/
# 3. ๆฅ็้จ็ฝฒ็ถๆ
kubectl get pods -n anime-role-detect
| Service | URL | Port |
|---|---|---|
| Frontend | http://localhost:3000 | 3000 |
| API Gateway | http://localhost:8080 | 8080 |
| Model Service | http://localhost:8000 | 8000 |
| API Service | http://localhost:8001 | 8001 |
| Multimedia Service | http://localhost:8002 | 8002 |
| Search Service | http://localhost:8003 | 8003 |
| Monitoring | http://localhost:8888 | 8888 |
| Supervisor Dashboard | http://localhost:9001 | 9001 |
| RabbitMQ Management | http://localhost:15672 | 15672 |
Infrastructure ports: Redis 6379, MySQL 3306, RabbitMQ 5672, fluent-bit 2020 (Docker Compose only).
http://localhost:8080/docshttp://localhost:8080/redocadmin / userADMIN_PASSWORD and USER_PASSWORDanime_role_detect/
โโโ src/ # Source code (editable install: pip install -e .)
โ โโโ api/ # Backend API service (FastAPI, port 8001)
โ โ โโโ routes/ # API routes (classification, auth, collector, search, video,
โ โ # cleaning, history, models, onnx_inference, async_inference,
โ โ # tracing, version, health, misc)
โ โโโ services/ # Microservices
โ โ โโโ api_gateway/ # API Gateway (port 8080, aggregates Swagger docs)
โ โ โโโ model_service/ # Model Service (port 8000, includes keypoint_worker)
โ โ โโโ multimedia_service/ # Multimedia Service (port 8002, video rendering)
โ โ โโโ search_service/ # Search Service + worker (port 8003, CLIP+FAISS)
โ โ โโโ inference_worker/ # CLIP inference worker
โ โ โโโ inference_queue/ # Inference queue manager (Redis/Memory fallback)
โ โ โโโ cache_service/ # Redis Cache Service
โ โ โโโ model/ # Business model services (classify/recognize/NSFW/multi-model/version)
โ โ โโโ processor/ # Model loaders / image processors / preprocessors
โ โ โโโ support/ # Database service and support layer
โ โ โโโ training/ # Training-related services
โ โ โโโ notification_service.py # Feishu notifications
โ โโโ core/ # Core capabilities
โ โ โโโ classification/ # EfficientNet/MobileNet/DeepDanbooru classification
โ โ โโโ detection/ # YOLO multi-role detection + anime_face_detector
โ โ โโโ recognition/ # CLIP/ArcFace open-set recognition + feature store
โ โ โโโ tagging/ # WD-ViT-Tagger + DeepDanbooru tagging
โ โ โโโ keypoint/ # MediaPipe keypoints
โ โ โโโ ocr/ # EasyOCR
โ โ โโโ feature_extraction/ # Feature extraction (incl. CoreML)
โ โ โโโ log_fusion/ # Log fusion
โ โ โโโ preprocessing/ # Image/data preprocessors
โ โ โโโ config/ # Configuration (ServiceConfig / DeviceManager)
โ โ โโโ cache/ # Cache abstractions
โ โ โโโ logging/ # Structured logging (loguru JSON)
โ โ โโโ ... # error / exception / feedback / version / utils
โ โโโ data/ # Data collection / cleaning / augmentation / search index
โ โโโ data_pipeline/ # Data cleaning pipeline + active_learning + Streamlit webui
โ โโโ data_collection/ # (Legacy) keyword-based collector entry
โ โโโ models/ # Database models + training / evaluation / prediction / deployment
โ โโโ tasks/ # Celery tasks (classify/image/video/model/cleanup)
โ โโโ utils/ # Shared utilities (image, http, concurrency, memory, monitoring, config)
โ โโโ middleware/ # HTTP middleware (auth_enhanced / monitoring / tracing)
โ โโโ frontend/ # Frontend (Next.js 15 + React 18 + TypeScript App Router)
โ โโโ run/ # Service management / monitor dashboard / launch scripts
โ โโโ cache/ # HuggingFace / Keras model cache directories
โ โโโ static/ # Static assets
โโโ models/ # Model weights (git-ignored)
โโโ tests/ # Test suites (unit / integration / model / workflow / regression / performance / benchmark)
โโโ docs/ # Documentation (architecture / deployment / training / blog / testing / technical_challenges)
โโโ scripts/ # Utility scripts (k8s, monitoring, data_*, model_evaluation, coreml, detection, ...)
โ โโโ skillhub/ # โ ๏ธ Archived experiment sub-project (88MB, not referenced)
โโโ archived/ # Historical / broken modules (spider_image_system, arona, ...)
โโโ deployment/ # Docker deployment files (11 Dockerfile.* + nginx + grafana)
โโโ k8s/ # Kustomize (base/ + overlays/ci/)
โโโ config/ # Config templates (config.ini / config.py)
โโโ supervisord.conf # Process manager configuration (12 programs)
โโโ docker-compose.yml # Docker Compose configuration (13 services)
โโโ Dockerfile # Backend Dockerfile (root)
โโโ Dockerfile.model # Model Service Dockerfile (root)
โโโ requirements.txt # Full dependencies
โโโ requirements-base.txt # Base dependencies (for base image)
โโโ requirements-ml.txt # ML dependencies
โโโ requirements-model-service.txt
โโโ requirements-scripts.txt
โโโ requirements-dev.txt # Development dependencies
โโโ pyproject.toml # Project configuration (v2.3.0, authoritative version source)
โโโ .env.example # Environment template
| Endpoint | Method | Description |
|---|---|---|
/api/classify | POST | Image classification |
/api/classify/multi-role | POST | Multi-character detection (YOLO) |
/api/classify/async | POST | Async classification (task queue) |
/api/search/image | POST | Reverse image search (CLIP+FAISS) |
/api/video/recognize | POST | Video recognition |
/api/collect | POST | Data collection task |
/api/cleaning | POST | Data cleaning task |
/api/history | GET | Recognition history |
/api/models | GET | Model info & version |
/api/onnx/infer | POST | ONNX inference |
/api/health | GET | Health check |
/api/services | GET | Service status |
/api/auth/login | POST | User login |
/api/auth/refresh | POST | Refresh token |
/api/version | GET | Version info |
/metrics | GET | Prometheus metrics |
Full route definitions in src/api/routes/. Gateway aggregated docs:
http://localhost:8080/docs.
| Variable | Description | Default |
|---|---|---|
REDIS_URL | Redis connection URL | redis://localhost:6379 |
JWT_SECRET | JWT secret key | (required) |
JWT_EXPIRE_MINUTES | Token expiration | 1440 (24h) |
MAX_IMAGE_SIZE | Max upload size (MB) | 10 |
DEVICE | Compute device (cpu/cuda/mps) | auto |
The project includes comprehensive Docker support:
efficientnet_b3_v9 โ EfficientNet-B3 backbone, 167 character classes, canonical preprocessing Resize(288)โCenterCrop(256), evaluated on the held-out test split (post_id-grouped, no train/test overlap). Trained 2026-08-12.
| Metric | Value |
|---|---|
| Top-1 Accuracy (held-out TEST, honest) | 61.19% |
| Top-5 Accuracy | 78.48% |
| Macro-F1 (167 classes) | 0.5633 |
| Weighted-F1 | 0.6071 |
| Balanced Accuracy | 0.5741 |
| Validation Best Macro-F1 (model-selection metric) | 0.5875 (Val Top-1 63.15%) |
Deployment note: the running backend currently loads
efficientnet_b3_v4(174 classes) by default; v9 is the latest honestly-evaluated checkpoint and is pending promotion to default. Full per-class report:deliverables/gstack/model-baseline-v9-honest-2026-08-12.md.
Earlier documentation reported efficientnet_b3 at 51 classes with Top-1 84.00% / 82.65% and Macro-F1 0.8401. These came from a train/test leakage (same images used for both training and testing) and were superseded by the honest 167-class evaluation above. See docs/training/DATA_LEAKAGE_STATUS.md for the leakage analysis.
yolov8n.pt is the COCO-pretrained baseline (6.25 MB, 3.15M params). It is not fine-tuned on anime characters โ avg confidence 0.444, ~4 FPS on MPS. Fine-tuning is pending.
| Model | Classes | Top-1 (honest TEST) | Note |
|---|---|---|---|
| EfficientNet-B3 v9 (latest) | 167 | 61.19% | Honest held-out TEST; Macro-F1 0.5633 |
| EfficientNet-B3 v4 (serving default) | 174 | โ | Currently loaded by backend |
| EfficientNet-B0 / MobileNetV2 / ResNet50 | โ | โ | Earlier experiments, see docs/blog/10_training_and_evaluation.md |
# Run unit tests
python -m pytest tests/ -v
# Run integration tests
python -m pytest tests/integration/ -v
# Run model benchmark (produces scripts/model_evaluation/benchmark_results.json)
python scripts/model_evaluation/run_benchmark.py
For detailed documentation:
docs/architecture/ - Project structure & architecture designdocs/deployment/ - Deployment guides (Kubernetes, Ubuntu)docs/training/ - Model training guides + data leakage analysisdocs/blog/ - Technical blog postsdocs/testing/ - Testing guidesdocs/technical_challenges/ - Technical challenges & solutionsdocs/system_design.md / docs/system_design_perf.md - System design & performance optimization planWe welcome contributions! Please see CONTRIBUTING.md for details on:
This project is licensed under the MIT License - see the LICENSE file for details.
Version: v2.4.0 | Last Updated: 2026-08-12 | Maintainer: ARD Team
Topics: anime, character-recognition, image-classification, deep-learning, python-api, computer-vision, yolov8, nextjs, docker, microservices
588 commits
9 commits
Python
87.8%
TypeScript
5.2%
Shell
2.6%
Vue
1.9%
HTML
1.7%
The Character Classification System is an AI-based image recognition tool specifically designed to identify characters from games and anime.
1
stars
597
commits
Python
primary language
Aug 21, 2026
updated
An AI-powered image recognition system designed to identify characters from games and anime.
Layered topology: Access (API Gateway) โ Business services (API / Model / Multimedia / Search) โ Async workers (Inference / Search Worker) โ Core AI (Classification / Detection / Recognition / Tagging / Keypoint) โ Infrastructure (Redis / MySQL / RabbitMQ / Fluent-bit / Grafana) โ Deployment (Supervisord / Docker Compose / Kubernetes).
# Clone the repository
git clone https://github.com/ard-team/anime_role_detect.git
cd anime_role_detect
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements-base.txt
pip install -r requirements-ml.txt # For model training/inference
pip install -r requirements-dev.txt # For development
pip install supervisor # For process management
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Start Redis (required for caching)
redis-server &
# Start all services using supervisord
supervisord -c supervisord.conf
# Check service status
supervisorctl status
# Stop all services
supervisorctl stop all
# linux
nohup ./src/run/sh/run_with_supervisor.sh start >/dev/null 2>&1 &
# Build and start all services
docker-compose up --build -d
# Check container status
docker-compose ps
# View logs
docker-compose logs -f <service_name>
# Stop services
docker-compose down
# k8s deployment
# 1. ๆๅปบๆๆ้ๅ
./scripts/k8s/build_k8s_images.sh
# 2. ้จ็ฝฒๅฐ K8s๏ผๆๅจๆบ๏ผk8s/base/๏ผ่ฏฆ่ง k8s/README.md๏ผ
kubectl apply -k k8s/base/
# 3. ๆฅ็้จ็ฝฒ็ถๆ
kubectl get pods -n anime-role-detect
| Service | URL | Port |
|---|---|---|
| Frontend | http://localhost:3000 | 3000 |
| API Gateway | http://localhost:8080 | 8080 |
| Model Service | http://localhost:8000 | 8000 |
| API Service | http://localhost:8001 | 8001 |
| Multimedia Service | http://localhost:8002 | 8002 |
| Search Service | http://localhost:8003 | 8003 |
| Monitoring | http://localhost:8888 | 8888 |
| Supervisor Dashboard | http://localhost:9001 | 9001 |
| RabbitMQ Management | http://localhost:15672 | 15672 |
Infrastructure ports: Redis 6379, MySQL 3306, RabbitMQ 5672, fluent-bit 2020 (Docker Compose only).
http://localhost:8080/docshttp://localhost:8080/redocadmin / userADMIN_PASSWORD and USER_PASSWORDanime_role_detect/
โโโ src/ # Source code (editable install: pip install -e .)
โ โโโ api/ # Backend API service (FastAPI, port 8001)
โ โ โโโ routes/ # API routes (classification, auth, collector, search, video,
โ โ # cleaning, history, models, onnx_inference, async_inference,
โ โ # tracing, version, health, misc)
โ โโโ services/ # Microservices
โ โ โโโ api_gateway/ # API Gateway (port 8080, aggregates Swagger docs)
โ โ โโโ model_service/ # Model Service (port 8000, includes keypoint_worker)
โ โ โโโ multimedia_service/ # Multimedia Service (port 8002, video rendering)
โ โ โโโ search_service/ # Search Service + worker (port 8003, CLIP+FAISS)
โ โ โโโ inference_worker/ # CLIP inference worker
โ โ โโโ inference_queue/ # Inference queue manager (Redis/Memory fallback)
โ โ โโโ cache_service/ # Redis Cache Service
โ โ โโโ model/ # Business model services (classify/recognize/NSFW/multi-model/version)
โ โ โโโ processor/ # Model loaders / image processors / preprocessors
โ โ โโโ support/ # Database service and support layer
โ โ โโโ training/ # Training-related services
โ โ โโโ notification_service.py # Feishu notifications
โ โโโ core/ # Core capabilities
โ โ โโโ classification/ # EfficientNet/MobileNet/DeepDanbooru classification
โ โ โโโ detection/ # YOLO multi-role detection + anime_face_detector
โ โ โโโ recognition/ # CLIP/ArcFace open-set recognition + feature store
โ โ โโโ tagging/ # WD-ViT-Tagger + DeepDanbooru tagging
โ โ โโโ keypoint/ # MediaPipe keypoints
โ โ โโโ ocr/ # EasyOCR
โ โ โโโ feature_extraction/ # Feature extraction (incl. CoreML)
โ โ โโโ log_fusion/ # Log fusion
โ โ โโโ preprocessing/ # Image/data preprocessors
โ โ โโโ config/ # Configuration (ServiceConfig / DeviceManager)
โ โ โโโ cache/ # Cache abstractions
โ โ โโโ logging/ # Structured logging (loguru JSON)
โ โ โโโ ... # error / exception / feedback / version / utils
โ โโโ data/ # Data collection / cleaning / augmentation / search index
โ โโโ data_pipeline/ # Data cleaning pipeline + active_learning + Streamlit webui
โ โโโ data_collection/ # (Legacy) keyword-based collector entry
โ โโโ models/ # Database models + training / evaluation / prediction / deployment
โ โโโ tasks/ # Celery tasks (classify/image/video/model/cleanup)
โ โโโ utils/ # Shared utilities (image, http, concurrency, memory, monitoring, config)
โ โโโ middleware/ # HTTP middleware (auth_enhanced / monitoring / tracing)
โ โโโ frontend/ # Frontend (Next.js 15 + React 18 + TypeScript App Router)
โ โโโ run/ # Service management / monitor dashboard / launch scripts
โ โโโ cache/ # HuggingFace / Keras model cache directories
โ โโโ static/ # Static assets
โโโ models/ # Model weights (git-ignored)
โโโ tests/ # Test suites (unit / integration / model / workflow / regression / performance / benchmark)
โโโ docs/ # Documentation (architecture / deployment / training / blog / testing / technical_challenges)
โโโ scripts/ # Utility scripts (k8s, monitoring, data_*, model_evaluation, coreml, detection, ...)
โ โโโ skillhub/ # โ ๏ธ Archived experiment sub-project (88MB, not referenced)
โโโ archived/ # Historical / broken modules (spider_image_system, arona, ...)
โโโ deployment/ # Docker deployment files (11 Dockerfile.* + nginx + grafana)
โโโ k8s/ # Kustomize (base/ + overlays/ci/)
โโโ config/ # Config templates (config.ini / config.py)
โโโ supervisord.conf # Process manager configuration (12 programs)
โโโ docker-compose.yml # Docker Compose configuration (13 services)
โโโ Dockerfile # Backend Dockerfile (root)
โโโ Dockerfile.model # Model Service Dockerfile (root)
โโโ requirements.txt # Full dependencies
โโโ requirements-base.txt # Base dependencies (for base image)
โโโ requirements-ml.txt # ML dependencies
โโโ requirements-model-service.txt
โโโ requirements-scripts.txt
โโโ requirements-dev.txt # Development dependencies
โโโ pyproject.toml # Project configuration (v2.3.0, authoritative version source)
โโโ .env.example # Environment template
| Endpoint | Method | Description |
|---|---|---|
/api/classify | POST | Image classification |
/api/classify/multi-role | POST | Multi-character detection (YOLO) |
/api/classify/async | POST | Async classification (task queue) |
/api/search/image | POST | Reverse image search (CLIP+FAISS) |
/api/video/recognize | POST | Video recognition |
/api/collect | POST | Data collection task |
/api/cleaning | POST | Data cleaning task |
/api/history | GET | Recognition history |
/api/models | GET | Model info & version |
/api/onnx/infer | POST | ONNX inference |
/api/health | GET | Health check |
/api/services | GET | Service status |
/api/auth/login | POST | User login |
/api/auth/refresh | POST | Refresh token |
/api/version | GET | Version info |
/metrics | GET | Prometheus metrics |
Full route definitions in src/api/routes/. Gateway aggregated docs:
http://localhost:8080/docs.
| Variable | Description | Default |
|---|---|---|
REDIS_URL | Redis connection URL | redis://localhost:6379 |
JWT_SECRET | JWT secret key | (required) |
JWT_EXPIRE_MINUTES | Token expiration | 1440 (24h) |
MAX_IMAGE_SIZE | Max upload size (MB) | 10 |
DEVICE | Compute device (cpu/cuda/mps) | auto |
The project includes comprehensive Docker support:
efficientnet_b3_v9 โ EfficientNet-B3 backbone, 167 character classes, canonical preprocessing Resize(288)โCenterCrop(256), evaluated on the held-out test split (post_id-grouped, no train/test overlap). Trained 2026-08-12.
| Metric | Value |
|---|---|
| Top-1 Accuracy (held-out TEST, honest) | 61.19% |
| Top-5 Accuracy | 78.48% |
| Macro-F1 (167 classes) | 0.5633 |
| Weighted-F1 | 0.6071 |
| Balanced Accuracy | 0.5741 |
| Validation Best Macro-F1 (model-selection metric) | 0.5875 (Val Top-1 63.15%) |
Deployment note: the running backend currently loads
efficientnet_b3_v4(174 classes) by default; v9 is the latest honestly-evaluated checkpoint and is pending promotion to default. Full per-class report:deliverables/gstack/model-baseline-v9-honest-2026-08-12.md.
Earlier documentation reported efficientnet_b3 at 51 classes with Top-1 84.00% / 82.65% and Macro-F1 0.8401. These came from a train/test leakage (same images used for both training and testing) and were superseded by the honest 167-class evaluation above. See docs/training/DATA_LEAKAGE_STATUS.md for the leakage analysis.
yolov8n.pt is the COCO-pretrained baseline (6.25 MB, 3.15M params). It is not fine-tuned on anime characters โ avg confidence 0.444, ~4 FPS on MPS. Fine-tuning is pending.
| Model | Classes | Top-1 (honest TEST) | Note |
|---|---|---|---|
| EfficientNet-B3 v9 (latest) | 167 | 61.19% | Honest held-out TEST; Macro-F1 0.5633 |
| EfficientNet-B3 v4 (serving default) | 174 | โ | Currently loaded by backend |
| EfficientNet-B0 / MobileNetV2 / ResNet50 | โ | โ | Earlier experiments, see docs/blog/10_training_and_evaluation.md |
# Run unit tests
python -m pytest tests/ -v
# Run integration tests
python -m pytest tests/integration/ -v
# Run model benchmark (produces scripts/model_evaluation/benchmark_results.json)
python scripts/model_evaluation/run_benchmark.py
For detailed documentation:
docs/architecture/ - Project structure & architecture designdocs/deployment/ - Deployment guides (Kubernetes, Ubuntu)docs/training/ - Model training guides + data leakage analysisdocs/blog/ - Technical blog postsdocs/testing/ - Testing guidesdocs/technical_challenges/ - Technical challenges & solutionsdocs/system_design.md / docs/system_design_perf.md - System design & performance optimization planWe welcome contributions! Please see CONTRIBUTING.md for details on:
This project is licensed under the MIT License - see the LICENSE file for details.
Version: v2.4.0 | Last Updated: 2026-08-12 | Maintainer: ARD Team
Topics: anime, character-recognition, image-classification, deep-learning, python-api, computer-vision, yolov8, nextjs, docker, microservices
588 commits
9 commits
Python
87.8%
TypeScript
5.2%
Shell
2.6%
Vue
1.9%
HTML
1.7%