-
Set the pythonpath:
export PYTHONPATH=/path/to/pocket-cnn/code/python_tools
-
Choose a framework of your choice to train the CNN. In this example, Pytorch is used, because it has built in ONNX export. A list of available frameworks can be found at https://github.com/onnx/tutorials.
-
Install the python modules numpy, onnx and fpbinary.
-
Clone the repository:
git clone [email protected]:marph91/pocket-cnn.git
-
Run the script:
cd pocket-cnn/examples/end_to_end && ./end_to_end.sh
The script executes the following steps:- Train a CNN and save it in ONNX format. The model is an adapted Lenet, which is trained on the MNIST dataset. Example training results are an accuracy of 91% and a loss of 0.3253 on the test images.
- Quantize the exported ONNX model.
- Create a synthesizable toplevel wrapper and corresponding weights files from the ONNX model.
-
Import the generated VHDL toplevel file (
examples/end_to_end/work/top_wrapper.vhd
) in the project, like the other sources fromcode/vhdl/src
. Make sure the weights path is set correctly and the weights files don't get moved later. -
Synthesize with a tool of your choice. Right now it was only tested with Xilinx Vivado.