AI-Lab-Makerere/beans
Viewer • Updated • 1.3k • 7.24k • 46
ViT-B/16 fine-tuned to classify bean leaf images into three classes:
angular_leaf_spotbean_rusthealthyTraining occurred in two stages:
The model was selected exclusively using validation macro-F1.
| Split | Accuracy | Macro-F1 | Balanced accuracy |
|---|---|---|---|
| Validation | 0.9925 | 0.9925 | - |
| Test | 0.9688 | 0.9690 | 0.9690 |
Test set:
All healthy images were classified correctly. The four errors occurred between angular_leaf_spot and bean_rust.
| Model | Parameters | Test accuracy | Test macro-F1 |
|---|---|---|---|
| Custom CNN | 1,206,499 | 0.9141 | 0.9114 |
| ViT-B/16 | 85,800,963 | 0.9688 | 0.9690 |
The ViT obtained higher test performance, but it is approximately 71 times larger than the custom CNN. The CNN may remain preferable for resource-constrained deployment.
Download the repository and use inference.py.
Example:
from PIL import Image
from inference import load_model, predict
model, config, device = load_model(".")
image = Image.open("bean_leaf.jpg")
results = predict(
image,
model,
config,
device
)
print(results)