Giter Site home page Giter Site logo

hrn-projects / amazon-captcha-solver Goto Github PK

View Code? Open in Web Editor NEW
28.0 2.0 13.0 36.72 MB

A TensorFlow (Deep Learning - CNN) based solution for tackling captcha when collecting data from Amazon.

License: GNU General Public License v3.0

Python 100.00%
captcha amazon-captcha captcha-solving captcha-solver python python3 tensorflow keras open-cv hrn-projects

amazon-captcha-solver's Introduction

GPLv3 License PyPi Python Versions

Amazon Captcha Solver

A Flask API based solution for tackling captcha when collecting data from Amazon.

This is a Flask API based solution to solve the captcha, by accepting the captcha image from POST request. The API then calls the captcha solving script and sends the solved captcha text in return.

The goal is to solve the captcha images from Amazon. Sample captcha image can be seen below -

a sample captcha image

How to use :

  1. Run the Flask API script -
python solve_api.py
  1. To check the status of API, call the default method by accessing its IP -
your_api_ip_address:5000    # '5000' being the default port for Flask Server, which hosts the API.
  1. To call the captcha solver function with 'requests' module and passing captcha image as file -
import requests

def captcha_uploader():
    # API URL with a call to function to solve captcha
    captcha_solver_api_url = 'your_api_ip_address:5000/solve'
    # opening the captcha image file as binary and putting it as value for key 'captcha'
    file = {'captcha': open('your_captcha_image_filepath','rb')}
    
    # Calling the API function as a 'POST' request with 'files' parameter
    response = requests.post(captcha_solver_api_url, files=file)
    print("Captcha file uploaded.")

    # Fetching the captcha text from API response.
    try:
        captcha_text = resp.json()['output']
    except:
        print("Response not in JSON format. Please check your API code.")
        captcha_text = "NA"
    
    return captcha_text

How to contribute :

  1. Please start with installing all the required packages from requirements file-
pip install -r requirements.txt
  1. Then to initially run the model on test_captchas, use following command -
python solve_captchas_with_model.py

P.S. Notes :

Regarding model file

The current model file is built after training some 4K training set captcha images. Training can performed on much more larger dataset for better results, but current results aren't bad either ๐Ÿ˜‰.

Regarding API code

The API works fine but can be enhanced further according to use cases. The API's reponses would highly depend upon the training quality of the model file.

amazon-captcha-solver's People

Contributors

dependabot[bot] avatar hrn-projects avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

amazon-captcha-solver's Issues

error

Traceback (most recent call last): File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 2464, in __call__ return self.wsgi_app(environ, start_response) File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 2450, in wsgi_app response = self.handle_exception(e) File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 1867, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\_compat.py", line 39, in reraise raise value File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\_compat.py", line 39, in reraise raise value File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\flask\app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Users\fabio\PycharmProjects\amazon-captcha-solver\solve_api.py", line 31, in solve_captcha img.save(os.path.join(image_file_path, img.filename)) File "C:\Users\fabio\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\werkzeug\datastructures.py", line 3066, in save dst = open(dst, "wb") FileNotFoundError: [Errno 2] No such file or directory: '/home/webspider/hrn/projects/amazon-captcha-solver-main\\test.jpg'

your python code works only on linux?

call the captcha solver function with 'requests'

Hi,

How do I use the captcha_uploader code to upload an image to get the predicted captcha text ? I want to consume the service using POSTMAN API tool, making a request with an image, I have moved it into the Captcha_Solver class in solve_captcha_with_model.py and it didn't work ? how can I use this as a service please

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.