Skip to content
ModelListedExternal
Browse files

Agri Ai Model

Two MobileNetV2-based models used in the AgriAI project:

KindOtherVersionLeaf detectorUnratedgrade

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:

  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

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
Hugging FacePrimaryVersion 5fef9090d5548c15127a286753513d79eca72bd2
huggingface.co/AAYUSHSAVALIYA/agri-ai-model/tree/5fef9090d5548c15127a286753513d79eca72bd2

Verified Nov 5

Download files

Model artifacts

2 artifacts

leaf_detector.pth

pth · 8.72 MB · SHA-256 e20ca8ea972a…5d72 · Hugging Face

Download file

model.pth

pth · 9.04 MB · SHA-256 acbe97b77cda…2522 · Hugging Face

Download file

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