Views
No views yet
.pth.pth model and configuration files are hosted here:mobilenetv2_plant.pthclass_names.jsonREADME.md (this file)1model = models.mobilenet_v2(pretrained=True)
2
3for p in model.features.parameters():
4 p.requires_grad = False # freeze feature extractor
5
6model.classifier[1] = nn.Sequential(
7 nn.Dropout(0.2),
8 nn.Linear(model.classifier[1].in_features, 38)
9)class_names.json)1import torch
2from torchvision import models, transforms
3from PIL import Image
4
5model = ... # load your mobilenetv2_plant.pth
6model.eval()
7
8tf = transforms.Compose([
9 transforms.Resize((224,224)),
10 transforms.ToTensor(),
11 transforms.Normalize([0.485,0.456,0.406],
12 [0.229,0.224,0.225])
13])
14
15img = Image.open("leaf.jpg").convert("RGB")
16x = tf(img).unsqueeze(0)
17
18with torch.no_grad():
19 preds = model(x)
20 probs = torch.softmax(preds, dim=1)[0]
21 index = probs.argmax().item()
22
23print("Predicted Class:", CLASS_NAMES[index])
24print("Confidence:", float(probs[index]))| Platform | Status | Link |
|---|---|---|
| HuggingFace | ✔ Model Hosted | https://huggingface.co/Daksh159/plant-disease-mobilenetv2 |
| Streamlit Cloud | ✔ Web App Live | https://agriguard271005.streamlit.app/ |