Inspiration

Every packaged product in India must follow the Legal Metrology (Packaged Commodities) Rules, 2011 — MRP format, net quantity units, date formats, manufacturer address, consumer-care details, and even minimum font sizes. But enforcement officers still check all of this by eye, label by label. One missed undersized declaration can mean a non-compliant product stays on shelves. We wanted to give officers a second pair of eyes: snap a photo, get a compliance verdict in seconds.

What it does

DrishtiLM is a CPU-only AI scanner for packaged-commodity label compliance:

  • 📸 Upload or photograph a product label
  • 🔍 OCR + AI extraction reads MRP, net quantity, dates, manufacturer & consumer-care fields
  • 📏 Spatial calibration measures physical font height from a reference marker and checks it against Rule 7 minimum-size tables
  • ⚖️ A deterministic rule engine returns PASS / VIOLATION / NOT_ASSESSABLE per rule — a rule that couldn't run can never silently look like it passed
  • 📄 One-click printable PDF compliance report with Gazette-verified citations

How we built it

Pipeline: OpenCV preprocessing (deskew, binarization, ESPCN super-resolution for micro-text) → Tesseract/EasyOCR on CPU → hybrid Regex + spaCy NER field extractor → spatial calibration engine → deterministic Python rule engine → FastAPI backend → Next.js dashboard + PostgreSQL.

Key engineering: physical font measurement from a photo. Given a reference object of known width, we compute the pixel-per-mm ratio and convert each text box height to millimetres:

$$h_{mm} = \frac{h_{px}}{PPM}, \quad PPM = \frac{w_{px}}{w_{ref,mm}}$$

Measured heights are matched against Rule 7 tables (e.g. 1 mm / 2 mm / 4 mm tiers by pack size). Citations verified against the Gazette mirror carry a Verified: YES provenance badge; everything else is honestly labelled Verified: NO.

Stack: FastAPI, Next.js 16, PostgreSQL, Tesseract, spaCy, OpenCV, ReportLab, Docker Compose, GitHub Actions CI. 100% local CPU — no GPU, no paid APIs required.

Challenges we ran into

  • Phone-photo OCR: glare, skew and tiny fonts wrecked accuracy. Fixed with a deskew + super-resolution pass and a phone-photo eval set we built ourselves.
  • The dangerous error direction: reporting an unmeasurable label as "compliant." Solved structurally with a NOT_ASSESSABLE status — missing calibration data can never render as PASS.
  • Citation trust: LLMs hallucinate legal clauses. We grounded Rule 7 citations in the official Rules PDF mirror and badged every citation's verification state.

Accomplishments that we're proud of

  • A compliance tool that refuses to guess: our NOT_ASSESSABLE status makes it structurally impossible for an unmeasurable label to show as PASS.
  • Real millimetre measurement from a phone photo — spatial calibration against a reference card, checked against Rule 7 font-size tiers.
  • 100% CPU pipeline that runs on an ordinary laptop with zero GPU and zero paid APIs.
  • Honest citations: every legal claim badged Verified: YES/NO against the Gazette mirror.
  • Court-ready output: one-tap PDF reports plus JSON/CSV, with every officer correction audit-logged.
  • Full engineering bar: Docker one-command deploy, CI with lint + types + tests, and a phone-photo eval set proving it survives real market conditions.

What we learned

Accuracy without provenance is worthless in compliance tooling. The hardest part wasn't the ML — it was designing a system that says "I don't know" loudly instead of guessing, and proving every claim it makes.

What's next for DrishtiLM

Multilingual label support (Hindi + regional languages), on-device mobile scanning, and expanding coverage beyond Rule 7 to the full 2011 Rules schedule.

Built With

Share this project:

Updates

Submission history