A lightweight and async OCR server powered by FastAPI, Celery, EasyOCR, and Redis. Supports image and PDF OCR using CPU.
.jpg
, .png
, etc.) and PDFsocr-server/
โโโ Dockerfile
โโโ docker-compose.yml
โโโ requirements.txt
โโโ src/
โ โโโ __main__.py # FastAPI app entrypoint
โ โโโ worker.py # Celery worker app
โ โโโ tasks.py # Celery OCR task
โ โโโ ocr_engine.py # EasyOCR logic
โ โโโ utils.py # PDF/Image tools
โ โโโ config.py # Paths & settings
docker-compose up --build
Submit OCR task
POST /ocr
Form-Data: file=@yourfile.pdf
Get result
GET /result/{task_id}
{
"status": "completed",
"result": {
"type": "pdf",
"pages": [
{
"page": 1,
"text": [
{
"text": "Hello World",
"confidence": 0.98,
"box": [[x1, y1], [x2, y2], ...]
}
]
}
]
}
}
curl
curl -F "file=@sample.pdf" http://localhost:8000/ocr
curl http://localhost:8000/result/<task_id>