Delete README.md
Browse files
README.md
DELETED
|
@@ -1,101 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: KYC OCR (India)
|
| 3 |
-
emoji: 📄
|
| 4 |
-
colorFrom: blue
|
| 5 |
-
colorTo: green
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: "4.44.0"
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
license: mit
|
| 11 |
-
short_description: Extract fields from Indian PAN cards and cheques on CPU
|
| 12 |
-
---
|
| 13 |
-
|
| 14 |
-
# 🇮🇳 KYC Document OCR
|
| 15 |
-
|
| 16 |
-
A lightweight, CPU-friendly pipeline for extracting structured fields from
|
| 17 |
-
Indian KYC documents (PAN card, cheque) from images or PDFs.
|
| 18 |
-
|
| 19 |
-
Built on [RapidOCR](https://github.com/RapidAI/RapidOCR) — ONNX-runtime
|
| 20 |
-
deployment of PaddleOCR PP-OCRv4 models. No GPU needed.
|
| 21 |
-
|
| 22 |
-
## What it does
|
| 23 |
-
|
| 24 |
-
- **PDF or image input** (PyMuPDF rasterises PDFs at 300 DPI)
|
| 25 |
-
- **Document type auto-detection** via keyword + regex scoring
|
| 26 |
-
- **Cheque rotation correction** — detects sideways-scanned cheques (text
|
| 27 |
-
spans more vertically than horizontally) and rotates before MICR extraction
|
| 28 |
-
- **Format-spec validation** — PAN regex with 4th-character entity-type
|
| 29 |
-
lookup, IFSC regex, date normalisation, MICR positional parse
|
| 30 |
-
|
| 31 |
-
## Supported documents
|
| 32 |
-
|
| 33 |
-
| Document | Fields extracted |
|
| 34 |
-
|---|---|
|
| 35 |
-
| **PAN card** | PAN number, name, father's name (individual) / company name, DOB / date of incorporation, entity type (Individual / Company / HUF / Firm / Trust / etc.) |
|
| 36 |
-
| **Cheque** | Bank name, branch address, IFSC code, account number, 9-digit MICR code, cheque number, transaction code |
|
| 37 |
-
| **Aadhaar** | _Coming soon — recommended path: read the secure QR code via `pyzbar` rather than OCR_ |
|
| 38 |
-
| **Passport** | _Coming soon — recommended path: parse the MRZ via `passporteye`_ |
|
| 39 |
-
|
| 40 |
-
## How to use the Space
|
| 41 |
-
|
| 42 |
-
1. Drop a PDF or image into the upload box
|
| 43 |
-
2. Click **Extract fields**
|
| 44 |
-
3. View the structured output and raw OCR (for debugging)
|
| 45 |
-
|
| 46 |
-
The included example is a synthetic PAN with fake data so you can try it
|
| 47 |
-
without uploading real documents.
|
| 48 |
-
|
| 49 |
-
## Running locally
|
| 50 |
-
|
| 51 |
-
```bash
|
| 52 |
-
git clone <this-space-url>
|
| 53 |
-
cd <repo>
|
| 54 |
-
pip install -r requirements.txt
|
| 55 |
-
python app.py
|
| 56 |
-
```
|
| 57 |
-
|
| 58 |
-
Then open `http://127.0.0.1:7860`.
|
| 59 |
-
|
| 60 |
-
## Using `kyc_extract.py` directly as a library
|
| 61 |
-
|
| 62 |
-
```python
|
| 63 |
-
from kyc_extract import process, RapidOCR
|
| 64 |
-
|
| 65 |
-
engine = RapidOCR()
|
| 66 |
-
results = process("path/to/document.pdf", engine)
|
| 67 |
-
|
| 68 |
-
for page in results:
|
| 69 |
-
print(page["detected_type"]) # 'pan' or 'cheque'
|
| 70 |
-
print(page["fields"]) # structured dict
|
| 71 |
-
```
|
| 72 |
-
|
| 73 |
-
## Privacy
|
| 74 |
-
|
| 75 |
-
This is a public Space. **Do not upload real personal documents.** For
|
| 76 |
-
production KYC pipelines, fork this repo and deploy on your own private
|
| 77 |
-
infrastructure (DPDP Act and UIDAI guidelines require it for Aadhaar in
|
| 78 |
-
particular).
|
| 79 |
-
|
| 80 |
-
## Architecture notes
|
| 81 |
-
|
| 82 |
-
- All extraction is rule-based — no model is hardcoded to specific names,
|
| 83 |
-
banks, PANs, or addresses. The same script handles any PAN or any bank's
|
| 84 |
-
cheque.
|
| 85 |
-
- Document classification uses keyword + regex scoring; if confidence is
|
| 86 |
-
low, type is `unknown` and no extractor runs.
|
| 87 |
-
- For cheques in portrait-orientation PDFs (common when phones are held
|
| 88 |
-
vertically), the pipeline detects the layout anomaly and re-OCRs the
|
| 89 |
-
rotated image, merging text from both passes so address and IFSC don't
|
| 90 |
-
get lost in the rotation.
|
| 91 |
-
|
| 92 |
-
## Limitations
|
| 93 |
-
|
| 94 |
-
- English-only OCR — Hindi label text (`नाम/Name`) comes out garbled but
|
| 95 |
-
the pipeline has shape-based fallbacks so this doesn't break field
|
| 96 |
-
extraction. For full Hindi extraction, add `lang='hi'` to RapidOCR.
|
| 97 |
-
- MICR fonts are E-13B and not perfectly read by general OCR. The pipeline
|
| 98 |
-
reconstructs the 9-digit MICR from OCR fragments via positional parsing,
|
| 99 |
-
which works on most cheques but degrades on poor scans.
|
| 100 |
-
- Aadhaar and passport extractors are stubs. The proper approach uses QR
|
| 101 |
-
and MRZ respectively, not pure OCR.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|