Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ONNXハンズオン
Search
NearMeの技術発表資料です
May 24, 2024
2
21
ONNXハンズオン
NearMeの技術発表資料です
May 24, 2024
Tweet
Share
More Decks by NearMeの技術発表資料です
See All by NearMeの技術発表資料です
Object–relational mapping and query builder battle 1: Intro to Prisma
nearme_tech
1
10
深層学習モデルの最適化 -Deep Learning Tuning Playbookを読む-
nearme_tech
1
24
機械学習を支える連続最適化
nearme_tech
1
24
サードパーティクッキーの終焉と Topics APIによる代替の可能性
nearme_tech
1
70
DBのindex(B-tree周り) に触れてみよう
nearme_tech
0
26
Infrastructure as Code: Intro to Pulumi
nearme_tech
1
33
OR-Toolsの中⾝ -VRPの解法について-
nearme_tech
0
81
GTFSのデータを Streamlitで可視化してみた
nearme_tech
0
67
Offset / Cursor Paginationについて
nearme_tech
3
150
Featured
See All Featured
For a Future-Friendly Web
brad_frost
172
9.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
661
120k
Building Flexible Design Systems
yeseniaperezcruz
321
37k
Making the Leap to Tech Lead
cromwellryan
126
8.6k
Rails Girls Zürich Keynote
gr2m
91
13k
Robots, Beer and Maslow
schacon
PRO
155
8k
Learning to Love Humans: Emotional Interface Design
aarron
269
39k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
188
16k
Agile that works and the tools we love
rasmusluckow
325
20k
How STYLIGHT went responsive
nonsquared
92
4.9k
Building a Scalable Design System with Sketch
lauravandoore
457
32k
Transcript
0 ONNXハンズオン 2024-05-24 第91回NearMe技術勉強会 Takuma KAKINOUE
1 ONNXとは • Open Neural Network eXchangeの略 • ある機械学習フレームワークで訓練したモデルを、統⼀されたフォーマットに 出⼒し(.onnxファイル)、ONNXランタイムが含まれる任意の環境で推論を実
⾏可能にしようというもの • 例えば、Pythonで訓練したPytorchのNNモデルを使って、TypeScriptやC#上 でも推論(not 訓練)が実⾏可能になる ◦ TypeScriptやC#の環境の中にはONNXランタイムさえインストールされて いれば良い ※ web: https://onnx.ai/ ※ github: https://github.com/onnx/onnx ※ .onnxファイルはProtocol Buffers形式
2 ONNX概略図 ONNXランタイム ONNX Model Zoo 訓練済みモデルをpull 自前で訓練して エクスポート .onnx
ファイル 推論実行 ※ クラウドストレージ等でも可 実行ホストは、 マイコンやコンシューマー ゲーム機など無限の可能 性!! 訓練済みモデルを ダウンロードして 使用可! 今回のハンズオンではPytorchで自前で訓練
3 ONNXハンズオン • Pythonで⼿書き⽂字を認識するモデルをPytorchで学習し、Javascriptのwebアプリ上 から推論を⾏う ◦ サンプルのレポジトリ:
[email protected]
:kakky-hacker/sandbox.git • ⼿順 ◦
git clone
[email protected]
:kakky-hacker/sandbox.git ◦ cd sandbox/onnx-test ◦ pip install -r requirements.txt ◦ python train.py ▪ mnist.onnxが⽣成される ◦ python -m http.server 8000 ◦ ブラウザからhttp://localhost:8000にアクセス
4 ONNXハンズオン • Canvasに適当な数字を書いてPredictボタンを押すと予測結果が表⽰される 正しく予測できた!
5 ONNXの注意点 • opsetバージョンが存在し、モデルをエクスポートする時に注意しなければならない (https://github.com/onnx/onnx/blob/main/docs/Operators.md) • 全ての演算オペレータが実装されているわけではない ◦ ⼀応、カスタムオペレータという⼿段は存在する •
当たり前だが、推論速度は推論を⾏うハードウェアに依存する ◦ 訓練するハードウェアと推論するハードウェアのマシンスペック差はちゃんと考慮 しなければならない ▪ ONNXランタイムはGPU対応 ▪ ちなみにONNXランタイム⾃体もそこまで遅くなさそう (https://qiita.com/john-rocky/items/caa55453f40f5f444edf)
6 Thank you