Image Classification
Transformers
Safetensors
timm
timm_wrapper
vision
Generated from Trainer
Eval Results (legacy)
Instructions to use omaralshareef/beans-image-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use omaralshareef/beans-image-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="omaralshareef/beans-image-classifier") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("omaralshareef/beans-image-classifier") model = AutoModelForImageClassification.from_pretrained("omaralshareef/beans-image-classifier", device_map="auto") - timm
How to use omaralshareef/beans-image-classifier with timm:
import timm model = timm.create_model("hf-hub:omaralshareef/beans-image-classifier", pretrained=True) - Notebooks
- Google Colab
- Kaggle
Upload fine-tuned bean leaf image classifier
Browse files- README.md +78 -0
- all_results.json +13 -0
- config.json +61 -0
- model.safetensors +3 -0
- test_results.json +8 -0
- train_results.json +8 -0
README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
base_model: timm/mobilenetv3_small_100.lamb_in1k
|
| 5 |
+
tags:
|
| 6 |
+
- image-classification
|
| 7 |
+
- vision
|
| 8 |
+
- timm
|
| 9 |
+
- generated_from_trainer
|
| 10 |
+
datasets:
|
| 11 |
+
- AI-Lab-Makerere/beans
|
| 12 |
+
metrics:
|
| 13 |
+
- accuracy
|
| 14 |
+
pipeline_tag: image-classification
|
| 15 |
+
model-index:
|
| 16 |
+
- name: beans-image-classifier
|
| 17 |
+
results:
|
| 18 |
+
- task:
|
| 19 |
+
type: image-classification
|
| 20 |
+
name: Image Classification
|
| 21 |
+
dataset:
|
| 22 |
+
name: AI-Lab-Makerere/beans
|
| 23 |
+
type: AI-Lab-Makerere/beans
|
| 24 |
+
metrics:
|
| 25 |
+
- type: accuracy
|
| 26 |
+
value: 0.9549
|
| 27 |
+
name: Validation Accuracy
|
| 28 |
+
- type: accuracy
|
| 29 |
+
value: 0.8984
|
| 30 |
+
name: Test Accuracy
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
# Bean Leaf Disease Classifier
|
| 34 |
+
|
| 35 |
+
Fine-tuned [MobileNetV3-Small](https://huggingface.co/timm/mobilenetv3_small_100.lamb_in1k) on [AI-Lab-Makerere/beans](https://huggingface.co/datasets/AI-Lab-Makerere/beans).
|
| 36 |
+
|
| 37 |
+
Given a photo of a bean leaf, the model predicts one of:
|
| 38 |
+
|
| 39 |
+
- `angular_leaf_spot`
|
| 40 |
+
- `bean_rust`
|
| 41 |
+
- `healthy`
|
| 42 |
+
|
| 43 |
+
## Metrics
|
| 44 |
+
|
| 45 |
+
| Split | Accuracy | Loss |
|
| 46 |
+
| --- | ---: | ---: |
|
| 47 |
+
| Validation (best checkpoint) | 95.49% | 0.235 |
|
| 48 |
+
| Test | 89.84% | 0.303 |
|
| 49 |
+
|
| 50 |
+
Training ran for 5 epochs on Apple Silicon (MPS). The best checkpoint was restored before export.
|
| 51 |
+
|
| 52 |
+
## Usage
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from transformers import pipeline
|
| 56 |
+
|
| 57 |
+
clf = pipeline("image-classification", model="omaralshareef/beans-image-classifier")
|
| 58 |
+
print(clf("leaf.jpg"))
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Training hyperparameters
|
| 62 |
+
|
| 63 |
+
- learning rate: `5e-5`
|
| 64 |
+
- train batch size: 16
|
| 65 |
+
- eval batch size: 16
|
| 66 |
+
- epochs: 5
|
| 67 |
+
- optimizer: AdamW
|
| 68 |
+
- seed: 42
|
| 69 |
+
|
| 70 |
+
## Training results
|
| 71 |
+
|
| 72 |
+
| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|
| 73 |
+
|:-------------:|:-----:|:----:|:---------------:|:--------:|
|
| 74 |
+
| 0.5874 | 1.0 | 65 | 0.4124 | 0.8346 |
|
| 75 |
+
| 0.4042 | 2.0 | 130 | 0.2352 | 0.9549 |
|
| 76 |
+
| 0.2805 | 3.0 | 195 | 0.1679 | 0.9549 |
|
| 77 |
+
| 0.2367 | 4.0 | 260 | 0.1370 | 0.9549 |
|
| 78 |
+
| 0.1933 | 5.0 | 325 | 0.1394 | 0.9398 |
|
all_results.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 5.0,
|
| 3 |
+
"test_accuracy": 0.8984375,
|
| 4 |
+
"test_loss": 0.3027333617210388,
|
| 5 |
+
"test_runtime": 0.4308,
|
| 6 |
+
"test_samples_per_second": 297.123,
|
| 7 |
+
"test_steps_per_second": 18.57,
|
| 8 |
+
"total_flos": 7101802602639360.0,
|
| 9 |
+
"train_loss": 0.3954382254527165,
|
| 10 |
+
"train_runtime": 40.5848,
|
| 11 |
+
"train_samples_per_second": 127.387,
|
| 12 |
+
"train_steps_per_second": 8.008
|
| 13 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architecture": "mobilenetv3_small_100",
|
| 3 |
+
"architectures": [
|
| 4 |
+
"TimmWrapperForImageClassification"
|
| 5 |
+
],
|
| 6 |
+
"do_pooling": true,
|
| 7 |
+
"dtype": "float32",
|
| 8 |
+
"initializer_range": 0.02,
|
| 9 |
+
"label_names": [
|
| 10 |
+
"angular_leaf_spot",
|
| 11 |
+
"bean_rust",
|
| 12 |
+
"healthy"
|
| 13 |
+
],
|
| 14 |
+
"model_args": null,
|
| 15 |
+
"model_type": "timm_wrapper",
|
| 16 |
+
"num_classes": 3,
|
| 17 |
+
"num_features": 1024,
|
| 18 |
+
"pretrained_cfg": {
|
| 19 |
+
"classifier": "classifier",
|
| 20 |
+
"crop_mode": "center",
|
| 21 |
+
"crop_pct": 0.875,
|
| 22 |
+
"custom_load": false,
|
| 23 |
+
"first_conv": "conv_stem",
|
| 24 |
+
"fixed_input_size": false,
|
| 25 |
+
"input_size": [
|
| 26 |
+
3,
|
| 27 |
+
224,
|
| 28 |
+
224
|
| 29 |
+
],
|
| 30 |
+
"interpolation": "bicubic",
|
| 31 |
+
"mean": [
|
| 32 |
+
0.485,
|
| 33 |
+
0.456,
|
| 34 |
+
0.406
|
| 35 |
+
],
|
| 36 |
+
"pool_size": [
|
| 37 |
+
7,
|
| 38 |
+
7
|
| 39 |
+
],
|
| 40 |
+
"std": [
|
| 41 |
+
0.229,
|
| 42 |
+
0.224,
|
| 43 |
+
0.225
|
| 44 |
+
],
|
| 45 |
+
"tag": "lamb_in1k"
|
| 46 |
+
},
|
| 47 |
+
"problem_type": "single_label_classification",
|
| 48 |
+
"transformers_version": "5.16.1",
|
| 49 |
+
"use_cache": false,
|
| 50 |
+
"id2label": {
|
| 51 |
+
"0": "angular_leaf_spot",
|
| 52 |
+
"1": "bean_rust",
|
| 53 |
+
"2": "healthy"
|
| 54 |
+
},
|
| 55 |
+
"label2id": {
|
| 56 |
+
"angular_leaf_spot": 0,
|
| 57 |
+
"bean_rust": 1,
|
| 58 |
+
"healthy": 2
|
| 59 |
+
},
|
| 60 |
+
"num_labels": 3
|
| 61 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d259d88786c006095ed7428cb434ff56cc412b1d6f4c1ddfc199dd716b454ac8
|
| 3 |
+
size 6154236
|
test_results.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 5.0,
|
| 3 |
+
"test_accuracy": 0.8984375,
|
| 4 |
+
"test_loss": 0.3027333617210388,
|
| 5 |
+
"test_runtime": 0.4308,
|
| 6 |
+
"test_samples_per_second": 297.123,
|
| 7 |
+
"test_steps_per_second": 18.57
|
| 8 |
+
}
|
train_results.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"epoch": 5.0,
|
| 3 |
+
"total_flos": 7101802602639360.0,
|
| 4 |
+
"train_loss": 0.3954382254527165,
|
| 5 |
+
"train_runtime": 40.5848,
|
| 6 |
+
"train_samples_per_second": 127.387,
|
| 7 |
+
"train_steps_per_second": 8.008
|
| 8 |
+
}
|