Spaces:
Sleeping
Sleeping
update .gitattributes so git lfs will track .pkl files and .jpeg
Browse files- .gitattributes +1 -0
- app.py +30 -0
- grain_classifier.pkl +3 -0
- requirements.txt +2 -0
- sample/barley_seed.jpeg +3 -0
- sample/corn_seed.jpeg +3 -0
- sample/rye_seed.jpeg +3 -0
- sample/wheat_seed.jpeg +3 -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 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
#import skimage # for interpretation
|
4 |
+
|
5 |
+
learn = load_learner('grain_classifier.pkl')
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
def predict(img):
|
9 |
+
pred,pred_idx,probs = learn.predict(img)
|
10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
11 |
+
|
12 |
+
title = "Grain Classifier"
|
13 |
+
description = "A grain classifier trained on the xxx online images with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
14 |
+
#article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
15 |
+
examples = ['sample/barley_seed.jpeg',
|
16 |
+
'sample/corn_seed.jpeg',
|
17 |
+
'sample/rye_seed.jpeg',
|
18 |
+
'sample/wheat_seed.jpeg']
|
19 |
+
interpretation='default' # what parts of the input are responsible for the output
|
20 |
+
enable_queue=True
|
21 |
+
|
22 |
+
gr.Interface(fn=predict,
|
23 |
+
inputs=gr.inputs.Image(shape=(224, 224)),
|
24 |
+
outputs=gr.outputs.Label(num_top_classes=4),
|
25 |
+
title=title,
|
26 |
+
description=description,
|
27 |
+
#article=article,
|
28 |
+
examples=examples,
|
29 |
+
interpretation=interpretation,
|
30 |
+
enable_queue=enable_queue).launch()
|
grain_classifier.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bfdd9045739bd4e3d6e65e83057bbdd0b87ca4fafae13cdb88595a9ed7bb275e
|
3 |
+
size 46979395
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|
sample/barley_seed.jpeg
ADDED
![]() |
Git LFS Details
|
sample/corn_seed.jpeg
ADDED
![]() |
Git LFS Details
|
sample/rye_seed.jpeg
ADDED
![]() |
Git LFS Details
|
sample/wheat_seed.jpeg
ADDED
![]() |
Git LFS Details
|