YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
KYC Document Corner Detector
Lightweight document segmentation model trained on KYC documents (Aadhaar, PAN, passports, visas) from the Jwalit/moire-docs dataset.
Model Details
| Property | Value |
|---|---|
| Architecture | MobileNetV3-Small encoder + upsampling decoder |
| Task | Binary segmentation (document vs background) |
| Training | CPU only, 8 epochs |
| Images | 461 (391 train, 70 val) |
| Best Val IoU | 74.79% |
| Model size | ~10 MB |
| Labels | Self-supervised via OpenCV contour detection |
How It Works
- Input: Raw KYC document image (any size)
- Segmentation: Model predicts binary mask of document region
- Corner Detection: OpenCV contour extraction finds 4 corners from mask
- Perspective Transform: Crops to document boundaries
Self-Supervised Label Generation
Labels are generated automatically using classical computer vision:
- Grayscale β Gaussian blur β Adaptive thresholding
- Morphological closing connects text regions
- Largest contour extraction β 4-corner approximation
No manual annotation required.
Files
| File | Description |
|---|---|
pytorch_model.bin |
Trained model weights |
config.json |
Model configuration |
inference_pipeline.py |
Complete inference script (crop + rotate) |
train_rotation_classifier.py |
Script to train rotation classifier |
Usage
import torch
from inference_pipeline import SegModel, predict_corners
model = SegModel()
model.load_state_dict(torch.load("pytorch_model.bin", map_location="cpu"))
corners = predict_corners(model, "your_document.jpg")
Related Model
- Rotation Classifier: https://huggingface.co/Jwalit/kyc-document-rotation-classifier
- 4-class classifier: 0Β°, 90Β°, 180Β°, 270Β°
- Run
train_rotation_classifier.pyto train on your CPU
Pipeline
Raw Image β SegModel β Mask β Contours β 4 Corners β Crop
β
RotModel β Classify Rotation β Correct Orientation
- Downloads last month
- 53
Inference Providers NEW
This model isn't deployed by any Inference Provider. π Ask for provider support