Script+ Reader โ handwritten Indian prescription recognition
TrOCR (LoRA-merged) + LayoutLMv3 field pairing + curated Indian brandโgeneric vocabulary + beam-consensus abstention gate. The model runs inside this Space โ upload a prescription photo and get an explained, confidence-tiered reading.
Deploying (one-time, ~20 min)
Space repos on HF cap free storage at 1 GB โ too small for a merged TrOCR
checkpoint. So checkpoints live in a separate model repo and get pulled
onto the Space's disk automatically the first time rx_pipeline.py runs.
- Create the Space: huggingface.co/new-space โ SDK: Gradio.
Upload
app.py,rx_pipeline.py,requirements.txt,README.md. - Create a separate model repo: huggingface.co/new โ type Model,
e.g.
YOURNAME/scriptplus-checkpoints(private is fine). - Push your checkpoints there from Colab (Drive already mounted):
!pip -q install huggingface_hub from huggingface_hub import HfApi api = HfApi(token="hf_...your write token...") api.upload_folder(folder_path="/content/drive/MyDrive/rx_system/m_htr_merged", repo_id="YOURNAME/scriptplus-checkpoints", repo_type="model", path_in_repo="m_htr_merged") api.upload_folder(folder_path="/content/drive/MyDrive/rx_system/m2_model", repo_id="YOURNAME/scriptplus-checkpoints", repo_type="model", path_in_repo="m2_model") api.upload_file(path_or_fileobj="/content/drive/MyDrive/rx_system/abstention_gate.joblib", repo_id="YOURNAME/scriptplus-checkpoints", repo_type="model", path_in_repo="abstention_gate.joblib") - On the Space page โ Settings โ Variables and secrets:
- Add secret
HF_TOKEN= a read-scope token (needed if your model repo is private). - Add variable
RX_CKPT_REPO=YOURNAME/scriptplus-checkpoints(skip this if you kept the defaultshadowfurynon/scriptplus-checkpoints).
- Add secret
- Restart the Space. On first boot
rx_pipeline.pydownloads the checkpoints from the model repo into local disk automatically โ watch the Logs tab, this takes a few minutes the first time only.
Hardware
Free CPU tier works but a page takes ~2โ5 min (8 beams ร every crop is heavy). For demos, switch Space hardware to T4 small while presenting, then back to CPU.
Env knobs
RX_EXPAND_VOCAB=0โ curated-only vocabulary (recall ceiling-limited)RX_GATE_THโ abstention gate threshold (default 0.5)RX_CKPT_REPOโ HF model repo holding checkpoints (defaultshadowfurynon/scriptplus-checkpoints)HF_TOKENโ set as a Space secret if the checkpoint model repo is private
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ Ask for provider support