
Hi !
Today’s post will be mostly focused on code. And on the main tasks
- Merge and create a new docker definition file.
- Merge Azure IoT project files with the exported Azure Custom Vision project
- Update the main Python app to run as Azure IoT Module and also perform Computer Vision analysis.
Azure IoT Module Docker
Let’s start with the docker file. The following docker file
- Uses an ARM32V7 with Python 3.7 installed
- Install requirements from the requirements.txt file. This includes the Azure IoT req: azure-iot-device~=2.0.0
- The install the required libraries to perform Custom Vision tasks. I know this maybe part of the requirements.txt file. I’ll upgrade this in next iteration.
- Opens the 80 port
- Run the app from the python file [main.py]
FROM arm32v7/python:3.7-slim-buster
WORKDIR /app
COPY requirements.txt ./
RUN pip install -r requirements.txt
# Code added to support Custom Vision app in the Azure IoT Module
RUN apt update && apt install -y libjpeg62-turbo libopenjp2-7 libtiff5 libatlas-base-dev libgl1-mesa-glx
RUN pip install absl-py six protobuf wrapt gast astor termcolor keras_applications keras_preprocessing --no-deps
RUN pip install numpy==1.16 tensorflow==1.13.1 --extra-index-url 'https://www.piwheels.org/simple' --no-deps
RUN pip install flask pillow --index-url 'https://www.piwheels.org/simple'
# Expose the port
EXPOSE 8089
COPY . .
# use default launch for the python app
# Run the flask server for the endpoints
CMD python -u main.py
Good start, now let’s merge files.
Merging files
I copied all the Custom Vision ARM32v7 export files to the root of the Azure IoT module. We don’t need the app.py file, so the final list this one.
- cvexport.manifest
- Dockerfile.amd64
- Dockerfile.arm32v7
- Dockerfile.arm64v8
- Dockerfile.amd64.debug
- Dockerfile.arm32v7.debug
- Dockerfile.arm64v8.debug
- labels.txt
- main.py
- metadata_properties.json
- model.pb
- module.json
- predict.py
- requirements.txt

Now let’s work to the Python app.
Python app
The final code is running with 2 main threads:
- Register and interact with the Azure IoT environment
- Run an WebApp for Computer Vision
So far, so good. In the next post, I’ll deploy and test the module on an Azure IoT Device and start to think on adding some configuration options, and refactor and improve!
Resources
- Azure Custom Vision
- Azure Custom Vision Documentation
- Azure IoT Tools
- Deploy your first IoT Edge module to a virtual Linux device
Happy coding!
Greetings
El Bruno
More posts in my blog ElBruno.com.
More info in https://beacons.ai/elbruno
Azure ☁ IoT
- Install ☁ Azure IoT on Raspberry Pi
- Deploy ☁ Azure Blob Storage on IoT Edge, lessons learned
- Connect to ☁ Azure Blob Storage on IoT Edge using Microsoft Azure Storage Explorer
- Lesson learned and tips on how to install Azure IoT Edge on Ubuntu on a Raspberry Pi
- Azure IoT Explorer, in preview and awesome
- Mapping a local ☁ Azure IoT Edge folder module with an Edge device folder 📁
- Creating a folder 📂 in the docker definition in an ☁ Azure IoT Edge
- Granting access to Raspberry Pi GPIO from an ☁ Azure IoT Edge Module
Create an Azure IoT Module using Raspberry Pi and Grove Sensors
- Raspberry Pi + Grove Sensors, read temperature and humidity values
- Raspberry Pi + Grove Sensors, send temperature and humidity values as telemetry to Azure IoT Hub
- Raspberry Pi + Grove Sensors, create a Azure IoT Module to send temperature and humidity values as telemetry to Azure IoT Hub
- Raspberry Pi + Grove Sensors, publish and use the Azure IoT Module
- Raspberry Pi + Grove Sensors, notes on build and configuration
- Raspberry Pi + Grove Sensors, details on how to send a telemetry message and sample messages
Create an Azure IoT Module from Azure Custom Vision project
- Create and export a Custom Vision Project as Docker image
- Analyze the content of the CV Docker image
- Create and analyze an Azure IoT Module
- Merge the CV project as an Azure IoT Module
- Deploy to an Azure IoT device and test the CV module
- Send telemetry for each analyzed image
- Add digital twin configuration to the Azure IoT module (coming soon)
¿Con ganas de ponerte al día?
En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:
- Si tienes ganas de ponerte al día con Front End (ES6, Typescript, React, Angular, Vuejs…) te recomendamos nuestros Máster Front End: https://lemoncode.net/master-frontend#inicio-banner
- Si te quieres poner al día en Backend (stacks .net y nodejs), te aconsejamos nuestro Bootcamp Backend: https://lemoncode.net/bootcamp-backend#bootcamp-backend/banner
- Y si tienes ganas de meterte con Docker, Kubernetes, CI/CD…, tenemos nuestro Bootcamp Devops: https://lemoncode.net/bootcamp-devops#bootcamp-devops/inicio
1 comment