More Related Content Similar to Osc fukuoka xAI Meetup Similar to Osc fukuoka xAI Meetup(20) Osc fukuoka xAI Meetup1. Open Source x AI
2020-11-28
Open Source Conference
2020 Online/Fukuoka
Yuta Ishibashi & Tsukasa Kato
2. Profile
• Yuta Ishibashi / 石橋 裕太
• TOYOTA MOTOR KYUSHU, INC.
Future technology & Business DEV.
• xAI Meetup 主催
• https://rupic.hatenablog.com/
• https://www2.slideshare.net/rupic
3. Profile
• Tsukasa Kato / 加藤 司
• 日本ビジネスシステムズ株式会社
シニアエキスパート
• Microsoft MVP for Microsoft Azure
• https://tsukatoh.hatenablog.com/
• https://www.slideshare.net/tsukasakatou9
19. Agenda
• Azure Cognitive Services
• Custom Vision
• Kubernetes
• Kubernetes-based Serverless
• KEDA
OpenSource x AI の実現方法を知っていただく
21. • Microsoft が提供するAIサービス群。
• 開発者が直接的なAIやデータサイエンスのスキルや知識がな
くても利用できるAPI、SDKを提供。
• 現状サービスカタログとしては意思決定、視覚、音声、言語、
Web検索の5つに分類される
Cognitive Services
22. Cognitive Services
22
Decision Language Speech Vision Web Search
Bing SearchComputer Vision
Custom Vision
Face
Form Recognizer
Video Indexer
Speech to Text
Text to Speech
Speech Translation
Speaker Recognition
Immersive Reader
Language
Understanding
QnA Maker
Text Analytics
Translator Text
Anomaly Detector
Content Moderator
Personalizer
Metrics Advizor
↑
Marcketplace
から作成
25. • TensorFlow でエクスポートできるオプション
• TensorFlow
• TensorFlow Lite
• TensorFlow Lite Float16
• TensorFlow.js
• SavedModel
TensorFlow export
TensorFlow Download Files
• Cvexport.manifest
• Labels.txt
• Metadata_properties.json
• Model.pb
26. • Dockerfile でエクスポートできるオプション
• Linux
• Windows
• ARM (Raspberry Pi 3)
Dockerfile export
Dockerfile(Linux) Download Files
• app
• app.py
• cvexport.manifest
• labels.txt
• metadata_properties.json
• model.pb
• predict.py
• azureml
• README.txt
• score.py
• Dockerfile
• README.txt
27. Dockerfile
FROM python:3.7-slim
RUN pip install -U pip
RUN pip install --no-cache-dir numpy~=1.17.5 tensorflow~=2.0.2 flask~=1.1.2 pillow~=7.2.0
COPY app /app
# By default, we run manual image resizing to maintain parity with CVS webservice prediction results.
# If parity is not required, you can enable faster image resizing by uncommenting the following lines.
# RUN apt-get update && apt-get install -y --no-install-recommends libglib2.0-bin
# RUN pip install opencv-python-headless
# Expose the port
EXPOSE 80
# Set the working directory
WORKDIR /app
# Run the flask server for the endpoints
CMD python -u app.py
28. Docker Build
> docker build -t customvision .
[+] Building 4.3s (10/10) FINISHED
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.2s
=> => transferring dockerfile: 673B 0.1s
=> [internal] load metadata for docker.io/library/python:3.7-slim 3.5s
=> [internal] load build context 0.4s
=> => transferring context: 5.12MB 0.4s
=> [1/5] FROM docker.io/library/python:3.7-slim@sha256:ac0c17ada735be16aae9f4b91ba564a6566c 0.0s
=> CACHED [2/5] RUN pip install -U pip 0.0s
=> CACHED [3/5] RUN pip install --no-cache-dir numpy~=1.17.5 tensorflow~=2.0.2 flask~=1.1.2 0.0s
=> CACHED [4/5] COPY app /app 0.0s
=> CACHED [5/5] WORKDIR /app 0.0s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:0c4e8db0777165b012e0d54d549f19292bc5a2b94e8d55861b1f4eabf694d067 0.0s
=> => naming to docker.io/library/customvision 0.0s
34. Horizontal Pod Autoscaler(HPA)
• Kubernetes クラスターのメトリック サーバーを使用して、
Podのリソースの需要をモニターし、 アプリケーションで
必要なリソースが増えるとその需要を満たすためにレプリ
ケーションコントローラー、デプロイ、レプリカセット内
のポッドの数を自動的にスケーリング
• また、リソースが不要になったときにスケールインできる
• Kubernetes 標準APIオブジェクトとコントローラとして実
装されている
43. KEDA
(Kubernetes-based Event Driven Autoscaling Component)
K8sでイベント駆動型の
Podレベルオートスケールを可能にするフレームワーク
• Red HatとMicrosoftのエンジニアリングチームのコラボ
レーションの結果として開始されたプロジェクト
• Kubernetesクラスターにインストールしてイベントベース
のコンテナースケーリングを有効にすることができるオープ
ンソースコンポーネントとして定義される
• CPUメトリックスとメモリを活用してコンテナをゼロからス
ケーリングし、Kubernetes機能を拡張する
46. KEDA
• Kubernetesのスケーリング「Horizontal pod autoscaler
(HPA)」はPodのCPUやメモリ消費量で調整される
• KEDAは非HTTPなイベントに連動してクラスターへのデプロ
イを自動スケールできる
• HPAなどのKubernetesコンポーネントとネイティブに統合
され、クラウドとエッジの両方で実行できる
• KEDAがZero Scale in/outを行い、他はHPAがScale in/out
する
• 様々なスケーラーが用意されており、今後も追加予定
48. Scalers
• ActiveMQ Artemis
• Apache Kafka
• AWS CloudWatch
• AWS Kinesis Stream
• AWS SQS Queue
• Azure Bob Storage
• Azure Event Hubs
• Azure Log Analytics
• Azure Monitor
• Azure Service Bus
• Azure Storage Queue
• CPU
• Cron
• External
• External Push
• Google Cloud Platform
Pub/Sub
• Huawei Cloudeye
• IBM MQ
• Liiklus Topic
• Memory
• Metrics API
• MySQL
• NATS Streaming
• PostgreSQL
• Prometheus
• RabbitMQ Queue
• Redis Lists
• Redis Streams
50. HelmでKEDAをデプロイ
1. Helm repoを追加
2. Helm repoをアップデート
3. KEDAのHelm chartをインストール
$ helm repo add kedacore https://kedacore.github.io/charts
$ helm repo update
$ kubectl create namespace keda
$ helm install keda kedacore/keda --namespace keda
53. Azure Functions Core Toolsのインストール
• Azure Functions Core Toolsをインストールすることで
Kubernetes上でAzure Functionsが利用可能となる
• 以前はスケールも自分での実装が必要だったが、KEDAを使
うことでスケールの実装が不要となった
• インストールするには以下のコマンドを投入する
※要作業端末へのAzure Functions Core Toolsインストール
$ func kubernetes install --namespace keda
56. DEMO Architecture
Azure Kubernetes Service
Nodes
Web Application
(Pod)
Custom Vision
(Pod)
Storage Account
BLOB
Model
download
Container build/Deploy Custom
Vision
Image upload Webhook
image recognition
Upload
Send slack
BLOB
trigger
BLOB URL
58. • Azure Cognitive Services
• https://docs.microsoft.com/ja-jp/azure/cognitive-services/
• モバイルデバイスで使用するためにモデルをエクスポートする
• https://docs.microsoft.com/ja-jp/azure/cognitive-services/custom-
vision-service/export-your-model
• Custom Vision Serviceを使用してエッジで画像の分類を実行する
• https://docs.microsoft.com/ja-jp/azure/iot-edge/tutorial-deploy-
custom-vision
• KEDA
• https://keda.sh
• Azure Functions Core Tools
• https://docs.microsoft.com/ja-jp/azure/azure-functions/functions-
run-local?tabs=macos%2Ccsharp%2Cbash
参考URL