Scan → Extract → Validate → Track → Export
ExpiryScanner is an open-source local AI system that extracts medicine, batch, and expiry information from pharmacy images and PDF documents, validates the results, keeps structured local records, and optionally exports tracking data to Google Sheets.
A credential-free, local-first reference project for extracting pharmacy inventory and expiry information from medicine images and scanned pharmacy bills.
Built from a real-world development/learning experience by Shivam Kumar.
Real pharmacy documents are messy:
- low-quality photographs
- scanned PDFs without a real text layer
- OCR substitutions
- handwritten marks
- wrapped invoice rows
- different supplier layouts
- missing fields
- column confusion such as HSN vs batch and MRP vs rate
- ambiguous dates
The project is designed to fail safely instead of producing plausible-looking bad inventory data.
Priority:
Item NameBatch NoEXP— highest priorityMFGMRPQuantity
Secondary fields may include supplier, manufacturer, pack, HSN, rate, GST, amount, deal/scheme and remarks.
Rules:
- missing data →
NA - uncertain core data →
REVIEW - never invent a date
- HSN is never batch
- GST is never expiry
- rate is never MRP
- MFG is
NAunless explicit evidence exists - human correction is the only source for persistent learning
IMAGE / PDF
|
v
High-resolution rendering
|
v
OCR + spatial evidence
|
+-----------+-----------+
| |
v v
IMAGE FLOW INVOICE FLOW
direct vision OCR/table evidence
| |
+-----------+-----------+
|
v
Candidate extraction
|
v
Deterministic validator
|
+-----------+-----------+
| | |
VALID REVIEW REJECT
| |
v v
Outputs Review queue
|
v
Human correction
|
v
Local learning
VALID— core checks pass.REVIEW— missing/ambiguous data, low confidence, expired date, or processing failure.
Reference configuration:
qwen3-vl:2b— local vision extractionllama3.1:8b— optional local text/reasoning check
The public demo does not require Google or cloud AI.
git clone https://github.com/snvx7576/ExpiryScanner.git
cd ExpiryScanner
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txtOn macOS:
brew install tesseractInstall Ollama separately and pull a local vision model:
ollama pull qwen3-vl:2bOptional:
ollama pull llama3.1:8bImage:
python -m src.pharmacy_expiry_ai.cli image /path/to/medicine.jpgPDF:
python -m src.pharmacy_expiry_ai.cli pdf /path/to/invoice.pdfWatcher:
python -m src.pharmacy_expiry_ai.cli watch ./inboxThe reference watcher routes .pdf files to the PDF flow and image formats to the image flow.
Optional. See:
docs/google-sheets.md
No credentials are included.
Human corrections may be stored locally as JSONL examples.
See:
docs/learning.md
Never publish private inventory, invoices, patients, addresses, tokens or API credentials.
Run before every public push:
python scripts/secret_scan.py .See SECURITY.md.
Shivam Kumar — @snvx7576
Repository: github.com/snvx7576/ExpiryScanner
This repository is the cleaned, credential-free learning/demo edition of a practical pharmacy inventory automation experiment developed by Shivam Kumar.
It is intended to help other developers build local expiry/inventory workflows while learning from the realities of noisy Indian pharmacy images and invoices.
This software is an extraction/automation aid. It is not a substitute for checking the physical medicine package or source invoice, and it is not medical or regulatory advice.
MIT.