nielsr HF staff commited on
Commit
c42fd79
·
1 Parent(s): 2b979ac

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +88 -0
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ - image-classification
6
+ datasets:
7
+ - imagenet-1k
8
+ widget:
9
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/tiger.jpg
10
+ example_title: Tiger
11
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg
12
+ example_title: Teapot
13
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/palace.jpg
14
+ example_title: Palace
15
+ ---
16
+
17
+ # Swin Transformer v2 (tiny-sized model)
18
+
19
+ 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](https://arxiv.org/abs/2111.09883) by Liu et al. and first released in [this repository](https://github.com/microsoft/Swin-Transformer).
20
+
21
+ 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.
22
+
23
+ ## Model description
24
+
25
+ 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.
26
+
27
+ ![model image](https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/swin_transformer_architecture.png)
28
+
29
+ [Source](https://paperswithcode.com/method/swin-transformer)
30
+
31
+ ## Intended uses & limitations
32
+
33
+ You can use the raw model for image classification. See the [model hub](https://huggingface.co/models?search=swin) to look for
34
+ fine-tuned versions on a task that interests you.
35
+
36
+ ### How to use
37
+
38
+ Here is how to use this model to classify an image of the COCO 2017 dataset into one of the 1,000 ImageNet classes:
39
+
40
+ ```python
41
+ from transformers import AutoFeatureExtractor, SwinForImageClassification
42
+ from PIL import Image
43
+ import requests
44
+
45
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
46
+ image = Image.open(requests.get(url, stream=True).raw)
47
+
48
+ feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/swinv2-tiny-patch4-window8-256")
49
+ model = SwinForImageClassification.from_pretrained("microsoft/swinv2-tiny-patch4-window8-256")
50
+
51
+ inputs = feature_extractor(images=image, return_tensors="pt")
52
+ outputs = model(**inputs)
53
+ logits = outputs.logits
54
+ # model predicts one of the 1000 ImageNet classes
55
+ predicted_class_idx = logits.argmax(-1).item()
56
+ print("Predicted class:", model.config.id2label[predicted_class_idx])
57
+ ```
58
+
59
+ For more code examples, we refer to the [documentation](https://huggingface.co/transformers/model_doc/swin.html#).
60
+
61
+ ### BibTeX entry and citation info
62
+
63
+ ```bibtex
64
+ @article{DBLP:journals/corr/abs-2111-09883,
65
+ author = {Ze Liu and
66
+ Han Hu and
67
+ Yutong Lin and
68
+ Zhuliang Yao and
69
+ Zhenda Xie and
70
+ Yixuan Wei and
71
+ Jia Ning and
72
+ Yue Cao and
73
+ Zheng Zhang and
74
+ Li Dong and
75
+ Furu Wei and
76
+ Baining Guo},
77
+ title = {Swin Transformer {V2:} Scaling Up Capacity and Resolution},
78
+ journal = {CoRR},
79
+ volume = {abs/2111.09883},
80
+ year = {2021},
81
+ url = {https://arxiv.org/abs/2111.09883},
82
+ eprinttype = {arXiv},
83
+ eprint = {2111.09883},
84
+ timestamp = {Thu, 02 Dec 2021 15:54:22 +0100},
85
+ biburl = {https://dblp.org/rec/journals/corr/abs-2111-09883.bib},
86
+ bibsource = {dblp computer science bibliography, https://dblp.org}
87
+ }
88
+ ```