Amirah's picture
Update app.py
e07ab3e
raw
history blame
866 Bytes
# TensorFlow and tf.keras
import tensorflow as tf
# Helper libraries
import numpy as np
import cv2
import os
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, classification_report
import h5py
import gradio as gr
#category
cat = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y']
def predict_image(img):
model=tf.keras.models.load_model('Exp32ALP.hdf5')
img_4d=img.reshape(-1,224,224,1)
prediction=model.predict(img_4d)[0]
return {cat[i]: float(prediction[i]) for i in range(24)}
image = gr.inputs.Image(shape=(224,224))
label = gr.outputs.Label(num_top_classes=24)
gr.Interface(fn=predict_image, inputs=image, outputs=label, title="Sign Language Alphabet", allow_flagging="never").launch(debug='True')