Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- app.py +34 -6
- examples/hispa/200999.jpg +0 -0
- examples/normal/100002.jpg +3 -0
- models/mobilenetv4_conv_small.e3600_r256_in1k_v3.pth +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 |
+
examples/normal/100002.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -1,29 +1,57 @@
|
|
| 1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
-
__all__ = ['learn', 'labels', 'demo', 'predict']
|
| 5 |
|
| 6 |
# %% app.ipynb 3
|
| 7 |
import os
|
| 8 |
import gradio as gr
|
| 9 |
from fastai.vision.all import *
|
|
|
|
| 10 |
# import dill
|
| 11 |
|
| 12 |
# %% app.ipynb 5
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
labels = learn.dls.vocab; labels
|
| 15 |
|
| 16 |
-
# %% app.ipynb
|
| 17 |
def predict(img):
|
| 18 |
img = PILImage.create(img)
|
| 19 |
pred,pred_idx,probs = learn.predict(img)
|
| 20 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 21 |
|
| 22 |
-
# %% app.ipynb
|
|
|
|
|
|
|
|
|
|
| 23 |
demo = gr.Interface(
|
| 24 |
-
fn=predict,
|
| 25 |
inputs=gr.Image(),
|
| 26 |
-
outputs=gr.Label(num_top_classes=3)
|
|
|
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
demo.launch(share=True)
|
|
|
|
| 1 |
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
| 2 |
|
| 3 |
# %% auto 0
|
| 4 |
+
__all__ = ['vocab', 'img_path', 'dblock', 'dls', 'learn', 'labels', 'example_files', 'demo', 'predict']
|
| 5 |
|
| 6 |
# %% app.ipynb 3
|
| 7 |
import os
|
| 8 |
import gradio as gr
|
| 9 |
from fastai.vision.all import *
|
| 10 |
+
import pathlib
|
| 11 |
# import dill
|
| 12 |
|
| 13 |
# %% app.ipynb 5
|
| 14 |
+
vocab = ['bacterial_leaf_blight', 'bacterial_leaf_streak', 'bacterial_panicle_blight',
|
| 15 |
+
'blast', 'brown_spot', 'dead_heart', 'downy_mildew', 'hispa', 'normal', 'tungro']
|
| 16 |
+
|
| 17 |
+
# Dummy image path - replace with your real test image path
|
| 18 |
+
img_path = pathlib.Path("examples/hispa/200999.jpg")
|
| 19 |
+
dblock = DataBlock(
|
| 20 |
+
blocks=(ImageBlock, CategoryBlock(vocab=vocab)),
|
| 21 |
+
get_items=lambda x: [img_path], # x is source, ignored here
|
| 22 |
+
get_y=lambda x: 'normal',
|
| 23 |
+
item_tfms=Resize(192)
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Pass a dummy 'source' argument, e.g. '.' or pathlib.Path('.')
|
| 27 |
+
dls = dblock.dataloaders(pathlib.Path('.'), bs=1)
|
| 28 |
+
|
| 29 |
+
# %% app.ipynb 7
|
| 30 |
+
learn = vision_learner(dls,"mobilenetv4_conv_small.e3600_r256_in1k", metrics=[error_rate, accuracy]); learn
|
| 31 |
+
|
| 32 |
+
# %% app.ipynb 8
|
| 33 |
+
learn.load("mobilenetv4_conv_small.e3600_r256_in1k_v3"); learn
|
| 34 |
+
# learn.dls.vocab = ['bacterial_leaf_blight', 'bacterial_leaf_streak', 'bacterial_panicle_blight', 'blast', 'brown_spot', 'dead_heart', 'downy_mildew', 'hispa', 'normal', 'tungro']
|
| 35 |
+
# learn.dls.c = len(['bacterial_leaf_blight', 'bacterial_leaf_streak', 'bacterial_panicle_blight', 'blast', 'brown_spot', 'dead_heart', 'downy_mildew', 'hispa', 'normal', 'tungro'])
|
| 36 |
labels = learn.dls.vocab; labels
|
| 37 |
|
| 38 |
+
# %% app.ipynb 10
|
| 39 |
def predict(img):
|
| 40 |
img = PILImage.create(img)
|
| 41 |
pred,pred_idx,probs = learn.predict(img)
|
| 42 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 43 |
|
| 44 |
+
# %% app.ipynb 12
|
| 45 |
+
example_files = list(pathlib.Path('./examples').glob("*/*.jpg")); example_files
|
| 46 |
+
|
| 47 |
+
# %% app.ipynb 15
|
| 48 |
demo = gr.Interface(
|
| 49 |
+
fn=predict,
|
| 50 |
inputs=gr.Image(),
|
| 51 |
+
outputs=gr.Label(num_top_classes=3),
|
| 52 |
+
examples=[[str(f)] for f in example_files],
|
| 53 |
+
title="Paddy Disease Classifier",
|
| 54 |
+
description="Upload an image or select one of the examples to classify rice diseases."
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch(share=True)
|
examples/hispa/200999.jpg
ADDED
|
examples/normal/100002.jpg
ADDED
|
Git LFS Details
|
models/mobilenetv4_conv_small.e3600_r256_in1k_v3.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:69e8f4de09ee4fb1557af861d647151616bc478bc562b14824d91dd2cdb10887
|
| 3 |
+
size 32316683
|