https://github.com/l-nmch/hailo-mnist
A guide on training a model, testing it, and optimizing it for deployment on a Hailo8L NPU unsing MNIST
https://github.com/l-nmch/hailo-mnist
ai cnn hailo8l machine-learning mnist tensorflow
Last synced: 2 months ago
JSON representation
A guide on training a model, testing it, and optimizing it for deployment on a Hailo8L NPU unsing MNIST
- Host: GitHub
- URL: https://github.com/l-nmch/hailo-mnist
- Owner: l-nmch
- License: mit
- Created: 2025-03-23T00:41:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-31T21:00:00.000Z (over 1 year ago)
- Last Synced: 2025-06-10T20:49:06.562Z (about 1 year ago)
- Topics: ai, cnn, hailo8l, machine-learning, mnist, tensorflow
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MNIST Model for Hailo8L
This repository provides a guide to training and running a TensorFlow-based MNIST model locally, and deploying it on the [Hailo8L](https://www.raspberrypi.com/products/ai-hat/) chip. It includes tools for training, testing, generating images, as well as instructions for converting the trained model to a format that can be optimized and deployed on the Hailo8L.
## Features
- Train a Convolutional Neural Network (CNN) model on the MNIST dataset using TensorFlow.
- Export the trained model in various formats (.keras, .tflite, .onnx).
- Run inference locally on the trained model.
- A utility to generate images for the MNIST model, if needed.
- Instructions for converting and optimizing the model using Hailo8L's DFC (Hailo Dataflow Compiler) (installation and usage instructions in a separate document).
## Setup
1. Install Dependencies
To get started, clone this repository :
```sh
git clone https://github.com/l-nmch/hailo-mnist.git
cd hailo-mnist
```
Create a virtualenv :
```sh
python3 -m venv .venv
source .venv/bin/activate
```
Install the required Python libraries
```sh
python3 -m pip install -r requirements.txt
```
2. Train the Model
Once the dependencies are installed, you can train the MNIST model using the following command:
```sh
python3 src/model.py --save mnist.keras
```
This will train the model on the MNIST dataset and save it in the .keras format as mnist.keras.
3. Test the Model Locally
To perform inference locally, use the predict.py script. For example, if you have an image (e.g., images/0.png), run:
```sh
python3 src/predict.py --model mnist.keras --input_file images/0.png
```
## Documentation
For further explanation on how to run the model on Hailo NPU, head to the [Documentation](./docs/README.md)
## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.