Successfully reported this slideshow.
Your SlideShare is downloading. ×

Open Source x AI

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Ml.NET
Ml.NET
Loading in …3
×

Check these out next

1 of 59 Ad

More Related Content

Slideshows for you (20)

Similar to Open Source x AI (20)

Advertisement

More from Tsukasa Kato (20)

Recently uploaded (20)

Advertisement

Open Source x AI

  1. 1. Open Source x AI 2020-11-28 Open Source Conference 2020 Online/Fukuoka Yuta Ishibashi & Tsukasa Kato
  2. 2. Profile • Yuta Ishibashi / 石橋 裕太 • TOYOTA MOTOR KYUSHU, INC. Future technology & Business DEV. • xAI Meetup 主催 • https://rupic.hatenablog.com/ • https://www2.slideshare.net/rupic
  3. 3. Profile • Tsukasa Kato / 加藤 司 • 日本ビジネスシステムズ株式会社 シニアエキスパート • Microsoft MVP for Microsoft Azure • https://tsukatoh.hatenablog.com/ • https://www.slideshare.net/tsukasakatou9
  4. 4. 38 Categories 296 Services + more
  5. 5. AIって難しい…😢
  6. 6. AIってお金がかかる…😢
  7. 7. AI をもっと身近に もっと簡単に 自分の得意な分野に ”AI という手段” を 掛け合わせてみよう!!
  8. 8. AI is for everyone it's so easy
  9. 9. Agenda • Azure Cognitive Services • Custom Vision • Kubernetes • Kubernetes-based Serverless • KEDA OpenSource x AI の実現方法を知っていただく
  10. 10. Azure Cognitive Services
  11. 11. • Microsoft が提供するAIサービス群。 • 開発者が直接的なAIやデータサイエンスのスキルや知識がな くても利用できるAPI、SDKを提供。 • 現状サービスカタログとしては意思決定、視覚、音声、言語、 Web検索の5つに分類される Cognitive Services
  12. 12. 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 から作成
  13. 13. • コンピュータービジョンモデルを自分好みにカスタマイズし て作成するサービス • 画像をアップロードしてラベル付けするだけでトレーニング を開始することができる • 生成したモデルデータはエクスポートが可能 • CoreML (iOS) • TensorFlow (Android) • ONNX (Windows) • Dockerfile • Vision AI Dev Kit • エクスポートはDomainsをcompactにする必要がある Custom Vision
  14. 14. Custom Vision
  15. 15. • TensorFlow でエクスポートできるオプション • TensorFlow • TensorFlow Lite • TensorFlow Lite Float16 • TensorFlow.js • SavedModel TensorFlow export TensorFlow Download Files • Cvexport.manifest • Labels.txt • Metadata_properties.json • Model.pb
  16. 16. • 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
  17. 17. 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
  18. 18. 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
  19. 19. Kubernetes
  20. 20. Kubernetes • コンテナーアプリケーションを管理するためのオーケスト レーションツール • 自動デプロイ、スケーリング、アプリ・コンテナーの運用 自動化 • Webコンソールが用意されており、GUIでの管理が可能 • Google が社内のオーケストレーションツール「Borg」を 元に開発 • CNCFに寄贈され管理されておりオープンソースで提供さ れている • マイクロサービスを構築する基盤として採用される事が多 い
  21. 21. Kubernetes Architecture
  22. 22. Kubernetes managed services Google Kubernetes Engine Azure Kubernetes Service Amazon Elastic Container Service for Kubernetes IBM Cloud Kubernetes Service Alibaba Cloud Container Service for Kubernetes Rancher NetApp Kubernetes Service
  23. 23. Cluster Autoscaler • 追加容量が必要になった場合は新しいノードが自動的に追 加され、不要になれば削除される • 実行するワークロードの量に基づいてクラスタのサイズを 自動的に変更 • リソース制約のためにノードでスケジュールできないPod を監視 • ノードプール単位で機能 • Horizontal Pod Autoscaler(HPA)と連携して機能してノー ドとポッドの管理を行う
  24. 24. Horizontal Pod Autoscaler(HPA) • Kubernetes クラスターのメトリック サーバーを使用して、 Podのリソースの需要をモニターし、 アプリケーションで 必要なリソースが増えるとその需要を満たすためにレプリ ケーションコントローラー、デプロイ、レプリカセット内 のポッドの数を自動的にスケーリング • また、リソースが不要になったときにスケールインできる • Kubernetes 標準APIオブジェクトとコントローラとして実 装されている
  25. 25. Kubernetes-based Serverless
  26. 26. Knative KEDA Virtual Kubelet Kubernetes-based Serverless
  27. 27. Knative • Serverless ワークロードをビルド、デプロイ、管理機能を提 供するKubernetesベースのプラットフォーム • Scale-to-zero、自動 スケーリング、クラ スタ内ビルド、 Kubernetes 上のク ラウド ネイティブ アプリケーション用 のイベント フレーム ワークなどの機能が ある https://github.com/knative
  28. 28. Knative Components Serving •スケール •カナリアリース •ルーティング •リクエスト受信 Building •コンテナのビルド •パッケージング Eventing •イベントソースの抽 象化 •コードの発火
  29. 29. Virtual Kubelet • Kubeletの仮想実装で、汎用的にk8sクラスタから外部リソー スを利用できる • バースティングなど を目的として利用す るのがベター • Microsoftが始めた OSSプロジェクトで、 現在はCNCFによっ て管理されている https://github.com/virtual-kubelet/virtual-kubelet
  30. 30. Virtual Kubelet Alibaba Cloud ECI Provider Azure Container Instances Provider Azure Batch GPU Provider AWS Fargate Provider HashiCorp Nomad OpenStack Zun
  31. 31. Serverless Container Serverless Containers = Nodeless Containers VM、クラスタ (ノード)が不要 コンピュート課金 オンデマンド実行 可能 AWS FargateAzureContainer Instances Alibaba Elastic Container Instance
  32. 32. KEDA
  33. 33. KEDA (Kubernetes-based Event Driven Autoscaling Component) K8sでイベント駆動型の Podレベルオートスケールを可能にするフレームワーク • Red HatとMicrosoftのエンジニアリングチームのコラボ レーションの結果として開始されたプロジェクト • Kubernetesクラスターにインストールしてイベントベース のコンテナースケーリングを有効にすることができるオープ ンソースコンポーネントとして定義される • CPUメトリックスとメモリを活用してコンテナをゼロからス ケーリングし、Kubernetes機能を拡張する
  34. 34. KEDAの特徴 イベント ドリブン オート スケーリング ビルトイン スケーラー 複数のワーク ロードタイプ 非ベンダー依存 Azure Functions サポート
  35. 35. Architecture • Scaler:選択したソースに接続 して、メトリックを読み取る • Metrics adapter:Scalerに よって読み取られたメトリック をHorizontal Pod Autoscaler に転送して、アプリの自動ス ケーリングを有効にする • Controller:0⇔1のスケーリン グを提供する https://keda.sh/concepts/overview/#how-keda-works
  36. 36. KEDA • Kubernetesのスケーリング「Horizontal pod autoscaler (HPA)」はPodのCPUやメモリ消費量で調整される • KEDAは非HTTPなイベントに連動してクラスターへのデプロ イを自動スケールできる • HPAなどのKubernetesコンポーネントとネイティブに統合 され、クラウドとエッジの両方で実行できる • KEDAがZero Scale in/outを行い、他はHPAがScale in/out する • 様々なスケーラーが用意されており、今後も追加予定
  37. 37. Scalers
  38. 38. 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
  39. 39. KEDAを使用するには 以下の方法でデプロイすることで利用可能 • HelmでKEDAをデプロイ →通常はこちら • Kubectlでyamlからのデプロイ →minikubeなどHelmを使わない場合はこちら
  40. 40. 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
  41. 41. Kubectlでyamlからのデプロイ 1. Githubからサンプルをダウンロードしてインストール https://github.com/kedacore/keda $ kubectl apply -f https://github.com/kedacore/keda/releases/download/v2.0.0/keda-2.0.0.yaml
  42. 42. KEDAをデプロイ • keda-operator podやカスタムリソースが追加される
  43. 43. Azure Functions Core Toolsのインストール • Azure Functions Core Toolsをインストールすることで Kubernetes上でAzure Functionsが利用可能となる • 以前はスケールも自分での実装が必要だったが、KEDAを使 うことでスケールの実装が不要となった • インストールするには以下のコマンドを投入する ※要作業端末へのAzure Functions Core Toolsインストール $ func kubernetes install --namespace keda
  44. 44. Azure Functions Core Toolsをデプロイ • Functionsを実行するのに必要なapiserverなどの podが追 加される
  45. 45. DEMO
  46. 46. 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
  47. 47. まとめ • Custom Visionを使うことで簡単に画像判定のモデルが作成 できる • エクスポートして使うことでクラウドに接続せず、オンプレ ミスやスマホアプリの中でも利用可能 • KubernetesやServerlessと組み合わせてコンテナアプリとし て構築することでインターネットに接続できないポリシーの 企業でも利用検討が視野に入ってくる • まずは試して実践してみてください
  48. 48. • 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
  49. 49. ご清聴ありがとうございました

×