dpc7 commited on
Commit
2d81f0a
·
1 Parent(s): 0ae1a0d

categorizer v1

Browse files
Files changed (5) hide show
  1. .DS_Store +0 -0
  2. app.py +25 -4
  3. export.pkl +3 -0
  4. requirements.txt +2 -0
  5. siamese.jpg +0 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -1,7 +1,28 @@
 
 
 
 
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
+ # import gradio as gr
2
+
3
+ # def greet(name):
4
+ # return "Hello " + name + "!!"
5
+
6
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
+ # iface.launch()
8
+
9
  import gradio as gr
10
+ from fastai.vision.all import *
11
+ import skimage
12
+
13
+ learn = load_learner('export.pkl')
14
+
15
+ labels = learn.dls.vocab
16
+ def predict(img):
17
+ img = PILImage.create(img)
18
+ pred,pred_idx,probs = learn.predict(img)
19
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
20
 
21
+ title = "Pet Breed Classifier"
22
+ description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
23
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
24
+ examples = ['siamese.jpg']
25
+ interpretation='default'
26
+ enable_queue=True
27
 
28
+ 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()
 
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a74d38984038f5dcb50a2b2edcef48b32d3ee3422244f2c22e6f041df0a2266
3
+ size 103043093
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image
siamese.jpg ADDED