ValueError Traceback (most recent call last)
in
22 face_section = cv2.resize(face_section,(100,100))
23
—> 24 out = knn(trainset,face_section.flatten())
25 pred_name = names[int(out)]
26 cv2.putText(frame,pred_name,(x,y-10),cv2.FONT_HERSHEY_SIMPLEX,1,(255,0,0),2,cv2.LINE_AA)
in knn(train, test, k)
16 labels = np.array(dk)[:, -1]
17 #GET FREQUENCIES
—> 18 output = np.unique(labels,return_counts=True)
19 #Find max frequency
20 index = np.argmax(output[1])
<array_function internals> in unique(*args, **kwargs)
c:\users\hp\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\arraysetops.py in unique(ar, return_index, return_inverse, return_counts, axis)
261 ar = np.asanyarray(ar)
262 if axis is None:
–> 263 ret = _unique1d(ar, return_index, return_inverse, return_counts)
264 return _unpack_tuple(ret)
265
c:\users\hp\appdata\local\programs\python\python37\lib\site-packages\numpy\lib\arraysetops.py in unique1d(ar, return_index, return_inverse, return_counts)
309 aux = ar[perm]
310 else:
–> 311 ar.sort()
312 aux = ar
313 mask = np.empty(aux.shape, dtype=np.bool)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()