Azureを使用しないAzureカスタムビジョン、または「マスクはどこにありますか?」顔(および体の他の部分)のマスクをどのように認識したか

GitHub上のAzureの一連の例の中で、非常に興味深いものが1つ見つかりました。それは、オフラインのRaspberryPiでの画像認識です。著者は、Azureクラウドサービスの1つで機械学習モデルを準備し、それをほとんどの時間インターネットに接続されていないコンピューターに転送することを提案しています。その後、パターン認識はオフラインで機能します。開発者は、ARM32(Raspberry Pi自体)とAMD64(ただし、Webカメラのサポートなし)の2つのプラットフォーム用のプロジェクトを準備しました。







コロナウイルスの誇大宣伝をきっかけに、人がマスクを着用しているかどうかを認識するために例を適応させることにしました。例を適応させる手順が完全に明白ではないことがすぐに明らかになりました。この資料では、この例を最初に機械学習モデルで機能するように変更し、次にAMD64プラットフォームに転送する方法を順次検討します。モデルが実行されているコンピューターが回転式改札口を制御していると仮定します。人がマスクを着用してくると、回転式改札口が開き、そうでない場合は閉じたままになります。







それは複雑です...



ほとんどすべてのクラウドプロバイダーには一連の機械学習ツールがあり、参入障壁は低いことがよくあります。







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.







- , . , - Raspberry Pi , .







, . AMD64 , - - , , . , "" -, ARM32.







. AMD64 "" SenseHat, Raspberry Pi, , SenseHat, , - .







(Custom Vision)



Custom Vision ( Azure) New Project.







  • Name — ;
  • Description — ;
  • ResourceCreate new Cognitive Services;
  • Classification TypesMultilabel, / , — ( " ")
  • 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.




! 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 (FileOpen 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


- "". , :









, - — , . , , . 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 , , , .







Microsoft — .







.







— , . sergant (at) quarta.ru.








All Articles