|
from tensorflow.keras.preprocessing import image |
|
import numpy as np |
|
|
|
def predict_class(model, image_path): |
|
img = image.load_img(image_path, target_size=(100, 100)) |
|
img_array = image.img_to_array(img) |
|
img_array = np.expand_dims(img_array, axis=0) |
|
predictions = model.predict(img_array) |
|
predicted_index = np.argmax(predictions[0]) |
|
classes = ['Banano', 'Durazno', 'Fresa', 'Guanabana', 'Guayaba', 'Kiwi', 'Limon', 'Lulo', 'Mandarina', 'Mango', 'Manzana', 'Manzana Verde', 'Melon', 'Mora', 'Naranja'] |
|
predicted_class = classes[predicted_index] |
|
return predicted_class |