dmitryhits commited on
Commit
841823d
1 Parent(s): 672d629

first hugging space deployment

Browse files
Files changed (4) hide show
  1. SugarBeet.png +0 -0
  2. app.py +28 -0
  3. export.pkl +3 -0
  4. requirements.txt +2 -0
SugarBeet.png ADDED
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../weed_classifier.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'labels', 'title', 'description', 'article', 'examples', 'interpretation', 'enable_queue', 'predict']
5
+
6
+ # %% ../weed_classifier.ipynb 1
7
+ from fastai.vision.all import *
8
+ import gradio as gr
9
+ import skimage
10
+
11
+ # %% ../weed_classifier.ipynb 2
12
+ learn = load_learner('export.pkl')
13
+
14
+ # %% ../weed_classifier.ipynb 3
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
+ # %% ../weed_classifier.ipynb 5
22
+ title = "Weed Classifier"
23
+ description = "A weed classifier trained on the Kaggle V2 Plant Seedling dataset with fastai. Dataset has mostly african weeds in it at the moment."
24
+ article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
25
+ examples = ['SugarBeet.png']
26
+ interpretation='default'
27
+ enable_queue=True
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).launch(share=True, enable_queue=enable_queue)
export.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8611976c26b9bb1e6deedf03ae034d9be1992786048915b8b9cfed4c4ad2d9f5
3
+ size 87656638
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ scikit-image