How shiva2410/document_verification works
Project Type and Purpose
• This is a Python-based open-source library/tool for automated document verification (KYC) using AI/Computer Vision and OCR.
• Its core features are:
• Classify uploaded images into Aadhaar Card, PAN Card, Voter ID Card or Other Documents via a pre-trained RCNN model.
• Extract text content using Tesseract-OCR and Google OCR.
• Provide a ready-to-use library that can be plugged into customer onboarding pipelines.
File Structure Analysis
• Top-level files:
• .gitignore, LICENSE, README.md
• Three Python packages (one per document type):
• aadhaar_card/aadhaar_object.py
• pancard/opclass.py
• voter_card/voter_card.py
• No explicit “src” or “tests” directory—each package encapsulates its classification and OCR logic.
• Dependencies and configuration are declared in README; model weights likely loaded at runtime by these modules.
Key Components
a. Data Ingestion & Augmentation (Training Pipeline)
• Input: Raw customer document images (Aadhaar, PAN, Voter, Others).
• ImageDataGenerator (Keras) for upsampling: rotation, blurring.
• Dataset Split: training, validation.
b. Model Trainer
• Base RCNN convolutional layers (frozen).
• Custom fully connected layers + dropout.
• Training engine (Keras/TensorFlow backend).
• Model artifacts output (saved weights).
c. Model Evaluation
• Accuracy computation.
• Manual verification loop feeding back corrections.
d. Inference Engine (Library)
• DocumentClassifier core module (abstract): loads model weights.
• Per-document modules:
• aadhaar_object.py
• opclass.py (PAN)
• voter_card.py
• OCR Integrations:
• Local Tesseract
• Google OCR API
• Output: Document type + extracted fields.
e. Client Application / API Layer
• Upstream systems invoke the library (could be a web API, batch script or desktop app).
f. External Services
• Google OCR endpoint
• Possibly a database or message queue (not in file tree but typical in KYC pipelines).
Relationships and Interactions
• Training pipeline writes model artifacts to a model store or file system.
• Inference Engine reads model artifacts.
• Inference components call Tesseract and Google OCR, parse results.
• Client Application calls the Inference Engine API and receives classification + text.
• Manual verification feedback can update training data.
Architectural Patterns and Design Principles
• Modular design: one Python package per document class.
• Separation of concerns:
• Data augmentation & training
• Model inference
• OCR integration
• Reuse of pre-trained convolutional layers (transfer learning).
• Dependency injection for OCR providers (abstract interface, two implementations).
• Stateless inference library (can be scaled horizontally).
Essential Elements
• Clear labels on every component (e.g. “ImageDataGenerator”, “RCNN Trainer”, “aadhaar_object.py”).
• Annotations for key design decisions (e.g. “Frozen conv layers for transfer learning”, “Dropout to prevent overfitting”).