flobbit commited on
Commit
c9d1ead
·
1 Parent(s): c276e58

Upload 9 files

Browse files
Files changed (9) hide show
  1. README.md +1 -1
  2. app.py +25 -4
  3. cat.jpg +0 -0
  4. persimmon.jpg +0 -0
  5. persimmontree.jpg +0 -0
  6. requirements.txt +1 -0
  7. tomato.jpg +0 -0
  8. tomatoplant.jpg +0 -0
  9. tomatoplant2.jpg +0 -0
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Persimmon
3
  emoji: 🐢
4
  colorFrom: gray
5
  colorTo: purple
 
1
  ---
2
+ title: Persimmon or Tomato?
3
  emoji: 🐢
4
  colorFrom: gray
5
  colorTo: purple
app.py CHANGED
@@ -1,7 +1,28 @@
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Howdy " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ #def is_cat(x): return x[0].isupper()
 
5
 
6
+ # Cell
7
+ learn = load_learner('persimmon_model.pkl')
8
+
9
+ # Cell
10
+ categories = ('persimmon', 'tomato')
11
+
12
+ def classify_image(img):
13
+ pred,idx,probs = learn.predict(img)
14
+ return dict(zip(categories, map(float,probs)))
15
+
16
+ image = gr.inputs.Image(shape=(192, 192))
17
+ label = gr.outputs.Label()
18
+ examples = ['persimmon.jpg', 'tomato.jpg', 'persimmontree.jpg',
19
+ 'tomatoplant.jpg', 'cat.jpg', 'tomatoplant2.jpg']
20
+
21
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
22
+ intf.launch(inline=False)
23
+
24
+ #def greet(name):
25
+ # return "Howdy " + name + "!!"
26
+
27
+ #iface = gr.Interface(fn=greet, inputs="text", outputs="text")
28
+ #iface.launch()
cat.jpg ADDED
persimmon.jpg ADDED
persimmontree.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fastai
tomato.jpg ADDED
tomatoplant.jpg ADDED
tomatoplant2.jpg ADDED