Spaces:
Sleeping
Sleeping
george sami commited on
Commit ·
251a7c9
1
Parent(s): c751f41
Add application file
Browse files
app.py
CHANGED
|
@@ -1,7 +1,21 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
|
| 6 |
+
def is_cat(x): return x[0].isupper()
|
| 7 |
+
|
| 8 |
+
learner = load_learner('model.pkl')
|
| 9 |
+
|
| 10 |
+
categories = ('cat', 'dog')
|
| 11 |
+
|
| 12 |
+
def classify_image(img):
|
| 13 |
+
pred, pred_idx, probs = learner.predict(img)
|
| 14 |
+
return dict(zip(categories, map(float, probs)))
|
| 15 |
+
|
| 16 |
+
image = gr.inputs.Image(shape=(224, 224))
|
| 17 |
+
label = gr.outputs.Label()
|
| 18 |
+
example_images = ['cat1.jpeg', 'dog1.avif', 'cat2.jpeg', 'dog2.webp']
|
| 19 |
+
|
| 20 |
+
demo = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=example_images)
|
| 21 |
+
demo.launch(inline=False)
|