Minuano commited on
Commit
59d6279
1 Parent(s): 6238411

Added application files.

Browse files
Files changed (3) hide show
  1. app.py +25 -0
  2. model.pkl +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+ learner_inf = load_learner('model.pkl')
6
+
7
+ labels = learner_inf.dls.vocab
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred,pred_idx,probs = learner_inf.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ title = "Cat vs. Dog Classifier"
15
+ description = "A Cat/Dog Classfier trained on random images obtained from DuckDuckGo. Used as a demo for Gradio + HuggingFace."
16
+ interpretation='default'
17
+
18
+ gr.Interface(
19
+ fn=predict, inputs=gr.inputs.Image(shape=(512, 512)),
20
+ outputs=gr.outputs.Label(num_top_classes=2),
21
+ title=title,
22
+ description=description,
23
+ interpretation=interpretation
24
+ ).launch()
25
+
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64431f34ed401fcaa10b405d606cee11cef268358ce945a1a98d0371d73a3724
3
+ size 46963361
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image