I learn to Emotion Recognition program in python
I tried to here source , I ran the code
('size of training set is:', 379, 'images')
predicting classification set
Traceback (most recent call last):
File "prepare_model.py", line 72, in <module>
correct = run_recognizer()
File "prepare_model.py", line 63, in run_recognizer
correct = sum(1 for id, image in enumerate(prediction_data) if fishface.predict(image)[0] == prediction_labels[id])
ict(image)[0] == prediction_labels[id])
File "prepare_model.py", line 63, in <genexpr>
correct = sum(1 for id, image in enumerate(prediction_data) if fishface.predict(image)[0] == prediction_labels[id])
TypeError: 'int' object has no attribute '__getitem__'
I use Ubuntu 16.04LTS 64bit / python 2.7 / opencv3.1.0 + contrib
help me please...
i changed in line 63
correct = sum(1 for id, image in enumerate(prediction_data) if fishface.predict(image)[0] == prediction_labels[id])
to
correct = sum(1 for id, image in enumerate(prediction_data) if fishface.predict[image][0] == prediction_labels[id])
but doesn't work...
How can fix that ??
This line:
fishface.predict(image)[0] ...
shows you predict is a function. When you change (...) to [...], python interprets predict[]
as a list on which the first element (index 0) has to be set to a value. Therefore the above error. So in Python, x(...) is a function call, while x[..] is a list or dict on which an element is reqested.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.