SNNF Model Creater
Multiple models have been pre-prepared in SNNF that can run directly on the C3V platform. Please refer to the document for relevant model information:V1.1.0 of SNNF | Usage of V1.1.0
In SNNF code, model-related code is placed in the directory:nnmodels/sources/models
Divided into customized and official directories, the code in the official directory is the official provided example code. This includes parameter configuration information for the model, pre-processing, post-processing, and other code. If users want to add models to SNNF by themselves, they can follow the following process:
The added steps are illustrated using the YoloV5s object detection model as an example.
1. Prepare model files
Please refer to the document for model conversion:NN Model Conversion
Retrieve the following two files from the folder yolov5s_uint8_nbg_unify after completing the model conversion:
vnn_yolov5suint8.c
network_binary.nb
Then use snnf_model_creater tools to convert model files. snnf_model_creater is now available for Ubuntu 20.04 and above.
snnf_model_creater [source file] [target path] [model name]
[source file] vnn_model.c file exported by Acuity toolkit
[target path] target direct to generate
[model name] model name to create
./snnf_model_creater ./vnn_yolov5suint8.c ./yolov5sModel/ YoloV5sDetection
copy and rename complete: "./yolov5sModel/YoloV5sDetectionPostProcess.h"
copy and rename complete: "./yolov5sModel/YoloV5sDetectionModelInfo.cpp"
copy and rename complete: "./yolov5sModel/YoloV5sDetectionPostProcess.cpp"
copy and rename complete: "./yolov5sModel/YoloV5sDetectionModel.h"
copy and rename complete: "./yolov5sModel/YoloV5sDetectionModel.cpp"
Target file size: 8583
Model Generate Complete!
After execution, the model file used by SNNF will be generated in the output path:
yolov5sModel$ tree
.
├── YoloV5sDetectionModel.cpp
├── YoloV5sDetectionModel.h
├── YoloV5sDetectionModelInfo.cpp
├── YoloV5sDetectionModelPostProcess.cpp
└── YoloV5sDetectionModelPostProcess.h
2. Put the model files into the SNNF project
Please rename the network_binary.nb to snnf_YoloV5sDetection.nb and then copy it to the directory: resource/model.
Double-check that the MODEL_NB_FILE which is defined in file YoloV5sDetectionModelInfo.cpp is configured with the same name as your network_binay.nb :
#define MODEL_NB_FILE "resource/model/snnf_YoloV5sDetection.nb"
Put the generated cpp file into the directory:nnmodels/sources/models/customized/YoloV5sDetection
Put the generated header file into the directory:nnapi/include/models/customized/YoloV5sDetection
Modify nnmodes/makefile_sources.mk,add files related to the YOLOV5s model to the project:
3. Add customized post-process code
Please add your post-process code here in file YoloV5sDetectionPostProcess.cpp
4. Compile and run
copy the release folder to C3V.
By using the command, you can see that the model has been added to the project: