tallwhitestck commited on
Commit
d7bdd20
·
1 Parent(s): 5253a31

added articles

Browse files
Files changed (2) hide show
  1. app.py +16 -15
  2. flagged/log.csv +2 -0
app.py CHANGED
@@ -6,6 +6,8 @@ import numpy as np
6
  from PIL import Image
7
  import gradio as gr
8
 
 
 
9
  def recog(img):
10
  model = load_model('hack36_2.h5')
11
 
@@ -15,36 +17,35 @@ def recog(img):
15
  img_array=clone_resized/255
16
  img_final = np.expand_dims(img_array, axis=0)
17
  prediction = model.predict(img_final).tolist()[0]
18
- 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']
19
 
20
- return {alphabet[i]: prediction[i] for i in range(29)}
21
 
22
 
23
  title = "ASL Fingerspelling Recognition"
24
- desc = ""
25
  input = [
26
- gr.inputs.Image(type="pil", source="webcam", label="Image")
27
  ]
28
- # output = gr.outputs.HTML(label="")
29
  output = [
30
- gr.outputs.Label(label="")
31
- ]
32
- # output = "text"
33
- examples = [
34
- ["images/B_test.jpg"],
35
- ["images/C_test.jpg"],
36
- ["images/L_test.jpg"],
37
- ["images/R_test.jpg"],
38
- ["images/Y_test.jpg"]
39
  ]
40
 
 
 
 
 
 
 
 
41
  iface = gr.Interface(
42
  fn=recog,
43
  title=title,
44
  description=desc,
45
  examples=examples,
46
  inputs=input,
47
- outputs=output
 
48
  )
49
 
50
  iface.launch()
 
6
  from PIL import Image
7
  import gradio as gr
8
 
9
+ labels = ['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']
10
+
11
  def recog(img):
12
  model = load_model('hack36_2.h5')
13
 
 
17
  img_array=clone_resized/255
18
  img_final = np.expand_dims(img_array, axis=0)
19
  prediction = model.predict(img_final).tolist()[0]
 
20
 
21
+ return {labels[i]: prediction[i] for i in range(29)}
22
 
23
 
24
  title = "ASL Fingerspelling Recognition"
25
+ desc = "A Gradio demonstration for ASL fingerspelling recognition. Use your webcam to take a snapshot of your hand forming any of the ASL alphabet signs."
26
  input = [
27
+ gr.inputs.Image(type="pil", shape=(200,200), source="webcam", label="Image")
28
  ]
29
+
30
  output = [
31
+ gr.outputs.Label(num_top_classes=5, label="")
 
 
 
 
 
 
 
 
32
  ]
33
 
34
+ sample_letters = ['A', 'B', 'E', 'L', 'Y']
35
+ examples = [["images/{}_test.jpg".format(letter)] for letter in sample_letters]
36
+
37
+ a1="<h2>How to Use</h2><p style='text-align: justify'>For better results, please make sure your hand covers majority of the frame of the image. It is also preferred to have a neutral light background as seen in the examples. You can refer to the images <a href='https://huggingface.co/spaces/tallwhitestck/asl-fingerspelling-recognition/tree/main/images' target='_blank'>here</a> to get an idea of how each letter is signed.</p>"
38
+ a2="<h2>More information</h2><p style='text-align: justify'>This demo was based on a project implemented for a hackathon. The GitHub repository can be found on <a href='https://github.com/namanmanchanda09/American-Sign-Language-Detection-using-Computer-Vision' target='_blank'>namanmanchanda09/American-Sign-Language-Detection-using-Computer-Vision</a>. The model was trained on <a href='https://www.kaggle.com/datasets/grassknoted/asl-alphabet' target='_blank'>this ASL Alphabet dataset on Kaggle</a> containing 87,000 200x200 images. The examples used in the demo are from the test set of the aforementioned dataset.</p>"
39
+ a3="<h2>Limitations</h2><p style='text-align: justify'>The model was originally designed to process videos in order to spell out full English words, however, this demo implementation only processes images. Thus, the letters that require motion such as <b>J</b> and <b>Z</b> may be inaccurate.</p>"
40
+
41
  iface = gr.Interface(
42
  fn=recog,
43
  title=title,
44
  description=desc,
45
  examples=examples,
46
  inputs=input,
47
+ outputs=output,
48
+ article=a1+a2+a3
49
  )
50
 
51
  iface.launch()
flagged/log.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ 'Image','','timestamp'
2
+ '','','2022-03-29 07:08:01.632982'