Spaces:
Sleeping
Sleeping
Update app with an image classifier
Browse files
app.py
CHANGED
@@ -1,9 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
|
|
3 |
|
4 |
-
def greet(name):
|
5 |
-
return "Hello " + name + "!!"
|
6 |
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.learner import load_learner
|
3 |
|
4 |
+
model = load_learner("model.pkl")
|
5 |
|
|
|
|
|
6 |
|
7 |
+
def classify_image(image):
|
8 |
+
preds = model.predict(image)[2]
|
9 |
+
return dict(zip(["Bird", "Forest"], preds.tolist()))
|
10 |
|
11 |
+
|
12 |
+
gr.Interface(
|
13 |
+
fn=classify_image,
|
14 |
+
inputs=gr.Image(),
|
15 |
+
outputs=gr.Label(num_top_classes=2),
|
16 |
+
examples=["images/bird.jpeg", "images/forest.jpeg"],
|
17 |
+
title="Bird or Forest?",
|
18 |
+
).launch()
|