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.
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
Y utilizando un comando cURL podemos probar el análisis de la imagen en local en la RPI!
Happy coding!
Saludos @ Toronto
El Bruno
References
- Custom Vision
- Docker Desktop
- Raspberry Pi
- Custom Vision + Azure IoT Edge on a Raspberry Pi 3
- Balena Docker Files for Raspberry Pi 3
My Posts
- Object recognition with Custom Vision and ONNX in Windows applications using WinML
- Object recognition with Custom Vision and ONNX in Windows applications using WinML
- Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, drawing frames
- Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, calculate FPS
- Can’t install Docker on Windows 10 Home, need Pro or Enterprise
- Running a Custom Vision project in a local Docker Container
- Analyzing images in a Console App using a Custom Vision project in a Docker Container
- Analyzing images using PostMan from a Custom Vision project hosted in a Docker Container
Windows 10 and YOLOV2 for Object Detection Series
- Introduction to YoloV2 for object detection
- Create a basic Windows10 App and use YoloV2 in the camera for object detection
- Transform YoloV2 output analysis to C# classes and display them in frames
- Resize YoloV2 output to support multiple formats and process and display frames per second
- How to convert Tiny-YoloV3 model in CoreML format to ONNX and use it in a Windows 10 App
- Updated demo using Tiny YOLO V2 1.2, Windows 10 and YOLOV2 for Object Detection Series
- Alternatives to Yolo for object detection in ONNX format