carvermichael commited on
Commit
4d0861b
1 Parent(s): 4b2c680

Upload 8 files

Browse files
Files changed (8) hide show
  1. app.py +28 -0
  2. homer-or-peter.pkl +3 -0
  3. homer_1.jpg +0 -0
  4. homer_2.jpg +0 -0
  5. homer_3.jpg +0 -0
  6. peter_1.jpg +0 -0
  7. peter_2.jpg +0 -0
  8. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ title = "Homer or Peter"
6
+ examples = ["homer_1.jpg",
7
+ "homer_2.jpg",
8
+ "homer_3.jpg",
9
+ "peter_1.jpg",
10
+ "peter_2.jpg"]
11
+ interpretation='default'
12
+ enable_queue=True
13
+
14
+ learn = load_learner('homer-or-peter.pkl')
15
+
16
+ labels = learn.dls.vocab
17
+ def predict(img):
18
+ img = PILImage.create(img)
19
+ pred, pred_idx, probs = learn.predict(img)
20
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
21
+
22
+ gr.Interface(fn=predict,
23
+ inputs=gr.components.Image(shape=(512, 512)),
24
+ outputs=gr.components.Label(num_top_classes=3),
25
+ title=title,
26
+ examples=examples,
27
+ interpretation=interpretation
28
+ ).launch(enable_queue=enable_queue)
homer-or-peter.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3aba321e5b490604499c4f800c997b2f2bfb6fc4e8b2c656a1f21d0746acebc4
3
+ size 46959494
homer_1.jpg ADDED
homer_2.jpg ADDED
homer_3.jpg ADDED
peter_1.jpg ADDED
peter_2.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image