Pantai Suyasri commited on
Commit
a5b2735
·
1 Parent(s): f33ff7f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import platform
2
+ import pathlib
3
+
4
+ if platform.system() == "Windows":
5
+ temp = pathlib.PosixPath
6
+ pathlib.PosixPath = pathlib.WindowsPath
7
+
8
+ from fastai.vision.all import *
9
+ import gradio as gr
10
+
11
+ learn = load_learner(Path("model.pkl"))
12
+
13
+ categories = {'Pizza', 'Pasta'}
14
+
15
+ def classify_image(img):
16
+ pred, idx, probs = learn.predict(img)
17
+ return dict(zip(categories, map(float, probs)))
18
+
19
+
20
+ image = gr.Image(shape=(192, 192))
21
+ label = gr.Label()
22
+ examples = ['pizza.jpg', 'pasta.jpg', 'dunno.jpg']
23
+
24
+ app = gr.Interface(fn=classify_image,
25
+ inputs=image,
26
+ outputs=label,
27
+ examples=examples)
28
+ app.launch()