samjeffcoat commited on
Commit
811e05a
1 Parent(s): a9d375b

let's deploy to huggingface spaces

Browse files
Files changed (5) hide show
  1. app.py +23 -0
  2. cottonmouth.jpeg +0 -0
  3. export (2).pkl +3 -0
  4. rattlesnake.jpg +0 -0
  5. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ from fastai.vision.widgets import *
4
+ from fastai.callback.preds import load_learner
5
+ import skimage
6
+
7
+ learner = load_learner('export (2).pkl')
8
+
9
+ labels = learner.dls.vocab
10
+ def classify_image(img):
11
+ pred, idx, probs = learner.predict(img)
12
+ return dict(zip(learner.dls.vocab, map(float, probs)))
13
+ title = "Oklahoma Snake Classifier"
14
+ description = "A snake classifier trained on pictures of Oklahoma Snakes dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
15
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
16
+ examples = ['cottonmouth.jpg', 'rattlesnake.jpeg']
17
+ interpretation='default'
18
+ enable_queue=True
19
+ image = gr.inputs.Image(shape=(192, 192))
20
+ label = gr.outputs.Label(num_top_classes=3)
21
+ out_pl = widgets.Output()
22
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
23
+ intf.launch()
cottonmouth.jpeg ADDED
export (2).pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8aa22189cf5eccc9e0b808b706ced2264f5792553d2884346cee080d56039f5
3
+ size 47005711
rattlesnake.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image