#CustomVision – Running a Custom Vision project in a local #Docker Container

Hi !

So now that I have Docker running in Windows 10, it’s time to use a Custom Vision model in Windows hosted in Docker container.

There are 2 version available to export from CustomVision.ai for each one the projects: Linux or Windows

00 CV exported to docker

I could not sucessfully built the Windows version, so I’ll work with the Linux one. Once exported the zip file have a set of python files to tun the model, the model file (model.pb) and a Dockerfile to build the docker image.

FROM python:3.5

ADD app /app

RUN pip install –upgrade pip
RUN pip install -r /app/requirements.txt

# Expose the port
EXPOSE 80

# Set the working directory
WORKDIR /app

# Run the flask server for the endpoints
CMD python app.py

The image uses Python 3.5, and the build command is as simple as

docker build -t elbruno/cvmarvel:3.0 .

05 CV docker build image in windows

After a couple of seconds, the image is build in the local store

docker image ls

07 Docker local images

Once I have my IMAGE ID, it’s time to start the image. For this demo, I’ll use the port 8080

docker run -p 127.0.0.1:8080:80 -d ddd1623ee694

And then I can submit an image using Invoke-WebRequest and view the results directly in PowerShell

Invoke-WebRequest -uri “http://127.0.0.1:8080/image” -Method Post -Infile “D:\docker\test01.jpg” -ContentType ‘image/jpg’

06 CV running and testing an image on docker

In order to get the complete output of the POST request, I must add an OutFile into the PowerShell comand. And in the complete output we can see some Iron Fist and Venom results!

Invoke-WebRequest -uri “http://127.0.0.1:8080/image” -Method Post -Infile “D:\docker\test01.jpg” -Outfile “D:\docker\result.json” -ContentType ‘image/jpg’

08 docker results in visual studio code

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

Advertisements

21 thoughts on “#CustomVision – Running a Custom Vision project in a local #Docker Container”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.