Spaces:
Sleeping
Sleeping
Aravinth Meganathan
commited on
Commit
·
955b698
1
Parent(s):
903a4c8
app commit
Browse files- app.py +25 -4
- export.pkl +3 -0
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
import timm
|
5 |
+
learn = load_learner('/content/drive/MyDrive/Rice Category Prediction/export.pkl')
|
6 |
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
def predict(img):
|
9 |
+
img = PILImage.create(img)
|
10 |
+
pred,pred_idx,probs = learn.predict(img)
|
11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
12 |
|
13 |
+
title = "Rice Category Classifier"
|
14 |
+
description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
15 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
16 |
+
examples = ['/content/drive/MyDrive/Rice Category Prediction/Arborio.jpg',
|
17 |
+
'/content/drive/MyDrive/Rice Category Prediction/Basmati.jpg',
|
18 |
+
'/content/drive/MyDrive/Rice Category Prediction/Jasmine.jpg',
|
19 |
+
'/content/drive/MyDrive/Rice Category Prediction/Ispala.jpg',
|
20 |
+
'/content/drive/MyDrive/Rice Category Prediction/Karacadag.jpg'
|
21 |
+
|
22 |
+
]
|
23 |
+
interpretation='default'
|
24 |
+
enable_queue=True
|
25 |
+
|
26 |
+
demo = gr.Interface(fn=predict, inputs="image", outputs="label",examples= examples)
|
27 |
+
if __name__ == "__main__":
|
28 |
+
demo.launch()
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0627f01583c64be5631e3d83746f89c83b3cae9d282b280180b5846a198ea503
|
3 |
+
size 103743675
|