Amirah commited on
Commit
1373cd2
1 Parent(s): cdd7809

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TensorFlow and tf.keras
2
+ import tensorflow as tf
3
+
4
+ # Helper libraries
5
+ import numpy as np
6
+ import cv2
7
+ import os
8
+ import matplotlib.pyplot as plt
9
+ from sklearn.model_selection import train_test_split
10
+ from sklearn.metrics import confusion_matrix, classification_report
11
+ import h5py
12
+ import gradio as gr
13
+
14
+ #category
15
+
16
+ cat = ['EIGHT', 'FIVE', 'FOUR', 'NINE', 'ONE', 'SEVEN', 'SIX', 'THREE', 'TWO', 'ZERO']
17
+
18
+ def predict_image(img):
19
+ model=tf.keras.models.load_model('/content/drive/MyDrive/FYP/Exp32DIG.hdf5')
20
+ img_4d=img.reshape(-1,224,224,1)
21
+ prediction=model.predict(img_4d)[0]
22
+ return {cat[i]: float(prediction[i]) for i in range(10)}
23
+
24
+ image = gr.inputs.Image(shape=(224,224))
25
+ label = gr.outputs.Label(num_top_classes=10)
26
+
27
+ gr.Interface(fn=predict_image, inputs=image, outputs=label, title="Sign Language Digit", allow_flagging="never").launch(debug='True')