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
91
2
Share
ONNXハンズオン
NearMeの技術発表資料です
PRO
May 24, 2024
More Decks by NearMeの技術発表資料です
See All by NearMeの技術発表資料です
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
0
28
SQL/ID抽出タスクから考える 実践的なハルシネーション対策
nearme_tech
PRO
0
45
OpenCode & Local LLM
nearme_tech
PRO
0
43
OpenCode Introduction
nearme_tech
PRO
0
40
【Browser Automation × AI】 Stagehandを試してみよう
nearme_tech
PRO
0
110
AIを用いた PID制御で部屋 の温度制御をしてみた
nearme_tech
PRO
0
110
CopilotKit + AG-UIを学ぶ
nearme_tech
PRO
3
460
Tile38 Overview
nearme_tech
PRO
0
90
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
1
1.7k
Featured
See All Featured
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
240
エンジニアに許された特別な時間の終わり
watany
107
240k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
370
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
390
A better future with KSS
kneath
240
18k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
450
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
270
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
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