AmanSengar commited on
Commit
a9dce72
Β·
verified Β·
1 Parent(s): 027b95b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +121 -0
README.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🧠 Beans-Image-Classification-AI-Model
2
+
3
+ A fine-tuned image classification model trained on the Beans dataset with 3 classes: angular_leaf_spot, bean_rust, and healthy. This model is built using Hugging Face Transformers and the ViT (Vision Transformer) architecture and is suitable for educational use, plant disease classification tasks, and image classification experiments.
4
+
5
+ ---
6
+
7
+
8
+ ## ✨ Model Highlights
9
+
10
+ - πŸ“Œ Base Model: google/vit-base-patch16-224-in21k
11
+ - πŸ“š Fine-tuned: Beans dataset
12
+ - 🌿 Classes: angular_leaf_spot, bean_rust, healthy
13
+ - πŸ”§ Framework: Hugging Face Transformers + PyTorch
14
+ - πŸ“¦ Preprocessing: AutoImageProcessor from Transformers
15
+
16
+ ---
17
+
18
+ ## 🧠 Intended Uses
19
+
20
+ - βœ… Educational tools for training and evaluation in agriculture and plant disease detection
21
+ - βœ… Benchmarking vision transformer models on small datasets
22
+ - βœ… Demonstration of fine-tuning workflows with Hugging Face
23
+
24
+ ---
25
+
26
+ ## 🚫 Limitations
27
+
28
+ - ❌ Not suitable for real-world diagnosis in agriculture without further domain validation
29
+ - ❌ Not robust to significant background noise or occlusion in images
30
+ - ❌ Trained on small dataset, may not generalize beyond bean leaf diseases
31
+
32
+ ---
33
+
34
+ πŸ“ Input & Output
35
+
36
+ - Input: RGB image of a bean leaf (expected size 224x224)
37
+ - Output: Predicted class label β€” angular_leaf_spot, bean_rust, or healthy
38
+
39
+ ---
40
+
41
+ ## πŸ‹οΈβ€β™‚οΈ Training Details
42
+
43
+ | Attribute | Value |
44
+ |--------------------|----------------------------------|
45
+ | Base Model |`google/vit-base-patch16-224-in21k|
46
+ | Dataset |Beans Dataset (train/val/test) |
47
+ | Task Type | Image Classification |
48
+ | Image Size | 224 Γ— 224 |
49
+ | Epochs | 3 |
50
+ | Batch Size | 16 |
51
+ | Optimizer | AdamW |
52
+ | Loss Function | CrossEntropyLoss |
53
+ | Framework | PyTorch + Transformers |
54
+ | Hardware | CUDA-enabled GPU |
55
+
56
+ ---
57
+
58
+ ## πŸ“Š Evaluation Metrics
59
+
60
+
61
+ | Metric | Score |
62
+ | ----------------------------------------------- | ----- |
63
+ | Accuracy | 0.98 |
64
+ | F1-Score | 0.99 |
65
+ | Precision | 0.98 |
66
+ | Recall | 0.99 |
67
+
68
+
69
+ ---
70
+
71
+ ---
72
+ πŸš€ Usage
73
+ ```python
74
+ from transformers import AutoImageProcessor, AutoModelForImageClassification
75
+ from PIL import Image
76
+ import torch
77
+
78
+ model_name = "AventIQ-AI/Beans-Image-Classification-AI-Model"
79
+
80
+ processor = AutoImageProcessor.from_pretrained(model_name)
81
+ model = AutoModelForImageClassification.from_pretrained(model_name)
82
+ model.eval()
83
+
84
+ def predict(image_path):
85
+ image = Image.open(image_path).convert("RGB")
86
+ inputs = processor(images=image, return_tensors="pt").to(model.device)
87
+ with torch.no_grad():
88
+ outputs = model(**inputs)
89
+ preds = torch.argmax(outputs.logits, dim=1)
90
+ return model.config.id2label[preds.item()]
91
+
92
+ # Example
93
+ print(predict("example_leaf.jpg"))
94
+
95
+
96
+ ```
97
+ ---
98
+
99
+ - 🧩 Quantization
100
+ - Post-training static quantization applied using PyTorch to reduce model size and accelerate inference on edge devices.
101
+
102
+ ----
103
+
104
+ πŸ—‚ Repository Structure
105
+ ```
106
+ .
107
+ beans-vit-finetuned/
108
+ β”œβ”€β”€ config.json βœ… Model architecture & config
109
+ β”œβ”€β”€ pytorch_model.bin βœ… Model weights
110
+ β”œβ”€β”€ preprocessor_config.json βœ… Image processor config
111
+ β”œβ”€β”€ special_tokens_map.json βœ… (Auto-generated, not critical for ViT)
112
+ β”œβ”€β”€ training_args.bin βœ… Training metadata
113
+ β”œβ”€β”€ README.md βœ… Model card
114
+
115
+ ```
116
+ ---
117
+ 🀝 Contributing
118
+
119
+ Open to improvements and feedback! Feel free to submit a pull request or open an issue if you find any bugs or want to enhance the model.
120
+
121
+