Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
+
from gradio import Interface, components
|
| 3 |
+
|
| 4 |
+
learn = load_learner('model.pkl')
|
| 5 |
+
categories = learn.dls.vocab
|
| 6 |
+
examples = ['bird.jpg']
|
| 7 |
+
|
| 8 |
+
# function for the prediction
|
| 9 |
+
def classify_image(img):
|
| 10 |
+
pred,idx,probs = learn.predict(img)
|
| 11 |
+
return dict(zip(categories, map(float,probs)))
|
| 12 |
+
|
| 13 |
+
image = components.Image(shape=(192, 192))
|
| 14 |
+
label = components.Label()
|
| 15 |
+
|
| 16 |
+
intf = Interface(
|
| 17 |
+
fn=classify_image, inputs=[image], outputs=[label], examples=examples
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
intf.launch(debug=True)
|