javex commited on
Commit
a103242
1 Parent(s): 0fa82ff

Commit initial model

Browse files
Files changed (4) hide show
  1. app.py +22 -0
  2. border_collie.jpg +0 -0
  3. model.pkl +3 -0
  4. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *import gradio as gr
2
+
3
+
4
+ learn = load_learner('model.pkl')
5
+
6
+
7
+ labels = learn.dls.vocab
8
+ def predict(img):
9
+ pil_img = PILImage.create(img)
10
+ pred, pred_idx, probs = learn.predict(pil_img)
11
+ result = {}
12
+ for label_idx, label in enumerate(labels):
13
+ result[label] = float(probs[label_idx])
14
+ return result
15
+
16
+
17
+ gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.inputs.Image(shape=(512, 512)),
20
+ outputs=gr.outputs.Label(num_top_classes=3),
21
+ examples=['border_collie.jpg'],
22
+ ).launch()
border_collie.jpg ADDED
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a04c41daeb4526770f89f7df1d857892a196482d7f4ca2dde358597a9deb7f7
3
+ size 47033105
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image