s1ri1337 commited on
Commit
343b998
1 Parent(s): 99dcb8c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from tensorflow.keras.preprocessing import image
3
+ import matplotlib.pyplot as plt
4
+ from keras.models import load_model
5
+
6
+ def load_image(img_path, show=False):
7
+
8
+ img = image.load_img(img_path, target_size=(224, 224))
9
+ img_tensor = image.img_to_array(img)
10
+ img_tensor = np.expand_dims(img_tensor, axis=0)
11
+ img_tensor /= 255
12
+
13
+ if show:
14
+ plt.imshow(img_tensor[0])
15
+ plt.axis('off')
16
+ plt.show()
17
+
18
+ return img_tensor
19
+
20
+ def run_model(img):
21
+ model = load_model("res.h5")
22
+
23
+ #img_path = '/content/Indian/9/1020.jpg'
24
+ #new_image = load_image(img_path)
25
+ #result = model.predict(new_image)
26
+ result = model.predict(img)
27
+ results = dict(zip(classes, result[0]))
28
+ return max(results, key = results.get)
29
+
30
+ title = "Indian Sign Language Classifier"
31
+ description = "<p style='text-align: center'>Classifies images from 0-9, A-Z made using Indian Sign Language"
32
+ examples = ['ex1.jpg','ex2.jpg','ex3.jpg','ex4.jpg','ex5.jpg','ex6.jpg','ex7.jpg','ex8.jpg','ex9.jpg','ex10.jpg']
33
+
34
+
35
+ import gradio as gr
36
+ gr.Interface(fn=run_model, inputs=gr.inputs.Image(shape=(224, 224)), outputs='text', title=title, description=description, examples=examples).launch()