Spaces:
Runtime error
Runtime error
mahmohajer
commited on
Commit
·
6a9cdf6
1
Parent(s):
f73eb9a
creating the app
Browse files- app.py +19 -0
- fresh.jpg +0 -0
- requirements.txt +1 -0
- rotten meat.jpeg +0 -0
- semi-fresh.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
def is_cat(x): return x[0].isupper()
|
5 |
+
|
6 |
+
learn = load_learner("model.pkl")
|
7 |
+
|
8 |
+
categories = ('Fresh', 'Half-fresh', 'Spoiled')
|
9 |
+
|
10 |
+
def classify_image(img):
|
11 |
+
pred, idx, probs = learn.predict(img)
|
12 |
+
return dict(zip(categories, map(float, probs)))
|
13 |
+
|
14 |
+
image = gr.Image(height=280, width=340, type='numpy')
|
15 |
+
label = gr.Label()
|
16 |
+
examples = ['fresh.jpg', 'semi-fresh.jpg', 'rotten meat.jpg']
|
17 |
+
|
18 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
19 |
+
intf.launch(inline=False)
|
fresh.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai>=2.0.0
|
rotten meat.jpeg
ADDED
semi-fresh.jpg
ADDED