Coder Social home page Coder Social logo

example-python-cv's Introduction

Example-Python-CV

tests deploy license

This is an example of service written in Python, it provides a base from which make other services related to image processing using OpenCV. The implementation uses gunicorn, Flask

Installation

To run this service locally, you require Python which can be downloaded here and you may require the Docker daemon as well, which can be easily installed with Docker Desktop. However, if you plan to run this service on the cloud, the best way is to fork this repo and edit the cd.yml file to deploy it with Continous Deployment. (CD) Also, after forking you can set the CD with your provider, it must be possible for sure.

Following the local installation, run the following commands in order:

git clone https://github.com/Vicente-G/Example-Python-CV
cd example-python-cv

Now you should be on the service folder, from where you can run it with either Python or Docker, depending on your needs.

Running

If you plan on editing this service to your needs, you may prefer Flask, as it can be continously tested with its debug mode. To run this example using Python, install the dependencies and run the dev script, like this:

pip install --user pdm
pdm sync
pdm run dev

In the other hand, if you plan to just run the service in your local server, the best option is to use containers, for reliability and security. With that on mind, Docker is your option. First enable the Docker daemon, and right after run these commands:

docker build -t example-python-cv .
docker run -p 8080:8080 -e PORT='8080' example-python-cv

In any way you run the service, it will block your terminal. Now, to test its responses, you can try any HTTP request emitter, such as Postman, Axios or cURL. The following example shows a GET request over the service with cURL

curl --head localhost:8080/status

If everything is working as intended, the answer to that response should be a 200, which means that everything is okay! (The 200 should be in the first line or so)

Requests

As this is just an example, this service only has one extra route asides from the status one. This service provides the route process, with the following command:

curl -X POST localhost:8080/process \
-d '{"image":"<your Base64 string encoding an image>"' \
-H 'Content-Type: application/json'

The output should be something with the following shape: (key changes to error if the processing fails)

{
    "image": "<a Base64 string encoding the processed image>"
}

Also, the following correspond to the equivalent action in axios:

const { image, error } = await axios.post(
    'localhost:8080/process',
    { image: '<your Base64 string encoding an image>' },
    {
        headers: {
            'Content-Type': 'application/json'
        }
    }
)

example-python-cv's People

Contributors

vicente-g avatar

Watchers

 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.