'I get the error: " AttributeError: 'Sequential' object has no attribute 'predict_classes' " while coding. Its wrong here
def classify(file_path):
global label_packed
image = Image.open(file_path)
image = image.resize((30,30))
image = numpy.expand_dims(image, axis=0)
image = numpy.array(image)
pred = model.predict_classes(image)[0]
sign = classes[pred+1]
print(sign)
label.configure(foreground='#011638', text=sign)
Solution 1:[1]
Change the:
model.predict_classes()
to
model.predict()
and it'll return a probability. Then you should define a threshold to consider prediction probabilities to one of the classes. Remember that threshold is up to you. You can be strict about that or not. However, I suppose it to be 0.5:
pred_class = np.where(model.predict(example) > 0.5, 1, 0)
Then, you'll get predicted classes.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mojtaba Abdi Kh. |
