SAVRN
Search Contact SAVRN

Open-weight model · Image classification

swinv2-tiny-patch4-window16-256

by Microsoft microsoft/swinv2-tiny-patch4-window16-256

Swin Transformer v2 model pre-trained on ImageNet-1k at resolution 256x256. It was introduced in the paper Swin Transformer V2: Scaling Up Capacity and Resolution by Liu et al. and first released in this repository.

Parameters
Context
Weights113.5 MB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads413.1k

Model Card

By Microsoft, published under apache-2.0, revision f4d3075206f2.

Swin Transformer v2 model pre-trained on ImageNet-1k at resolution 256x256. It was introduced in the paper Swin Transformer V2: Scaling Up Capacity and Resolution by Liu et al. and first released in this repository. Disclaimer: The team releasing Swin Transformer v2 did not write a model card for this model so this model card has been written by the Hugging Face team. The Swin Transformer is a type of Vision Transformer. It builds hierarchical feature maps by merging image patches (shown in gray) in deeper layers and has linear computation complexity to input image size due to computation of self-attention only within each local window (shown in red). It can thus serve as a general-purpose…

Read Microsoft's full model card

Swin Transformer v2 (tiny-sized model)

Swin Transformer v2 model pre-trained on ImageNet-1k at resolution 256x256. It was introduced in the paper Swin Transformer V2: Scaling Up Capacity and Resolution by Liu et al. and first released in this repository.

Disclaimer: The team releasing Swin Transformer v2 did not write a model card for this model so this model card has been written by the Hugging Face team.

Model description

The Swin Transformer is a type of Vision Transformer. It builds hierarchical feature maps by merging image patches (shown in gray) in deeper layers and has linear computation complexity to input image size due to computation of self-attention only within each local window (shown in red). It can thus serve as a general-purpose backbone for both image classification and dense recognition tasks. In contrast, previous vision Transformers produce feature maps of a single low resolution and have quadratic computation complexity to input image size due to computation of self-attention globally.

Swin Transformer v2 adds 3 main improvements: 1) a residual-post-norm method combined with cosine attention to improve training stability; 2) a log-spaced continuous position bias method to effectively transfer models pre-trained using low-resolution images to downstream tasks with high-resolution inputs; 3) a self-supervised pre-training method, SimMIM, to reduce the needs of vast labeled images.

Source

Intended uses & limitations

You can use the raw model for image classification. See the model hub to look for fine-tuned versions on a task that interests you.

How to use

Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:

from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import requests

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)

processor = AutoImageProcessor.from_pretrained("microsoft/swinv2-tiny-patch4-window16-256")
model = AutoModelForImageClassification.from_pretrained("microsoft/swinv2-tiny-patch4-window16-256")

inputs = processor(images=image, return_tensors="pt")
outputs = model(**inputs)
logits = outputs.logits
# model predicts one of the 1000 ImageNet classes
predicted_class_idx = logits.argmax(-1).item()
print("Predicted class:", model.config.id2label[predicted_class_idx])

For more code examples, we refer to the documentation.

BibTeX entry and citation info

