tallwhitestck commited on
Commit
5db7732
·
1 Parent(s): bebc6fd

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ from tensorflow.keras.models import load_model
3
+ import matplotlib.pyplot as plt
4
+ import numpy as np
5
+ from PIL import Image
6
+ import gradio as gr
7
+
8
+ def recog(img):
9
+ model = load_model('hack36_2.h5')
10
+
11
+ img_array = np.asarray(img)
12
+ clone = img_array.copy()
13
+ clone_resized = cv2.resize(clone, (64,64))
14
+ img_array=clone_resized/255
15
+ img_final = np.expand_dims(img_array, axis=0)
16
+ prediction = model.predict(img_final).tolist()[0]
17
+ alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'space', 'space', 'space']
18
+
19
+ return {alphabet[i]: prediction[i] for i in range(29)}
20
+
21
+
22
+ title = "ASL Fingerspelling Recognition"
23
+ desc = ""
24
+ input = gr.inputs.Image(type="pil", source="webcam")
25
+ # output = gr.outputs.HTML(label="")
26
+ output = gr.outputs.Label(num_top_classes=5)
27
+ # output = "text"
28
+ examples = [
29
+ ["B_test.jpg"],
30
+ ["C_test.jpg"],
31
+ ["Y_test.jpg"]
32
+ ]
33
+
34
+ iface = gr.Interface(
35
+ fn=recog,
36
+ title=title,
37
+ description=desc,
38
+ examples=examples,
39
+ inputs=input,
40
+ outputs=output
41
+ )
42
+
43
+ iface.launch()