|
| 1 | +# TensorFlow to MPLAB® Harmony v3 Model Converter |
| 2 | + |
| 3 | +**Welcome to tf2mplabh3!** |
| 4 | + |
| 5 | +This project is proudly developed and maintained by **Microchip Technology Inc.** |
| 6 | +It enables you to convert TensorFlow models to C code, ready for seamless integration into your MPLAB® Harmony v3 embedded projects. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## What is this? |
| 11 | + |
| 12 | +`tf2mplabh3` is a command-line tool that automates the conversion of TensorFlow models to C code, making it easy to deploy machine learning models on embedded systems using MPLAB® Harmony v3. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | + |
| 17 | +## Table of Contents |
| 18 | + |
| 19 | +- [Features](#features) |
| 20 | +- [Installation](#installation) |
| 21 | +- [Quick Start](#quick-start) |
| 22 | +- [Usage](#usage) |
| 23 | +- [Arguments](#arguments) |
| 24 | +- [Examples](#examples) |
| 25 | +- [License](#license) |
| 26 | +- [Acknowledgments](#acknowledgments) |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Features |
| 31 | + |
| 32 | +- Convert TensorFlow SavedModel to C code |
| 33 | +- Easy CLI interface |
| 34 | +- Verbosity control for logging |
| 35 | +- Ready for integration with MPLAB Harmony v3 |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Installation |
| 40 | +Clone the repository and run the installation script: |
| 41 | +```bash |
| 42 | +git clone --recursive https://github.com/yourusername/tf2mplabh3.git |
| 43 | +cd tf2mplabh3 |
| 44 | +./install.sh |
| 45 | +``` |
| 46 | +### If you already cloned without --recursive, run: |
| 47 | +```bash |
| 48 | +git submodule update --init --recursive |
| 49 | +``` |
| 50 | +--- |
| 51 | + |
| 52 | +## Quick Start |
| 53 | +Activate the virtual environment and run the script, by passing the TensorFlow model path as shown in the example below: |
| 54 | +```bash |
| 55 | +source .venv/bin/activate |
| 56 | +python3 -m tf2mplabh3 -m examples/mobilenet-v2-tensorflow2-035-128-classification-v2 |
| 57 | +``` |
| 58 | +--- |
| 59 | + |
| 60 | +## Usage |
| 61 | +```bash |
| 62 | +python3 -m tf2mplabh3 [options] |
| 63 | +``` |
| 64 | +--- |
| 65 | + |
| 66 | +## Arguments |
| 67 | + |
| 68 | +| Argument | Description | Default | |
| 69 | +|-----------------------------|---------------------------------------------|---------------------------------------------------------------| |
| 70 | +| `-m`, `--model` | Path to TensorFlow SavedModel directory | `examples/mobilenet-v2-tensorflow2-035-128-classification-v2` | |
| 71 | +| `-onnx`, `--onnx_model` | Path to output ONNX intermediate model file | `examples/model.onnx` | |
| 72 | +| `-c_file`, `--c_model_file` | Path to output C model file | `examples/model.c` | |
| 73 | +| `--tag` | SavedModel tag (e.g., `serve`) | `None` | |
| 74 | +| `--signature_def` | Signature def key (e.g., `serving_default`) | `None` | |
| 75 | +| `--onnx2c` | Path to the onnx2c executable | `c_deps/onnx2c/build/onnx2c` | |
| 76 | +| `-v`, `--verbosity` | Verbosity level (`0`=quiet, `1`=all logs) | `0` | |
| 77 | + |
| 78 | +--- |
| 79 | +## Examples |
| 80 | + |
| 81 | +### Convert a model with default settings: |
| 82 | +```bash |
| 83 | +python3 -m tf2mplabh3 |
| 84 | +``` |
| 85 | +### Convert a specific model and increase verbosity: |
| 86 | +```bash |
| 87 | +python3 -m tf2mplabh3 -m path/to/model -v 1 |
| 88 | +``` |
| 89 | +## License |
| 90 | + |
| 91 | +[Apache-2.0 License](LICENSE) |
| 92 | + |
| 93 | +## Acknowledgments |
| 94 | + |
| 95 | +- [tf2onnx](https://github.com/onnx/tensorflow-onnx) |
| 96 | +- [onnx2c](https://github.com/kraiskil/onnx2c) |
| 97 | +- [TensorFlow](https://www.tensorflow.org/) |
0 commit comments