WofoAI commited on
Commit
4065562
·
verified ·
1 Parent(s): 2aec074

Delete README.md

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