Okay, so element14 gave me a Pynq Z2 and I tried running some simple applications on it to see what is all the hype about.
1) CIFAR 10 using pre-trained binary neural networks - I use my own images and change the code a little to see performance comparison between hardware accelerated inference and software inference:
# take the above pieces and put together into a function
#======================================================== CODE ========================================================================================================#
import bnn
from PIL import Image
import numpy as np
import time
hw_classifier = bnn.CnvClassifier(bnn.NETWORK_CNVW1A1,'cifar10',bnn.RUNTIME_HW)
sw_classifier = bnn.CnvClassifier(bnn.NETWORK_CNVW1A1,'cifar10',bnn.RUNTIME_SW)
im_name = '/home/xilinx/jupyter_notebooks/SAMBIT_DATA/car' + str(4) + '.jpg'
print("Classifying image : {0}".format(im_name))
im = Image.open(im_name)
im
def classify_images_cifar10():
"""
Function classifies a series of images using the hardware classifier
platform : hw -> hardware
sw -> software
"""
print("Available classes")
print(hw_classifier.classes)
print ("========================== hardware classifications ==============================")
for i in range(1,10):
im_name = '/home/xilinx/jupyter_notebooks/SAMBIT_DATA/car' + str(i) + '.jpg'
print("Classifying image : {0}".format(im_name))
im = Image.open(im_name)
im
class_out=hw_classifier.classify_image(im)
print("Class number: {0}".format(class_out))
print("Class name: {0}".format(hw_classifier.class_name(class_out)))
print("======================== software classifications ===============================")
for i in range(1,10):
im_name = '/home/xilinx/jupyter_notebooks/SAMBIT_DATA/car' + str(i) + '.jpg'
print("Classifying image : {0}".format(im_name))
im = Image.open(im_name)
im
class_out = sw_classifier.classify_image(im)
print("Class number: {0}".format(class_out))
print("Class name: {0}".format(sw_classifier.class_name(class_out)))
return im
if __name__ == '__main__':
im = classify_images_cifar10()
im
Here is the output:
Problems:
1) As you can see in the code:
im_name = '/home/xilinx/jupyter_notebooks/SAMBIT_DATA/car' + str(i) + '.jpg'
print("Classifying image : {0}".format(im_name))
im = Image.open(im_name)
im
I expected this to first show the image that I am classifying and then show classifcation result. But, the images are not displayed.
The code seems to be correct since it is just an adaptation of:
This works, but in the loop, it does not.
2) The accuracy is just above 50%, as can be seen in the output, only 4 images were classified correctly out of 9 (the last output is not visible here).
3) Development resources and documentation:
- I haven't seen a more unorganized and confused documentation for an embedded development platform EVER!!! It is absolutely incoherent and mixed up.
- There isn't even an API guide that describes all APIs, parameters and examples.
- The documentation at best, just glances over what Pynq has, never really mentioning how to.
- Even a simple LED blink app will take about 30 mins of scourging through examples - I don't like learning how to use an API by reading examples.
- Even the BNN/ FINN repository does not mention anything about how to build a BNN, just presents some examples and expects users to just tweak some code and there and be happy. I am not!!!!
- Overlay design, a very key concept has just been hinted at, never showing an end-to-end example. May be this is enough for an experience FPGA developer, but for someone like me who is trying to figure out Pynq and FPGA design, it makes absolutely no sense.
I found better resources for overlay design on the internet than in the documentation for Pynq.
- Development environment : Jupyter is okay just for fun, NOT for serious and large code development!! Especially with all the new overlay packages and others (minus the documentation), I would like to have the support of intellisense like in a professional IDE like PyCharm or Eclipse.
So far, I could not find any.
What I like:
1) Quick prototyping for existing overlays and libraries
2) Easy file transfer via samba
3) Pretty impressive hardware performance for such low cost.
I shall try some more applications and may be an overlay design, since I have some more time on hand.
Top Comments