Spaces:
Sleeping
Sleeping
Sachin
commited on
Commit
·
0a7e96e
1
Parent(s):
51714f9
let's deploy to huggingface spaces
Browse files
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
learn = load_learner('model.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 |
+
title = "Is it a car or plance or bus?"
|
13 |
+
description = "Are you a vampire sleeping for last 500 years and struggling to cope with this new world? Have you ever looked at something and could not figure out if it is a car or plane or bus? Don't worry you can now use this app to help you figure what it is exactly"
|
14 |
+
examples = ['car.jpg', 'plane.jpg', 'bus.jpg']
|
15 |
+
interpretation='default'
|
16 |
+
enable_queue=True
|
17 |
+
|
18 |
+
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,examples=examples,interpretation=interpretation).launch()
|