Agri Ai Model
Two MobileNetV2-based models used in the AgriAI project:
Model source
- Kind
- Other
- File size
- 8.72–9.04 MB
- Version
- vLeaf detector
- Updated
- Nov 5, 2026
- Source
- Hugging Face
Source description
AgriAI - Crop Disease Detection Models
Two MobileNetV2-based models used in the AgriAI project:
- model.pth — classifies crop leaf diseases (tomato, potato, pepper, rice, bitter gourd)
- leaf_detector.pth — checks whether an uploaded image is actually a valid leaf
Architecture
- Backbone: MobileNetV2 (torchvision,
weights=None, trained from scratch/fine-tuned) - Final layer:
nn.Linear(num_features, len(class_names)) - Checkpoint format: dict with
class_namesandmodel_state_dictkeys
Usage
from huggingface_hub import hf_hub_download
import torch, torch.nn as nn
from torchvision import models, transforms
from PIL import Image
model_path = hf_hub_download("AAYUSHSAVALIYA/agri-ai-model", "model.pth")
checkpoint = torch.load(model_path, map_location="cpu")
class_names = checkpoint["class_names"]
model = models.mobilenet_v2(weights=None)
model.classifier[1] = nn.Linear(model.classifier[1].in_features, len(class_names))
model.load_state_dict(checkpoint["model_state_dict"])
model.eval()
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
img = Image.open("leaf.jpg").convert("RGB")
with torch.no_grad():
output = model(transform(img).unsqueeze(0))
pred = output.argmax(dim=1).item()
print(class_names[pred])
Classes
[list your crop/disease class names here — pull from class_names in the checkpoint]
Sources
1 source
Sources
1 sourceVerified Nov 5
Download files
Model artifacts
2 artifacts
Model artifacts
2 artifactsSource excerpts
2 excerpts
Source excerpts
2 excerpts--- license: mit tags: - image-classification - agriculture - pytorch - mobilenet-v2 - plant-disease --- # AgriAI - Crop Disease Detection Models Two MobileNetV2-based models used in the [AgriAI project](https://github.com/Parth070711/AgriAI): 1. **model.pth** — classifies crop leaf diseases (tomato, potato, pepper, rice, bitter gourd) 2. **leaf_detector.pth** — checks whether an uploaded image is actually a valid leaf ## Architecture - Backbone: MobileNetV2 (torchvision, `weights=None`, trained from scratch/fine-tuned) - Final layer: `nn.Linear(num_features, len(class_names))` - Checkpoint format: dict with `class_names` and `model_state_dict` keys ## Usage ```python from huggingface_hub import hf_hub_download import torch, torch.nn as nn from torchvision import models, transforms from PIL import Image model_path = hf_hub_download("AAYUSHSAVALIYA/agri-ai-model", "model.pth") checkpoint = torch.load(model_path, map_location="cpu") class_names = checkpoint["class_names"] model = models.mobilenet_v2(weights=None) model.classifier[1] = nn.Linear(model.classifier[1].in_features, len(class_names)) model.load_state_dict(checkpoint["model_state_dict"]) model.eval() transform = transforms.Compose([ transforms.Resize((224, 224)), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) img = Image.open("leaf.jpg").convert("RGB") with torch.no_grad(): output = model(transform(img).unsqueeze(0)) pred = output.argmax(dim=1).item() print(class_names[pred]) ``` ## Classes [list your crop/disease class names here — pull from `class_names` in the checkpoint]
Source context: 0 downloads · 1 likes · Pipeline image-classification · Repo AAYUSHSAVALIYA/agri-ai-model
