The TensorFlow ResNet-50 Convolutional Neural Network (CNN) is provided with the Xilinx Deep Neural Network Development Kit (DNNDK) v3.1.
The model can be found in the in the folder below:
How can I test this example on hardware?
The CNN Resnet50 developed with TensorFlow can be tested on hardware by completing the following steps:
This Answer Record provides additional help on some of these steps.
It is important to know how the model was trained: the same image pre-processing sequence must be used during quantization and the hardware test.
The Resnet50 CNN in the example comes from the Model Zoo (https://github.com/Xilinx/AI-Model-Zoo)
The CNN has been pre-trained with images coming from the ImageNet set, with the following characteristics:
Scaling the images to 0-1 during quantization, or reversing the order to BGR, or forgetting the average value subtraction are very common errors that will cause unexpected results in hardware.
The Quantization process requires some images for calibration, but they are not provided with the model.
The user should download 100 to 1000 images of ImageNet data set from http://academictorrents.com/collection/imagenet-2012 or http://www.image-net.org/download.php
Note that the TensorFlow Calibration does not require the label value, so you will need to slightly modify the resnet_v1_50_input_fn.py and skip the label information.
You might also need to edit line 21 and 22 that set the path to the calibration folder.
Notes on the resnet_v1_50_input_fn.py:
Remember that the image for training was in RGB format. The resnet_v1_50_input_fn.py preprocesses the images using two functions:
The Deep Neural Network Compiler (DNNC) generates one .elf file.
The kernel names are resnet_v1_50_0 (DPUKernel) and resnet_v1_50_1 (CPUKernel)
The same kernel names must be used in the main.cc file and Makefile.
Build on Target
The TensorFlow model needs a dedicated main.cc file which is different from the Caffe model.
In particular, the Kernel name, input/output names, images extensions, and some other cosmetic changes have been edited in the attached main.cc file.
Also the Makefile which comes with DNNDK 3.1 should be fixed due to a typo in the .elf model name.