Slide 1

Slide 1 text

Raspberry Pi AI Kit 介紹 台灣樹莓派 2024/08/05 @Raspberry Pi Meetup #43

Slide 2

Slide 2 text

姓名標示 — 非商業性 — 相同方式分享 CC (Creative Commons) 姓名標示 — 你必須給予 適當表彰、提供指向本授權 條款的連結,以及 指出(本作品的原始版本)是否已 被變更。你可以任何合理方式為前述表彰,但不得以 任何方式暗示授權人為你或你的使用方式背書。 非商業性 — 你不得將本素材進行商業目的之使 用。 相同方式分享 — 若你重混、轉換本素材,或依本 素材建立新素材,你必須依本素材的授權條款來 散布你的貢獻物。

Slide 3

Slide 3 text

3 ● Raspberry Pi 官方經銷商 ● 專注 Raspberry Pi 應用與推廣 , 舉辦社群活動 關於我們

Slide 4

Slide 4 text

● COSCUP , MakerConf, PyCon, HKOSCon 講者 ● 投影片 ● https://speakerdeck.com/piepie_tw ● 程式碼 ● https://github.com/piepie-tw ● 台灣樹莓派網站 : ● https://piepie.com.tw/ ● Facebook: ● https://www.facebook.com/RaspberryPi.Taiwan 分享 x 教學

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

6 ● 什麼是 Raspberry Pi AI Kit? ● Hailo 解決方案 ● 訓練自己的資料集 ( 實做 ) 大綱

Slide 7

Slide 7 text

新產品 Raspberry Pi AI Kit https://piepie.com.tw/product/raspberry-pi-ai-kit

Slide 8

Slide 8 text

● 包含 M.2 HAT+ 和 Hailo-8L NPU 模組 ( 不分售 ) ● Hailo-8L 高達 13 TOPS 算力 ● M.2 2242 樣式 Raspberry Pi AI Kit 規格 https://www.easydiy.com.tw/products_detail/43.htm

Slide 9

Slide 9 text

● Hailo 在 2017 年由以色列國防單位成員創立 ● 專注於人工智慧的晶片製造商 ● 產品包含 AI accelerators 和 AI vision processors ● Hailo-8L 是台灣製造 ● Hailo-8 和 Hailo-8L 是不同產品 ● Hailo-8 算力為 26 TOPS, 具有更高性能 ● Hailo-8L 算力為 13 TOPS, 低功耗適合邊緣加速

Slide 10

Slide 10 text

● 軟硬體環境 :Pi 5 + Bookworm 64-bit ● $ sudo apt-get update ● $ sudo apt-get full-upgrade ● $ sudo apt-get install hailo-all 開始使用 AI Kit

Slide 11

Slide 11 text

在 Raspberry Pi 5 設定 Hailo-8L https://datasheets.raspberrypi.com/camera/raspberry-pi-camera-guide.pdf

Slide 12

Slide 12 text

● $ cd ~ ● $ git clone https://github.com/hailo-ai/hailo- rpi5-examples.git ● $ cd hailo-rpi5-examples ● $ source setup_env.sh ● (venv)$ pip install -r requirements.txt ● (venv)$ ./download_resources.sh 下載 Hailo 範例程式

Slide 13

Slide 13 text

DEMO

Slide 14

Slide 14 text

● 一個 Docker 包含四個 Hailo 核心軟體 ● 1. Hailo Model Zoo ● 2. Hailo Applications (TAPPAS High- Performance Application Toolkit) ● 3. Hailo Runtime(Hailo RT) ● 4. Dataflow Compiler(DFC) Hailo 一體式方案簡化 AI 開發流程 https://hailo.ai/blog/how-software-can-streamline-customer-experience-in-edge-ai/

Slide 15

Slide 15 text

● 提供多種 pre-trained 模型 , 開箱即用 ● 支援 TensorFlow 或是 ONNX 格式 Hailo Model Zoo https://hailo.ai/blog/how-software-can-streamline-customer-experience-in-edge-ai/

Slide 16

Slide 16 text

● GStreamer 是一個跨平台的多媒體框架 , 可串接 各種多媒體應用包括視訊和音訊 ● GStreamer 使用管道 (Pipeline) 方式對每一個 元素 (Element) 或插件 (Plugins) 進行串聯 GStreamer Framework https://github.com/hailo-ai/tappas/blob/master/docs/terminology.rst

Slide 17

Slide 17 text

● 整合 GStreamer 以提供多媒體的預處理和後處理 ● 無縫建立視覺管道 , 將編譯後模型整合到處理流程 整合 GStreamer https://hailo.ai/blog/how-software-can-streamline-customer-experience-in-edge-ai/

Slide 18

Slide 18 text

TAPPAS = Template APPlications And Solutions https://github.com/hailo-ai/tappas/

Slide 19

Slide 19 text

● 將客製化模型或是 Model Zoo 整合到視覺管道 利用 HailoRT 和 GStreamer 框架 https://hailo.ai/blog/how-software-can-streamline-customer-experience-in-edge-ai/

Slide 20

Slide 20 text

以邊緣 AI 開發情境為例 https://github.com/hailo-ai/tappas/blob/master/docs/terminology.rst

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

可快速開發邊緣 AI 情境 https://github.com/hailo-ai/tappas/blob/master/docs/terminology.rst

Slide 23

Slide 23 text

