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
110
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ONNXハンズオン
NearMeの技術発表資料です
PRO
May 24, 2024
More Decks by NearMeの技術発表資料です
See All by NearMeの技術発表資料です
Claude Code × git worktree で並列開発 (続き) -差分のサービスだけを併設する-
nearme_tech
PRO
1
43
Claude Code × git worktree で並列開発 — サブモジュール構成のリポジトリで成立させる —
nearme_tech
PRO
0
48
LLM + 強化学習
nearme_tech
PRO
0
30
PosthogのA/Bテスト機能の紹介
nearme_tech
PRO
1
41
AIフレンドリーなプロダクトに向けて
nearme_tech
PRO
2
65
初めてのLean言語
nearme_tech
PRO
0
100
Apache Airflow Workflow orchestration without turning cron into spaghetti
nearme_tech
PRO
2
37
実務で役立つ幾何学 ボロノイ図の基礎から グラフ・ネットワーク応用まで
nearme_tech
PRO
1
72
SQL/ID抽出タスクから考える 実践的なハルシネーション対策
nearme_tech
PRO
1
87
Featured
See All Featured
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
290
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
320
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
The Pragmatic Product Professional
lauravandoore
37
7.4k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
550
GitHub's CSS Performance
jonrohan
1033
470k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
710
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