mpfoley73 commited on
Commit
91b5b18
1 Parent(s): d636eb7

initial commit

Browse files
Files changed (6) hide show
  1. .gitattributes +1 -0
  2. .gitignore +1 -0
  3. app.py +45 -0
  4. chester_14.jpg +3 -0
  5. dog_breed_classifier.pkl +3 -0
  6. requirements.txt +2 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jpg filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ hugging_spaces_pat.txt
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gradio app interface to dog_breed_classifier model fine-tuned on kaggle.
2
+ # This is the project from lesson 2 of the fastai Deep Learning course.
3
+ #
4
+ # Reference:
5
+ # Kaggle: https://www.kaggle.com/code/mpfoley73/dog-breed-classification
6
+ # Dog Breed dataset: https://www.kaggle.com/datasets/khushikhushikhushi/dog-breed-image-dataset
7
+ # Tanishq blog: https://www.tanishq.ai/blog/posts/2021-11-16-gradio-huggingface.html
8
+ # Fastai: https://course.fast.ai/Lessons/lesson2.html
9
+ #
10
+
11
+ import gradio as gr
12
+ from fastai.vision.all import *
13
+ import skimage
14
+
15
+ learn = load_learner('dog_breed_classifier.pkl')
16
+
17
+ labels = learn.dls.vocab
18
+ def predict(img):
19
+ img = PILImage.create(img)
20
+ pred,pred_idx,probs = learn.predict(img)
21
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
22
+
23
+ title = "Dog Breed Classifier"
24
+ description = "A dog breed classifier trained on the Dog Breed dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
25
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
26
+ examples = ['Chester 14.jpg']
27
+ interpretation='default'
28
+ enable_queue=True
29
+
30
+ # Construct a Gradio Interface object from the function (usually an ML model
31
+ # inference function), Gradio input components (the number should match the
32
+ # number of function parameters), and Gradio output components (the number
33
+ # should match the number of values returned by the function).
34
+
35
+ gr.Interface(
36
+ fn=predict,
37
+ inputs=gr.inputs.Image(shape=(512, 512)),
38
+ outputs=gr.outputs.Label(num_top_classes=3),
39
+ title=title,
40
+ description=description,
41
+ article=article,
42
+ examples=examples,
43
+ interpretation=interpretation,
44
+ enable_queue=enable_queue
45
+ ).launch()
chester_14.jpg ADDED

Git LFS Details

  • SHA256: 878025bfb8353a14c34c6c5a7f366b8f08e2d1b8fee0792897d5b86a2755e4ef
  • Pointer size: 132 Bytes
  • Size of remote file: 1.02 MB
dog_breed_classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86196aa05c2694a0f3940795f23f94ff3bdd5005e10d4dc2d4b6b461bd45d157
3
+ size 46997568
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image