LoginSignup
2
1

More than 3 years have passed since last update.

ラズパイにCoral USBAccelerator を繋いで画像分類などしたいなーと思いモデルの変換方法を調べました。

TensorFlowLiteのモデルからEdgeTPU用のモデルコンパイルは、以前はWebコンパイラーがあってファイルをアップロードするだけで出来たらしいです。

が、今はWebコンパイラーが無く、公式ページ ではDebianベースのLinuxを使った手順が書かれています。

RaspbianだってDebianベースだいっ、ということでRaspberryPi 3 Model B(Raspbian Buster)で公式の手順を試してみましたが普通に怒られました。

pi@raspberrypi:~ $ sudo apt-get install edgetpu
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 edgetpu : Depends: edgetpu-compiler but it is not installable
E: Unable to correct problems, you have held broken packages.

64bitのARMv8なら大丈夫と公式ページに書かれてあり、RaspberryPi 3(4も)のCPUはハード的にはクリアしているはずですが、Raspbian上ではarmv7lとなっているのでOSが対応していないようです。

そんなわけで、普段使いのOSが非Debian系の方は、PC上でDockerを使ってモデルのコンパイルをするのが良さそうです。

FROM debian

WORKDIR /work

RUN apt-get update

RUN apt-get -y install \
  curl \
  gnupg2

RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" > /etc/apt/sources.list.d/coral-edgetpu.list

RUN apt-get update

RUN apt-get -y install edgetpu

RUN apt-get clean

CMD command

こんな感じのDockerfileを作成し、同じディレクトリにTensorFlowLiteのモデルを置いて以下のコマンドでいけました。

docker build -t tflite2edgetpu .
docker run -v `pwd`:/work tflite2edgetpu edgetpu_compiler model.tflite

(Windowsの方は `pwd`の部分を絶対パスにするなど適宜変更して下さい)

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1