Spaces:
Runtime error
Runtime error
Pantai Suyasri
commited on
Commit
·
f33ff7f
1
Parent(s):
b6c925a
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|