Update app.py
Browse files
app.py
CHANGED
|
@@ -20,9 +20,13 @@ model = keras.models.load_model('best_model.h5')
|
|
| 20 |
# Define a function that takes an image as input and uses the model for inference
|
| 21 |
def image_classifier(image):
|
| 22 |
# Preprocess the input image
|
|
|
|
|
|
|
|
|
|
| 23 |
image = np.array(image)
|
| 24 |
image = image / 255.0
|
| 25 |
image = np.expand_dims(image, axis=0)
|
|
|
|
| 26 |
|
| 27 |
# Use your custom model for inference
|
| 28 |
predictions = model.predict(image)
|
|
|
|
| 20 |
# Define a function that takes an image as input and uses the model for inference
|
| 21 |
def image_classifier(image):
|
| 22 |
# Preprocess the input image
|
| 23 |
+
image = Image.fromarray(image)
|
| 24 |
+
image = image.convert('L')
|
| 25 |
+
image = image.resize((128, 128))
|
| 26 |
image = np.array(image)
|
| 27 |
image = image / 255.0
|
| 28 |
image = np.expand_dims(image, axis=0)
|
| 29 |
+
image = np.expand_dims(image, axis=-1)
|
| 30 |
|
| 31 |
# Use your custom model for inference
|
| 32 |
predictions = model.predict(image)
|