An open-source machine learning project designed for recognizing and extracting metadata from South African ID documents. It implements document classification, OCR, structured field extraction and facial extraction and aims to be self hosted for data security and transparency.
# South African ID Card Information Extraction
A comprehensive solution for extracting and processing information from South African ID cards using Detectron2 for object detection.
## Running the Scripts
### Environment Setup
Before running any scripts, make sure to activate the correct conda environment:
```bash
conda activate detectron2_env
```
Alternatively, you can use the full path to the Python executable:
```bash
C:\Users\lfana\anaconda3\envs\detectron2_env\python.exe run_batch_inference.py
```
### Running Batch Inference
The `run_batch_inference.py` script processes multiple ID images and generates structured output. To run:
1. Activate the environment (as shown above)
2. Place your ID images in the appropriate directory:
- New IDs: `test_dataset/new_ids/`
- Old IDs: `test_dataset/old_ids/`
3. Run the script:
```bash
python run_batch_inference.py
```
The script will:
- Process all images in both directories
- Generate OCR results in JSON format
- Create text summaries for each ID
- Show progress with a progress bar
## Current Status (February 7, 2025)
### Development Environments
1. **Google Colab (Training Environment)**
- Used for model training and experimentation
- GPU acceleration available
- Jupyter notebook interface
- Shared model storage via Google Drive
2. **Local Windows (Inference Environment)**
- Used for production inference
- CPU-based processing
- Command-line interface
- Local file system storage
### Object Detection
- Model: Detectron2 Faster R-CNN
- Performance:
* AP (IoU=0.50:0.95): 52.30%
* AP50 (IoU=0.50): 89.64%
* AP75 (IoU=0.75): 53.40%
### OCR Pipeline
- Implemented Features:
* Dual OCR Engine Support (Tesseract + PaddleOCR)
* Field-specific preprocessing
* OCR visualization
* Results packaging (JSON/Text)
* Image-only field handling
### Latest Updates
- Added local inference script with dual OCR support
- Implemented comprehensive error handling
- Created detailed setup and usage documentation
- Added field-specific OC …