Upload 9 files
Browse files- README.md +1 -1
- app.py +25 -4
- cat.jpg +0 -0
- persimmon.jpg +0 -0
- persimmontree.jpg +0 -0
- requirements.txt +1 -0
- tomato.jpg +0 -0
- tomatoplant.jpg +0 -0
- 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
|
| 4 |
-
return "Howdy " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|