File size: 8,248 Bytes
2b293a8
 
 
 
 
 
 
 
 
 
 
 
8ab75d1
f99e19b
 
 
8ab75d1
f99e19b
8ab75d1
f99e19b
2b293a8
 
 
f99e19b
 
 
8ab75d1
a42a7e2
2b293a8
 
 
 
 
 
 
 
 
 
a42a7e2
8ab75d1
a42a7e2
8ab75d1
a42a7e2
8ab75d1
2b293a8
8ab75d1
 
 
 
 
 
a42a7e2
2b293a8
 
 
 
 
 
 
 
 
a42a7e2
 
 
8ab75d1
a42a7e2
2b293a8
8ab75d1
 
2b293a8
8ab75d1
2b293a8
 
 
 
 
 
8ab75d1
2b293a8
 
 
8ab75d1
2b293a8
 
 
 
 
 
 
8ab75d1
a42a7e2
 
 
8ab75d1
 
2b293a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f99e19b
 
 
8ab75d1
ec08603
2b293a8
8ab75d1
2b293a8
8ab75d1
f99e19b
8ab75d1
2b293a8
8ab75d1
2b293a8
 
8ab75d1
 
f99e19b
ec08603
f99e19b
ec08603
2b293a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8ab75d1
ec08603
2b293a8
 
 
 
 
 
 
 
 
 
 
 
 
ec08603
f99e19b
ec08603
f99e19b
8ab75d1
 
2b293a8
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---
title: DocIQ - Intelligent Document Processing
emoji: 🧠
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: "1.40.0"
python_version: "3.10"
app_file: app.py
pinned: false
---

# 🧠 DocIQ β€” Intelligent Document Processing

[![Python](https://img.shields.io/badge/Python-3.10%2B-blue.svg)](https://www.python.org/)
[![Streamlit](https://img.shields.io/badge/Streamlit-1.40%2B-FF4B4B.svg)](https://streamlit.io/)
[![EasyOCR](https://img.shields.io/badge/EasyOCR-PyTorch-green.svg)](https://github.com/JaidedAI/EasyOCR)
[![License](https://img.shields.io/badge/License-MIT-purple.svg)](LICENSE)
[![HF Space](https://img.shields.io/badge/πŸ€—%20Live%20Demo-HuggingFace-orange.svg)](https://huggingface.co/spaces/Goutam112/Text_Extracted)

**DocIQ** is an Intelligent Document Processing (IDP) platform that transforms document images into structured, searchable, and exportable information.

Upload a document image, select a built-in sample, or capture an image using your webcam. DocIQ performs OCR, evaluates recognition confidence, visualizes detected text, extracts entities, detects sensitive information, and exports the results in multiple formats.

---

## ✨ Features

| Feature                    | Description                                                                         |
| -------------------------- | ----------------------------------------------------------------------------------- |
| 🎯 **OCR Accuracy Score**  | Confidence-weighted accuracy grade from A+ to D                                     |
| πŸ–ΌοΈ **Visual Canvas**      | Bounding boxes, confidence heatmap, and reading-order overlay on the original image |
| πŸ”Ž **Keyword Search**      | Instantly search and highlight words on the document canvas                         |
| πŸ—‚οΈ **Entity Extraction**  | Automatically detect dates, amounts, invoice numbers, emails, and phone numbers     |
| πŸ›‘οΈ **PII Redaction**      | Detect and mask sensitive information such as Aadhaar, PAN, and credit-card numbers |
| 🧬 **Semantic Embeddings** | Generate 2D word-cluster visualizations using sentence-transformers with PCA/t-SNE  |
| πŸ“€ **Multi-Format Export** | Export searchable PDFs, annotated PDFs, JSON, CSV, plain text, and ZIP bundles      |
| πŸ“Έ **Camera Scanner**      | Capture documents directly through the webcam when the scanner is enabled           |

---

## πŸš€ Quick Start

### Run Locally

```bash
git clone https://github.com/Goutam16-Withcode/DocIQ---Intelligent-Document-Processing.git
cd DocIQ---Intelligent-Document-Processing
pip install -r requirements.txt
python -m streamlit run app.py
```

Open:

```text
http://localhost:8501
```

### πŸ€— Live Demo

[DocIQ β€” Hugging Face Space](https://huggingface.co/spaces/Goutam112/Text_Extracted?utm_source=chatgpt.com)

---

## πŸ”„ How It Works

```text
Upload / Camera Capture
        ↓
Display Original Image
        ↓
Image Preprocessing
        β”œβ”€β”€ EXIF orientation correction
        β”œβ”€β”€ Automatic deskew
        β”œβ”€β”€ CLAHE contrast enhancement
        β”œβ”€β”€ Shadow removal
        └── Unsharp-mask sharpening
        ↓
EasyOCR Neural Inference
        β”œβ”€β”€ Primary OCR pass
        └── High-sensitivity fallback pass
        ↓
Structured Document Output
        β”œβ”€β”€ Bounding boxes
        β”œβ”€β”€ Confidence analysis
        β”œβ”€β”€ OCR quality grade
        β”œβ”€β”€ Entity extraction
        β”œβ”€β”€ PII detection/redaction
        └── Multi-format export
```

---

## πŸ“Š OCR Quality Grades

|  Grade | Accuracy | Meaning                                         |
| :----: | :------: | ----------------------------------------------- |
| **A+** |  90–100% | Exceptional recognition confidence              |
|  **A** |  80–89%  | High recognition confidence                     |
|  **B** |  68–79%  | Good recognition with possible minor errors     |
|  **C** |  50–67%  | Moderate recognition; manual review recommended |
|  **D** |   < 50%  | Low recognition; better image quality may help  |

> **Note:** The grade is an application-level confidence metric and should not be interpreted as a formal benchmark of OCR accuracy against ground-truth annotations.

---

## 🧠 Processing Pipeline

DocIQ separates the image shown to the user from the image transformations used internally for OCR.

### 1. Image Acquisition

Documents can be provided through:

* πŸ“ File upload
* πŸ§ͺ Built-in sample documents
* πŸ“Έ Webcam capture

### 2. Preprocessing

The OCR pipeline can apply several image-processing operations:

* EXIF orientation correction
* Deskewing
* CLAHE contrast enhancement
* Shadow removal for camera images
* Sharpening

These transformations are performed internally to improve OCR recognition while preserving the original document for visualization.

### 3. OCR

DocIQ uses **EasyOCR with PyTorch** to detect and recognize text.

The OCR output contains:

* Detected text
* Bounding boxes
* Confidence scores
* Reading order information

### 4. Information Extraction

The recognized text is further processed to identify structured information such as:

* Dates
* Currency amounts
* Invoice numbers
* Email addresses
* Phone numbers

### 5. PII Detection

Potentially sensitive identifiers can be detected and optionally redacted, including:

* Aadhaar numbers
* PAN numbers
* Credit-card numbers

### 6. Semantic Analysis

Recognized words can be converted into semantic embeddings and projected into a 2D visualization using dimensionality-reduction techniques such as PCA or t-SNE.

---

## πŸ“€ Export Formats

DocIQ supports multiple output formats:

| Format             | Use Case                                     |
| ------------------ | -------------------------------------------- |
| **Searchable PDF** | Searchable version of the extracted document |
| **Annotated PDF**  | Document with OCR annotations                |
| **JSON**           | Structured OCR and entity data               |
| **CSV**            | Tabular extraction results                   |
| **TXT**            | Plain-text OCR output                        |
| **ZIP**            | Bundle of multiple generated outputs         |

---

## πŸ“ Project Structure

```text
DocIQ/
β”œβ”€β”€ app.py              # Main Streamlit application
β”œβ”€β”€ requirements.txt    # Python dependencies
└── src/
    β”œβ”€β”€ preprocessor.py # Image enhancement pipeline
    β”œβ”€β”€ ocr_engine.py   # EasyOCR engine and OCR metrics
    β”œβ”€β”€ visualizer.py   # Bounding boxes, heatmap, reading order
    β”œβ”€β”€ extractor.py    # Entity and invoice field extraction
    β”œβ”€β”€ embedder.py     # Semantic embeddings and clustering
    β”œβ”€β”€ exporter.py     # PDF, JSON, CSV, ZIP export
    └── sample_docs.py  # Built-in sample document generator
```

---

## βš™οΈ Technology Stack

* **Python 3.10+**
* **Streamlit**
* **PyTorch**
* **EasyOCR**
* **OpenCV**
* **NumPy**
* **Pandas**
* **Sentence Transformers**
* **PCA / t-SNE**
* **ReportLab**
* **JSON / CSV processing**

---

## πŸ›‘οΈ Privacy

DocIQ is designed with local processing in mind.

OCR processing, image preprocessing, and embedding generation are performed within the application environment. The application does not intentionally send uploaded document images or extracted text to external APIs as part of the core processing pipeline.

When deploying the application to a hosted environment such as Hugging Face Spaces, uploaded data is processed within that hosted runtime. Users should therefore avoid uploading sensitive documents unless they understand the hosting environment and its data-retention policies.

---

## πŸ€— Hugging Face Space

**Live Demo:**

[Open DocIQ on Hugging Face](https://huggingface.co/spaces/Goutam112/Text_Extracted?utm_source=chatgpt.com)

---

## πŸ“„ License

MIT License β€” open source and free to use.

---

## πŸ”— Project Repository

[DocIQ GitHub Repository](https://github.com/Goutam16-Withcode/DocIQ---Intelligent-Document-Processing?utm_source=chatgpt.com)

---

Check out the configuration reference at [Hugging Face Spaces Configuration Reference](https://huggingface.co/docs/hub/spaces-config-reference?utm_source=chatgpt.com)