# Final results

## Performance

***

As we seen before on the deployment of the YOLOv3 model on the PYNQ-Z2, the inference is quite a fast process. It takes less than a second to detect and even draw the bounding boxes on the image. This all looks very promissing but how does it compare to the performance of a normal computer?

First, we should use the same image on all the tests. The ideal image would be the infamous image with the dog, the bicycle and the pick-up truck. This will make sure that there are no disparities when it comes to processing the image. Wouldn't be fair if the post-processing had more pixels in one case than the other.

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FPBZsTTFsYHSOXqiNWWQf%2Fdog.jpg?alt=media&#x26;token=1d50802e-7e55-40dc-afa7-5412ab194fbd" alt="" width="563"><figcaption><p>YOLO test image</p></figcaption></figure>

To make the comparison, I ran the YOLOv3 model on my computer using the Darknet API. You can find the details on the YOLO website but in short, you just have to download Darknet and the pre-trained YOLOv3 model. Then you execute the detection command to make inference on the image and the result will be the image with the detections and the time it took to process the image.

```
//Download and compile Darknet
git clone https://github.com/pjreddie/darknet
cd darknet
make
```

Then we download the weights file for the YOLOv3 and execute the inference:

```
wget https://pjreddie.com/media/files/yolov3.weights
./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
```

This was my first result:

<figure><img src="https://2477548334-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjW7iX6UPM2ifyvOJm6AX%2Fuploads%2FfNP6cN0G1dpBPx1ab4Kl%2Fimage.png?alt=media&#x26;token=9e1eea2c-5bf1-4a8c-99de-af142d425a41" alt=""><figcaption><p>YOLO inference on the computer</p></figcaption></figure>

My computer doesn't have a graphics card so the processing is all a job for the AMD Rayzen 5 3500U CPU. With a GPU the results would be much different but unfair.

As you can see, the computer took on average 19 seconds to predict the objects on the test image! This is result is 23 times slower than the time it took on the PYNQ-Z2 which makes it a very good result.

I should note that the YOLOv3 network used on the CPU is obviously more complex as it wasn't compressed. Maybe with the quantized network the results would be a lot better.



&#x20;

## Accuracy

***

As we saw earlier, the YOLO model is a lot faster on the PYNQ-Z2 than on the CPU. But what about the accuracy? Will it be a lot less than the original model?

It is a fact that a compressed network will lose accuracy because the parameters are simplified. But, the trade for inference speed should not be so high because a model with low accuracy isn't very useful.

We saw on the previous chapter how to obtain some metrics for the YOLO model running on the PYNQ-Z2. We will now compare those results with the official YOLOv3 metrics that you can consult on this [amazing paper](https://arxiv.org/pdf/1804.02767.pdf;) written by Joseph Redmon and Ali Farhadi. Take a look at this tale:

<table><thead><tr><th width="191">Platform</th><th width="80">AP</th><th width="82">AP50</th><th width="78">AP75</th><th width="74">APS</th><th width="78">APM</th><th width="74">APL</th><th>mAP</th></tr></thead><tbody><tr><td>YOLOv3</td><td>33,00</td><td>57,90</td><td>34,40</td><td>18,30</td><td>35,40</td><td>41,90</td><td>55,30</td></tr><tr><td>PYNQ-Z2 YOLOv3</td><td>21,41</td><td>40,10</td><td>20,53</td><td>6,07</td><td>20,46</td><td>32,19</td><td>40,36</td></tr></tbody></table>

As you can see, there was a little decrement on the accuracy of the model on the PYNQ-Z2. But, the decrement wasn't very big and the results still make the model very accurate both teorically and pratically. Also, the smaller accuracy is not proportional to the inference speed. In other words, the YOLOv3 model on the PYNQ-Z2 is 23 times faster and 27% less accurate than the original YOLO model.

This goes to show that FPGA's are indeed a really good way to embed a Neural Network. The Hardware maked the execution time of the Neural Network really fast and the accuracy still very acceptable. Also, the PLD has a really low power consumption - about 4,166W which is less than some LED lightbulbs!
