--- 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.