Spaces:
Sleeping
Sleeping
bhavyagiri
commited on
Commit
•
3a15671
1
Parent(s):
dfe6bde
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
learn = load_learner("export.pkl")
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
|
8 |
+
def classify_garbage(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred,idx,probs = learn.predict(img)
|
11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
+
|
13 |
+
image = gr.inputs.Image(shape = (224,224))
|
14 |
+
label = gr.outputs.Label(num_top_classes=10)
|
15 |
+
title = "Garbage Classifier"
|
16 |
+
description = "A Garbage classifier trained with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
17 |
+
interpretation='default'
|
18 |
+
enable_queue=True
|
19 |
+
|
20 |
+
iface = gr.Interface(fn=classify_garbage, inputs=image, outputs=label,title=title,description=description,interpretation=interpretation,enable_queue=enable_queue)
|
21 |
+
iface.launch(inline=False)
|