(h, w)[c] - mean[c]) * input_scale);
}
}
}
```
Note that the DPU API apply [OpenCV](https://opencv.org/) functions to read an image file (either ``png`` or ``jpg`` or whatever format) therefore the images are seen as BGR and not as native RGB. All the training and inference steps done in this tutorial treat images as BGR, which is true also for the above C++ normalization routine.
#### 5.4.2 Run-Time Execution
It is possible and straight-forward to compile the application directly on the target (besides compiling it into the host computer environment).
In fact this is what the script [run_all_imagenet_target.sh](files/target/imagenet/run_all_imagenet_target.sh) does, when launched on the target.
Turn on your target board and establish a serial communication with a ``putty`` terminal from Ubuntu or with a ``TeraTerm`` terminal from your Windows host PC.
Ensure that you have an Ethernet point-to-point cable connection with the correct IP addresses to enable ``ssh`` communication in order to quickly transfer files to the target board with ``scp`` from Ubuntu or ``pscp.exe`` from Windows host PC. For example, you can set the IP addresses of the target board to be ``192.168.1.217`` while the host PC is ``192.168.1.140``.
Once a ``tar`` file of the ``build/target_zcu102`` (or ``build/target_vck190``) folder has been created, copy it from the host PC to the target board. For example, in case of an Ubuntu PC, use the following command:
```
scp target_zcu102.tar root@192.168.1.217:~/
```
From the target board terminal, run the following commands (in case of ZCU102):
```bash
tar -xvf target_zcu102.tar
cd target_zcu102
bash -x ./imagenet/run_all_imagenet_target.sh zcu102
```
With this command, the ``val_dataset.zip`` archive with the 500 test images will be uncompressed.
The application based on VART C++ APIs is built with the [build_resnet50.sh](files/target/imagenet/code_resnet50/build_resnet50.sh) script and finally launched for each CNN, the effective top-5 classification accuracy is checked by a python script [check_runtime_top1_imagenet.py](files/target/imagenet/code_resnet50/src/check_runtime_top1_imagenet.py) which is launched from within
the [imagenet_performance.sh](files/target/imagenet/imagenet_performance.sh) script.
#### 5.4.3 ResNet50 Performance
On the VEK280 board, the purely DPU performance (not counting the CPU tasks) measured in fps is:
- ~2997 fps with 1 thread,
- ~4685 fps with 3 threads.
The top-1 average prediction accuracy measured at run time is:
```
./rpt/predictions_resnet50_imagenet.log has 3510 lines
number of total images predicted 499
number of top1 false predictions 153
number of top1 right predictions 346
top1 accuracy = 0.690
```
The preprocessing applied in the C++ code top-1 accuracy is the "brutal" one, just applying the images resize without preserving the aspect ratio, as done in the training phase of the CNN algorithmic development.
The value of ``0.690`` is pretty closed to the ``0.698`` result we have got when evaluating the quantized model in the host Vitis AI environment; remember that by applying a better preprocessing in the C++ code you should achieve a result closed to ``0.750``.
Alternatively to changing the C++ code, you could prepare - once forever- test images that are already preprocessed in the same way which was applied during the CNN training.
#### 5.4.4 ResNet18 Performance
On the VEK280 board, the purely DPU performance (not counting the CPU tasks) measured in fps is:
- ~3964 fps with 1 thread,
- ~7169 fps with 3 threads.
Indeed ResNet18 achieves higher fps being "smaller" than ResNet50, which is expected.
The top-1 average prediction accuracy measured at run time is:
```
./rpt/predictions_resnet18_imagenet.log has 3510 lines
number of total images predicted 499
number of top1 false predictions 212
number of top1 right predictions 287
top1 accuracy = 0.580
```
Also this ``0.580`` top-1 result is achieved with the "brutal" preprocessing in the C++ application and it should be compared with the ``0.606`` obtained while evaluating the quantized model in the host environment (with a better preprocessing you should achieve a value closed to ``0.651``).
Similarly to the ResNet50 case, alternatively to changing the C++ code, you could prepare - once forever- test images already preprocessed in the same way that was applied during the CNN training.
## Appendix
### UART connectivity (PuTTY, minicom, etc)
For more details, see [5 Linux/Unix Commands For Connecting To The Serial Console](https://www.cyberciti.biz/hardware/5-linux-unix-commands-for-connecting-to-the-serial-console/).
Figure A1.1 illustrate some screeshot taken while using the ``minicom`` utility,
the following code illustrate how installing it or other alternative tools:
```
#sudo apt install setserial # alternative tool to minicom
#sudo apt install cu # alternative tool to minicom
#sudo apt install putty # alternative tool to minicom
sudo apt-get install minicom
sudo minicom -s
```




*Figure A1.1: Working with minicom tool*
## License
The MIT License (MIT)
Copyright © 2023 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
XD106 | © Copyright 2022 Xilinx, Inc.