Spaces:
Sleeping
Sleeping
File size: 791 Bytes
7804fbe 5509100 6189582 7804fbe 1751d3f 7804fbe 1751d3f 7804fbe 1751d3f 34ec86b 1751d3f 1471381 9c0a4a0 1751d3f f68a643 7804fbe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import tensorflow as tf
import gradio as gr
import numpy as np
# Load the CNN model from the .h5 file
model = tf.keras.models.load_model('mnist_cnn_model.h5')
def predict_digit(image):
# Preprocess the input image
image = np.expand_dims(image, axis=0) # Add batch dimension
image = image / 255.0 # Normalize pixel values
# Make predictions
predictions = model.predict(image)
# Get the predicted digit
predicted_digit = np.argmax(predictions)
return predicted_digit
# Define Gradio interface
gr.Interface(
title="Reconnaissance d'écriture manuscrite des données MNIST by Papa Sega",
fn=predict_digit,
inputs=gr.Sketchpad(label="Desinner le chiffre ici", height=300, width=800),
outputs="number",
live=True
).launch(debug=True)
|