/transfinitte2022

Primary LanguagePythonApache License 2.0Apache-2.0

Transfinitte 2022

Problem Statement: [BharatX] Build a Family Tree

Team Name: Project ONN

Contributors:

Local Setup Instructions

Steps to setup the API:

  1. Clone the repo
  2. Change working directory
cd captch_solver
  1. Create a virtualenv
python -m venv venv
  1. Activate the created virtualenv
. venv/bin/activate
  1. Execute the following command:
sudo apt install tesseract-ocr
sudo apt install tesseract-ocr-tam
  1. Install all the requirements (Note: There are a lot of dependencies, hence it might take some time)
pip install -r requirements.txt
  1. Download the model files for CRAFT model from here and for TPS-ResNet-BiLSTM-Attn-case-sensitive from here and place them both inside the captch_solver folder.

  2. Change the Chrome Driver filepath in this line to the path where your Chrome Driver has been installed. (Download the Chrome Driver corresponding to your Google Chrome version here)

  3. Run the API using the following command (Note: Our captcha and transliteration model needs time to setup, it might take some time to get the API started)

python3 api.py
  1. Visit localhost:8000 to check if the API is working.
  2. To search any records, send a POST request to localhost:8000/getpdfinfo in the following JSON format.
{
    "name" : "<Some name>",
    "age" : "<Some number>",
    "fathername" : "<Some name>",
    "gender" : "<M or F or O>",
    "state" : "<Some state>",
    "district" : "<Some district>"
}

These requests take some time to process (~7 min), since we download the file each time and run OCR on it.

  1. We also have a UI through which you can enter the above information and a JSON will be returned in the console window of your browser. Visit this link to check that out.

A sample response from the API will look like this:

{
    "<EPIC NO>": {
        "info": {
            "age": <number>,
            "house_no": "<number>",
            "gender": "<M or F or O>",
            "name": "<name>",
            "father/husband": [
                "<name>",
                "<F or H>"
            ],
            "uniqueid": "<EPIC NO>"
        },
        "children": [<List of names>],
        "spouse": "<Name>",
        "parents": [<List of names>],
        "same": []
    }
}

The keys returned in this JSON are self-explanatory.

States supported

We can take requests for Tamil Nadu and NCT of Delhi currently. Automation scripts for Uttar Pradesh and West Bengal have been written, but have not been implemented in the API.

Novelty

  • We have not used any external API's for finding these family trees, and used only open-source software to build this app.
  • Our captcha solver can work for multilingual text too, which makes it a robust solver for many situations.
  • OCR accuracy during conversion of PDFs to text has been improved using special mathematical algorithms created from scratch.

Tech Stack

  • Selenium (for automation)
  • AI4Bharat Indic-Transliteration (translating between regional languages)
  • Resnet Bi-LSTM Attention (captcha text detection)
  • Tessaract OCR (captcha text recognition)

Main Files