đ Indian ID Validator
This project offers a robust computer - vision pipeline for classifying, detecting, and extracting text from Indian identification documents. It supports various IDs such as Aadhaar, PAN Card, Passport, Voter ID, and Driving License, powered by YOLO11 models and PaddleOCR.
đ Quick Start
The Indian ID Validator uses deep - learning techniques to achieve multiple tasks on Indian ID documents:
- Classify different ID types (e.g.,
aadhar_front
, passport
) with the Id_Classifier
model.
- Detect specific fields (e.g., Aadhaar Number, DOB, Name) using type - specific YOLO11 detection models.
- Extract text from detected fields via PaddleOCR with image pre - processing (upscaling, denoising, contrast enhancement).
Supported ID Types:
- Aadhaar (front and back)
- PAN Card (front)
- Passport (front)
- Voter ID (front and back)
- Driving License (front and back)
⨠Features
Model Composition
The pipeline consists of several models, each tailored for specific tasks in the ID validation process. These models can be downloaded from their respective Ultralytics Hub links in various formats (e.g., PyTorch, ONNX, TensorRT) for deployment in different environments.
Model Name |
Type |
Description |
Link |
Id_Classifier |
YOLO11l - cls |
Classifies the type of Indian ID document (e.g., Aadhaar, Passport). |
Ultralytics Hub |
Aadhaar |
YOLO11l |
Detects fields on Aadhaar cards (front and back), such as Aadhaar Number, DOB, and Address. |
Kaggle Notebook |
Driving_License |
YOLO11l |
Detects fields on Driving Licenses (front and back), including DL No, DOB, and Vehicle Type. |
Ultralytics Hub |
Pan_Card |
YOLO11l |
Detects fields on PAN Cards, such as PAN Number, Name, and DOB. |
Ultralytics Hub |
Passport |
YOLO11l |
Detects fields on Passports, including MRZ lines, DOB, and Nationality. |
Ultralytics Hub |
Voter_Id |
YOLO11l |
Detects fields on Voter ID cards (front and back), such as Voter ID, Name, and Address. |
Ultralytics Hub |
Model Details
Here is a detailed breakdown of each model, including the classes they detect and their evaluation metrics on a custom Indian ID dataset.
Model Name |
Task |
Classes |
Metrics |
Id_Classifier |
Image Classification |
aadhar_back , aadhar_front , driving_license_back , driving_license_front , pan_card_front , passport , voter_id |
Accuracy (Top - 1): 0.995, Accuracy (Top - 5): 1.0 |
Aadhaar |
Object Detection |
Aadhaar_Number , Aadhaar_DOB , Aadhaar_Gender , Aadhaar_Name , Aadhaar_Address |
mAP50: 0.795, mAP50 - 95: 0.553, Precision: 0.777, Recall: 0.774, Fitness: 0.577 |
Driving_License |
Object Detection |
Address , Blood Group , DL No , DOB , Name , Relation With , RTO , State , Vehicle Type |
mAP50: 0.690, mAP50 - 95: 0.524, Precision: 0.752, Recall: 0.669 |
Pan_Card |
Object Detection |
PAN , Name , Father's Name , DOB , Pan Card |
mAP50: 0.924, mAP50 - 95: 0.686, Precision: 0.902, Recall: 0.901 |
Passport |
Object Detection |
Address , Code , DOB , DOI , EXP , Gender , MRZ1 , MRZ2 , Name , Nationality , Nation , POI |
mAP50: 0.987, mAP50 - 95: 0.851, Precision: 0.972, Recall: 0.967 |
Voter_Id |
Object Detection |
Address , Age , DOB , Card Voter ID 1 Back , Card Voter ID 2 Front , Card Voter ID 2 Back , Card Voter ID 1 Front , Date of Issue , Election , Father , Gender , Name , Point , Portrait , Symbol , Voter ID |
mAP50: 0.917, mAP50 - 95: 0.772, Precision: 0.922, Recall: 0.873 |
For additional details, refer to the model - index
section in the YAML metadata at the top of this README.
đĻ Installation
-
Clone the Repository:
git clone https://huggingface.co/logasanjeev/indian - id - validator
cd indian - id - validator
-
Install Dependencies:
Ensure Python 3.8+ is installed, then run:
pip install -r requirements.txt
The requirements.txt
includes ultralytics
, paddleocr
, paddlepaddle
, numpy==1.24.4
, pandas==2.2.2
, and others.
-
Download Models:
Models are downloaded automatically via inference.py
from the Hugging Face repository. Ensure config.json
is in the root directory. Alternatively, use the Ultralytics Hub links above to download models in formats like PyTorch, ONNX, etc.
đģ Usage Examples
Python API
Basic Usage
Use Id_Classifier
to identify the ID type:
from ultralytics import YOLO
import cv2
model = YOLO("models/Id_Classifier.pt")
image = cv2.imread("samples/aadhaar_front.jpg")
results = model(image)
for result in results:
predicted_class = result.names[result.probs.top1]
confidence = result.probs.top1conf.item()
print(f"Predicted Class: {predicted_class}, Confidence: {confidence:.2f}")
Output:
Predicted Class: aadhar_front, Confidence: 1.00
Advanced Usage
Use inference.py
for classification, detection, and OCR:
from inference import process_id
result = process_id(
image_path="samples/aadhaar_back.jpg",
save_json=True,
output_json="detected_aadhaar_back.json",
verbose=True
)
import json
print(json.dumps(result, indent=2))
Output:
{
"Aadhaar": "996269466937",
"Address": "S/O Gocala Shinde Jay Bnavani Rahiwasi Seva Sangh ..."
}
Processing a Passport with Visualizations
Process a passport image to classify, detect fields, and extract text, with visualizations enabled:
from inference import process_id
result = process_id(
image_path="samples/passport_front.jpg",
save_json=True,
output_json="detected_passport.json",
verbose=True
)
import json
print("\nPassport Results:")
print(json.dumps(result, indent=4))
Visualizations:
The verbose=True
flag generates visualizations for the raw image, bounding boxes, and each detected field with extracted text. Below are the results for passport_front.jpg
:
Type |
Image |
Raw Image |
 |
