Skip to content

Commit 96b5146

Browse files
authored
Merge pull request #20 from PINTO0309/r2.15
r2.15
2 parents 687f5f1 + 5297951 commit 96b5146

5 files changed

+66
-117
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
TFVER=2.15.0
4+
curl -OL https://github.com/PINTO0309/TensorflowLite-bin/releases/download/v${TFVER}/tflite_runtime-${TFVER/-/}-cp310-none-linux_aarch64.whl
5+
6+
echo Download finished.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
TFVER=2.15.0
4+
curl -OL https://github.com/PINTO0309/TensorflowLite-bin/releases/download/v${TFVER}/tflite_runtime-${TFVER/-/}-cp310-none-linux_armv7l.whl
5+
6+
echo Download finished.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
TFVER=2.15.0
4+
curl -OL https://github.com/PINTO0309/TensorflowLite-bin/releases/download/v${TFVER}/tflite_runtime-${TFVER/-/}-cp311-none-linux_aarch64.whl
5+
6+
echo Download finished.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
TFVER=2.15.0
4+
curl -OL https://github.com/PINTO0309/TensorflowLite-bin/releases/download/v${TFVER}/tflite_runtime-${TFVER/-/}-cp311-none-linux_armv7l.whl
5+
6+
echo Download finished.

README.md

Lines changed: 42 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,40 @@ A repository that shares tuning results of trained models generated by Tensorflo
4444
|RaspberryPi3/4|Ubuntu 21.04/Debian/RaspberryPiOS|Hirsute/Bullseye|aarch64 / armv8|3.9|64bit|
4545
|RaspberryPi3/4|Ubuntu 22.04|Jammy|armhf / armv7l|3.10|32bit|
4646
|RaspberryPi3/4|Ubuntu 22.04|Jammy|aarch64 / armv8|3.10|64bit|
47-
|RaspberryPi3/4|Debian|Bookworm|armhf / armv7l|3.11|32bit|
48-
|RaspberryPi3/4|Debian|Bookworm|aarch64 / armv8|3.11|64bit|
47+
|RaspberryPi3/4/5|RaspberryPiOS/Debian|Bookworm|armhf / armv7l|3.11|32bit|
48+
|RaspberryPi3/4/5|RaspberryPiOS/Debian|Bookworm|aarch64 / armv8|3.11|64bit|
4949

