mahmohajer commited on
Commit
6a9cdf6
·
1 Parent(s): f73eb9a

creating the app

Browse files
Files changed (5) hide show
  1. app.py +19 -0
  2. fresh.jpg +0 -0
  3. requirements.txt +1 -0
  4. rotten meat.jpeg +0 -0
  5. 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