Giter Club home page Giter Club logo

nuclear-waste-storage / captcha_solving_service Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m-niemiec/captcha_solving_service

0.0 0.0 0.0 63.51 MB

Captcha Solving Service is a mock-up SaaS that allows users to send their captcha images and receive solutions in simple text format. Project is divided into 4 parts. Scraping datasets for machine learning models, GUI for renaming collected images, captcha solving OCR and captcha solving API.

Home Page: http://18.189.161.236

License: MIT License

Shell 0.42% Python 98.55% Mako 0.62% Dockerfile 0.41%

captcha_solving_service's Introduction

Captcha Solving Service

captcha_solving_service_screen_main

This time I decided to create something bigger, with more depth to it in order to learn more.

My main concept was to create a product (mock-up SaaS) that would allow users to send their captcha images and receive solutions in simple text format.

In order to achieve this I had to solve several problems and divide my project into 4 parts.

Working on this project was very fun and fulfilling. I had many opportunities to work closer and explore more deeply things like creating GUI, design patterns, asynchronous programming and finally Docker and docker-compose with AWS and EC2.

Part I - Scraping Captcha Dataset:

captcha_solving_service_screen_1

Firstly I selected 2 example captcha types and with Scrapy I needed to gather enough data to have a learning dataset for my model.

After solving some problems with monkey patching MediaPipeline it went smoothly.

Part II - Captcha Renaming Tool:

captcha_solving_service_screen_2

After I gathered captcha images I had to come up with a better way of renaming them than the ones that are built in operating systems because of dataset sizes.

I decided to build an application with the help of Tkinter and Pillow. The app had several tools to make renaming captcha images easier and faster. Amongst others, it helped user with faster switching between images after assigning a new name, had options to increase or decrease size and contrast or convert captcha to black and white mode.

Part III - Captcha Solving OCR:

captcha_solving_service_screen_3

When all captcha images were renamed with proper solutions, it was time to actually build and save Machine Learning models with Tensorflow and Keras.

I needed three models, one to distinguish between captcha types and two for predicting proper solutions of those captcha types.

In this task, the book "Neural Network Projects with Python" written by James Loy and website keras.io with articles by A_K_Nain were really helpful.

Part IV - Captcha Solving API:

captcha_solving_service_screen_4

The final part of the whole project. I decided to go with Fast API for this task to also explore deeper asynchronous programming and PostgreSQL with SQLAlchemy for database tasks. For security, I used oauth2. I wanted to create an API so every potential "user" could get their captcha solved. I created several endpoints for things like, solving captcha, adding, deleting, viewing info about users and adding credits.

API was accepting CURL requests formdata with captcha images, which were processed by saved ML models from previous step and returning a solution. I also decided to write tests using pytest to make my life easier.

I Dockerized the whole API alongside PostgreSQL and PgAdmin using docker-compose.

As a final touch, I decided to host it on AWS with EC2. Here is address - http://18.189.161.236/

Example captcha images to solve:

captcha_solving_service_test_captcha_1 captcha_solving_service_test_captcha_2

Example API CURLs:

Test user: Username - test Password - test

Admin user: Username - admin Password - admin (for deleting users and adding more credits)

Solve Captcha:

curl -X POST '[URL]/upload_captcha' --header 'Authorization: Bearer [YOUR_TOKEN]' -F captcha_image=@/directory/file.jpeg"

Add User:

curl -X POST '[URL]/add_user' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{\"username\": \"[YOUR_USERNAME]\", \"email\": \"[YOUR_EMAIL]\", \"password\": \"[YOUR_PASSWORD]\"}'

Get Token:

curl -X POST '[URL]/get_token' -F username=[YOUR_USERNAME] -F password=[YOUR_PASSWORD]

Add Credits:

curl -X POST '[URL]/add_credit_balance' -H 'accept: application/json' -H 'Content-Type: application/json' --header 'Authorization: Bearer [ADMIN_TOKEN]' -d '{\"user_id\": [ID], \"credit_amount\": [CREDIT_AMOUNT]}'

Get Account Info:

curl -X POST '[URL]/get_account_info' --header 'Authorization: Bearer [YOUR_TOKEN]'

Delete User:

curl -X POST '[URL]/delete_user?delete_user_id=[ID]' --header 'Authorization: Bearer [ADMIN_TOKEN]'

If you would like to build API on your machine, you need to do following steps:

(you need to have docker and docker-compose installed on your machine)

  1. Download 2 files from repo:
    1. docker-compose-development.yml
    2. .env
  2. cd into download directory
  3. run docker-compose -f docker-compose-deployment.yml --env-file env up command to build and start images
  4. After build will finish, the API will be available on address http://127.0.0.1/ or http://0.0.0.0/

API is also available online on AWS EC2 on this address - http://18.189.161.236/

Some of the technologies used - Scrapy, Tkinter, Pillow, Py2app, Tensorflow, Keras, FastAPI, PostgreSQL, SQLAlchemy, pytest, Docker, docker-compose, AWS, EC2

It was really fun to work on this.

Thank You :-)

captcha_solving_service's People

Contributors

m-niemiec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.