Views
No views yet
| Metric | Score |
|---|---|
| Test Accuracy | 79.86% |
| F1-Score (Macro) | 0.7519 |
| Classes | 28 |
| Training Time | 83.0 min |
1import torch
2import timm
3from PIL import Image
4import albumentations as A
5from albumentations.pytorch import ToTensorV2
6import numpy as np
7
8# Load model
9model = timm.create_model(
10 'tf_efficientnetv2_m.in21k_ft_in1k',
11 pretrained=False,
12 num_classes=28
13)
14checkpoint = torch.load('weights/best_model.pth', map_location='cpu')
15model.load_state_dict(checkpoint['model_state_dict'])
16model.eval()
17
18# Preprocessing
19transform = A.Compose([
20 A.Resize(256, 256),
21 A.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
22 ToTensorV2()
23])
24
25# Inference
26image = Image.open('leaf.jpg').convert('RGB')
27image = transform(image=np.array(image))['image'].unsqueeze(0)
28
29with torch.no_grad():
30 logits = model(image)
31 probs = torch.softmax(logits, dim=1)
32 pred_class = probs.argmax(1).item()
33 confidence = probs[0, pred_class].item()
34
35class_names = ['Apple_Scab_Leaf', 'Apple_leaf', 'Apple_rust_leaf', 'Bell_pepper_leaf', 'Bell_pepper_leaf_spot'] # ... truncated for README
36print(f"Prediction: {class_names[pred_class]} ({confidence:.2%})")plantdoc_model/
├── weights/
│ ├── model.safetensors # Model weights (preferred)
│ └── best_model.pth # Full checkpoint with metadata
├── plots/
│ ├── training_history.png # Training curves
│ ├── confusion_matrix.png # Confusion matrix
│ └── per_class_metrics.png # Per-class performance
├── logs/
│ └── training.json # Training logs
├── config.json # Model configuration
├── preprocessor_config.json # Preprocessing settings
└── README.md # This file1@misc{plantdoc_elite,
2 title={PlantDoc Elite Disease Classifier},
3 author={Your Name},
4 year={2025},
5 publisher={HuggingFace},
6 url={https://huggingface.co/your-username/plantdoc-elite}
7}