Я хочу проверить мою модель классификации изображений с изображением.Но я получаю некоторую ошибку:
--> path = 'E:/My Work Elements/Thesis Related/Trash Classification/Trash New Code/test/cardboard/cardboard42.jpg'
test_single_image(path)
Traceback (most recent call last):
File "<ipython-input-15-4a6021aada0c>", line 2, in <module>
test_single_image(path)
File "<ipython-input-14-1654f8f7a46b>", line 3, in test_single_image
images = read_image(path)
NameError: name 'read_image' is not defined
Я использую этот код:
def test_single_image(path):
Garbage = ['cardboard','Glass','Metal','paper','plastic','Trash']
images = read_image(path)
time.sleep(.5)
bt_prediction = vgg16.predict(images)
preds = model.predict_proba(bt_prediction)
for idx, Garbage, x in zip(range(0,6), Garbage , preds[0]):
print("ID: {}, Label: {} {}%".format(idx, Garbage, round(x*100,2) ))
print('Final Decision:')
time.sleep(.5)
for x in range(3):
print('.'*(x+1))
time.sleep(.2)
class_predicted = model.predict_classes(bt_prediction)
class_dictionary = generator_top.class_indices
print(class_dictionary)
inv_map = {v: k for k, v in class_dictionary.items()}
print("Class: {}, prediction Result: {}".format(class_predicted[0], inv_map[class_predicted[0]]))
return load_img(path, target_size=(224,224))
path = 'E:/My Work Elements/Thesis Related/Trash Classification/Trash New Code/test/cardboard/cardboard42.jpg'
test_single_image(path)
Как мне исправить код?