Spaces:
Runtime error
Runtime error
Commit
•
3052b88
1
Parent(s):
20b0fd2
added model
Browse files
app.py
CHANGED
@@ -1,7 +1,25 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'intf', 'classify_images']
|
5 |
+
|
6 |
+
# %% ../app.ipynb 1
|
7 |
+
from fastai.vision.all import *
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
# %% ../app.ipynb 2
|
11 |
+
learn = load_learner('country-pred-model.pkl')
|
12 |
+
|
13 |
+
# %% ../app.ipynb 3
|
14 |
+
categories = ('mexico', 'usa')
|
15 |
+
|
16 |
+
def classify_images(img):
|
17 |
+
pred, idx, probs = learn.predict(img)
|
18 |
+
return dict(zip(categories, map(float, probs)))
|
19 |
+
|
20 |
+
# %% ../app.ipynb 6
|
21 |
+
image = gr.inputs.Image()
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
|
24 |
+
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=(''))
|
25 |
+
intf.launch(inline=False)
|