Raspberry Pi with AI Kitでの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の場合
Raspberry Pi 5用
reComputer AI R2130 |
---|
![]() |
Hailoソフトウェアのインストールとインストール確認
システムの更新
sudo apt update
sudo apt full-upgrade
アップデート中に以下の問題が発生することがあります。
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 の時刻を設定した後、Raspberry をアップデートできます。
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
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
正しい結果は以下のように表示されます:
Raspberry Pi5でターミナルを開き、以下のコマンドを入力してhailo-8Lが接続されているかどうかを確認します。
lspci | grep Hailo
正しい結果は以下のように表示されます:
プロジェクトの実行
プロジェクトのインストール
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モデルが異なるオブジェクトを認識します。
技術サポート & 製品ディスカッション
弊社製品をお選びいただき、ありがとうございます!お客様の製品体験を可能な限りスムーズにするため、さまざまなサポートを提供しております。異なる好みやニーズに対応するため、複数のコミュニケーションチャネルをご用意しています。