/tiny_cnn

Primary LanguageJupyter Notebook

Tiny CNN - Developing Efficient CNN Architectures for Image Classification on Microcontroller Units

This repository contains the notebooks for the CNN-Analyzer - a dashboard based tool for determining optimal CNN architecture parameters

No. File Name Description
01 01 Model Factory.ipynb tf.model.summary
tf.keras.utils.plot_model
Visualization of model graph
Untrained TensorFlow model
02 02 TensorFlow Layer Analyzer.ipynb tf.model.layers layerwise model info
03 03 Model Analyzer.ipynb Parsing .txt
MACs
FLOPs
Total parameters
Trainable parameters
Non-trainable parameters
Create dataframe from _layers.csv
Untrained TensorFlow model conversion to TFLite
TFLite model
Untrained TensorFlow model conversion to TFLite with int8-quantization
Int8 quantized TFLite model
TFLite model size in KB
TFLite int8 model size in KB
tflite_tools.py (E. Liberis) layerwise RAM in bytes
Max value from layerwise RAM in bytes
General model architecture parameters
Model name
Model variation
Alpha factor
Image resolution
Number of classes
Number of input channels (RGB or grayscale)
MLTK Profiler (hardware simulation) layerwise metrics (ops, MACs, CPU cycles, energy, input shape and output shape)
Model size in bytes
RAM in bytes
FLOPs
MACs
Number of unsupported layers
Int8 energy
04 04 Deploy to MCU.ipynb Convert TFLite model to C code
05 05 LINUX - Benchmarking TFLite Models.ipynb TensorFlow native benchmarking tool
Layerwise benchmarking report of int8 model running on desktop
06 06 LINUX - Parsing CPU Benchmark Data.ipynb Parsing _benchmark.txt
07 07 Model Training.ipynb Trained TensorFlow model
TFLite model
Int8 quantized TFLite model
08 08 Update Model DB.ipynb Write test accuracy from model training project to the model database
09 09 Benchmarking on STM32-Cube.AI.ipynb Requires profiling int8 quantized with STM32-Cube.AI on external MCU
Parsing <model_name>_stm32_benchmark/network_validate_report_INT8.txt
CPU cycles per MAC
Inference time in milliseconds
Inference duration and layer type per layer
10 10 Model Comparison & Visualizations.ipynb Create visualizations

Install the Conda Environment

conda env create -f conda-environment.yhttps://github.com/subrockmann/tiny_cnn/blob/master/08%20Update%20Model%20DB.ipynb

Activate the Environmnet

conda activate tiny_cnn

Update the Environment

conda activate tiny_cnn
conda env update --file environment.yml # --prune

Uninstalling the Environment

If there are too many error about inconsistencies, it might be easier to uninstall the environment and re-install it from scratch.

conda deactivate
conda env remove --name tiny_cnn

If Nothing Else Helps

conda clean --all

You Might Want to Run:

conda update --all

Libcupti Issue:

conda install -c nvidia cuda-cupti

Setting up the Arduino IDE

Unfortunately the Arduino_TensorFlowLite library is not include in the Arduino Library Manager. Instead the library has to be installed from a ZIP File https://www.ardu-badge.com/Arduino_TensorFlowLite/zip