Skip to main content

AI Kit搭載Raspberry PiでのClipアプリケーション

はじめに

CLIP(Contrastive Language-Image Pre-Training)は、様々な(画像、テキスト)ペアで訓練されたニューラルネットワークです。画像が与えられた際に、最も関連性の高いテキストスニペットを予測するよう自然言語で指示することができ、GPT-2や3のゼロショット機能と同様に、タスクを直接最適化することなく実行できます。CLIPは、元の128万個のラベル付きサンプルを一切使用せずに、ImageNetでの「ゼロショット」において元のResNet50の性能と同等であることが判明し、コンピュータビジョンにおけるいくつかの主要な課題を克服しています。

このwikiでは、Raspberry Pi5またはRecomputer r1000にclipアプリケーションをデプロイする方法を説明します。clipはAI kitで推論を実行します。

ハードウェアの準備

Recomputer R1000の場合

reComputer r1000Raspberry Pi AI Kit

Raspberry Pi 5/CM5の場合

reComputer R1125reComputer AI R2130reComputer AI Industrial R2145
reComputer Industrial R20xxreComputer Industrial R21xx

Hailoソフトウェアのインストールと確認

システムの更新

sudo apt update
sudo apt full-upgrade
note

更新中に以下の問題が発生することがあります。

Get:1 http://deb.debian.org/debian bookworm InRelease [151 kB]
Get:2 http://deb.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:3 http://deb.debian.org/debian bookworm-updates InRelease [55.4 kB]
Get:4 http://archive.raspberrypi.com/debian bookworm InRelease [39.0 kB]
Reading package lists... Done
E: Release file for http://deb.debian.org/debian/dists/bookworm/InRelease is not valid yet (invalid for another 58d 8h 26min 35s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian-security/dists/bookworm-security/InRelease is not valid yet (invalid for another 84d 18h 23min 59s). Updates for this repository will not be applied.
E: Release file for http://archive.raspberrypi.com/debian/dists/bookworm/InRelease is not valid yet (invalid for another 84d 13h 13min 5s). Updates for this repository will not be applied.
E: Release file for http://deb.debian.org/debian/dists/bookworm-updates/InRelease is not valid yet (invalid for another 85d 0h 52min 29s). Updates for this repository will not be applied.

これはRaspberry Piの時刻が正しく設定されていないためです。以下のコマンドでRaspberry Piの時刻を手動で設定する必要があります:

# This command only you can connect google.com
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

Raspberry Piの時刻を設定した後、Raspberry Piを更新できます。

PCIeをgen2/gen3に設定(gen3はgen2より高速)

/boot/firmware/config.txtに以下のテキストを追加します

#Enable the PCIe external connector

dtparam=pciex1

#Force Gen 3.0 speeds

dtparam=pciex1_gen=3

note

gen2を使用したい場合は、dtparam=pciex1_gen=3をコメントアウトしてください

hailo-allのインストールと再起動

Raspberry Pi5でターミナルを開き、以下のコマンドを入力してHailoソフトウェアをインストールします。

sudo apt install hailo-all
sudo apt-get -y install libblas-dev nlohmann-json3-dev
sudo reboot

ソフトウェアとハードウェアの確認

Raspberry Pi5でターミナルを開き、以下のコマンドを入力してhailo-allがインストールされているかを確認します。

hailortcli fw-control identify

正しい結果は以下のように表示されます:

pir

Raspberry Pi5でターミナルを開き、以下のコマンドを入力してhailo-8Lが接続されているかを確認します。

lspci | grep Hailo

正しい結果は以下のように表示されます:

pir

プロジェクトの実行

プロジェクトのインストール

git clone https://github.com/hailo-ai/hailo-CLIP.git
cd hailo-CLIP
./install.sh

プロジェクトの実行

以下のコマンドを入力すると、clipデモが表示されます:

 source setup_env.sh
clip_app --input demo

独自のカメラを使用したい場合は、Raspberry Piに独自のカメラが接続されていることを確認した後、以下のコマンドを入力してください:

clip_app --input /dev/video0

結果

以下に示すビデオでは、「banana」と入力するとCLIPモデルがバナナを認識し、「apple」と入力するとモデルがリンゴを認識することがわかります。異なる単語を入力するだけで、CLIPモデルが異なるオブジェクトを認識します。

技術サポートと製品ディスカッション

弊社製品をお選びいただきありがとうございます!弊社製品での体験が可能な限りスムーズになるよう、さまざまなサポートを提供しています。さまざまな好みやニーズに対応するため、複数のコミュニケーションチャネルを提供しています。

Loading Comments...