davidmasip commited on
Commit
3c123d7
1 Parent(s): 02a2ca2

first commit

Browse files
Files changed (9) hide show
  1. .gitattributes +0 -1
  2. .gitignore +1 -0
  3. 1355.png +0 -0
  4. 2.png +0 -0
  5. 2194.png +0 -0
  6. README.md +1 -0
  7. app.py +37 -0
  8. model.pkl +3 -0
  9. requirements.txt +20 -0
.gitattributes CHANGED
@@ -2,7 +2,6 @@
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
 
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
 
5
  *.ftz filter=lfs diff=lfs merge=lfs -text
6
  *.gz filter=lfs diff=lfs merge=lfs -text
7
  *.h5 filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ flagged/
1355.png ADDED
2.png ADDED
2194.png ADDED
README.md CHANGED
@@ -10,3 +10,4 @@ pinned: false
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
13
+
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+ import gradio as gr
4
+ import numpy as np
5
+ from fastai.vision.all import *
6
+
7
+ config = {
8
+ "labels": [
9
+ "Plantation",
10
+ "Grassland",
11
+ "Smallholder Agriculture"
12
+ ],
13
+ "size": 256,
14
+ }
15
+
16
+ learn = load_learner("model.pkl")
17
+
18
+ def classify_image(input):
19
+ _, _, prediction = learn.predict(input)
20
+ print(prediction)
21
+ outputs = {label: float(prediction[i]) for i, label in enumerate(config["labels"])}
22
+ # Get argmax
23
+ argmax_label = config["labels"][np.argmax(prediction)]
24
+ return argmax_label, round(outputs[argmax_label], 3) * 100
25
+
26
+
27
+ gr.Interface(
28
+ fn=classify_image,
29
+ inputs=gr.inputs.Image(shape=(config["size"], config["size"])),
30
+ outputs=[
31
+ gr.outputs.Textbox(label="Output of the model"),
32
+ gr.outputs.Textbox(label="Probability (0 - 100)")
33
+ ],
34
+ examples=[str(x) for x in Path("./").glob("*.jpg")],
35
+ flagging_options=["Correct label", "Incorrect label"],
36
+ allow_flagging="manual",
37
+ ).launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce511c43ceeb3fb89c7ffcc58c4c13c464925978159e92762c48a02c061d829f
3
+ size 87507001
requirements.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ipython==8.4.0
2
+ jupyter==1.0.0
3
+ matplotlib==3.5.2
4
+ numpy==1.22.4
5
+ pandas==1.4.2
6
+ pydot==1.4.2
7
+ scikit-learn==1.1.1
8
+ scipy==1.8.1
9
+ tensorflow==2.8.0
10
+ protobuf==3.20.0
11
+ sklearn
12
+ opencv-python
13
+ fastai
14
+ torch==1.11.0
15
+ timm
16
+ transformers
17
+ ipykernel
18
+ huggingface_hub[fastai]
19
+ dill
20
+ gradio