nullzero-live commited on
Commit
7c16820
·
1 Parent(s): 99194b9

Upload 4 files

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. app.py +21 -0
  3. model.pkl +3 -0
  4. requirements.txt +2 -0
  5. siamese.jpg +3 -0
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ siamese.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Chapter 2 Hugging Face Spaces
2
+ import gradio as gr
3
+ from fastai.vision.all import *
4
+ import skimage
5
+
6
+ learn = load_learner('model.pkl')
7
+
8
+ labels = learn.dls.vocab
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ pred,pred_idx,probs = learn.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ title = "Pet Breed Classifier"
15
+ description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
16
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
17
+ examples = ['siamese.jpg']
18
+ interpretation='default'
19
+ enable_queue=True
20
+
21
+ 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()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72c677768503b22af461afb3f9b06ccb5b6a9affff19ae9713c1917823869e72
3
+ size 47058513
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image
siamese.jpg ADDED

Git LFS Details

  • SHA256: fa5e665b660f4c22e78fff630e555d0db98ba36942ed6a6c3d3a9c398cdbd44c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.02 MB