Skip to main content

paddleocrserver-powered

PyPI version Python versions License: MIT

A self-contained, multi-language PaddleOCR HTTP server packaged as a single PyPI install. Flask + Waitress, configurable per-language YAML pipelines, and two preprocessing modes (fast for screens/UI/printed docs, full for photographed/curved/rotated documents).

Any client (Java, Python, RF, curl)  →  HTTP POST  →  Flask  →  PaddleOCR  →  JSON

Install

pip install paddleocrserver-powered

The first request for a given (language, mode) pair downloads the corresponding PaddleOCR model weights into the local PaddleX cache.

Quickstart

paddleocrserver-powered
# → serves http://127.0.0.1:5000  (latin language, fast mode)

Run a quick OCR:

curl -X POST http://127.0.0.1:5000/ocr \
  -H 'Content-Type: application/json' \
  -d '{"image_path": "/abs/path/to/image.png"}'

You can also run it as a module:

python -m paddleocrserver_powered --port 5000

OCR modes

Mode Pipeline flags enabled Latency (indicative) Use cases
fast text detection + recognition only ~150–400 ms / image UI screenshots, screen captures, clean printed documents
full + doc orientation classify + textline orientation + doc unwarping ~600–1500 ms / image Photographed docs, curved/rotated pages, low-quality scans

fast is the default. Pass "preprocess": "full" in the request body to enable the full pipeline for a single call.


Languages

Built-in language packs (PP-OCRv5 mobile recognition models):

Code Recognition model
latin latin_PP-OCRv5_mobile_rec (default)
japan japan_PP-OCRv5_mobile_rec
korean korean_PP-OCRv5_mobile_rec
chinese_cht chinese_cht_PP-OCRv5_mobile_rec
cyrillic cyrillic_PP-OCRv5_mobile_rec
arabic arabic_PP-OCRv5_mobile_rec
devanagari devanagari_PP-OCRv5_mobile_rec

By default only latin is enabled. Activate other languages by editing languages.yaml:

enabled:
  latin: true
  japan: true
  korean: false
  chinese_cht: false
  cyrillic: false
  arabic: false
  devanagari: false
default_language: latin

Then point the server at it:

paddleocrserver-powered --languages-config /path/to/languages.yaml
# or
OCR_LANGUAGES_CONFIG=/path/to/languages.yaml paddleocrserver-powered

All enabled: true languages are eager-loaded at startup in fast mode, so the first request never pays a cold-start cost. The corresponding full engine is created lazily the first time someone requests preprocess: "full".

Adding languages

To add a custom language pack:

  1. Drop two YAML files next to the packaged ones (or beside your custom languages.yaml): ocr_config_<code>.yaml and ocr_config_<code>_full.yaml.
  2. Set the appropriate model_name under SubModules.TextRecognition (e.g. myscript_PP-OCRv5_mobile_rec).
  3. Add <code>: true to your languages.yaml.

The shipped YAMLs are a safe template — copy ocr_config_latin.yaml, change the model_name, you're done.


API endpoints

POST /ocr

Run OCR on an image.

curl -X POST http://127.0.0.1:5000/ocr \
  -H 'Content-Type: application/json' \
  -d '{
    "image_path": "/abs/path/to/image.png",
    "lang": "latin",
    "preprocess": "fast"
  }'
Field Type Required Default Notes
image_path string yes — Absolute path on the server side
lang string no default_language Must be in the enabled list
preprocess string no "fast" "fast" or "full"

If lang is not enabled the server returns 400 with the list of currently-enabled languages.

POST /ocr_strikethrough

OCR + strikethrough detection in one call. Always uses fast preprocessing.

curl -X POST http://127.0.0.1:5000/ocr_strikethrough \
  -H 'Content-Type: application/json' \
  -d '{"image_path": "/abs/path/img.png", "text": "cancelled", "lang": "latin"}'

GET /status

curl http://127.0.0.1:5000/status

Returns {status, uptime, loaded_engines}.

GET /languages

curl http://127.0.0.1:5000/languages

Returns {enabled, default_language, supported}.


Configuration

Env var Default Purpose
OCR_HOST 127.0.0.1 Bind address
OCR_PORT 5000 Bind port
OCR_LANGUAGES_CONFIG (packaged) Path to a custom languages.yaml
OCR_RATE_LIMIT_DEFAULT 100 per minute Global rate limit (per IP)
OCR_RATE_LIMIT_OCR 30 per minute Per-IP limit on /ocr and /ocr_strikethrough
OCR_RATE_LIMIT_STORAGE memory:// flask-limiter storage URI (e.g. Redis)

CLI flags (override env vars): --host, --port, --languages-config.


Advanced: multi-port deployment

PaddleOCR is not thread-safe — a single process runs with threads=1. To serve multiple languages efficiently, run one process per language on its own port and route from the client side.

/etc/paddleocr/latin.yaml:

enabled: { latin: true }
default_language: latin

/etc/paddleocr/japan.yaml:

enabled: { japan: true }
default_language: japan

Launch:

OCR_PORT=5000 paddleocrserver-powered --languages-config /etc/paddleocr/latin.yaml &
OCR_PORT=5001 paddleocrserver-powered --languages-config /etc/paddleocr/japan.yaml &

Each instance keeps only its own model in RAM and answers only on its port.


Programmatic usage

from paddleocrserver_powered import spawn_server

proc = spawn_server(port=5050, languages_config="/etc/paddleocr/latin.yaml")
try:
    # ... do work, hit http://127.0.0.1:5050/ocr ...
    pass
finally:
    proc.terminate()
    proc.wait(timeout=10)

spawn_server returns a subprocess.Popen running python -m paddleocrserver_powered with the provided arguments.


License

MIT — see LICENSE.

Metadata

Release files for paddleocrserver-powered 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for paddleocrserver-powered 0.1.1
File Size Uploaded
paddleocrserver_powered-0.1.1.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for paddleocrserver-powered 0.1.1
File Interpreter ABI Platform
paddleocrserver_powered-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 44.9 kB

Release files / paddleocrserver_powered-0.1.1.tar.gz

Download URL paddleocrserver_powered-0.1.1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1258bc634731af7341cecdb9c3c8cadd42f94ea4df0bc81a85912806afbd8384
BLAKE2b-256 checksum
How to use checksums
e4db07045c34094b79b9bce7b61286b4e912991a4bb99fa124615180e1db58c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / paddleocrserver_powered-0.1.1-py3-none-any.whl

Download URL paddleocrserver_powered-0.1.1-py3-none-any.whl
Size 26.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a1be44371b1801b268e80cf2516e0d0419867c79c7e1a24713e941d0b29bc28
BLAKE2b-256 checksum
How to use checksums
f180b15301c90cc90331bbc0c31db3ba4a13496a7b3521fdb3184872ceabd790
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page