Views
No views yet
Linear(1536 → 17)💡 This model requires preprocessing consistent with training (image resizing, normalization). For ready-to-use prediction.
1import torch
2from torchvision import transforms
3from PIL import Image
4import requests
5from huggingface_hub import hf_hub_download
6
7# Download the model file from Hugging Face
8model_path = hf_hub_download(repo_id="VisionaryQuant/5_Crop_Disease_Detection", filename="best_crop_disease_model.pt")
9
10# Load the model (make sure your architecture matches)
11model = torch.load(model_path, map_location=torch.device('cpu'))
12model.eval()
13
14# Preprocess input image
15image = Image.open("your_crop_image.jpg").convert("RGB")
16transform = transforms.Compose([
17 transforms.Resize((300, 300)),
18 transforms.ToTensor(),
19 transforms.Normalize(mean=[0.485, 0.456, 0.406],
20 std=[0.229, 0.224, 0.225])
21])
22input_tensor = transform(image).unsqueeze(0)
23
24# Run inference
25with torch.no_grad():
26 logits = model(input_tensor)
27 probs = torch.nn.functional.softmax(logits, dim=1)
28 predicted_idx = torch.argmax(probs, dim=1).item()
29
30# Map class index to label
31idx2label = {0: "Corn___Common_Rust", 1: "Corn___Gray_Leaf_Spot", ..., 16: "Sugarcane___Healthy"} # Add full mapping
32print("Prediction:", idx2label[predicted_class])@misc{5cropdiseasedetection2025,
title = {Crop Disease Detection using EfficientNet-B3},
author = {Abdullahi Olalekan Abdulmumeen},
year = {2025},
url = {https://huggingface.co/VisionaryQuant/5_Crop_Disease_Detection}
}Abdulmumeen, A. O. (2025). Crop disease detection using EfficientNet-B3 [Model]. Hugging Face. https://huggingface.co/VisionaryQuant/5_Crop_Disease_Detection