
# Vision Transformer fine-tuned on `Matthijs/snacks` dataset

Vision Transformer (ViT) model pre-trained on ImageNet-21k and fine-tuned on [**Matthijs/snacks**](https://huggingface.co/datasets/Matthijs/snacks) for 5 epochs using various data augmentation transformations from `torchvision`.

The model achieves a **94.97%** and **94.43%** accuracy on the validation and test set, respectively.

## Data augmentation pipeline

The code block below shows the various transformations applied during pre-processing to augment the original dataset.
The augmented images where generated on-the-fly with the `set_transform` method.

```python
from transformers import ViTFeatureExtractor
from torchvision.transforms import (
    Compose,
    Normalize,
    Resize,
    RandomResizedCrop,
    RandomHorizontalFlip,
    RandomAdjustSharpness,
    ToTensor
)

checkpoint = 'google/vit-base-patch16-224-in21k'
feature_extractor = ViTFeatureExtractor.from_pretrained(checkpoint)

# transformations on the training set
train_aug_transforms = Compose([
    RandomResizedCrop(size=feature_extractor.size),
    RandomHorizontalFlip(p=0.5),
    RandomAdjustSharpness(sharpness_factor=5, p=0.5),
    ToTensor(),
    Normalize(mean=feature_extractor.image_mean, std=feature_extractor.image_std),
])

# transformations on the validation/test set
valid_aug_transforms = Compose([
    Resize(size=(feature_extractor.size, feature_extractor.size)),
    ToTensor(),
    Normalize(mean=feature_extractor.image_mean, std=feature_extractor.image_std),
])
```
{"datasets": ["Matthijs/snacks"], "model-index": [{"name": "matteopilotto/vit-base-patch16-224-in21k-snacks", "results": [{"task": {"type": "image-classification", "name": "Image Classification"}, "dataset": {"name": "Matthijs/snacks", "type": "Matthijs/snacks", "config": "default", "split": "test"}, "metrics": [{"type": "accuracy", "value": 0.8928571428571429, "name": "Accuracy", "verified": true}, {"type": "precision", "value": 0.8990033704680036, "name": "Precision Macro", "verified": true}, {"type": "precision", "value": 0.8928571428571429, "name": "Precision Micro", "verified": true}, {"type": "precision", "value": 0.8972398709051788, "name": "Precision Weighted", "verified": true}, {"type": "recall", "value": 0.8914608843537415, "name": "Recall Macro", "verified": true}, {"type": "recall", "value": 0.8928571428571429, "name": "Recall Micro", "verified": true}, {"type": "recall", "value": 0.8928571428571429, "name": "Recall Weighted", "verified": true}, {"type": "f1", "value": 0.892544821273258, "name": "F1 Macro", "verified": true}, {"type": "f1", "value": 0.8928571428571429, "name": "F1 Micro", "verified": true}, {"type": "f1", "value": 0.8924168605019522, "name": "F1 Weighted", "verified": true}, {"type": "loss", "value": 0.479541540145874, "name": "loss", "verified": true}]}]}]}
transformers pytorch vit image-classification dataset:Matthijs/snacks model-index autotrain_compatible endpoints_compatible region:us
TAGS
#transformers #pytorch #vit #image-classification #dataset-Matthijs/snacks #model-index #autotrain_compatible #endpoints_compatible #region-us 


# Vision Transformer fine-tuned on 'Matthijs/snacks' dataset

Vision Transformer (ViT) model pre-trained on ImageNet-21k and fine-tuned on Matthijs/snacks for 5 epochs using various data augmentation transformations from 'torchvision'.

The model achieves a 94.97% and 94.43% accuracy on the validation and test set, respectively.

## Data augmentation pipeline

The code block below shows the various transformations applied during pre-processing to augment the original dataset.
The augmented images where generated on-the-fly with the 'set_transform' method.


# Vision Transformer fine-tuned on 'Matthijs/snacks' dataset

Vision Transformer (ViT) model pre-trained on ImageNet-21k and fine-tuned on Matthijs/snacks for 5 epochs using various data augmentation transformations from 'torchvision'.

The model achieves a 94.97% and 94.43% accuracy on the validation and test set, respectively. ## Data augmentation pipeline

The code block below shows the various transformations applied during pre-processing to augment the original dataset.
The augmented images where generated on-the-fly with the 'set_transform' method.
TAGS
#transformers #pytorch #vit #image-classification #dataset-Matthijs/snacks #model-index #autotrain_compatible #endpoints_compatible #region-us 
 # Vision Transformer fine-tuned on 'Matthijs/snacks' dataset

Vision Transformer (ViT) model pre-trained on ImageNet-21k and fine-tuned on Matthijs/snacks for 5 epochs using various data augmentation transformations from 'torchvision'.

The model achieves a 94.97% and 94.43% accuracy on the validation and test set, respectively. ## Data augmentation pipeline

The code block below shows the various transformations applied during pre-processing to augment the original dataset.
The augmented images where generated on-the-fly with the 'set_transform' method.
passage: TAGS
#transformers #pytorch #vit #image-classification #dataset-Matthijs/snacks #model-index #autotrain_compatible #endpoints_compatible #region-us 
# Vision Transformer fine-tuned on 'Matthijs/snacks' dataset

Vision Transformer (ViT) model pre-trained on ImageNet-21k and fine-tuned on Matthijs/snacks for 5 epochs using various data augmentation transformations from 'torchvision'.

The model achieves a 94.97% and 94.43% accuracy on the validation and test set, respectively.## Data augmentation pipeline

The code block below shows the various transformations applied during pre-processing to augment the original dataset.
The augmented images where generated on-the-fly with the 'set_transform' method.