Skip to content

Demo repository to construct CI/CD with Azure IoT Edge, Azure Custom Vision, and GitHub Actions

License

Notifications You must be signed in to change notification settings

dzeyelid/edgeai-cicd-with-github-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Edge AI における CI/CD を GitHub で構成するデモ

このリポジトリは、【オンライン】エッジAI入門&活用シリーズ#3『AzureDevOps/GitHubでCI/CD』編 - connpass のセッションで利用します。

リポジトリの内容

参考資料

Azure Custom Vision によるイテレーション(モデル)のエクスポート

Cognitive Services における CI/CD

Azure IoT Edge

分類用の画像データセット

検証メモ

Custom Vision のエクスポート

手組での作業ログ

CUSTOM_VISION_ENDPOINT=
CUSTOM_VISION_PROJECT_ID=
CUSTOM_VISION_ITERATION_ID=
CUSTOM_VISION_EXPORT_PLATFORM="Dockerfile"
CUSTOM_VISION_EXPORT_FLAVOR="Linux"

# Export an iteration
curl -X POST -i -H "training-key: ${CUSTOM_VISION_TRAINING_KEY}" -H "content-length: 0" "https://${CUSTOM_VISION_ENDPOINT}/customvision/v3.3/training/projects/${CUSTOM_VISION_PROJECT_ID}/iterations/${CUSTOM_VISION_ITERATION_ID}/export?platform=${CUSTOM_VISION_EXPORT_PLATFORM}&flavor=${CUSTOM_VISION_EXPORT_FLAVOR}"

# Get an export
EXPORTS=$(curl -X GET -H "training-key: ${CUSTOM_VISION_TRAINING_KEY}" "https://${CUSTOM_VISION_ENDPOINT}/customvision/v3.3/training/projects/${CUSTOM_VISION_PROJECT_ID}/iterations/${CUSTOM_VISION_ITERATION_ID}/export")

# Download the export
DOWNLOAD_URI=$(echo ${EXPORTS} | jq -r ".[] | select(.platform == \"DockerFile\") | .downloadUri")
FILE_NAME=$(echo ${DOWNLOAD_URI} | sed -r "s/.*\/([^\/]*.zip)\?.*/\\1/g")
curl -o ${FILE_NAME} ${DOWNLOAD_URI}
unzip ${FILE_NAME} -d exported-model

IoT Edge によるエッジへのアプリケーション配布

IoT Hub にデバイス登録を済ませて置き、そのデバイスには name=environment, value=demo のタグを設定しておく。

手組みでの作業ログ

PAT_FOR_CONTAINER_REGISTRY=
CUSTOM_VISION_MODEL_VERSION=
IOT_HUB_NAME=
DEPLOYMENT_ID=

mkdir temp
pushd temp

DEPLOYMENT_JSON=$(cat ../iot-edge/deployment.json)
DEPLOYMENT_JSON=$(echo $DEPLOYMENT_JSON | jq ".content.modulesContent.\"\$edgeAgent\".\"properties.desired\".runtime.settings.registryCredentials.ghcr.password=\"${PAT_FOR_CONTAINER_REGISTRY}\"")
DEPLOYMENT_JSON=$(echo $DEPLOYMENT_JSON | jq ".content.modulesContent.\"\$edgeAgent\".\"properties.desired\".modules.\"custom-vision\".settings.image=\"ghcr.io/dzeyelid/edgeai-cicd-with-github-demo/custom-vision:${CUSTOM_VISION_MODEL_VERSION}\"")
DEPLOYMENT_JSON=$(echo $DEPLOYMENT_JSON | jq ".content.modulesContent.\"\$edgeAgent\".\"properties.desired\".modules.\"custom-vision\".version=\"${CUSTOM_VISION_MODEL_VERSION}\"")
echo $DEPLOYMENT_JSON | jq > iot-edge_deployment.json

az login
az extension add --name azure-iot
az iot edge deployment create --deployment-id ${DEPLOYMENT_ID} --hub-name ${IOT_HUB_NAME} --content ./iot-edge_deployment.json --target-condition "tags.environment='demo'"

popd

About

Demo repository to construct CI/CD with Azure IoT Edge, Azure Custom Vision, and GitHub Actions

Topics

Resources

License

Stars

Watchers

Forks

Packages