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.

  1. Create the Space: huggingface.co/new-space โ†’ SDK: Gradio. Upload app.py, rx_pipeline.py, requirements.txt, README.md.
  2. Create a separate model repo: huggingface.co/new โ†’ type Model, e.g. YOURNAME/scriptplus-checkpoints (private is fine).
  3. 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")
    
  4. 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 default shadowfurynon/scriptplus-checkpoints).
  5. Restart the Space. On first boot rx_pipeline.py downloads 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 (default shadowfurynon/scriptplus-checkpoints)
  • HF_TOKEN โ†’ set as a Space secret if the checkpoint model repo is private
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support