5050
## Usage
5151
```bash
52-
$ sudo apt install -y \
53-
swig libjpeg-dev zlib1g-dev python3-dev \
54-
unzip wget python3-pip curl git cmake make
55-
$ sudo pip3 install numpy==1.24.3
56-
57-
$ TFVER=2.12.0
58-
59-
$ PYVER=39
60-
or
61-
$ PYVER=38
52+
sudo apt-get update && \
53+
sudo apt install -y \
54+
swig \
55+
libjpeg-dev \
56+
zlib1g-dev \
57+
python3-dev \
58+
python-is-python3 \
59+
unzip \
60+
wget \
61+
python3-pip \
62+
curl \
63+
git \
64+
cmake \
65+
make
66+
67+
pip install -U pip
68+
pip install numpy
69+
70+
TFVER=2.15.0.post1
71+
72+
PYVER=310
6273
or
63-
$ PYVER=310
64-
or
65-
$ PYVER=311
74+
PYVER=311
6675

67-
$ ARCH=aarch64
76+
ARCH=aarch64
6877
or
69-
$ ARCH=armhf
78+
ARCH=armhf
7079

71-
$ sudo -H pip3 install \
80+
pip install \
7281
--no-cache-dir \
7382
https://github.com/PINTO0309/TensorflowLite-bin/releases/download/v${TFVER}/tflite_runtime-${TFVER/-/}-cp${PYVER}-none-linux_${ARCH}.whl
7483
```
@@ -83,105 +92,21 @@ interpreter = Interpreter(model_path="foo.tflite")
8392
### Tensorflow v2.3.0+
8493
interpreter = Interpreter(model_path="foo.tflite", num_threads=4)
8594
```
86-
## Build parameter
87-
- git clone
88-
```bash
89-
TFVER=2.12.0
90-
git clone -b v${TFVER} --depth 1 https://github.com/tensorflow/tensorflow.git
91-
cd tensorflow
92-
```
93-
- Adjustment of Dockerfile and Header file
94-
```bash
95-
sed -i -e 's/RUN yes/#RUN yes/g' tensorflow/lite/tools/pip_package/Dockerfile.py3
96-
sed -i -e 's/RUN pip3 install numpy~=1.19.2/RUN pip3 install numpy==1.24.3/g' tensorflow/lite/tools/pip_package/Dockerfile.py3
97-
sed -i '19a ENV DEBIAN_FRONTEND=noninteractive' tensorflow/lite/tools/pip_package/Dockerfile.py3
98-
sed -i '20a ENV TZ=Etc/UTC' tensorflow/lite/tools/pip_package/Dockerfile.py3
99-
sed -i '29a \ tzdata \\' tensorflow/lite/tools/pip_package/Dockerfile.py3
100-
sed -i -e 's/RUN DEBIAN_FRONTEND=noninteractive/#RUN DEBIAN_FRONTEND=noninteractive/g' tensorflow/lite/tools/pip_package/Dockerfile.py3
101-
sed -i '50a \ python-is-python3 \\' tensorflow/lite/tools/pip_package/Dockerfile.py3
102-
sed -i '15a #include <assert.h>' tensorflow/tsl/framework/fixedpoint/MatMatProductAVX2.h
103-
```
104-
- Added FlexDelegate and XNNPACK as build options. If you want to keep the binary size as small as possible, change `tflite_pip_with_flex` and `tflite_with_xnnpack` to `false` and build. The `--copt=-fpermissive` option of armhf is deprecated.
105-
```bash
106-
nano tensorflow/lite/tools/pip_package/build_pip_package_with_bazel.sh
107-
108-
# Build python interpreter_wrapper.
109-
cd "${BUILD_DIR}"
110-
case "${TENSORFLOW_TARGET}" in
111-
armhf)
112-
BAZEL_FLAGS="--config=elinux_armhf
113-
--copt=-march=armv7-a --copt=-mfpu=neon-vfpv4
114-
--copt=-O3 --copt=-fno-tree-pre --copt=-fpermissive
115-
--define tensorflow_mkldnn_contraction_kernel=0
116-
--define=raspberry_pi_with_neon=true"
117-
;;
118-
aarch64)
119-
BAZEL_FLAGS="--config=elinux_aarch64
120-
--define tensorflow_mkldnn_contraction_kernel=0
121-
--copt=-O3"
122-
;;
123-
native)
124-
BAZEL_FLAGS="--copt=-O3 --copt=-march=native"
125-
;;
126-
*)
127-
BAZEL_FLAGS="--copt=-O3"
128-
;;
129-
esac
130-
131-
132-
133-
# Build python interpreter_wrapper.
134-
cd "${BUILD_DIR}"
135-
case "${TENSORFLOW_TARGET}" in
136-
armhf)
137-
BAZEL_FLAGS="--config=elinux_armhf
138-
--copt=-march=armv7-a --copt=-mfpu=neon-vfpv4
139-
--copt=-O3 --copt=-fno-tree-pre
140-
--define tensorflow_mkldnn_contraction_kernel=0
141-
--define=raspberry_pi_with_neon=true
142-
--define=tflite_pip_with_flex=true
143-
--define=tflite_with_xnnpack=false
144-
--define=tflite_kernel_use_xnnpack=false
145-
--ui_actions_shown=20"
146-
;;
147-
aarch64)
148-
BAZEL_FLAGS="--config=elinux_aarch64
149-
--define tensorflow_mkldnn_contraction_kernel=0
150-
--define=tflite_pip_with_flex=true
151-
--define=tflite_with_xnnpack=true
152-
--copt=-O3
153-
--ui_actions_shown=20"
154-
;;
155-
native)
156-
BAZEL_FLAGS="--copt=-O3 --copt=-march=native
157-
--define=tflite_pip_with_flex=true
158-
--define=tflite_with_xnnpack=true
159-
--ui_actions_shown=20"
160-
;;
161-
*)
162-
BAZEL_FLAGS="--copt=-O3
163-
--define=tflite_pip_with_flex=true
164-
--define=tflite_with_xnnpack=true
165-
--ui_actions_shown=20"
166-
;;
167-
esac
168-
```
169-
- Build
170-
```bash
171-
cd tensorflow/lite/tools/pip_package
172-
173-
make BASE_IMAGE=ubuntu:20.04 PYTHON=python3 PYTHON_VERSION=3.8 TENSORFLOW_TARGET=aarch64 docker-build
174-
make BASE_IMAGE=debian:bullseye PYTHON=python3 PYTHON_VERSION=3.9 TENSORFLOW_TARGET=aarch64 docker-build
175-
make BASE_IMAGE=ubuntu:22.04 PYTHON=python3 PYTHON_VERSION=3.10 TENSORFLOW_TARGET=aarch64 docker-build
176-
make BASE_IMAGE=debian:bookworm PYTHON=python3 PYTHON_VERSION=3.11 TENSORFLOW_TARGET=aarch64 docker-build
177-
178-
make BASE_IMAGE=ubuntu:20.04 PYTHON=python3 PYTHON_VERSION=3.8 TENSORFLOW_TARGET=armhf docker-build
179-
make BASE_IMAGE=debian:bullseye PYTHON=python3 PYTHON_VERSION=3.9 TENSORFLOW_TARGET=armhf docker-build
180-
make BASE_IMAGE=ubuntu:22.04 PYTHON=python3 PYTHON_VERSION=3.10 TENSORFLOW_TARGET=armhf docker-build
181-
make BASE_IMAGE=debian:bookworm PYTHON=python3 PYTHON_VERSION=3.11 TENSORFLOW_TARGET=armhf docker-build
182-
183-
make BASE_IMAGE=ubuntu:20.04 PYTHON=python3 PYTHON_VERSION=3.8 TENSORFLOW_TARGET=native docker-build
184-
```
95+
96+
## Build
97+
```bash
98+
BRANCH=r2.15-tflite-build
99+
git clone -b ${BRANCH} --depth 1 https://github.com/PINTO0309/tensorflow.git
100+
cd tensorflow/lite/tools/pip_package
101+
102+
make BASE_IMAGE=ubuntu:22.04 PYTHON=python3 PYTHON_VERSION=3.10 TENSORFLOW_TARGET=aarch64 docker-build
103+
make BASE_IMAGE=debian:bookworm PYTHON=python3 PYTHON_VERSION=3.11 TENSORFLOW_TARGET=aarch64 docker-build
104+
105+
make BASE_IMAGE=ubuntu:22.04 PYTHON=python3 PYTHON_VERSION=3.10 TENSORFLOW_TARGET=armhf docker-build
106+
make BASE_IMAGE=debian:bookworm PYTHON=python3 PYTHON_VERSION=3.11 TENSORFLOW_TARGET=armhf docker-build
107+
108+
make BASE_IMAGE=ubuntu:22.04 PYTHON=python3 PYTHON_VERSION=3.10 TENSORFLOW_TARGET=native docker-build
109+
```
185110

186111
## Operation check 【Classification】
187112
**Sample of MultiThread x4 by Tensorflow Lite [MobileNetV1 / 75ms]**

0 commit comments

Comments
 (0)