@article{DBLP:journals/corr/abs-2111-09883,
  author    = {Ze Liu and
               Han Hu and
               Yutong Lin and
               Zhuliang Yao and
               Zhenda Xie and
               Yixuan Wei and
               Jia Ning and
               Yue Cao and
               Zheng Zhang and
               Li Dong and
               Furu Wei and
               Baining Guo},
  title     = {Swin Transformer {V2:} Scaling Up Capacity and Resolution},
  journal   = {CoRR},
  volume    = {abs/2111.09883},
  year      = {2021},
  url       = {https://arxiv.org/abs/2111.09883},
  eprinttype = {arXiv},
  eprint    = {2111.09883},
  timestamp = {Thu, 02 Dec 2021 15:54:22 +0100},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2111-09883.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

Configuration

Architecture
Swinv2ForImageClassification
Hidden size
768
Stored precision
float32
Model type
swinv2

Identity and Version

Repository
microsoft/swinv2-tiny-patch4-window16-256
Publisher
Microsoft
Task
Image classification
Modality
Image
Library
transformers
Parameters
Not stated by the source
Languages
Not stated by the source
Revision
f4d3075206f2ad5eda586c30d6b4d0500f312421
First published
2022-06-14
Last updated
2022-12-10

Files and Weights

5 files, 113.5 MB in total. The weights are 1 file totalling 113.5 MB in bin.

Weights1 file · 113.5 MB
Configuration2 files · 70.1 KB
Documentation1 file · 4.2 KB
Repository1 file · 1.2 KB
Every file
FileTypeSizeSHA-256
pytorch_model.binWeights113.5 MB 6f38b148e61a
config.jsonConfiguration69.9 KB
preprocessor_config.jsonConfiguration240 B
README.mdDocumentation4.2 KB
.gitattributesRepository1.2 KB

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
113.5 MB
Download from Microsoft

Released by Microsoft through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published113.5 MB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About swinv2-tiny-patch4-window16-256

Can I use swinv2-tiny-patch4-window16-256 commercially?

Yes. swinv2-tiny-patch4-window16-256 is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

Similar Models

Model · Image classification

AI-image-detector

Matthew Maybe

NOTE: Unless you are trying to detect imagery generated using older models such as VQGAN+CLIP, please use the updated version of this detector instead. This model is a proof-of-concept demonstration of using a ViT model to predict whether an artistic image was generated using AI. It was created in October 2022, and as such, the training data did not include any samples generated by Midjourney 5, SDXL, or DALLE-3. It still may be able to correctly identify samples from these more recent models due to being trained on outputs of their predecessors. Furthermore the intended scope of this tool is artistic images; that is to say, it is not a deepfake photo detector, and general computer imagery…

Open weights cc-by-4.0 transformers

Model · Image classification

traffic-sign-adverse-weather

Yy

Official model checkpoints for the solution in the Traffic Sign Recognition under Adverse Weather Competition. See classes.txt for the 25 traffic sign classes. For inference scripts, training code, and in-depth engineering retrospective, visit the GitHub Repository.

Open weights mit timm

Model · Image classification

tinyvit-5m-int8-imagenet

Core Epoch

TinyViT-5M (timm/tinyvit5m224.distin22kftin1k, Apache-2.0) quantized to INT8 with Kenosis — 128-image calibration, no retraining. 80.53% top-1 from a 9.2 MB single file, on ONNX Runtime or OpenVINO, CPU or GPU, no accelerator required. ImageNet-1K validation, 49,872 images (disjoint from the 128 calibration images). Measured on a CPU with AVX-VNNI; on CPUs without VNNI this model's INT8 top-1 sits ~0.9 below FP32 rather than 0.34. Input 1x3x224x224, RGB, /255, ImageNet mean/std. Output logits [1,1000], sorted-synset order. runclassify.py / evalimagenet.py reproduce the demo and table. tinyvit5m224int8kenosis.onnx (9,228,567 B) — SHA-256…

Open weights apache-2.0 onnx

Model · Image classification

mmfm-breast-imaging-checkpoints

NFadlallah

ResNet-18 binary (benign vs. malignant) classification checkpoints, trained per-dataset on eight public breast-imaging sources spanning ultrasound, Full write-up, methodology, and comparison to each source paper's own These are single-modality baselines, not the 3-branch fusion model. Each checkpoint is models.SingleBackboneClassifier (one ResNet-18 backbone, ImageNet-pretrained, first conv adapted for non-RGB inputs where applicable) — see models/backbone.py / training/train.py in the repo for the loading code. For the 5-fold datasets, this is one fold's checkpoint, not an ensemble or the averaged model — reported accuracy is the 5-fold mean from the full report for context, not this…

Open weights cc-by-4.0