Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

convert numpy array

Hi I am loading an image from a file and i need to convert it from an numpy array to either a dictionary , list or tuple . Any suggestions pls ?

click to hide/show revision 2
retagged

updated 2017-04-17 14:59:52 -0600

berak gravatar image

convert numpy array

Hi I am loading an image from a file and i need to convert it from an numpy array to either a dictionary , list or tuple . Any suggestions pls ?

click to hide/show revision 3
No.3 Revision

updated 2017-04-23 03:52:14 -0600

berak gravatar image

convert numpy array

Hi I am loading an image from a file and i need to convert it from an numpy array to either a dictionary , list or tuple . Any suggestions pls ?

I am loading an image from a file using face = cv2.imread('faces/face.jpg') Then passing face to this method

results = classify(models,face)

def classify(models, dataSet):
    results = {}
    for trueClazz in CLASSES:
        count = 0
        correct = 0
        print("Class,Predicted Class,Problem")
        predClazz, prob = predict(models, dataSet)
        print "%s,%s,%f" % (trueClazz,predClazz, prob)
        count += 1
    print('classifying')
    return results

The error is :

  File "C:\Python27\lib\site-packages\svm.py", line 71, in gen_svm_nodearray
    raise TypeError('xi should be a dictionary, list or tuple')
TypeError: xi should be a dictionary, list or tuple