Marconcini commited on
Commit
38dda9b
·
verified ·
1 Parent(s): 17ae5ee

LeafScan ConvNeXt-T, field-calibrated (code: github.com/marconcini/leafscan @ 748c49a)

Browse files
Files changed (3) hide show
  1. README.md +85 -0
  2. config.json +48 -0
  3. model.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-sa-4.0
3
+ library_name: pytorch
4
+ pipeline_tag: image-classification
5
+ tags:
6
+ - plant-disease
7
+ - agriculture
8
+ - convnext
9
+ - timm
10
+ datasets:
11
+ - mohanty/PlantVillage
12
+ metrics:
13
+ - accuracy
14
+ ---
15
+
16
+ # LeafScan — ConvNeXt-T for plant disease classification (field-calibrated)
17
+
18
+ Classifies a leaf photo into **38 crop / disease classes** (14 crops) and says **"Not sure"**
19
+ when its confidence is too low. Research / portfolio project:
20
+ [github.com/marconcini/leafscan](https://github.com/marconcini/leafscan) — every number below
21
+ comes from experiments documented there, with hypotheses written before results.
22
+
23
+ - **Architecture:** ConvNeXt-T (`timm`: `convnext_tiny.fb_in22k_ft_in1k`), 28M parameters, 224×224 input.
24
+ - **Training:** ImageNet weights → PlantVillage (lab photos, 39k images) → 85% of PlantDoc train
25
+ (1,975 web/field photos). The other 15% of PlantDoc train (348 photos) is used only to fit a
26
+ temperature (T = 0.83) and an abstention threshold (0.75 on calibrated confidence).
27
+
28
+ ## Results
29
+
30
+ | | PlantDoc test (field, 228 photos) | PlantVillage test (lab, 10,709 photos) |
31
+ |---|---:|---:|
32
+ | Accuracy | **72.4%** (95% CI 66.2–78.1) | 96.6% |
33
+ | Right crop | 86.4% | – |
34
+ | Healthy vs diseased | 94.7% | – |
35
+ | Answers above the threshold | 65% of photos, **87%** of them right | 94% of photos, 98.7% right |
36
+
37
+ For context: the same architecture trained on PlantVillage only reaches 99.7% on lab photos but
38
+ **31%** on field photos. Lab accuracy says little about real-world use.
39
+
40
+ ## How to use
41
+
42
+ ```bash
43
+ pip install "leafscan @ git+https://github.com/marconcini/leafscan.git"
44
+ ```
45
+
46
+ ```python
47
+ from PIL import Image
48
+ from leafscan.predictor import Predictor
49
+
50
+ predictor = Predictor("Marconcini/leafscan-convnext-tiny") # downloads config.json + model.safetensors
51
+ pred = predictor(Image.open("leaf.jpg"))
52
+ print(pred.verdict) # diagnosis, or "Not sure" below the field-calibrated threshold
53
+ print(pred.top) # top-3 (class, calibrated probability)
54
+ ```
55
+
56
+ Files: `model.safetensors` (weights) and `config.json` (class names, input size, temperature,
57
+ threshold).
58
+
59
+ ## Intended use and limitations
60
+
61
+ - **Intended use:** demonstration and research on robustness of plant-disease classifiers.
62
+ **Not** a diagnostic tool and not a substitute for an agronomist.
63
+ - Knows only the 38 PlantVillage classes; any other plant or disease is forced into one of them
64
+ (or answered "Not sure").
65
+ - Test set is small (228 photos): differences under ~6 points are within noise.
66
+ - Calibration and threshold were fitted on PlantDoc photos; they may not hold for photos from
67
+ other sources (the project shows lab-fitted thresholds failing on field photos).
68
+ - Rejection of non-leaf images is weak next to real field photos (AUROC 0.6–0.8 in the
69
+ project's tests): a photo of something else may still receive a diagnosis.
70
+ - PlantDoc is web-scraped and contains label noise (duplicates filed under different classes
71
+ were removed).
72
+
73
+ ## Training data and licenses
74
+
75
+ - **PlantVillage** (Hughes & Salathé, 2015), CC BY-SA 3.0 — via `mohanty/PlantVillage`.
76
+ - **PlantDoc** (Singh et al., 2020), CC BY 4.0 — [github.com/pratikkayal/PlantDoc-Dataset](https://github.com/pratikkayal/PlantDoc-Dataset).
77
+ - Weights released under **CC BY-SA 4.0** (share-alike, following PlantVillage's license).
78
+ Code: MIT.
79
+
80
+ ## References
81
+
82
+ - Hughes & Salathé (2015). *An open access repository of images on plant health to enable the development of mobile disease diagnostics.* arXiv:1511.08060
83
+ - Singh et al. (2020). *PlantDoc: A Dataset for Visual Plant Disease Detection.* CoDS-COMAD
84
+ - Liu et al. (2022). *A ConvNet for the 2020s.* CVPR
85
+ - Guo et al. (2017). *On Calibration of Modern Neural Networks.* ICML
config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_name": "convnext_tiny.fb_in22k_ft_in1k",
3
+ "classes": [
4
+ "Apple___Apple_scab",
5
+ "Apple___Black_rot",
6
+ "Apple___Cedar_apple_rust",
7
+ "Apple___healthy",
8
+ "Blueberry___healthy",
9
+ "Cherry_(including_sour)___Powdery_mildew",
10
+ "Cherry_(including_sour)___healthy",
11
+ "Corn_(maize)___Cercospora_leaf_spot Gray_leaf_spot",
12
+ "Corn_(maize)___Common_rust_",
13
+ "Corn_(maize)___Northern_Leaf_Blight",
14
+ "Corn_(maize)___healthy",
15
+ "Grape___Black_rot",
16
+ "Grape___Esca_(Black_Measles)",
17
+ "Grape___Leaf_blight_(Isariopsis_Leaf_Spot)",
18
+ "Grape___healthy",
19
+ "Orange___Haunglongbing_(Citrus_greening)",
20
+ "Peach___Bacterial_spot",
21
+ "Peach___healthy",
22
+ "Pepper,_bell___Bacterial_spot",
23
+ "Pepper,_bell___healthy",
24
+ "Potato___Early_blight",
25
+ "Potato___Late_blight",
26
+ "Potato___healthy",
27
+ "Raspberry___healthy",
28
+ "Soybean___healthy",
29
+ "Squash___Powdery_mildew",
30
+ "Strawberry___Leaf_scorch",
31
+ "Strawberry___healthy",
32
+ "Tomato___Bacterial_spot",
33
+ "Tomato___Early_blight",
34
+ "Tomato___Late_blight",
35
+ "Tomato___Leaf_Mold",
36
+ "Tomato___Septoria_leaf_spot",
37
+ "Tomato___Spider_mites Two-spotted_spider_mite",
38
+ "Tomato___Target_Spot",
39
+ "Tomato___Tomato_Yellow_Leaf_Curl_Virus",
40
+ "Tomato___Tomato_mosaic_virus",
41
+ "Tomato___healthy"
42
+ ],
43
+ "img_size": 224,
44
+ "temperature": 0.8288379907608032,
45
+ "threshold": 0.7529807090759277,
46
+ "threshold_target_accuracy": 0.9,
47
+ "trained_on": "PlantVillage, then 85% of PlantDoc train"
48
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aba21125534108a6964a48fa437e1fdcee13482ef555f02f9dfb82b9e308c850
3
+ size 111415080