All checks were successful
build_docker / essential (push) Successful in 0s
build_docker / build_cpu (push) Successful in 5m0s
build_docker / build_gpu (push) Successful in 22m55s
build_docker / build_easyocr (push) Successful in 18m47s
build_docker / build_easyocr_gpu (push) Successful in 19m0s
build_docker / build_raytune (push) Successful in 3m27s
build_docker / build_doctr (push) Successful in 19m42s
build_docker / build_doctr_gpu (push) Successful in 14m49s
OCR Hyperparameter Tuning with Ray Tune
This directory contains the Docker setup for running automated hyperparameter optimization on OCR services using Ray Tune with Optuna.
Prerequisites
- Docker with NVIDIA GPU support (
nvidia-container-toolkit) - NVIDIA GPU with CUDA support
Quick Start
cd src
# Start PaddleOCR service and run tuning (images pulled from registry)
docker compose -f docker-compose.tuning.paddle.yml up -d paddle-ocr-gpu
docker compose -f docker-compose.tuning.paddle.yml run raytune --service paddle --samples 64
Available Services
| Service | Port | Compose File |
|---|---|---|
| PaddleOCR | 8002 | docker-compose.tuning.paddle.yml |
| DocTR | 8003 | docker-compose.tuning.doctr.yml |
| EasyOCR | 8002 | docker-compose.tuning.easyocr.yml |
Note: PaddleOCR and EasyOCR both use port 8002. Run them separately.
Usage Examples
PaddleOCR Tuning
# Start service
docker compose -f docker-compose.tuning.paddle.yml up -d paddle-ocr-gpu
# Wait for health check (check with)
curl http://localhost:8002/health
# Run tuning (64 samples)
docker compose -f docker-compose.tuning.paddle.yml run raytune --service paddle --samples 64
# Stop service
docker compose -f docker-compose.tuning.paddle.yml down
DocTR Tuning
docker compose -f docker-compose.tuning.doctr.yml up -d doctr-gpu
curl http://localhost:8003/health
docker compose -f docker-compose.tuning.doctr.yml run raytune --service doctr --samples 64
docker compose -f docker-compose.tuning.doctr.yml down
EasyOCR Tuning
docker compose -f docker-compose.tuning.easyocr.yml up -d easyocr-gpu
curl http://localhost:8002/health
docker compose -f docker-compose.tuning.easyocr.yml run raytune --service easyocr --samples 64
docker compose -f docker-compose.tuning.easyocr.yml down
Run Multiple Services (PaddleOCR + DocTR)
# Start both services
docker compose -f docker-compose.tuning.yml up -d paddle-ocr-gpu doctr-gpu
# Run tuning for each
docker compose -f docker-compose.tuning.yml run raytune --service paddle --samples 64
docker compose -f docker-compose.tuning.yml run raytune --service doctr --samples 64
# Stop all
docker compose -f docker-compose.tuning.yml down
Command Line Options
docker compose -f <compose-file> run raytune --service <service> --samples <n>
| Option | Description | Default |
|---|---|---|
--service |
OCR service: paddle, doctr, easyocr |
Required |
--samples |
Number of hyperparameter trials | 64 |
Output
Results are saved to src/results/ as CSV files:
raytune_paddle_results_<timestamp>.csvraytune_doctr_results_<timestamp>.csvraytune_easyocr_results_<timestamp>.csv
Directory Structure
src/
├── docker-compose.tuning.yml # All services (PaddleOCR + DocTR)
├── docker-compose.tuning.paddle.yml # PaddleOCR only
├── docker-compose.tuning.doctr.yml # DocTR only
├── docker-compose.tuning.easyocr.yml # EasyOCR only
├── raytune/
│ ├── Dockerfile
│ ├── requirements.txt
│ ├── raytune_ocr.py
│ └── run_tuning.py
├── dataset/ # Input images and ground truth
├── results/ # Output CSV files
└── debugset/ # Debug output
Docker Images
All images are pre-built and pulled from registry:
seryus.ddns.net/unir/raytune:latest- Ray Tune tuning serviceseryus.ddns.net/unir/paddle-ocr-gpu:latest- PaddleOCR GPUseryus.ddns.net/unir/doctr-gpu:latest- DocTR GPUseryus.ddns.net/unir/easyocr-gpu:latest- EasyOCR GPU
Build locally (development)
# Build raytune image locally
docker build -t seryus.ddns.net/unir/raytune:latest ./raytune
Troubleshooting
Service not ready
Wait for the health check to pass before running tuning:
# Check service health
curl http://localhost:8002/health
# Expected: {"status": "ok", "model_loaded": true, ...}
GPU not detected
Ensure nvidia-container-toolkit is installed:
nvidia-smi # Should show your GPU
docker run --rm --gpus all nvidia/cuda:12.4.1-base nvidia-smi
Port already in use
Stop any running OCR services:
docker compose -f docker-compose.tuning.paddle.yml down
docker compose -f docker-compose.tuning.easyocr.yml down