Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn = load_learner('orange_cats.pkl')
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
def predict(img):
|
8 |
+
img = PILImage.create(img)
|
9 |
+
pred,pred_idx,probs = learn.predict(img)
|
10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
11 |
+
|
12 |
+
import gradio as gr
|
13 |
+
title = "Cat, croissant, leaves, or yellow tiles?"
|
14 |
+
description = "This model can classify images into 4 categories: cat, croissant, leaves, or yellow tiles. Upload an image or click an example image to test the model."
|
15 |
+
examples =['examples/cat.jpg', 'examples/Croissant.png', 'examples/leaves.jpg', 'examples/Tiles.jpg']
|
16 |
+
gr.Interface(fn=predict,examples=examples, title=title,description=description,inputs=gr.Image(), outputs=gr.Label(num_top_classes=3)).launch(share=True)
|
17 |
+
|
18 |
+
|
19 |
+
|