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の技術発表資料です
PRO
May 24, 2024
95
2
Share
ONNXハンズオン
NearMeの技術発表資料です
PRO
May 24, 2024
More Decks by NearMeの技術発表資料です
See All by NearMeの技術発表資料です
Apache Airflow Workflow orchestration without turning cron into spaghetti
nearme_tech
PRO
0
11
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
0
43
SQL/ID抽出タスクから考える 実践的なハルシネーション対策
nearme_tech
PRO
0
54
OpenCode & Local LLM
nearme_tech
PRO
0
71
OpenCode Introduction
nearme_tech
PRO
0
45
【Browser Automation × AI】 Stagehandを試してみよう
nearme_tech
PRO
0
130
AIを用いた PID制御で部屋 の温度制御をしてみた
nearme_tech
PRO
0
130
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
3
520
Tile38 Overview
nearme_tech
PRO
0
94
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
It's Worth the Effort
3n
188
29k
WCS-LA-2024
lcolladotor
0
610
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
190
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
480
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Amusing Abliteration
ianozsvald
1
190
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
260
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