/captcha_solver

Капча fssp.gov.ru

Primary LanguagePythonMIT LicenseMIT

Captcha Solver

This module built to simplify the process of training NN to solve text captcha. (Cyrillic captcha is also available)

Using of pre-existing model for captcha from fssp.gov.ru

Installation of captcha-solver api with pre-trained model for captcha from fssp.gov.ru could be as simple as:

git clone git@github.com:punkerpunker/captcha_solver.git
cd captcha_solver
docker-compose up -d --build captcha-solver

This command registers API on port 2103.

Model works with images in base64 format. You can pass an image to API in a query argument. Example:

import requests
from matplotlib import pyplot as plt

url = 'http://0.0.0.0:2103/solve?'

img_bytes = requests.get('https://is.fssp.gov.ru/refresh_visual_captcha/').json()['image'].split(',')[1]

params = {'image': img_bytes}
resp = requests.get(url, params=params)

resp.json()

>>> 'л9м45'

Full example can be founded in test_app.ipynb:

alt text

Train model on external data

Model training is pretty simple. You need to create (or find) markup and store it in data/captcha_train folder. Each image must be in a .png format and have its solution written in name.

After you have your markup in data/captcha_train, run:

docker-compose up --build captcha-trainer

After its done, your model will be located in model folder. Then just run API container as usual:

docker-compose up -d --build captcha-solver

And then you can use Captcha Solver with model trained on your training dataset.