Unter den Beispielen fĂŒr Azure auf GitHub wurde eines sehr interessant gefunden: die Bilderkennung auf dem Raspberry Pi, offline. Die Autoren schlagen vor, ein Modell fĂŒr maschinelles Lernen in einem der Azure-Clouddienste vorzubereiten und es dann auf einen Computer zu ĂŒbertragen, der die meiste Zeit keine Internetverbindung hat. Danach funktioniert die Mustererkennung offline. Die Entwickler haben ein Projekt fĂŒr zwei Plattformen vorbereitet: ARM32 (Raspberry Pi selbst) und AMD64 (jedoch ohne Webcam-UnterstĂŒtzung).
Nach dem Coronavirus-Hype haben wir beschlossen, das Beispiel anzupassen, um zu erkennen, ob eine Person eine Maske trĂ€gt oder nicht. Es wurde sofort klar, dass die Schritte zur Anpassung des Beispiels nicht ganz offensichtlich waren. In diesem Material werden wir nacheinander betrachten, wie dieses Beispiel zum einen geĂ€ndert werden kann, um mit unserem maschinellen Lernmodell zu funktionieren, und zum anderen kann es auf die AMD64-Plattform ĂŒbertragen werden. Nehmen wir an, unser Computer, auf dem das Modell lĂ€uft, steuert das Drehkreuz: Wenn eine Person eine Maske trĂ€gt, öffnet sich das Drehkreuz, wenn nicht, bleibt es geschlossen.
Alles ist schwierig...
Fast jeder Cloud-Anbieter verfĂŒgt ĂŒber eine Reihe von Tools fĂŒr maschinelles Lernen, und die Eintrittsbarrieren sind hĂ€ufig gering.
Azure Computer Vision, , : API, . Azure Custom Vision, , . , . - , , .
, . , "" , :
- , - , ;
- ;
- .
, :
- ;
- , . , "" 100 ?
?
, " ", " ". â . , " ". , Azure Custom Vision, , , .
: Azure IoT Edge . , :
- ;
- â ;
- , .. , ;
Azure IoT Edge
IoT Edge . , IoT Edge â Linux, "" , , , Docker- . IoT Edge Azure IoT Hub. IoT Edge , , Azure, IoT Edge , .
"" IoT Edge Linux, 2019 IoT Edge Windows 10 Enterprise LTSC â .
IoT Edge , "" Azure:
- Azure Functions ( )
- Azure Stream Analytics ( )
- Azure Machine Learning ( "")
- Azure Custom Vision ( )
- Azure SQL Server ( "")
Custom Vision. "" .
IoT Edge . , (), Microsoft HTTP, .. web-, .
Microsoft

-, USB , IoT Edge.
IoT Edge? , , IoT Hub, ( ) IoT Hub. "" .
IoT Hub. IoT Edge "" , . , Container Registry ( ).
, , :

- Camera: . "" ( ! ) HTTP ;
- AI: , . , , "" . Custom Vision;
- Display: , . , , , ( ).
, IoT Hub.
, . AMD64 , - - , , . , "" -, ARM32.
. AMD64 "" SenseHat, Raspberry Pi, , SenseHat, , - .
(Custom Vision)
Custom Vision ( Azure) New Project.
- Name â ;
- Description â ;
- Resource â Create new Cognitive Services;
- Classification Types â Multilabel, / , â ( " ")
- Domains â General (compact).
:
- , MaskOnFace;
- (" "), MaskNotOnFace â - , (, -, );
- , , (Negative).
.
Train, Advanced training , . Performace .
, , .
Probability Threshold â , . Probability Threshold = 90% , , 90%. , . , (/), "" " " "" "". , - " 89%". , "" "". Probability Threshold 90%, " 89%" "", " 91%" "".
- Recall () ;
- Precision () â .
â .
, .
(Publish), (Export â Dockerfile â Linux). IoT Edge.
- ( â ) AVX (, AVX , , grep avx /proc/cpuinfo) â tensorflow. AVX, , . . Intel NUC Core i5.
Ubuntu 20.04 LTS. , IoT Edge ( Microsoft?), .
, Edge. (~).
:
sudo apt-get update sudo apt-get install wget nano
:
wget https://packages.microsoft.com/config/ubuntu/20.04/prod.list mv prod.list microsoft-prod.list
sources.list.d, "" Microsoft:
sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/
Microsoft GPG:
wget https://packages.microsoft.com/keys/microsoft.asc cat microsoft.asc | gpg --dearmor > microsoft.gpg sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/
( â , apt " "):
sudo apt-get update sudo apt-get install moby-engine
IoT Edge:
sudo apt-get install iotedge
, ( Ubuntu 20.04 â ), . Ubuntu (18.04 â , , ) (, , ). GitHub. Latest release dpkg. libssl :
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl1.0/libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb sudo dpkg -i libssl1.0.0_1.0.2n-1ubuntu5_amd64.deb wget https://github.com/Azure/azure-iotedge/releases/download/1.0.10.4/libiothsm-std_1.0.10.4-1_ubuntu16.04_amd64.deb sudo dpkg -i libiothsm-std_1.0.10.4-1_ubuntu16.04_amd64.deb wget https://github.com/Azure/azure-iotedge/releases/download/1.0.10.4/iotedge_1.0.10.4-1_ubuntu16.04_amd64.deb sudo dpkg -i iotedge_1.0.10.4-1_ubuntu16.04_amd64.deb
IoT Edge , Azure. , :
sudo nano /etc/iotedge/config.yaml
, Azure device_connection_string provisioning. , , IoT Edge Azure.
Azure
IoT Edge IoT Hub, Azure. â .
IoT Hub IoT Edge . , , :
IoT Edge IoT Hub, .
IoT Edge :
- . -, USB. HTTP;
- , ( / / ). HTTP, ;
- (-). -, .
:

