File size: 824 Bytes
1373cd2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bde588
1373cd2
 
 
 
 
 
 
 
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
27
# 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')