bencoman commited on
Commit
68b3950
1 Parent(s): 2e7ec5d
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1,6 +1,7 @@
1
  from fastai.vision.all import *
2
  import gradio as gr
3
  import logging
 
4
 
5
  learn = load_learner('watersports.pkl')
6
  categories = learn.dls.vocab
@@ -11,14 +12,21 @@ def classify_image(img):
11
  pred,idx,probs = learn.predict(img)
12
  return( dict(zip(categories, map(float,probs))))
13
 
 
 
 
 
 
 
 
14
  title = "Which Watersport? Compare your guess to the machine inferencing.y"
15
- description = "CLick an image and click submit. Drag an image into the classifier. Take a close look and guess it yourself, before hitting **\<Submit\>**. \n \
16
  You need to **\<Clear\>** before dragging next image. Other images can be dragged directly from google search."
17
- image = gr.inputs.Image(shape=(192,192))
18
- label = gr.outputs.Label()
19
- examples = './examples'
20
 
21
- iface = gr.Interface(fn=classify_image, inputs=image, outputs=label, \
22
- examples=examples, examples_per_page=100, title=title, description=description)
 
 
 
23
  iface.launch(inline=False)
24
 
 
1
  from fastai.vision.all import *
2
  import gradio as gr
3
  import logging
4
+ EXAMPLES_PATH = Path('./examples')
5
 
6
  learn = load_learner('watersports.pkl')
7
  categories = learn.dls.vocab
 
12
  pred,idx,probs = learn.predict(img)
13
  return( dict(zip(categories, map(float,probs))))
14
 
15
+ interface_options = {
16
+ "title": "Which Watersport? Compare your guess to the machine inferencing.z",
17
+ "description": "Click an image and click submit. Drag an image into the classifier. Take a close look and guess it yourself, before hitting **\<Submit\>**. \n \
18
+ You need to **\<Clear\>** before dragging next image. Other images can be dragged directly from google search.",
19
+ "examples" : [f'{EXAMPLES_PATH}/{f.name}' for f in EXAMPLES_PATH.iterdir()],
20
+ }
21
+
22
  title = "Which Watersport? Compare your guess to the machine inferencing.y"
23
+ description = "Click an image and click submit. Drag an image into the classifier. Take a close look and guess it yourself, before hitting **\<Submit\>**. \n \
24
  You need to **\<Clear\>** before dragging next image. Other images can be dragged directly from google search."
 
 
 
25
 
26
+ iface = gr.Interface(fn=classify_image,
27
+ inputs=gr.inputs.Image(shape=(192,192)),
28
+ outputs=gr.outputs.Label(),
29
+ **interface_options)
30
+
31
  iface.launch(inline=False)
32