feat(paddleocr): add PaddleOCR OCR service (Docker images, server, tests, docs) and CI workflows

This commit is contained in:
2026-01-16 13:23:01 +00:00
parent 67c38eeb67
commit bec379e9ca
10 changed files with 624 additions and 71 deletions

View File

@@ -77,6 +77,81 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CPU variant has longer `start-period` (120s) due to slower startup.
## PaddleOCR
### Overview
PaddleOCR is a standalone OCR service using PaddlePaddle's PP-OCRv4 model. It provides:
- Text detection and recognition
- Multi-language support
- FastAPI REST API
- GPU and CPU variants
### Docker Images
| Tag | Description |
|-----|-------------|
| `paddleocr` | GPU variant (default) |
| `paddleocr-gpu` | GPU variant (alias) |
| `paddleocr-cpu` | CPU-only variant |
### API Endpoints
| Endpoint | Method | Description |
|----------|--------|-------------|
| `/health` | GET | Health check with model info |
| `/ocr` | POST | OCR with base64 image (JSON body) |
| `/ocr/upload` | POST | OCR with file upload (multipart form) |
### Request/Response Format
**POST /ocr (JSON)**
```json
{
"image": "<base64-encoded-image>",
"language": "en" // optional
}
```
**POST /ocr/upload (multipart)**
- `img`: image file
- `language`: optional language code
**Response**
```json
{
"success": true,
"results": [
{
"text": "Invoice #12345",
"confidence": 0.98,
"box": [[x1,y1], [x2,y2], [x3,y3], [x4,y4]]
}
]
}
```
### Environment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| `OCR_LANGUAGE` | `en` | Default language for OCR |
| `SERVER_PORT` | `5000` | Server port |
| `SERVER_HOST` | `0.0.0.0` | Server host |
| `CUDA_VISIBLE_DEVICES` | (auto) | Set to `-1` for CPU-only |
### Performance
- **GPU**: ~1-3 seconds per page
- **CPU**: ~10-30 seconds per page
### Supported Languages
Common language codes: `en` (English), `ch` (Chinese), `de` (German), `fr` (French), `es` (Spanish), `ja` (Japanese), `ko` (Korean)
---
## Adding New Models
To add a new model variant: