File size: 3,463 Bytes
58e5648
 
8202ba2
 
 
 
 
 
 
 
 
 
 
 
58e5648
8202ba2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2b604f0
8202ba2
 
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
---
license: apache-2.0
library_name: pytorch
pipeline_tag: image-classification

tags:
- vision-transformer
- pytorch
- computer-vision
- image-classification
- document-classification
- identity-documents
- multi-task-learning
- vit
---

# Multi-Head Vision Transformer for Indian Identity Document Classification

> **Document Classification Module of the LLaVA ID Extraction Project**

This repository contains a fine-tuned Vision Transformer (ViT-Base) model that simultaneously predicts:

- πŸ“„ Document Type
- πŸͺͺ Document Side (Front / Back)
- πŸ—ΊοΈ Issuing State

using a shared Vision Transformer backbone with three independent classification heads.

This model serves as the **first component** of the larger **LLaVA ID Extraction** project, whose goal is to build an end-to-end AI pipeline for automated identity document understanding, information extraction, and verification.

---

# Project Overview

Current Pipeline

```
Identity Document

        β”‚

        β–Ό

Multi-Head Vision Transformer βœ…

        β”‚

        β”œβ”€β”€ Document Type

        β”œβ”€β”€ Front / Back

        └── State

        β”‚

        β–Ό

OCR (Planned)

        β”‚

        β–Ό

LLaVA Information Extraction (Planned)

        β”‚

        β–Ό

Identity Verification (Planned)

        β”‚

        β–Ό

Fraud Detection (Planned)
```

---

# Model Details

## Backbone

- Google ViT Base Patch16 224

## Architecture

Shared Vision Transformer encoder with three task-specific classification heads:

1. Document Type Classification
2. Document Side Classification
3. State Classification

## Framework

- PyTorch
- Hugging Face Transformers

---

# Dataset

The model was trained on a synthetic dataset containing Indian identity document images with annotations for:

- Document Type
- Document Side
- Issuing State

The dataset includes multiple document categories and image variations suitable for supervised multi-task learning.

---

# Training Configuration

| Parameter | Value |
|-----------|------|
| GPU | NVIDIA Tesla T4 |
| Epochs | 4 |
| Optimizer | AdamW |
| Scheduler | Cosine Annealing |
| Mixed Precision | FP16 |
| Image Size | 224 Γ— 224 |
| Backbone | ViT Base Patch16 224 |

---

# Results

| Task | Accuracy |
|------|---------:|
| Document Type | **100%** |
| Document Side | **100%** |
| State | **100%** |
| Combined Prediction | **100%** |

These results were obtained on the held-out validation split of the synthetic dataset.

---

# Repository Contents

```
multihead_vit_best.pth
label_mappings.json
training.ipynb
```

---

# Loading the Model

```python
import torch

model.load_state_dict(
    torch.load(
        "multihead_vit_best.pth",
        map_location="cpu"
    )
)

model.eval()
```

---

# Future Roadmap

This model represents the **document classification module** of the broader **LLaVA ID Extraction** project.

Future additions include:

- OCR integration
- LLaVA-based information extraction
- Identity verification
- Document forgery detection
- Fraud risk analysis
- Interactive Gradio demo

---

# Limitations

The model was trained exclusively on synthetic identity document images.

Although it achieves excellent performance on the held-out synthetic validation set, additional fine-tuning and evaluation on real-world document scans and photographs are recommended before production deployment.

---

# GitHub

GitHub repository:

**https://github.com/IshankAggarwal09/llava_id_extraction**