I have been working on converting the cpp super-resolution sample to Python. In order to make it work, it seems I need a function matU8ToBlob to convert the input images to a blob and then another function to convert the output blob to the final result (pixel values). This method is not really documented outside of the code and I am not a strong cpp programmer. Furthermore, I cannot find any python samples using the matU8ToBlob.
Can you confirm that I really need such a function and maybe point me in a right direction in terms of implementing the function in python3.
Hi i have written a small program with the python doing this.
I did not use that function.
I read the image in using openCV (which for python stores it in a numpy array BGR format already)
image = cv2.imread("new_img.png")
(you may need to resize the image for it to fit into the model)
After that you will need to create the bicupic version of the image
bicupic = cv2.resize(image,(1920,1080), interpolation = cv2.INTER_CUBIC)
Then you will need to reshape the array to fit into the openvino model
image = image.transpose((2, 0, 1)) bicupic = bicupic.transpose((2, 0, 1))
The last tricky part is you need to load the images into the plugin
exec_net.requests.inputs['0'][:] = image exec_net.requests.inputs['1'][:] = bicupic exec_net.requests.infer()
The infer command starts the inference.
If you plan on saving the file you will need to normalize the floating point representation and then convert it to an integer (im sure there is a fancier way of doing this than the way i did)
I left out a bunch of code but i believe that the pieces that i provided are the things you could stumble on in getting everything started.
I am submitting a request to the developers to port this sample to Python.
Let me know if this helps you.