Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
lern = load_learner('model.pkl')
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
|
8 |
+
def predict(img):
|
9 |
+
pred,idx,probs = learn.predict(img)
|
10 |
+
return {labels[i]: float(probs[i]) for i,_ in enumarate(labels))}
|
11 |
+
|
12 |
+
image = gr.inputs.Image(shape(256,256))
|
13 |
+
label = gr.outputs.Label()
|
14 |
+
examples = ['house1.jpg','house2.jpg','house3.jpg','house4.jpg','house5.jpg']
|
15 |
+
|
16 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
17 |
+
|
18 |
+
intf.launch()
|