Amirah's picture
Update app.py
214a550
raw
history blame
824 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 = ['EIGHT', 'FIVE', 'FOUR', 'NINE', 'ONE', 'SEVEN', 'SIX', 'THREE', 'TWO', 'ZERO']
def predict_image(img):
model=tf.keras.models.load_model('Exp32DIG.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(10)}
image = gr.inputs.Image(shape=(224,224))
label = gr.outputs.Label(num_top_classes=10)
gr.Interface(fn=predict_image, inputs=image, outputs=label, title="Sign Language Digit", allow_flagging="never").launch(debug='True')