chauhavu commited on
Commit
eac6f5e
1 Parent(s): a7d5db5

let's deploy to huggingface spaces

Browse files
Files changed (4) hide show
  1. app.py +26 -0
  2. requirements.txt +2 -0
  3. ufo-model.pkl +3 -0
  4. ufo.webp +0 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
+
5
+
6
+ learn = load_learner('ufo-model.pkl')
7
+
8
+
9
+ labels = learn.dls.vocab
10
+
11
+
12
+ def predict(img):
13
+ img = PILImage.create(img)
14
+ pred,pred_idx,probs = learn.predict(img)
15
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
16
+
17
+
18
+ title = "UFO vs Star Classifier"
19
+ description = "A Ufo classifier trained on the Duck Duck Go search dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
20
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
21
+ examples = ['ufo.webp']
22
+ interpretation='default'
23
+ enable_queue=True
24
+
25
+
26
+ gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image
ufo-model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f893da4880159dbffe08511135da599b55e083af79eccc47e00bdca0209e6428
3
+ size 46964741
ufo.webp ADDED