26 lines
628 B
Python
26 lines
628 B
Python
|
import numpy as np
|
||
|
from PIL import Image
|
||
|
from tensorflow import keras
|
||
|
|
||
|
saved_model_path = 'resources/model.h5'
|
||
|
model = keras.models.load_model(saved_model_path)
|
||
|
|
||
|
|
||
|
image_path = 'resources/indeks-fragile.png'
|
||
|
image_size = (32, 32)
|
||
|
|
||
|
image = Image.open(image_path).convert('L')
|
||
|
image = image.resize(image_size)
|
||
|
image_array = np.array(image) / 255.0
|
||
|
input_data = np.expand_dims(image_array, axis=0)
|
||
|
|
||
|
|
||
|
predictions = model.predict(input_data)
|
||
|
predicted_class = np.argmax(predictions, axis=1)
|
||
|
|
||
|
|
||
|
class_names = ['fragile', 'priority', 'skull']
|
||
|
predicted_label = class_names[predicted_class[0]]
|
||
|
|
||
|
print('Predicted class:', predicted_label)
|