Views
No views yet
benchmark_results.json).| Precision | Size | Accuracy (27-class) | Macro-F1 |
|---|---|---|---|
| bf16 | 193 MB | 96.45 | 0.965 |
| int8 | 103 MB | 96.43 | 0.965 |
| int4 | 60 MB | 95.22 | 0.955 |
Document (10 leaves)
├─ Letter (key: letter)
├─ Other document (key: other_document)
├─ Scan interpretation (key: scan_interpretation)
├─ Lab / diagnostic report (key: lab_diagnostic_report)
├─ OPD Consultation Record (key: opd_consultation_record)
├─ Discharge summary (key: discharge_summary)
├─ Insurance document (key: insurance_document)
├─ Form (key: form)
├─ Invoice / bill (key: invoice_bill)
├─ Certificate (key: certificate)
Card / credential (7 leaves)
├─ ABHA card (key: abha_card)
├─ Aadhaar card (key: aadhaar_card)
├─ PAN card (key: pan_card)
├─ Voter ID (key: voter_id)
├─ PMJAY / Ayushman (key: pmjay_ayushman)
├─ Insurance e-card (key: insurance_e_card)
├─ Other card (key: other_card)
Diagnostic imaging (5 leaves)
├─ X-ray (key: x_ray)
├─ CT (key: ct)
├─ MRI (key: mri)
├─ Ultrasound (key: ultrasound)
├─ Other (Diagnostic imaging) (key: other_diagnostic_imaging)
Body images (3 leaves)
├─ Skin / wound (key: skin_wound)
├─ Headshot (key: headshot)
├─ Other (Body images) (key: other_body_images)
Miscellaneous (2 leaves)
├─ Medication image (key: medication_image)
├─ Other (Miscellaneous) (key: other_miscellaneous)1from transformers import AutoModel
2from PIL import Image
3
4model = AutoModel.from_pretrained("ekacare/med-doc-classifier", trust_remote_code=True).eval()
5img = Image.open("doc.jpg")
6
7model.classify(img)1// example return value
2{
3 "l2": { "source": "flat", "key": "lab_diagnostic_report",
4 "value": "Lab / diagnostic report", "confidence": 0.97 },
5 "l1": { "value": "Document", "source": "inferred_from_flat_l2" },
6 "medical": { "value": "medical", "confidence": 0.99, "p_positive": 0.99 },
7 "handwritten": { "value": "printed", "confidence": 0.98, "p_positive": 0.02 }
8}1model.classify(img, scope="l1") # L1 group only (no L2)
2model.classify(img, scope="hierarchical") # L1 head → that group's leaf L2 head
3model.classify(img, l1="Document") # fix L1 → that group's leaf L2 head
4model.classify(img, top_k=3) # top-3 candidates for the multi-class headsmedical and handwritten are independent binary heads — disable them with medical=False / handwritten=False.1# pip install optimum-quanto
2from transformers.dynamic_module_utils import get_class_from_dynamic_module
3
4load_classifier = get_class_from_dynamic_module(
5 "modeling_siglip2_hier.load_classifier", "ekacare/med-doc-classifier")
6
7model = load_classifier("ekacare/med-doc-classifier", quantization="int4") # None | "int8" | "int4"
8model.classify(img)from modeling_siglip2_hier import load_classifier
inside the repo directory works too, and load_classifier(".", quantization="int8")
loads straight from the checkout.1@software{med_doc_classifier,
2 author = {{Eka Care}},
3 title = {Med Doc Classifier: hierarchical classification of health-app document uploads},
4 year = {2026},
5 url = {https://huggingface.co/ekacare/med-doc-classifier}
6}