File size: 1,689 Bytes
c5cf522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
license: apache-2.0
tags:
  - image-classification
  - plant-disease
  - agriculture
  - mobilenet
  - pytorch
library_name: pytorch
---

# AgroMind Plant Disease Classifier (MobileNetV2)

## Model Description
MobileNetV2 image classifier trained on the New Plant Diseases Dataset to detect 38 plant disease classes. Serves as a lightweight fallback for the NFNet-F1 model.

## Framework
- **Architecture**: MobileNetV2 (torchvision)
- **Format**: PyTorch checkpoint (.pth)
- **Input size**: 224×224 RGB (resize to 256, center crop to 224)
- **Normalization**: ImageNet (mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])

## Usage
```python
from huggingface_hub import hf_hub_download
import torch
from torchvision import models, transforms
from PIL import Image

repo_id = "Arko007/agromind-plant-disease-mobilenet"
ckpt = hf_hub_download(repo_id, "newplant_model_final.pth")
labels_path = hf_hub_download(repo_id, "labels.txt")

with open(labels_path) as f:
    labels = [l.strip() for l in f if l.strip()]

model = models.mobilenet_v2(pretrained=False)
model.classifier[1] = torch.nn.Linear(model.classifier[1].in_features, len(labels))
state = torch.load(ckpt, map_location="cpu")
model.load_state_dict(state)
model.eval()

transform = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])

img = Image.open("leaf.jpg").convert("RGB")
with torch.no_grad():
    logits = model(transform(img).unsqueeze(0))
    print(labels[logits.argmax(dim=1).item()])
```

## Output
Returns logits for 38 plant disease classes. See `labels.txt` for class names.