- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone
I'm a new user of the NCS-2 and need a help on the creation of a testing script to use it with NCS-2 on Raspberry Pi. To start by creating a CNN to classify a Digit from 0 to 9, using the example described in the link below.
https://www.youtube.com/watch?v=y1ZrOs9s2QA
I have saved a Keras model, next, I turn Keras to TensorFlow model. By using the model optimizer I have converted the Tensorflow model to an IR file (.bin and .xml files) that we can use on the Neural Compute Stick 2.
I have run the following Python script on CPU and he is working as expected,
###################################################
import numpy as np
import cv2
from keras.models import load_model
########### PARAMETERS ##############
threshold = 0.65 # MINIMUM PROBABILITY TO CLASSIFY
#####################################
#%%
#### LOAD THE TRAINNED MODEL
model = load_model('./keras_model/model_keras.h5')
#%%
#### PREPORCESSING FUNCTION
def preProcessing(img):
img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
img = cv2.equalizeHist(img)
img = img/255
return img
#%%
imgOriginal = cv2.imread('cap5.png')
img = np.asarray(imgOriginal)
img = cv2.resize(img,(32,32))
img = preProcessing(img)
cv2.imshow("Processed Image", img)
img = img.reshape(1,32,32,1)
#### PREDICT
classIndex = int(model.predict_classes(img))
print(classIndex)
predictions = model.predict(img)
print(predictions)
probVal= np.amax(predictions)
print(classIndex,probVal)
if probVal> threshold:
cv2.putText(imgOriginal,str(classIndex) + " "+str(probVal),
(50,50),cv2.FONT_HERSHEY_COMPLEX,
1,(0,0,255),1)
cv2.imwrite('cap5_pre.png',imgOriginal)
###################################################
Now I need help with writing the testing script for the NCS-2 using the Openvino inference engine functions (IENetwork, IEPlugin).
Can anyone help me to do it?
Thanks
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bengherbia,
Thanks for reaching out. It seems you already started a similar thread here.
If possible, let's keep the comments on that thread only.
Best regards,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page