Output with Bounding Boxes |
 |
Detected Fields:
Field |
Image |
Address |
 |
Code |
 |
DOB |
 |
DOI |
 |
EXP |
 |
Gender |
 |
MRZ1 |
 |
MRZ2 |
 |
Name |
 |
Nationality |
 |
Nation |
 |
POI |
 |
Output:
Passport Results:
{
"Nation": "INDIAN",
"DOB": "26/08/1996",
"POI": "AMRITSAR",
"DOI": "18/06/2015",
"Code": "NO461879",
"EXP": "17/06/2025",
"Address": "SHER SINGH WALAFARIDKOTASPUNJAB",
"Name": "SHAMINDERKAUR",
"Nationality": "IND",
"Gender": "F",
"MRZ1": "P<INDSANDHU<<SHAMINDER<KAUR<<<<<<<<<<<<<<<<<",
"MRZ2": "NO461879<4IND9608269F2506171<<<<<<<<<<<<<<<2"
}
Terminal
Run inference.py
via the command line:
python inference.py samples/aadhaar_front.jpg --verbose --output - json detected_aadhaar.json
Options:
--model
: Specify model (e.g., Aadhaar
, Passport
). Default: auto - detect.
--no - save - json
: Disable JSON output.
--verbose
: Show visualizations.
--classify - only
: Only classify ID type.
Example Output:
Detected document type: aadhar_front with confidence: 0.98
Extracted Text:
{
"Aadhaar": "1234 5678 9012",
"DOB": "01/01/1990",
"Gender": "M",
"Name": "John Doe",
"Address": "123 Main St, City, State"
}
đ Documentation
Colab Tutorial
Try the interactive tutorial to test the model with sample images or your own:
Open in Colab
Links
- Repository: [Hugging Face](https://huggingface.co/logasanjeev/indian - id - validator)
- Models:
- Tutorial: Colab Notebook
- Inference Script: [inference.py](https://huggingface.co/logasanjeev/indian - id - validator/blob/main/inference.py)
- Config: [config.json](https://huggingface.co/logasanjeev/indian - id - validator/blob/main/config.json)
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a branch:
git checkout -b feature - name
.
- Submit a pull request with your changes.
Report issues or suggest features via the [Hugging Face Issues](https://huggingface.co/logasanjeev/indian - id - validator/discussions) page.
đ License
This project is under the MIT License.