Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import tensorflow as tf
|
|
| 4 |
import cv2
|
| 5 |
|
| 6 |
# Load the trained model
|
| 7 |
-
model = tf.keras.models.load_model("Handwritten_model.h5") #
|
| 8 |
|
| 9 |
def predict_digit(image):
|
| 10 |
# Preprocess the image
|
|
@@ -19,10 +19,10 @@ def predict_digit(image):
|
|
| 19 |
predicted_class = np.argmax(prediction)
|
| 20 |
return predicted_class
|
| 21 |
|
| 22 |
-
# Define the Gradio interface
|
| 23 |
gr.Interface(
|
| 24 |
fn=predict_digit,
|
| 25 |
-
inputs=gr.
|
| 26 |
outputs="text",
|
| 27 |
title="Handwritten Digit Recognition",
|
| 28 |
description="Upload an image of a handwritten digit, and the model will predict which digit it is."
|
|
|
|
| 4 |
import cv2
|
| 5 |
|
| 6 |
# Load the trained model
|
| 7 |
+
model = tf.keras.models.load_model("Handwritten_model.h5") # Make sure the filename matches your uploaded model
|
| 8 |
|
| 9 |
def predict_digit(image):
|
| 10 |
# Preprocess the image
|
|
|
|
| 19 |
predicted_class = np.argmax(prediction)
|
| 20 |
return predicted_class
|
| 21 |
|
| 22 |
+
# Define the Gradio interface using the updated API
|
| 23 |
gr.Interface(
|
| 24 |
fn=predict_digit,
|
| 25 |
+
inputs=gr.Image(type="numpy", label="Upload a digit image"), # Updated to use gr.Image
|
| 26 |
outputs="text",
|
| 27 |
title="Handwritten Digit Recognition",
|
| 28 |
description="Upload an image of a handwritten digit, and the model will predict which digit it is."
|