Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to work with new debs from google #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 99-tpu.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SUBSYSTEM=="usb",ATTRS{idVendor}=="1a6e",GROUP="plugdev"
SUBSYSTEM=="usb",ATTRS{idVendor}=="18d1",GROUP="plugdev"
35 changes: 14 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# Built using https://coral.withgoogle.com/tutorials/accelerator/
FROM balenalib/raspberrypi3-debian

# Install some utilities we will need
RUN apt-get update && apt-get install build-essential wget feh

# Set our working directory
WORKDIR /usr/src/app

# Need udev for some dynamic dev nodes
# Add Google Coral sources lists
RUN echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

# Install the TPU packages we will need
RUN install_packages libedgetpu1-std \
libedgetpu-dev \
python3-edgetpu \
# edgetpu-examples \
python3-pip

# udev in the container to enable TPU correctly
ENV UDEV=1
COPY 99-tpu.rules /etc/udev/rules.d/99-tpu.rules

# Fetch latest edge TPU libs
RUN wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names && \
tar xzf edgetpu_api.tar.gz && rm edgetpu_api.tar.gz

WORKDIR /usr/src/app/edgetpu_api

# Override the MODEL variable so we can build in a container.
ENV MODEL="Raspberry Pi 3 Model B Rev"
RUN sed -i "s|MODEL=|#MODEL=|g" install.sh

# Pass N to the prompt in the install script if we want to overclock the tpu
RUN yes n | ./install.sh

# Set our working directory
# # Set our working directory
WORKDIR /usr/src/app

COPY requirements.txt requirements.txt
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,19 @@ The webstreaming code was heavily borrowed from [@lemariva great blog post](http
- libusb is used to communicate with the device.
- The device supports USB 3.0 but the Pi/Fin have USB 2.0 which will be the bottleneck.
- Google's installation script detects the platform and installs the relevant libraries. The platforms detected are only pi3/pi3b+ via the device tree model string. So need to 'tweak' the script a bit to run on the balena Fin

cat 99-edgetpu-accelerator.rules
```
SUBSYSTEM=="usb",ATTRS{idVendor}=="1a6e",GROUP="plugdev"
SUBSYSTEM=="usb",ATTRS{idVendor}=="18d1",GROUP="plugdev"
```

```
cd /usr/share/edgetpu/examples/

python3 classify_image.py \
--model models/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite \
--label models/inat_bird_labels.txt \
--image images/parrot.jpg

```