s1ri1337 commited on
Commit
509d11b
1 Parent(s): b58bd0e

Update app.py

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