nahuelnb commited on
Commit
f003db5
·
verified ·
1 Parent(s): 3965625

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +138 -0
README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - image-classification
5
+ - plant-pathology
6
+ - efficientnet
7
+ - pytorch
8
+ datasets:
9
+ - plant-pathology-2020-fgvc7
10
+ metrics:
11
+ - accuracy
12
+ library_name: pytorch
13
+ ---
14
+
15
+ # Plant Pathology EfficientNet-B2
16
+
17
+ This model classifies plant diseases using EfficientNet-B2 architecture. It was trained on the Plant Pathology 2020 FGVC7 dataset.
18
+
19
+ ## Model Description
20
+
21
+ - **Architecture**: EfficientNet-B2 (pretrained on ImageNet)
22
+ - **Task**: Multi-class image classification (4 classes)
23
+ - **Input Size**: 260x260 RGB images
24
+ - **Classes**:
25
+ - healthy
26
+ - multiple_diseases
27
+ - rust
28
+ - scab
29
+
30
+ ## Performance
31
+
32
+ - **Validation Accuracy**: 96.04%
33
+ - **Test Accuracy**: 97.00%
34
+
35
+ ### Requirements
36
+
37
+ ```bash
38
+ pip install torch torchvision Pillow safetensors
39
+ ```
40
+
41
+ ### Inference Code
42
+
43
+ ```python
44
+ import torch
45
+ import torch.nn as nn
46
+ from torchvision import transforms
47
+ from torchvision.models import efficientnet_b2
48
+ from PIL import Image
49
+ from safetensors.torch import load_file
50
+
51
+ # Define the model architecture
52
+ class PlantPathologyModel(nn.Module):
53
+ def __init__(self, num_classes=4):
54
+ super(PlantPathologyModel, self).__init__()
55
+ self.backbone = efficientnet_b2(pretrained=False)
56
+ in_features = self.backbone.classifier[1].in_features
57
+ self.backbone.classifier = nn.Sequential(
58
+ nn.Dropout(p=0.3, inplace=True),
59
+ nn.Linear(in_features, num_classes)
60
+ )
61
+
62
+ def forward(self, x):
63
+ return self.backbone(x)
64
+
65
+ # Load model
66
+ model = PlantPathologyModel(num_classes=4)
67
+ state_dict = load_file("plant-pathology-efficientnetb2.safetensors")
68
+ model.load_state_dict(state_dict)
69
+ model.eval()
70
+
71
+ # Define preprocessing
72
+ transform = transforms.Compose([
73
+ transforms.Resize((260, 260)),
74
+ transforms.ToTensor(),
75
+ transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
76
+ ])
77
+
78
+ # Inference
79
+ image = Image.open("your_plant_image.jpg").convert("RGB")
80
+ input_tensor = transform(image).unsqueeze(0)
81
+
82
+ with torch.no_grad():
83
+ output = model(input_tensor)
84
+ probabilities = torch.nn.functional.softmax(output[0], dim=0)
85
+ predicted_class = torch.argmax(probabilities).item()
86
+
87
+ # Class names
88
+ class_names = ["healthy", "multiple_diseases", "rust", "scab"]
89
+ print(f"Predicted: {class_names[predicted_class]}")
90
+ print(f"Confidence: {probabilities[predicted_class]:.2%}")
91
+ ```
92
+
93
+ ## Training Details
94
+
95
+ ### Training Data
96
+ - Dataset: Plant Pathology 2020 FGVC7
97
+ - Training samples: 1,310
98
+ - Validation samples: 328
99
+ - Test samples: 181
100
+
101
+ ### Training Configuration
102
+ - **Optimizer**: Adam (lr=0.001)
103
+ - **Loss Function**: CrossEntropyLoss
104
+ - **Batch Size**: 32
105
+ - **Epochs**: 15
106
+ - **Learning Rate Scheduler**: ReduceLROnPlateau
107
+ - **Data Augmentation**:
108
+ - Random horizontal flip
109
+ - Random vertical flip
110
+ - Random rotation (+/- 20 degrees)
111
+ - Color jitter (brightness=0.2, contrast=0.2)
112
+
113
+ ### Hardware
114
+ - GPU training on CUDA-enabled device
115
+
116
+ ## Limitations
117
+
118
+ - Model is trained specifically on apple leaf diseases from the Plant Pathology 2020 dataset
119
+ - Performance may vary on other plant species or different imaging conditions
120
+ - Requires consistent image preprocessing (resize to 260x260, normalize with ImageNet stats)
121
+
122
+ ## Citation
123
+
124
+ If you use this model, please cite:
125
+
126
+ ```bibtex
127
+ @misc{plant-pathology-efficientnetb2,
128
+ author = {Nahuel},
129
+ title = {Plant Pathology EfficientNet-B2},
130
+ year = {2026},
131
+ publisher = {Hugging Face},
132
+ howpublished = {\url{https://huggingface.co/nahuelnb/plant-pathology-efficientnetb2}}
133
+ }
134
+ ```
135
+
136
+ ## License
137
+
138
+ Apache 2.0