hf_mirrors/deit3_small_patch16_224.fb_in22k_ft_in1k
Model Introduction
Files & versions
Analysis

Model card for deit3_small_patch16_224.fb_in22k_ft_in1k

A DeiT-III image classification model. Pretrained on ImageNet-22k and fine-tuned on ImageNet-1k by paper authors.

Model Details

  • Model Type: Image classification / feature backbone
  • Model Stats:
    • Params (M): 22.1
    • GMACs: 4.6
    • Activations (M): 11.9
    • Image size: 224 x 224
  • Papers:
    • DeiT III: Revenge of the ViT: https://arxiv.org/abs/2204.07118
  • Original: https://github.com/facebookresearch/deit
  • Dataset: ImageNet-1k
  • Pretrain Dataset: ImageNet-22k

Model Usage

Image Classification

import torch 
import timm
import argparse
from PIL import Image
from openmind import is_torch_npu_available

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to model",
        default=None,
    )
    args = parser.parse_args()
    return args

if __name__ == "__main__":
    args = parse_args()
    model_path = args.model_name_or_path
    img_path = model_path + '/img/beignets-task-guide.png'
    img = Image.open(img_path)

    if is_torch_npu_available():
        device = "npu:0"
    else:
        device = "cpu"

    model_name = 'deit3_small_patch16_224.fb_in22k_ft_in1k'
    checkpoint_path=model_path + '/pytorch_model.bin'
    model = timm.create_model(model_name, pretrained=False, checkpoint_path=checkpoint_path).to(device)
    model = model.eval()

    # get model specific transforms (normalization, resize)
    data_config = timm.data.resolve_model_data_config(model)
    transforms = timm.data.create_transform(**data_config, is_training=False)

    output = model(transforms(img).unsqueeze(0).to(device))  # unsqueeze single image into batch of 1
    img.close()

    top5_probabilities, top5_class_indices = torch.topk(output.softmax(dim=1) * 100, k=5)
    print(top5_probabilities)
    print(top5_class_indices)

Model Comparison

Explore the dataset and runtime metrics of this model in timm model results.

Citation

@article{Touvron2022DeiTIR,
  title={DeiT III: Revenge of the ViT},
  author={Hugo Touvron and Matthieu Cord and Herve Jegou},
  journal={arXiv preprint arXiv:2204.07118},
  year={2022},
}
@misc{rw2019timm,
  author = {Ross Wightman},
  title = {PyTorch Image Models},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  doi = {10.5281/zenodo.4414861},
  howpublished = {\url{https://github.com/huggingface/pytorch-image-models}}
}