alfaBot / app.py
ciro-c's picture
Fixed model
6f7eb25
raw
history blame contribute delete
No virus
901 Bytes
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()