You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This example shows how to use Tensorflow Lite Micro together with embARC MLI application. It consists of two parts:
1
+
# EMNIST Example: Tensorflow Lite Micro Usage
2
+
3
+
This example shows how to use Tensorflow Lite Micro together with an embARC MLI application. It consists of two parts:
4
4
5
5
1) Example application. It demonstrates how to use the tflite-micro API and guides you through the building aspects of the application and libraries.
6
6
7
7
2) Conversion Tutorial. An independent part showing how the NN model for the application was converted into tflite format and adapted to be MLI compatible.
8
8
9
-
The first part is disclosed in this readme. The details of the conversion tutorial are covered in the separate [readme](/examples/tutorial_emnist_tflm/conversion_tutorial/README.md) in the [*conversion_tutorial*](/examples/tutorial_emnist_tflm/conversion_tutorial) directory. Passing the second part is not necessary to run the example application.
10
-
9
+
The first part is disclosed in this readme. The details of the conversion tutorial are covered in the separate readme file in the [*conversion_tutorial*](/examples/tutorial_emnist_tflm/conversion_tutorial) directory. Passing the second part is not necessary to run the example application.
11
10
12
11
**Important notes:**
13
-
* Example is supported only for VPX configurations with guard bits. For EM/HS, please use [MLI 1.1 release version](https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_mli/tree/Release_1.1/examples/tutorial_emnist_tflm).
14
12
15
-
16
-
# Building and Running
13
+
* Example is supported only for VPX configurations with guard bits. For EM/HS, please use [MLI 1.1 release version](https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_mli/tree/Release_1.1/examples/tutorial_emnist_tflm).
17
14
18
15
## Generate Tensorflow Lite Micro Library
19
16
@@ -23,40 +20,36 @@ Tensorflow Lite for Microcontrollers is a separate project with specific set of
The fork has been updating periodically from the [upstream repo](https://github.com/tensorflow/tflite-micro) using states that are stable in relation to ARC target:
23
+
The fork has been updating periodically from the [upstream repo](https://github.com/tensorflow/tflite-micro) using states that are stable in relation to ARC target.
27
24
28
-
Please first familiarize yourself with [TFLM ARC specific details](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/blob/main/tensorflow/lite/micro/tools/make/targets/arc/README.md) and make sure that your environment is set up appropriately.
25
+
Please first familiarize yourself with [TFLM ARC specific details](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/blob/main/tensorflow/lite/micro/tools/make/targets/arc/README.md) and make sure that your environment is set up appropriately.
29
26
30
-
Important information is listed inside [make tool section](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/tree/main/tensorflow/lite/micro/tools/make/targets/arc#make-tool) of the referred document.
31
-
The main message is that native *nix environment is required to build the TFLM library.
32
-
For Windows users there are no officially supported flow.
27
+
Important information is listed inside [make tool section](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/tree/main/tensorflow/lite/micro/tools/make/targets/arc#make-tool) of the referred document.
28
+
The main message is that native *nix environment is required to build the TFLM library.
29
+
For Windows users there are no officially supported flow.
33
30
You still may consider projects like [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) at your own risk.
34
31
35
-
To build **tflite-micro** library please find the corresponding section in documentation specified for a [custom ARC platform](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/tree/main/tensorflow/lite/micro/tools/make/targets/arc#Custom-ARC-EMHSVPX-Platform). You need to copy the generated library to the *third_party* directory of this example and rename it to *libtensorflow-microlite.a* (see the same documentation on where the generated library can be found).
36
-
32
+
To build **tflite-micro** library please find the corresponding section in documentation specified for a [custom ARC platform](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/tree/main/tensorflow/lite/micro/tools/make/targets/arc#Custom-ARC-EMHSVPX-Platform). You need to copy the generated library to the *third_party* directory of this example and rename it to *libtensorflow-microlite.a* (see the same documentation on where the generated library can be found).
37
33
38
-
## Building and running example
34
+
For the following example application build you should set ``TENSORFLOW_DIR``
35
+
environment variable to point to the cloned tflite-micro repository:
39
36
40
-
Before building the application you should set ``TENSORFLOW_DIR`` environment variable to point to your Tensorflow top folder:
After that you need to configure and build the library project for the desired VPX
51
-
configuration.
52
-
Please read the corresponding section on [building the package](/README.md#building-the-package).
53
-
54
-
**Known Issue:** To successfully build this example you need to invoke build process from the */examples/tutorial_emnist_tflm* folder.
45
+
After you've passed ["Generate Tensorflow Lite Micro Library"](#generate-tensorflow-lite-micro-library) step
46
+
you need to configure and build the library project for the desired VPX
47
+
configuration. Please read the corresponding section on [building the package](/README.md#building-the-package). **Also make sure you didn't forget to set ``TENSORFLOW_DIR`` environment variable.**
55
48
56
49
Build artifacts of the application are stored in the `/obj/<project>/examples/tutorial_emnist_tflm` directory where `<project>` is defined according to your target platform.
57
50
58
-
After you've built and configured the whole library project, you can proceed with the following steps.
59
-
You need to replace `<options>` placeholder in commands below with the same options list you used for the library configuration and build.
51
+
After you've built and configured the whole library project, you can proceed with the following steps.
52
+
You need to replace `<options>` placeholder in commands below with the same [build configuration options](README.md#build-configuration-options) list you used for the library configuration and build.
60
53
61
54
1. Open command line in the root of the embARC MLI repo and change working directory to './examples/tutorial_emnist_tflm/'
62
55
@@ -66,51 +59,36 @@ You need to replace `<options>` placeholder in commands below with the same opti
66
59
67
60
gmake <options> clean
68
61
69
-
3. Build the example. This is an optional step as you may go to the next step which automatically invokes the build process.
62
+
3. Build the example. This is an optional step as you may go to the next step which automatically invokes the build process.
70
63
71
64
gmake <options> build
72
65
73
66
4. Run the example
74
67
75
68
gmake <options> run
76
69
77
-
## ARC VPX Build Process Example
70
+
## ARC VPX Build Process Example
78
71
79
-
Assuming your environment satisfies all build requirements for ARC VPX platform, you can use the following script to build and run application using the nSIM simulator.
72
+
Assuming you've already built and copied *libtensorflow-microlite.a* and your environment satisfies all build requirements for ARC VPX platform, you can use the following script to build and run the application using the nSIM simulator.
80
73
The first step is to open a command line and change working directory to the root of the embARC MLI repo.
3. Change working directory and build project using generated TCF and appropriate built-in runtime library for it. Use multithreaded build process (4 threads):
This tutorial shows how to convert EMNIST Tensorflow model into Tensorflow Lite Micro format to furhter usage in application together with embARC MLI.
1
+
# Model Conversion Tutorial for EMNIST Example
2
+
3
+
This tutorial shows how to convert EMNIST Tensorflow model into Tensorflow Lite Micro format for further usage in application together with embARC MLI.
4
4
5
5
## Requirements
6
6
7
-
The following dependencies must be installed in your environment.
7
+
The following dependencies must be installed in your environment:
8
+
8
9
* Python 3.7
9
10
* Dependencies from the [requirements.txt](/examples/tutorial_emnist_tflm/conversion_tutorial/requirements.txt) file
10
-
* NumPy 1.19.2
11
-
* Matplotlib
12
-
* Jupyter Lab / Notebook
13
-
* TensorFlow 2.5.1
14
-
* Keras
15
-
* emnist
11
+
* NumPy 1.19.2
12
+
* Matplotlib
13
+
* Jupyter Lab / Notebook
14
+
* TensorFlow 2.5.1
15
+
* Keras
16
+
* emnist
16
17
17
-
If you are looking for instruction to set-up a compatible environment, then consider the comprehended guide on [TensorFlow](https://www.tensorflow.org/install) installation. We recommend to follow ["Install TensorFlow with pip"](https://www.tensorflow.org/install/pip) and not ignore recommendation on usage of the virtual environment.
18
+
If you are looking for instruction to set-up a compatible environment, then consider the comprehensive guide on [TensorFlow](https://www.tensorflow.org/install) installation. We recommend to follow ["Install TensorFlow with pip"](https://www.tensorflow.org/install/pip) and not ignore recommendation on usage of the virtual environment.
18
19
19
20
Make sure you have installed required version of dependencies listed in the *requirements.txt* file. In case you followed our recommendation on install TensorFlow with pip, for [step 3](https://www.tensorflow.org/install/pip#3.-install-the-tensorflow-pip-package) you can use the following commands instead the proposed ones. First change working directory in terminal to the [conversion_tutorial](/examples/tutorial_emnist_tflm/conversion_tutorial).
To convert the model, run the Jupyter Notebook (change working directory in terminal to the [conversion_tutorial](/examples/tutorial_emnist_tflm/conversion_tutorial) if you haven't done it):
After completing the tutorial you should have model and test samples generated.
31
+
After completing the tutorial, you should have model and test samples generated.
35
32
36
33
Please make sure you don't forget to use [Model Adaptation Tool](https://github.com/foss-for-synopsys-dwc-arc-processors/tflite-micro/blob/main/tensorflow/lite/micro/tools/make/targets/arc/adaptation_tool.py) to convert `emnist_model_int8.tflite` you got before saving it as C array.
37
34
38
35
## Using Converted Model in Application
39
36
40
-
See [EMNIST example part](/examples/tutorial_emnist_tflm) on how a converted model might be used in application together with TFLM and embARC MLI. It already contains converted model, hence this ste is optional.
41
-
42
-
To use generated models in the example you need to copy */examples/tutorial_emnist_tflm/conversion_tutorial/generated/model.h* and */examples/tutorial_emnist_tflm/conversion_tutorial/generated/test_samples.cc* to */examples/tutorial_emnist_tflm/src* folder. Make sure that name of buffers and constants in copied files are aligned with the former ones and change them if not. Afterward you can clean, beald and run example application according to instructions.
43
-
44
-
37
+
See [EMNIST example part](/examples/tutorial_emnist_tflm) on how a converted model might be used in application together with TFLM and embARC MLI. The example already contains converted model, hence this step is optional.
45
38
39
+
To use generated models in the example you need to copy */examples/tutorial_emnist_tflm/conversion_tutorial/generated/model.h* and */examples/tutorial_emnist_tflm/conversion_tutorial/generated/test_samples.cc* to */examples/tutorial_emnist_tflm/src* folder. Make sure that names of buffers and constants in copied files are aligned with the former ones and change them if not. Afterward you can clean, build and run example application according to instructions.
0 commit comments