Handwriting recognition #839
Unanswered
DavidMStraub
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This is an AI-generated design doc. **I evaluated the options and discarded Kraken. Although it's a great tool, it needs too much manual intervention to fit our use case.
Two new optional endpoints complement the existing Tesseract OCR endpoint
(
POST /media/<handle>/ocr) for handwritten and historical documents.1. Kraken HTR (
POST /media/<handle>/handwriting)Kraken is an open-source (Apache 2.0) HTR engine optimised
for historical and non-Latin scripts. It runs fully self-hosted.
Configuration
KRAKEN_MODELSunset or empty → feature disabled;GET /metadata/reports"handwriting": false; endpoint returns 503.Model loading
htrmopo(bundled with kraken) on first request,stored in
~/.cache/kraken/, then the loaded model object is kept in amodule-level dict so subsequent requests incur no I/O cost.
Query parameters
modelKRAKEN_DEFAULT_MODELKRAKEN_MODELSformat"text"text/alto/pageNew files
gramps_webapi/api/resources/handwriting.pyMediaHandwritingResourcegramps_webapi/api/tasks.pymedia_handwritingCelery taskgramps_webapi/api/file.pyFileHandler.get_handwriting(model_name, output_format)Core logic sketch
Metadata exposure
Docker note
Kraken pins
torch<=2.10,>=2.4.0. The existingDockerfile.baseinstallstorchunpinned from the CPU index, which currently resolves to2.11.0+cpu—outside kraken's upper bound. pip therefore fetches
torch==2.10.0from thedefault PyPI index, which is the CUDA build.
Fix: pin the CPU torch to a version that satisfies kraken's constraint before
installing kraken:
pip install krakenthen finds a satisfying torch already present and skips it.2. Transkribus Metagrapho (
POST /media/<handle>/transkribus)Transkribus is a commercial cloud HTR service
with high accuracy on handwritten historical documents. GDPR-compliant (EU-hosted).
Credit-based pricing.
Configuration
TRANSKRIBUS_USERunset → feature disabled; endpoint returns 503.Credentials are per-server (not per-tree): they represent an organisation's
Transkribus account and must not be exposed via
GET /trees/-/config.Authentication
OIDC Resource Owner Password Credentials flow — no client ID/secret:
Token cached in-process; refreshed proactively before expiry.
Query parameters
model_idTRANSKRIBUS_DEFAULT_MODELformat"text"text/page/altoNew files
gramps_webapi/api/resources/transkribus.pyMediaTranskribusResourcegramps_webapi/api/transkribus.pyTranskribusClient(auth + submit + poll)gramps_webapi/api/tasks.pymedia_transkribusCelery taskAPI flow
POST /processing/v2/processeswith image +modelId→{ processId }GET /processing/v2/processes/{processId}untilstatus == "FINISHED"Metadata exposure
Comparison
/ocr/handwriting/transkribusTESSERACT_DATA_DIRKRAKEN_MODELSTRANSKRIBUS_USER/PASSWORD?lang=deu?model=kurrent?model_id=38230All reactions