Skip to content

Commit 656261b

Browse files
committed
Fix setup.py to not include the direct link to tflite_runtime wheels (so that we can publish on PyPi). Add instructions for installing tflite_runtime, and fix the Raspberry Pi install script to reflect those new instructions.
1 parent bc93a40 commit 656261b

5 files changed

Lines changed: 22 additions & 20 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Lobe Python API
22
Code to run exported Lobe models in Python using the TensorFlow, TensorFlow Lite, or ONNX options.
33

4-
Works with Python 3.6, 3.7, or 3.8, untested for other versions.
4+
Works with Python 3.6, 3.7, and 3.8 untested for other versions.
55

66
## Install
77
### Backend options with pip
@@ -13,8 +13,9 @@ pip install lobe[all]
1313
# For TensorFlow only
1414
pip install lobe[tf]
1515

16-
# For TensorFlow Lite only
17-
pip install lobe[tflite]
16+
# For TensorFlow Lite only -- this requires two steps for the runtime and for lobe (note for Raspberry Pi see our setup script in scripts/lobe-rpi-install.sh)
17+
pip install --index-url https://google-coral.github.io/py-repo/ tflite_runtime
18+
pip install lobe
1819

1920
# For ONNX only
2021
pip install lobe[onnx]
@@ -72,7 +73,7 @@ pip install lobe[all]
7273
```python
7374
from lobe import ImageModel
7475

75-
model = ImageModel.load('path/to/exported/model')
76+
model = ImageModel.load('path/to/exported/model/folder')
7677

7778
# OPTION 1: Predict from an image file
7879
result = model.predict_from_file('path/to/file.jpg')

examples/raspberry-pi/README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ It is assumed you are starting with a Pi in a remote headless configuration alre
2424
2. Power up your Pi and log in to the desktop view.
2525
3. On the Pi, open a terminal window and create a directory where you want to store your Lobe model and code. For example, in the /home/pi folder:
2626
```
27-
mkdir Lobe
27+
mkdir Lobe
2828
```
29-
4. Navigate into your Lobe directory, and download the setuptools and the lobe-python package:
29+
4. Navigate into your Lobe directory, and install the lobe-python package:
3030
```
31-
pip3 install setuptools
32-
pip3 install git+https://github.com/lobe/lobe-python
31+
cd Lobe
32+
wget https://raw.githubusercontent.com/lobe/lobe-python/master/scripts/lobe-rpi-install.sh
33+
sudo ./lobe-rpi-install.sh
3334
```
3435
3536
## Getting the Lobe TF Model on your Pi
@@ -52,8 +53,4 @@ It is assumed you are starting with a Pi in a remote headless configuration alre
5253
### Troubleshooting
5354
1. Check that the Pi power light is bright red. A dim red light indicates insufficient power.
5455
2. Be sure you're installing and running your TF code using Python 3.
55-
3. If the TensorFlow module is not recognized, try re-installing:
56-
'''
57-
pip3 install tensorflow == 1.13.1
58-
'''
59-
4. If you're using multiple components, be sure they are all connected to the same common ground.
56+
3. If you're using multiple components, be sure they are all connected to the same common ground.

scripts/lobe-rpi-install.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
2-
#
3-
# Install Python3
2+
# Add TensorFlow Lite package repo (https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python)
3+
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
4+
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
5+
# Install Python3 and deps
46
sudo apt -y update
57
sudo apt install -y \
68
python3-dev \
@@ -11,5 +13,7 @@ sudo apt install -y \
1113
libjpeg62-turbo
1214
sudo apt-get install -y git
1315
sudo pip3 install setuptools
14-
# Install lobe-python with TensorFlow Lite backend
15-
sudo pip3 install lobe[tflite]
16+
# Install TensorFlow Lite Runtime
17+
sudo apt install -y python3-tflite-runtime
18+
# Install lobe-python which can use the tflite backend
19+
sudo pip3 install lobe

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@
7878
package_dir={"": "src"},
7979
install_requires=requirements,
8080
extras_require={
81-
'all': [tf_req, onnx_req, tflite_req],
81+
'all': [tf_req, onnx_req],
8282
'tf': [tf_req],
8383
'onnx': [onnx_req],
84-
'tflite': [tflite_req],
84+
#'tflite': [tflite_req],
8585
}
8686
)

src/lobe/backends/backend_tflite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
except ImportError:
1414
raise ImportError(
15-
"ERROR: This is a TensorFlow Lite model and requires TensorFlow Lite interpreter to be installed on this device. Please install lobe-python with lobe[tflite] or lobe[all] options. If that doesn't work, please go to https://www.tensorflow.org/lite/guide/python and download the appropriate version for you device."
15+
"ERROR: This is a TensorFlow Lite model and requires TensorFlow Lite interpreter to be installed on this device. Please go to https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python for installation instructions for you device."
1616
)
1717

1818

0 commit comments

Comments
 (0)