File size: 1,373 Bytes
ba3addf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
license: apache-2.0
tags:
- vit
- image-classification
- beans
- transfer-learning
---

# ViT Beans Model

This model was fine-tuned using transfer learning on the ["beans"](https://huggingface.co/datasets/beans) dataset from the Hugging Face Datasets Hub.  
It classifies bean plant leaves into the following categories:

- `LABEL_0`: angular_leaf_spot  
- `LABEL_1`: bean_rust  
- `LABEL_2`: healthy

## Model architecture

The base model is `google/vit-base-patch16-224`.

## Training

Transfer learning was used with a ViT model pre-trained on ImageNet-21k.

## Evaluation

This model was compared to a zero-shot classification using CLIP (`openai/clip-vit-base-patch32`).

### Zero-Shot Results on Oxford Pets (as required):

- **Accuracy**: 0.9993189573287964
- **Precision**: 0.5794700118713081
- **Recall**: 0.10156987264053896
- **Model used**: `openai/clip-vit-base-patch32`

## Example

```python
from transformers import ViTFeatureExtractor, ViTForImageClassification
from PIL import Image
import torch

image = Image.open("example_input.png")
extractor = ViTFeatureExtractor.from_pretrained("LindiSimon/vit-beans-model")
inputs = extractor(images=image, return_tensors="pt")
model = ViTForImageClassification.from_pretrained("LindiSimon/vit-beans-model")
with torch.no_grad():
    logits = model(**inputs).logits
predicted_class = logits.argmax(-1).item()