I have successfully followed this transfer learning tutorial to make my own classifier with two classes, "impressionism" and "modernism".
Now trying to get a label for my test image, applying advice from this thread:
y_prob = model.predict(new_image)
y_prob
(gives this output) array([[3.1922062e-04, 9.9968076e-01]], dtype=float32)
y_classes = y_prob.argmax(axis=-1)
y_classes
(gives this output) array([1])
# create a list containing the class labels
labels = ['modernism', 'impressionism']
predicted_label = sorted(labels)[y_classes]
Results in error:
"TypeError Traceback (most recent call last)
<ipython-input-35-571175bcfc65> in <module>()
1 # create a list containing the class labels
2 labels = ['modernism', 'impressionism']
----> 3 predicted_label = sorted(labels)[y_classes]
TypeError: only integer scalar arrays can be converted to a scalar index"
What am I doing wrong and what would be the right way to access the text labels (and their probabilities) for my test image? If I understand the array prediction, it has recognized from my image folders that there are two classes.
Many thanks if you have time to help!