Files
sunshineandsunshine 6b052da423 PR A: Pipeline Backend, YOLO to OCR multi-process, CPU auto-allocation (#10)
* feat(pipeline): multi-process YOLO→OCR pipeline backend

- server.py: FastAPI gateway, 3-level mp.Queue pipeline, round-robin dispatch
- worker.py: YOLO character detection worker (core-pinned, single-threaded)
- ppocr_worker.py: PP-OCRv5 recognition worker with pre-warm cache
- evaluate.py: select_fixed3 box selection from scripts/tools/

- Smart CPU core allocation: N_YOLO = cores/4, N_OCR = cores/2
- config.json auto-created on first run (_auto + _cores metadata)
- /health endpoint: {status:'starting'|'ok', workers:N, ready_workers:N}
- Worker watchdog: auto-restart crashed OCR workers
- Shutdown cleanup: _shutdown event + try/finally for orphaned processes

- one_click_start.ps1: pipeline dep check (fastapi/uvicorn/psutil) non-blocking
- setup_backend.py: smoke test includes pipeline deps
- requirements-backend-cpu/gpu.txt: +fastapi, uvicorn[standard], psutil

- README: pipeline architecture + auto CPU allocation
- .gitignore: +config.json, server logs

Minimal verification:
  python -m py_compile backend/server.py backend/worker.py backend/ppocr_worker.py backend/evaluate.py  # OK
  python backend/server.py  →  GET /health  →  {'status':'ok','workers':12,'ready_workers':12}

* fix: review feedback - timeout cleanup, watchdog, health, paddleocr

- handle_direct/handle_direct_url: clean pending_requests on TimeoutError
- _worker_watchdog: always check p.is_alive(), remove ready_count bypass
- /health: add alive_workers field (count is_alive)
- start_backend.ps1: include paddleocr in import check

---------

Co-authored-by: sunshine <qt22260@gmail.com>
2026-06-15 20:57:57 +08:00

0 lines
0 B
Python