A passport parsing service based on ROI and Tesseract: input : image url/ local image path ouput : [roi]
$ pip install -r requirements.txt optional arguments:
--SUPER_RESOLUTION Image super resolution to enhance ocr accurracy(True/False).
--DRAW_BOX To draw ROI bounding box for each class(True/False)
--SAVE_PATH_BOX Path to save bounding box images
--CROP_SAVE To crop ROI just to check if cropping is good or not for OCR(True/False)
--CROP_SAVE_PATH Path to save cropped ROI
--LOCAL_IMG_PATH Local image path to extract ROI All the model downloading are doing in start.sh module.
- ROI detection model(uploaded on s3 bucket)
- Image super resolution model(uploaded on s3 bucket)
- eng.traineddata for OCR(Download during starting of the service)
- Latin.traineddata for OCR(Download during starting of the service)
postman-collection folder includes postman urls and request body. We have 2 request body one for testing service through image url and another one from local image path.
python app.pyBuild Image:
docker build -t passport-parsing .Docker Run:
docker run -d -p 5050:5000 image-idDocker Run with volume mount:
docker run -d -v ./input:/app/input -p 5050:5000 image-idUse this repo to setup ROI detection model and training on custom dataset:
https://github.com/project-anuvaad/ocr-toolkit/tree/ocr_toolkit/layout-model-training
{
"config": {
"language": {
"sourceLanguage": "en"
},
"superresolution": "False"
},
"output": [
{
"source": {
"Date of Birth": "01/11/1973",
"Date of Expiry": "01/05/2016",
"Date of Issue": "02/05/2006",
"First Name": "AISHWARYA",
"Gender": "F",
"Nationality": "INDIAN",
"Place of Birth": "MANGALORE KARNATAKA",
"Place of Issue": "MUMBAI",
"Surname": "RAI",
"passport no.": "F7802033"
}
}
]
}