mirror of
https://github.com/vee1e/tflite-micro.git
synced 2026-09-01 17:57:27 +00:00
Allow using Python scripts without bazel. (#639)
* Allow using Python scripts without bazel. Manually verified and documented the steps that I can follow to run Python code without Bazel. BUG=http://b/204109200 NO_CHECK_TFLITE_FILES=manually ran the sync script. * Address review comments.
This commit is contained in:
parent
9452ef8381
commit
e958bb1161
15 changed files with 78 additions and 16 deletions
60
docs/python.md
Normal file
60
docs/python.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<!--ts-->
|
||||
* [Using Bazel](#using-bazel)
|
||||
* [Manual Setup Illustration](#manual-setup-illustration)
|
||||
|
||||
<!-- Added by: advaitjain, at: Fri Oct 29 11:57:14 AM PDT 2021 -->
|
||||
|
||||
<!--te-->
|
||||
|
||||
Writing and using Python scripts from the TFLM repository is currently in the
|
||||
prototyping stage. As such, the instructions below are somewhat sparse and
|
||||
subject to change.
|
||||
|
||||
|
||||
* [TensorFlow Python style guide](https://www.tensorflow.org/community/contribute/code_style#python_style)
|
||||
|
||||
|
||||
# Using Bazel
|
||||
|
||||
We use Bazel as our default build system for Python and the continuous
|
||||
integration infrastrucutre only runs the Python unit tests via Bazel.
|
||||
|
||||
When using Bazel + Python, all the environment setup is handled as part of the
|
||||
build.
|
||||
|
||||
Some example commands:
|
||||
```sh
|
||||
bazel test tensorflow/lite/tools:flatbuffer_utils_test
|
||||
bazel build tensorflow/lite/tools:visualize
|
||||
|
||||
bazel-bin/tensorflow/lite/tools/visualize tensorflow/lite/micro/models/person_detect.tflite tensorflow/lite/micro/models/person_detect.tflite.html
|
||||
```
|
||||
|
||||
# Manual Setup Illustration
|
||||
|
||||
For advanced users that would like to use the Python code in the TFLM repository
|
||||
independent of bazel, here is one approach.
|
||||
|
||||
Please note that this setup is unsupported and will need users to debug various
|
||||
issues on their own. It is described here for illustrative purposes only.
|
||||
|
||||
```sh
|
||||
# The cloned tflite-micro folder needs to be renamed to tflite_micro
|
||||
mv tflite-micro tflite_micro
|
||||
python -m venv tflite_micro/venv
|
||||
echo "export PYTHONPATH=\${PYTHONPATH}:${PWD}" >> tflite_micro/venv/bin/activate
|
||||
cd tflite_micro
|
||||
source venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -r third_party/requirements.txt
|
||||
|
||||
# (Optional)
|
||||
pip install ipython
|
||||
```
|
||||
|
||||
Run some tests and binaries:
|
||||
```sh
|
||||
python tensorflow/lite/tools/flatbuffer_utils_test.py
|
||||
python tensorflow/lite/tools/visualize.py tensorflow/lite/micro/models/person_detect.tflite tensorflow/lite/micro/models/person_detect.tflite.html
|
||||
```
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue