Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
learn_inf = load_learner('model.pkl')
|
| 5 |
+
categories = learn_inf.dls.vocab
|
| 6 |
+
|
| 7 |
+
def classify_image(img):
|
| 8 |
+
pred,pred_idx,probs = learn_inf.predict(img)
|
| 9 |
+
return dict(zip(categories, map(float, probs)))
|
| 10 |
+
|
| 11 |
+
iface = gr.Interface(
|
| 12 |
+
title = "Is it Huggable?",
|
| 13 |
+
description = "An image classifier that tells if something's huggable or not?",
|
| 14 |
+
article = "<p style='text-align: center'><a href='https://github.com/daspartho/is-it-huggable' target='_blank'>Github</a></p>",
|
| 15 |
+
fn=classify_image,
|
| 16 |
+
inputs=gr.Image(shape=(224,224)),
|
| 17 |
+
outputs=gr.outputs.Label(),
|
| 18 |
+
#examples=['examples/dog.jpg', 'examples/cactus.jpg', 'examples/plushie.jpg', 'examples/snowman.jpg', 'examples/chainsaw.jpg', 'examples/shark.jpg','examples/bunny.jpg', 'examples/knife.jpg', 'examples/tiger.jpg', 'examples/trex.jpg'],
|
| 19 |
+
live=True,
|
| 20 |
+
enable_queue=True
|
| 21 |
+
)
|
| 22 |
+
iface.launch()
|