PP-OCRv6 ONNX + YOLO26n + ImageCache Smart OCR System. TCP Socket based architecture.
HTTP 11719
+------------------+------------------+
| |
v v
+---------------+ TCP 11720 +---------------+
| API Service | <---------------> | SOE Server |
| (FastAPI) | | (TCP Socket) |
+---------------+ +---------------+
| |
| /v1/* (OpenAI) | OCR Engine
| /* (Standard JSON) | YOLO Detector
+------------------+ | Image Cache
| | Device Profiler
v |
+-------------+ |
| Client | |
| (Adapter) | <---------+
+-------------+
| File | Description |
|---|---|
ocr_openai_api.py |
API Service (HTTP), dual mode: v1 OpenAI + Standard JSON |
smart_ocr_onnx.py |
SOE TCP Server (TCP 11720), core OCR engine |
adapter.py |
TCP Client, connects to SOE via TCP |
model_downloader.py |
Multi-source auto downloader |
image_cache.py |
Image cache (SHA1 + pHash, SQLite) |
yolo_detector.py |
YOLO26n detector (ONNX/OpenVINO) |
device_profiler.py |
Device profiling & dynamic config |
onnx_ocr_engine.py |
ONNX OCR engine |
ocr_utils.py |
OCR utilities |
ocr_compat_onnx.py |
Compat entry (TCP client) |
compare_images_gt730_v34.py |
Deep feature comparison |
convert_models.py |
Model conversion |
launcher.py |
Launcher v3.0 |
config.json |
Full config with TCP settings |
requirements.txt |
Dependencies |
pip install -r requirements.txt
# Optional: pip install openvino
# Optional: pip install onnxruntime-gpupython smart_ocr_onnx.py --port 11720
# or
python launcher.py --soepython ocr_openai_api.py --port 11719 --soe-port 11720
# or
python launcher.py --api# Standard API - OCR
curl -X POST http://localhost:11719/ocr \
-H "Content-Type: application/json" \
-d '{"image_path": "test.jpg"}'
# Standard API - YOLO
curl -X POST http://localhost:11719/yolo \
-H "Content-Type: application/json" \
-d '{"image_path": "test.jpg"}'
# OpenAI v1 API
curl -X POST http://localhost:11719/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "ocr-ppocr-v4",
"messages": [{"role": "user", "content": "recognize"}],
"image_url": "https://example.com/image.jpg"
}'| Method | Path | Description |
|---|---|---|
| GET | / |
Service info |
| GET | /health |
Health check |
| GET | /models |
Model list |
| POST | /ocr |
Full OCR recognition |
| POST | /yolo |
YOLO detection only |
| GET | /cache/stats |
Cache statistics |
| POST | /cache/clear |
Clear cache |
| GET | /profile |
Device profile |
| POST | /ping |
Ping SOE |
| Method | Path | Description |
|---|---|---|
| GET | /v1/models |
Model list |
| POST | /v1/chat/completions |
Chat completion (OCR) |
SOE TCP Server listens on 127.0.0.1:11720.
Request format: JSON + newline
{"cmd": "ocr", "image_path": "test.jpg", "image_id": "test"}Response format: JSON + newline
{"status": "ok", "image_id": "test", "content": [...], "yolo": [...]}Commands:
ocr- Recognize imagecache_stats- Cache statisticscache_clear- Clear cacheprofile- Device profileping- Heartbeatexit- Shutdown
Key settings in config.json:
{
"tcp": {
"soe_host": "127.0.0.1",
"soe_port": 11720,
"api_host": "0.0.0.0",
"api_port": 11719
}
}# SOE Server
python smart_ocr_onnx.py --host 127.0.0.1 --port 11720
# API Service
python ocr_openai_api.py --host 0.0.0.0 --port 11719 --soe-host 127.0.0.1 --soe-port 11720
# Single image (auto starts SOE)
python smart_ocr_onnx.py image.jpg
# Download only
python smart_ocr_onnx.py --downloadYOLO26n supports: text, table, formula, handwriting, stamp, qr_code, barcode.