#CustomVision – Compilar el proyecto de CustomVision en #Docker en una #RaspberryPi

Buenas !

Después de compilar y utilizar el modelo exportado de CustomVision.ai en Windows y Linux, el siguiente paso es intentarlo en una RaspberryPi (RPI). Desde hace un tiempo RPI soporta docker, así que intentare tomar la imagen de Linux y modificar la misma para que funcione en la RPI.

Este es el contenido del [DockerFile] original que se ha exportado para Linux

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

En este archivo se utiliza una imagen base de python 3.5 para Linux. Navegando en los repositorios de Docker Hub y leyendo en la comunidad de Docker, he encontrado algunas imágenes base para RPI de Balena (link), see references.

La imagen que utilizare se llama [balenalib/raspberrypi3]. La misma solo posee Linux, sin nada de software instalado. Me he basado en parte  de los ejemplos de [Custom Vision + Azure IoT Edge on a Raspberry Pi 3] para instalar a mano el software necesario para que un proyecto de CustomVision.ai funcione en RPI.

FROM balenalib/raspberrypi3

RUN apt-get update &&  apt-get install -y \
        python3 \
        python3-pip \
        build-essential \
        python3-dev \
        libopenjp2-7-dev \
        libtiff5-dev \
        zlib1g-dev \
        libjpeg-dev \
        libatlas-base-dev \
        wget 

RUN pip3 install --upgrade pip 
RUN pip3 install pillow numpy flask tensorflow

RUN pip3 install flask 
RUN pip3 install pillow
RUN pip3 install numpy
RUN pip3 install tensorflow

ADD app /app

EXPOSE 80

WORKDIR /app

CMD python3 app.py

El proceso completo de compilación de la imagen en la RPI tarda unos 10 o 15 minutos, así que es la excusa perfecta para tomar un café, un te, o lo que gustes.

01 docker raspberry pi build

Una vez que el proceso esta completo, ya podemos ver la imagen en la lista de imágenes locales en Docker en RPI. Es el momento de ejecutar la misma, en el puerto 8080

02 docker raspberry pi image built

Y utilizando un comando cURL podemos probar el análisis de la imagen en local en la RPI!

01 raspberry pi docker image analyzed

Happy coding!

Saludos @ Toronto

El Bruno

References

My Posts

  1. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  2. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  3. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, drawing frames
  4. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, calculate FPS
  5. Can’t install Docker on Windows 10 Home, need Pro or Enterprise
  6. Running a Custom Vision project in a local Docker Container
  7. Analyzing images in a Console App using a Custom Vision project in a Docker Container
  8. Analyzing images using PostMan from a Custom Vision project hosted in a Docker Container

Windows 10 and YOLOV2 for Object Detection Series

Leave a comment

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 )

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.

%d bloggers like this: