This is a summary of the development process on API/web application for Rakuten AI API competition.

Goal: API/web application development with machine learning using Docker and cloud system

Tools: Python, Flask, Docker, Google Cloud Platform

Feature: Automatically detects human faces and apply mosaic effect

Below is the architecture of the application.

Firstly, we are going to develop the facial recognition part and the mosaic effect part on our local machine. After that, we are going to deploy it using Docker which enables us to wrap all the necessary stuff including framework, library and so on. By using Docker, we can avoid having unexpected errors among developers and different development stages. Those errors can be easily caused by, for example, version conflict or different environment we are using.

Thanks, Docker you are awesome.

This is the strategy.
1. Recieve HTTP request with POST method
2. Convert image file into binary data
3. The function applies the mosaic effect
4. Write out modified image data into a new image file
5. Return URL (web application) or binary data (API)

This is the snippet of the process.

You can find the rest of my codes on GitHub.

↑ git clone、move to the target directory

“docker build . -t auto_mosaic”
will make the Docker image.
(You can download Docker if you don’t have one)

“docker run -d -p 5000:5000 auto_mosaic”
will start your Flask application with the last line of the Dockerfile;
“CMD python3”
We set 5000 as the port number.
Then, make sure the application is running by accessing localhost:5000

Now, you are should be able to run the mosaic effect application with Flask on your local machine.

Thank you very much for reading.
I would be happy to see any comments or advice 🙂

Next post is how to deploy this application to GCP


Leave a Reply

Your email address will not be published.