Spaces:
Sleeping
Sleeping
PawarV
commited on
Commit
•
0f21786
1
Parent(s):
61c555b
update app.py to our application code
Browse files- app.py +15 -4
- cat1.png +0 -0
- dog1.png +0 -0
- python1.png +0 -0
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# determines if it's a cat from first letter
|
5 |
+
def is_cat(x): return x[0].isupper()
|
6 |
|
7 |
+
# load the model
|
8 |
+
learn = load_learner('model.pkl')
|
9 |
+
|
10 |
+
categories = ('Dog', 'Cat')
|
11 |
+
|
12 |
+
def predict(img):
|
13 |
+
pred,pred_idx,probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float, probs)))
|
15 |
+
|
16 |
+
# show it in a gradio interface
|
17 |
+
examples = [ 'cat1.png', 'dog1.png', 'python1.png']
|
18 |
+
gr.Interface(fn=predict, inputs=gr.Image(), outputs=gr.Label(), examples=examples).launch()
|
cat1.png
ADDED
dog1.png
ADDED
python1.png
ADDED
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|