Bhuvi20 commited on
Commit
ae279d6
·
verified ·
1 Parent(s): 2239c56

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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") # Adjust this if you use the SavedModel format
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.inputs.Image(type="numpy", label="Upload a digit 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."
 
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."