Spaces:
Runtime error
Runtime error
dgordonf
commited on
Commit
·
f314ce9
1
Parent(s):
316b073
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
def greet(name):
|
4 |
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
from fastai.text.all import *
|
3 |
+
from fastai.collab import *
|
4 |
+
from fastai.tabular.all import *
|
5 |
+
|
6 |
import gradio as gr
|
7 |
|
8 |
def greet(name):
|
9 |
return "Hello " + name + "!!"
|
10 |
|
11 |
+
learn = load_learner('model.pkl')
|
12 |
+
|
13 |
+
categories = ('golden', 'not golden')
|
14 |
+
|
15 |
+
def classify_img(img):
|
16 |
+
pred, pred_idx, probs = learn.predict(img)
|
17 |
+
return dict(zip(categories, map(float, probs)))
|
18 |
+
|
19 |
+
|
20 |
+
image = gr.inputs.Image(shape=(192, 192))
|
21 |
+
label = gr.outputs.label(num_top_classes=2)
|
22 |
+
examples = ["golden_retriever.jpg", "cat.jpg", "dog.jpg"]
|
23 |
+
|
24 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples = examples)
|
25 |
+
intf.launch(inline=False)
|