, , .
! Windows 10, IoT Edge.
- Visual Studio Code. Visual Studio;
- Azure IoT Edge Extension. Select IoT Hub, IoT Hub;
- Azure IoT Tools;
- Python 3.8.3. Add Python to PATH â Task 4;
- , , , Hyper-V . â , OK ;
- Docker for Windows â Task 5;
- Git Windows .
! Docker : bcdedit /set {current} hypervisorlaunchtype Auto .
! Hyper-V VirtualBox. , VirtualBox, : bcdedit /set {current} hypervisorlaunchtype off, "" Hyper-V Docker.
, :
git clone https://github.com/Azure-Samples/Custom-vision-service-iot-edge-raspberry-pi.git
, :
git checkout 6b3540f9b31121321f9e75d8df0ed86397c9324f
Visual Studio Code (File â Open Folder) . , . , .
, , . , , , . , , .
. â . â , , .
, .
.env
() , Azure:
- CONTAINER_REGISTRY_ADDRESS="__.azurecr.io"
- CONTAINER_REGISTRY_USERNAME="_"
- CONTAINER_REGISTRY_PASSWORD=""
deployment.template.json
- modules â camera-capture â env â RESIZE_WIDTH â 640, RESIZE_HEIGHT â 480
- modules â camera-capture â settings â image â ${MODULES.CameraCapture.amd64}
- modules â sensehat-display â env â THRESHOLD â value â 0.9
- modules â sensehat-display â settings â image â ${MODULES.SenseHatDisplay.amd64}, createOptions â HostConfig "PortBindings": { "8000/tcp": [ { "HostPort": "8000" } ] }
- modules â image â settings â image â ${MODULES.ImageClassifierService.amd64}
deployment.template_AMD64
.
ameraCapture\amd64.Dockerfile
AMD64 -, , , . .
CameraCapture.py
( Raspberry Pi), , . time.sleep(1.0) 1.0 0.1.
ImageClassifierService\amd64.Dockerfile
AMD64. .
labels.txt
, . Custom Vision, :
MaskNotOnFace MaskOnFace
model.pb
Custom Vision â .
SenseHatDisplay\amd64.Dockerfile
, .
SenseHatDisplay â . AMD64 SenseHat , , , , SenseHat, , - Python, .
.
SenseHatDisplay\module.json
platform , amd64:
"amd64": "./amd64.Dockerfile",
SenseHatDisplay\app ()
, . -, .
- custom.js
- index.htm
- jquery.js
- style.css
- DisplayManager.py
- MessageParser.py
- "". , :
- : IoT Edge, http://127.0.0.1:5012;
- â http://127.0.0.1:8000/status.
, - â , . , , . http://127.0.0.1:8000.
.
- VS Code View â Command Pallette â Azure IoT Edge: Set Default Target Platform for IoT Edge Solution amd64;
- Azure IoT Edge: Build and Push IoT Edge Solution. , IoT Edge;
- IoT Edge, config/deployment.json Create Deployment for Single device, , ;
- ( -!). IoT Edge Extension Start Monitoring D2C Message, .
IoT Edge UI - http://localhost:8000, -, . , , .

â , .
, , MaskNotOnFace, , .
- ...
, , IoT Edge . ( , , , AVX / tensorflow ). IoT Edge . . , :
- : iotedge list. ( );

- : iotedge logs _. , .
, IoT Edge, , ( Azure), IoT Edge .
?
IoT Edge , .
, , IoT Edge, , , , , " " - SQL Edge, .
IoT Edge Azure, .
â , , â .
, Azure , , , .
â , . sergant (at) quarta.ru.