Spaces:
Runtime error
Runtime error
SAwaida
commited on
Commit
·
7d19f9d
1
Parent(s):
9a6d7b7
Revert to old file
Browse files
app.py
CHANGED
@@ -1,7 +1,22 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
|
5 |
+
learn = load_learner('bears.pkl')
|
|
|
6 |
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
def predict(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred,pred_idx,probs = learn.predict(img)
|
11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
+
|
13 |
+
title = "Bear Classifier"
|
14 |
+
description = "A bear classifier trained on internet image dataset with fastai."
|
15 |
+
article="<p style='text-align: center'>Thank you</p>"
|
16 |
+
examples = ['black_bear_example.jpg']
|
17 |
+
enable_queue=True
|
18 |
+
|
19 |
+
gr.Interface(fn=predict,inputs=gr.Image(shape=(512, 512)),
|
20 |
+
outputs=gr.Label(num_top_classes=3),title=title,
|
21 |
+
description=description,article=article,examples=examples).launch(
|
22 |
+
enable_queue=enable_queue)
|