Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,3 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import tensorflow as tf
|
3 |
-
import numpy as np
|
4 |
-
from PIL import Image
|
5 |
-
|
6 |
-
# Load the model (ensure you have the correct model path)
|
7 |
-
model = tf.keras.models.load_model("denis_mnist_cnn_model.h5")
|
8 |
-
|
9 |
-
# Define a function to preprocess input and make predictions
|
10 |
def predict(image):
|
11 |
# Convert image to a numpy array
|
12 |
image = np.array(image)
|
@@ -27,8 +18,11 @@ def predict(image):
|
|
27 |
# Perform prediction
|
28 |
prediction = model.predict(image)
|
29 |
|
30 |
-
#
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
# Create a Gradio interface
|
34 |
interface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
def predict(image):
|
2 |
# Convert image to a numpy array
|
3 |
image = np.array(image)
|
|
|
18 |
# Perform prediction
|
19 |
prediction = model.predict(image)
|
20 |
|
21 |
+
# Get the predicted class (index of the highest probability)
|
22 |
+
predicted_class = np.argmax(prediction)
|
23 |
+
|
24 |
+
# Return prediction as JSON (with the predicted class label)
|
25 |
+
return {"prediction": int(predicted_class)}
|
26 |
|
27 |
# Create a Gradio interface
|
28 |
interface = gr.Interface(
|