Spaces:
Runtime error
Runtime error
File size: 901 Bytes
a187b93 6f7eb25 a187b93 |
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 |
import gradio as gr
import tensorflow as tf
import numpy as np
import matplotlib.image as mpimg
from tensorflow.keras import models
model = models.load_model('alfabot.keras')
UPPERCASE_ALFABET = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
def predict(img):
image = mpimg.imread(img)
image = np.expand_dims(image, axis=0)
image_tensor = tf.constant(image, dtype=tf.float32)
result = model.predict(image_tensor)[0]
return UPPERCASE_ALFABET[np.argmax(result)]
gr.Interface(
fn=predict,
inputs=gr.inputs.Image(shape=(28, 28)),
outputs=gr.outputs.Label(num_top_classes=3),
title="Identificador de letras manuscritas",
description="Esse modelo tem a capacidade de identificar qual é a letra manuscrita.",
examples=["A.jpg","B.jpg","C.jpg","D.jpg","E.jpg"],
).launch() |