● gst-launch-1.0 filesrc location=resources/detection0.mp4 ! qtdemux ! avdec_h264 ! video/x-raw ! videoconvert ! video/x-raw ! videoconvert ! fpsdisplaysink GStreamer Framework

Slide 24

Slide 24 text

● gst-launch-1.0 hailomuxer name=hmux filesrc location=resources/detection0.mp4 ! qtdemux ! avdec_h264 ! video/x-raw ! videoconvert ! video/x-raw ! tee name=t ! queue ! hmux.sink_0 t. ! videoconvert ! hailonet hef-path=/home/pi/hailo-rpi5- examples/resources/yolov6n.hef ! hailofilter so-path=/usr/lib/aarch64-linux- gnu/hailo/tappas/post- process/libyolo_hailortpp_post.so ! hmux.sink_1 hmux. ! hailooverlay ! videoconvert ! fpsdisplaysink GStreamer Framework

Slide 25

Slide 25 text

● 常見的基於深度學習的電腦視覺專案開發步驟 ● 根據自定義資料集重新訓練產生模型 ● 使用 SDK 重新編譯模型 ● 將編譯後的模型佈署到邊緣裝置 使用 Hailo Toolchain 部署模型 https://hailo.ai/blog/how-software-can-streamline-customer-experience-in-edge-ai/

Slide 26

Slide 26 text

https://hailo.ai/blog/how-software-can-streamline-customer-experience-in-edge-ai/

Slide 27

Slide 27 text

27 ● 1. 取得跌倒資料集 (Kaggle, roboflow…) ● 2. Amazon EC2 或是 Google Colab 重新訓練 ● 3. 佈署模型在邊緣裝置 ( 例如 Pi5) ● 4. 使用 AI Kit ● 4.1 將原模型 export 成 ONNX 模型 ● 4.2 建立環境 , 使用 SDK 重新編譯模型 ● 5. 將模型重新佈署到邊緣裝置 訓練自己的 YOLO 資料集實際步驟

Slide 28

Slide 28 text

28 Roboflow 車牌資料集範例 https://universe.roboflow.com/sosorry-ynrvk/taiwan-alpr-fork/

Slide 29

Slide 29 text

29 ● $ docker run --name "hailo_yolov8" -it --gpus all --ipc=host -v /home/ubuntu/datasets:/workspace/datasets yolov8:v0 ● # time yolo detect train data=/path/to/data.yaml model=yolov8s.pt name=retrain_yolov8s epochs=5 batch=16 (real 13m44.734s) 在 Amazon EC2 用 Docker 訓練 https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/retraining-example.md

Slide 30

Slide 30 text

30 ● $ python3 yolov8-video.py best.pt videos/alpr_demo.mp4 訓練好的模型佈署到邊緣裝置 https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/retraining-example.md

Slide 31

Slide 31 text

31 ● # cd /workspace/ultralytics ● # yolo export model=/workspace/ultralytics/runs/detect/r etrain_yolov8n/weights/best.pt imgsz=640 format=onnx opset=11 匯出成 ONNX 格式 https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/retraining-example.md

Slide 32

Slide 32 text

下載 Dataflow Compiler https://community.hailo.ai/

Slide 33

Slide 33 text

33 ● $ pip install hailo_dataflow_compiler-py3-none- linux_x86_64.whl ● $ pip install hailo_model_zoo-py3-none-any.whl ● $ time hailomz compile --hw-arch hailo8l --ckpt best.onnx --calib-path ~/path/to/images --yaml yolov8n.yaml --classes 1 (real 16m7.818s) 建立環境 , 使用 SDK 重新編譯模型 https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/retraining-example.md

Slide 34

Slide 34 text

34 ● $ python3 basic_pipelines/alpr_detection.py --network yolov8n --input /home/pi/videos/alpr_demo.mp4 將模型重新佈署到邊緣裝置 https://github.com/hailo-ai/hailo-rpi5-examples/blob/main/doc/retraining-example.md

Slide 35

Slide 35 text

DEMO

Slide 36

Slide 36 text

36 ● AMI: Deep Learning Base OSS Nvidia Driver GPU AMI (Ubuntu 22.04) (x64) ● type: g4dn.2xlarge Amazon EC2 價格

Slide 37

Slide 37 text

● Raspberry Pi AI Kit 官方文件 ● https://reurl.cc/bV8ER6 ● Hailo Raspberry Pi 5 Examples ● https://github.com/hailo-ai/hailo-rpi5-examples ● Hailo TAPPAS ● https://github.com/hailo-ai/tappas ● Hailo TAPPAS User Guide ● https://reurl.cc/jWZG7L 更多說明

Slide 38

Slide 38 text

● Hailo AI Software Suite User Guide ● Hailo TAPPAS User Guide ● HailoRT User Guide ● Hailo Dataflow Compiler User Guide ● Hailo Model Zoo User Guide ● Hailo Integration Tool User Guide 更多 Hailo 文件

Slide 39

Slide 39 text

● M.2 HAT+ 或是 AI Kit 可以加裝 Active Cooler? FAQ 第一名

Slide 40

Slide 40 text

● @Raspberry Pi 贊助 Raspberry Pi Beginner's Guide ● @Raspberry Pi 贊助 Raspberry Pi 5 ● @Raspberry Pi 贊助 Active Cooler for Raspberry Pi 5 ● @RICELEE 提供一片 Zero 2 W 抽獎 ● @Creative5 贊助 USB 小禮物 感謝乾爹們~

Slide 41

Slide 41 text

Raspberry Pi Rocks the World Thanks