Shaq2 commited on
Commit
9400e5e
·
verified ·
1 Parent(s): 47b176a

Publish rice YOLO26-cls TFLite + labels + source weights with model card

Browse files
Files changed (8) hide show
  1. CITATION.cff +13 -0
  2. LICENSE +21 -0
  3. NOTICE.md +8 -0
  4. README.md +142 -0
  5. best.pt +3 -0
  6. config.json +35 -0
  7. labels.json +28 -0
  8. model.tflite +3 -0
CITATION.cff ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ title: "ChashiBhAI Rice Disease Classifier"
3
+ message: If you use this model, please cite it.
4
+ type: software
5
+ authors:
6
+ - family-names: Ahmed
7
+ given-names: Shakil
8
+ alias: Shaq2
9
+ repository-code: https://github.com/MRSHAKILS/AI-Powered-Smart-Agriculture-Advisory-Platform-for-Bangladesh
10
+ url: https://huggingface.co/Shaq2/chashibhai-rice-disease-cls
11
+ license: MIT
12
+ version: "0.1.0"
13
+ date-released: "2026-08-16"
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shakil Ahmed (ChashiBhAI)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
NOTICE.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Attribution
2
+
3
+ On-device crop disease classifier for ChashiBhAI.
4
+ Author: Shakil Ahmed (Hugging Face: Shaq2).
5
+
6
+ Not claimed here:
7
+ - KrishokChat dataset / LLM / RAG — RaiyanKhaan/KrishokChat-Advisory-System, arXiv:2606.29243
8
+ - Ultralytics YOLO
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: ultralytics
4
+ pipeline_tag: image-classification
5
+ tags:
6
+ - agriculture
7
+ - bangladesh
8
+ - crop-disease
9
+ - tflite
10
+ - yolo26
11
+ - on-device
12
+ - rice
13
+ - chashibhai
14
+ language:
15
+ - bn
16
+ - en
17
+ base_model_relation: quantized
18
+ ---
19
+
20
+ # ChashiBhAI Rice Disease Classifier
21
+
22
+ | | |
23
+ |---|---|
24
+ | **Author** | [Shaq2](https://huggingface.co/Shaq2) (Shakil Ahmed) |
25
+ | **Crop** | rice (ধান) |
26
+ | **Task** | Image classification (leaf disease) |
27
+ | **Architecture** | YOLO26-cls → TFLite FP16 |
28
+ | **Input** | `[1, 640, 640, 3]` NHWC RGB `/255.0` |
29
+ | **Output** | `[1, 8]` softmax probabilities (`nms: false`) |
30
+ | **Status** | `production-demo` |
31
+ | **App** | ChashiBhAI (Expo / React Native, on-device diagnosis) |
32
+ | **Code** | [GitHub](https://github.com/MRSHAKILS/AI-Powered-Smart-Agriculture-Advisory-Platform-for-Bangladesh) |
33
+ | **Collection** | [ChashiBhAI on-device classifiers](https://huggingface.co/collections/Shaq2/chashibhai-on-device-disease-classifiers) |
34
+
35
+ Disease ID in ChashiBhAI **always** runs on-device. Gemini / KrishokChat generate advisory **text only** and never see the photo.
36
+
37
+ ## Files
38
+
39
+ | File | Role |
40
+ |---|---|
41
+ | `model.tflite` | On-device graph used by the Android app (~3.12 MB) |
42
+ | `labels.json` | Canonical class names **and** preprocess contract |
43
+ | `best.pt` | Ultralytics source weights (export parent) |
44
+
45
+ ## Classes (8)
46
+
47
+ | Label | English | Bangla |
48
+ |---|---|---|
49
+ | `Rice__Bacterial_Leaf_Blight` | Bacterial Leaf Blight | ব্যাকটেরিয়াজনিত পাতা পোড়া |
50
+ | `Rice__Brown_Spot` | Brown Spot | বাদামী দাগ |
51
+ | `Rice__Healthy_Leaf` | Healthy Leaf | সুস্থ পাতা |
52
+ | `Rice__Leaf_Blast` | Leaf Blast | ব্লাস্ট |
53
+ | `Rice__Leaf_Scald` | Leaf Scald | পাতা পোড়া |
54
+ | `Rice__Narrow_Brown_Leaf_Spot` | Narrow Brown Leaf Spot | সরু বাদামী দাগ |
55
+ | `Rice__Rice_Hispa` | Rice Hispa | হিসপা |
56
+ | `Rice__Sheath_Blight` | Sheath Blight | শেথ ব্লাইট |
57
+
58
+ ## Preprocessing (variant C) — required
59
+
60
+ Do **not** letterbox. Letterbox disagreed with the `.pt` on non-square photos.
61
+
62
+ 1. Resize the **shortest side** to `imgsz` = **640**, keep aspect ratio.
63
+ 2. **Centre-crop** to `640×640`.
64
+ 3. RGB, NHWC, `float32 / 255.0`.
65
+
66
+ `labels.json` is the source of truth (`preprocess: centercrop`).
67
+
68
+ ## Measured export checks
69
+
70
+ | Check | Result |
71
+ |---|---|
72
+ | Preprocess verified vs `.pt` | yes (variant C, 100% top-1 vs `.pt` on the rice hold-out used for export) |
73
+ | FP16 vs FP32 top-1 agreement | 1.0 |
74
+ | FP16 vs FP32 max softmax diff | 0.000372171 |
75
+ | Bundled in APK | yes (rice) |
76
+
77
+ ## Intended use
78
+
79
+ - On-device diagnosis in ChashiBhAI for Bangladeshi farmers (Bangla-first UI).
80
+ - Research reproduction of the mobile export.
81
+
82
+ **Out of scope:** detection / bounding boxes, crop auto-routing, chemical dosage (handled by a separate advisory stack with a refuse gate).
83
+
84
+ ## Limitations
85
+
86
+ Demo-grade on-device classifier. Not a plant-pathologist substitute. Retake if confidence is low or the leaf is not centred.
87
+
88
+ ## Load (Python)
89
+
90
+ ```python
91
+ import json
92
+ from pathlib import Path
93
+ import numpy as np
94
+ from PIL import Image
95
+ import tensorflow as tf
96
+
97
+ def preprocess_centercrop(path: str, imgsz: int = 640) -> np.ndarray:
98
+ im = Image.open(path).convert("RGB")
99
+ w, h = im.size
100
+ scale = imgsz / min(w, h)
101
+ nw, nh = int(round(w * scale)), int(round(h * scale))
102
+ im = im.resize((nw, nh), Image.BILINEAR)
103
+ left, top = (nw - imgsz) // 2, (nh - imgsz) // 2
104
+ im = im.crop((left, top, left + imgsz, top + imgsz))
105
+ return (np.asarray(im, dtype=np.float32) / 255.0)[None, ...]
106
+
107
+ labels = json.loads(Path("labels.json").read_text(encoding="utf-8"))
108
+ it = tf.lite.Interpreter(model_path="model.tflite")
109
+ it.allocate_tensors()
110
+ inp, out = it.get_input_details()[0], it.get_output_details()[0]
111
+ it.set_tensor(inp["index"], preprocess_centercrop("leaf.jpg", labels["imgsz"]))
112
+ it.invoke()
113
+ p = it.get_tensor(out["index"])[0]
114
+ i = int(p.argmax())
115
+ print(labels["names"][i], float(p[i]))
116
+ ```
117
+
118
+ ## Related models (same author)
119
+
120
+ - [Rice](https://huggingface.co/Shaq2/chashibhai-rice-disease-cls)
121
+ - [Brassica](https://huggingface.co/Shaq2/chashibhai-brassica-disease-cls)
122
+ - [Corn](https://huggingface.co/Shaq2/chashibhai-corn-disease-cls)
123
+ - Suite index: [chashibhai-disease-classifiers](https://huggingface.co/Shaq2/chashibhai-disease-classifiers)
124
+
125
+ ## Credit (not this model)
126
+
127
+ KrishokChat Bengali advisory LLM / RAG is **not** this classifier. See [RaiyanKhaan/KrishokChat-Advisory-System](https://huggingface.co/RaiyanKhaan/KrishokChat-Advisory-System) and arXiv:2606.29243 (Reza & Shahid).
128
+
129
+ ## Citation
130
+
131
+ ```bibtex
132
+ @software{ahmed2026chashibhai_rice_cls,
133
+ author = {Ahmed, Shakil},
134
+ title = {ChashiBhAI Rice Disease Classifier},
135
+ year = {2026},
136
+ url = {https://huggingface.co/Shaq2/chashibhai-rice-disease-cls}
137
+ }
138
+ ```
139
+
140
+ ## License
141
+
142
+ MIT (see `LICENSE`). Ultralytics remains under its own license. This pack redistributes **weights**, not training images.
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f25243959a3d7dd0851f4d2e53e30890515cadd5e318871ffe04c0413865d61a
3
+ size 3205243
config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "YOLO26Cls"
4
+ ],
5
+ "model_type": "yolo26-cls",
6
+ "library_name": "ultralytics",
7
+ "crop": "rice",
8
+ "task": "image-classification",
9
+ "imgsz": 640,
10
+ "num_classes": 8,
11
+ "id2label": {
12
+ "0": "Rice__Bacterial_Leaf_Blight",
13
+ "1": "Rice__Brown_Spot",
14
+ "2": "Rice__Healthy_Leaf",
15
+ "3": "Rice__Leaf_Blast",
16
+ "4": "Rice__Leaf_Scald",
17
+ "5": "Rice__Narrow_Brown_Leaf_Spot",
18
+ "6": "Rice__Rice_Hispa",
19
+ "7": "Rice__Sheath_Blight"
20
+ },
21
+ "label2id": {
22
+ "Rice__Bacterial_Leaf_Blight": 0,
23
+ "Rice__Brown_Spot": 1,
24
+ "Rice__Healthy_Leaf": 2,
25
+ "Rice__Leaf_Blast": 3,
26
+ "Rice__Leaf_Scald": 4,
27
+ "Rice__Narrow_Brown_Leaf_Spot": 5,
28
+ "Rice__Rice_Hispa": 6,
29
+ "Rice__Sheath_Blight": 7
30
+ },
31
+ "preprocess": "centercrop",
32
+ "softmaxed": true,
33
+ "nms": false,
34
+ "status": "production-demo"
35
+ }
labels.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop": "rice-disease",
3
+ "task": "classify",
4
+ "imgsz": 640,
5
+ "inputShape": [
6
+ 1,
7
+ 640,
8
+ 640,
9
+ 3
10
+ ],
11
+ "outputShape": [
12
+ 1,
13
+ 8
14
+ ],
15
+ "softmaxed": true,
16
+ "preprocess": "centercrop",
17
+ "preprocessVerified": true,
18
+ "names": [
19
+ "Rice__Bacterial_Leaf_Blight",
20
+ "Rice__Brown_Spot",
21
+ "Rice__Healthy_Leaf",
22
+ "Rice__Leaf_Blast",
23
+ "Rice__Leaf_Scald",
24
+ "Rice__Narrow_Brown_Leaf_Spot",
25
+ "Rice__Rice_Hispa",
26
+ "Rice__Sheath_Blight"
27
+ ]
28
+ }
model.tflite ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9b5e2de9e23c49ba3ccc3a54645d24a4aab991897a7f18aa599c212957ad478
3
+ size 3121879