keras-io / vit-small-ds

huggingface.co
Total runs: 11
24-hour runs: 0
7-day runs: 0
30-day runs: 3
Model's Last Updated: July 05 2024
image-classification

Introduction of vit-small-ds

Model Details of vit-small-ds

Train a Vision Transformer on small datasets

Author: Aritra Roy Gosthipaty

Keras Blog | Colab Notebook

In the academic paper An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale , the authors mention that Vision Transformers (ViT) are data-hungry. Therefore, pretraining a ViT on a large-sized dataset like JFT300M and fine-tuning it on medium-sized datasets (like ImageNet) is the only way to beat state-of-the-art Convolutional Neural Network models.

The self-attention layer of ViT lacks locality inductive bias (the notion that image pixels are locally correlated and that their correlation maps are translation-invariant). This is the reason why ViTs need more data. On the other hand, CNNs look at images through spatial sliding windows, which helps them get better results with smaller datasets.

In the academic paper Vision Transformer for Small-Size Datasets , the authors set out to tackle the problem of locality inductive bias in ViTs.

The main ideas are:

  • Shifted Patch Tokenization
  • Locality Self Attention

Use the pre-trained model

The model is pre-trained on the CIFAR100 dataset with the following hyperparameters:

# DATA
NUM_CLASSES = 100
INPUT_SHAPE = (32, 32, 3)
BUFFER_SIZE = 512
BATCH_SIZE = 256

# AUGMENTATION
IMAGE_SIZE = 72
PATCH_SIZE = 6
NUM_PATCHES = (IMAGE_SIZE // PATCH_SIZE) ** 2

# OPTIMIZER
LEARNING_RATE = 0.001
WEIGHT_DECAY = 0.0001

# TRAINING
EPOCHS = 50

# ARCHITECTURE
LAYER_NORM_EPS = 1e-6
TRANSFORMER_LAYERS = 8
PROJECTION_DIM = 64
NUM_HEADS = 4
TRANSFORMER_UNITS = [
    PROJECTION_DIM * 2,
    PROJECTION_DIM,
]
MLP_HEAD_UNITS = [
    2048,
    1024
]

I have used the AdamW optimizer with cosine decay learning schedule. You can find the entire implementation in the keras blog post.

To use the pretrained model:

loaded_model = from_pretrained_keras("keras-io/vit-small-ds")
_, accuracy, top_5_accuracy = loaded_model.evaluate(test_ds)
print(f"Test accuracy: {round(accuracy * 100, 2)}%")
print(f"Test top 5 accuracy: {round(top_5_accuracy * 100, 2)}%")

For an indepth understanding of the model uploading and downloading process one can refer to this colab notebook .

Important: The data augmentation pipeline is excluded from the model. TensorFlow 2.7 has a weird issue of serializaiton with augmentation pipeline. You can follow this GitHub issue for more updates. To send images through the model, one needs to make use of the tf.data and map API to map the augmentation.

Runs of keras-io vit-small-ds on huggingface.co

11
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
3
30-day runs

More Information About vit-small-ds huggingface.co Model

More vit-small-ds license Visit here:

https://choosealicense.com/licenses/apache-2.0

vit-small-ds huggingface.co

vit-small-ds huggingface.co is an AI model on huggingface.co that provides vit-small-ds's model effect (), which can be used instantly with this keras-io vit-small-ds model. huggingface.co supports a free trial of the vit-small-ds model, and also provides paid use of the vit-small-ds. Support call vit-small-ds model through api, including Node.js, Python, http.

vit-small-ds huggingface.co Url

https://huggingface.co/keras-io/vit-small-ds

keras-io vit-small-ds online free

vit-small-ds huggingface.co is an online trial and call api platform, which integrates vit-small-ds's modeling effects, including api services, and provides a free online trial of vit-small-ds, you can try vit-small-ds online for free by clicking the link below.

keras-io vit-small-ds online free url in huggingface.co:

https://huggingface.co/keras-io/vit-small-ds

vit-small-ds install

vit-small-ds is an open source model from GitHub that offers a free installation service, and any user can find vit-small-ds on GitHub to install. At the same time, huggingface.co provides the effect of vit-small-ds install, users can directly use vit-small-ds installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

vit-small-ds install url in huggingface.co:

https://huggingface.co/keras-io/vit-small-ds

Url of vit-small-ds

vit-small-ds huggingface.co Url

Provider of vit-small-ds huggingface.co

keras-io
ORGANIZATIONS

Other API from keras-io

huggingface.co

Total runs: 35
Run Growth: 27
Growth Rate: 77.14%
Updated:August 15 2022
huggingface.co

Total runs: 34
Run Growth: 12
Growth Rate: 35.29%
Updated:February 18 2022
huggingface.co

Total runs: 16
Run Growth: 11
Growth Rate: 68.75%
Updated:February 23 2022
huggingface.co

Total runs: 15
Run Growth: -13
Growth Rate: -86.67%
Updated:May 23 2025
huggingface.co

Total runs: 15
Run Growth: 7
Growth Rate: 46.67%
Updated:February 06 2022
huggingface.co

Total runs: 14
Run Growth: 6
Growth Rate: 42.86%
Updated:July 05 2024
huggingface.co

Total runs: 14
Run Growth: -8
Growth Rate: -57.14%
Updated:January 13 2022
huggingface.co

Total runs: 12
Run Growth: -4
Growth Rate: -33.33%
Updated:February 04 2022
huggingface.co

Total runs: 11
Run Growth: 3
Growth Rate: 27.27%
Updated:July 05 2024
huggingface.co

Total runs: 10
Run Growth: -7
Growth Rate: -70.00%
Updated:July 05 2024
huggingface.co

Total runs: 10
Run Growth: -1
Growth Rate: -10.00%
Updated:July 05 2024
huggingface.co

Total runs: 9
Run Growth: -9
Growth Rate: -100.00%
Updated:July 05 2024
huggingface.co

Total runs: 9
Run Growth: 1
Growth Rate: 11.11%
Updated:July 05 2024
huggingface.co

Total runs: 7
Run Growth: 3
Growth Rate: 42.86%
Updated:March 01 2022
huggingface.co

Total runs: 7
Run Growth: -4
Growth Rate: -57.14%
Updated:July 05 2024
huggingface.co

Total runs: 6
Run Growth: -14
Growth Rate: -233.33%
Updated:July 05 2024
huggingface.co

Total runs: 4
Run Growth: -2
Growth Rate: -50.00%
Updated:July 05 2024
huggingface.co

Total runs: 3
Run Growth: -5
Growth Rate: -166.67%
Updated:July 05 2024
huggingface.co

Total runs: 2
Run Growth: -4
Growth Rate: -200.00%
Updated:July 05 2024
huggingface.co

Total runs: 2
Run Growth: 1
Growth Rate: 50.00%
Updated:February 16 2022
huggingface.co

Total runs: 1
Run Growth: -1
Growth Rate: -100.00%
Updated:July 05 2024
huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:August 12 2023