Justina Tran
commited on
Commit
·
2697a60
1
Parent(s):
f3c0e7e
add files
Browse files- app.py +17 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def is_cat(x): return x[0].isupper()
|
5 |
+
|
6 |
+
learn = load_learner('model.pkl')
|
7 |
+
categories = ('Dog', 'Cat')
|
8 |
+
def classify_img(img):
|
9 |
+
pred,idx,probs = learn.predict(img)
|
10 |
+
return dict(zip(categories, map(float,probs)))
|
11 |
+
|
12 |
+
image = gr.inputs.Image(shape=(192, 192))
|
13 |
+
label = gr.outputs.Label()
|
14 |
+
examples = ['images/cat.jpeg', 'images/dog.jpeg', 'images/dogcat.jpeg']
|
15 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label, examples=examples,
|
16 |
+
title = 'Cat vs Dog Images')
|
17 |
+
intf.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai==2.7.7
|