File size: 865 Bytes
0de284f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80d5644
0de284f
 
 
 
 
 
 
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
# 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('Exp33AL.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')