Cecilia Casarini commited on
Upload 4 files
Browse files- app.py +22 -0
- coffee.jpg +0 -0
- vanilla.jpg +3 -0
- vanillaorcoffee.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
learn = load_learner('vanillaorcoffee.pkl')
|
| 6 |
+
|
| 7 |
+
def is_vanilla(x): return x[0].isupper()
|
| 8 |
+
|
| 9 |
+
categories = ('vanilla', 'orchid')
|
| 10 |
+
|
| 11 |
+
def classify_image(img):
|
| 12 |
+
pred, idx, probs = learn.predict(img)
|
| 13 |
+
return dict(zip(categories, map(float, probs)))
|
| 14 |
+
|
| 15 |
+
image = gr.Image()
|
| 16 |
+
label = gr.Label()
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
examples = ['vanilla.jpg', 'orchid.jpg']
|
| 20 |
+
|
| 21 |
+
intf = gr.Interface(fn = classify_image, inputs=image, outputs=label, examples=examples)
|
| 22 |
+
intf.launch(inline=False)
|
coffee.jpg
ADDED
|
vanilla.jpg
ADDED
|
Git LFS Details
|
vanillaorcoffee.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ac49b7dcf2e7ccbf12f9d2bc1d9d0ae245f7432db6bf55ab2a4e92ee8638fbc8
|
| 3 |
+
size 46957615
|