nielsr HF staff commited on
Commit
f5c5a23
1 Parent(s): e6cbdec

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -0
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - vision
5
+ - image-classification
6
+ datasets:
7
+ - imagenet-21k
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 (large-sized model)
18
+
19
+ Swin Transformer model pre-trained on ImageNet-21k (14 million images, 21,843 classes) at resolution 384x384. It was introduced in the paper [Swin Transformer: Hierarchical Vision Transformer using Shifted Windows](https://arxiv.org/abs/2103.14030) by Liu et al. and first released in [this repository](https://github.com/microsoft/Swin-Transformer).
20
+
21
+ Disclaimer: The team releasing Swin Transformer 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/swin-tiny-patch4-window7-224")
49
+ model = SwinForImageClassification.from_pretrained("microsoft/swin-tiny-patch4-window7-224")
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-2103-14030,
65
+ author = {Ze Liu and
66
+ Yutong Lin and
67
+ Yue Cao and
68
+ Han Hu and
69
+ Yixuan Wei and
70
+ Zheng Zhang and
71
+ Stephen Lin and
72
+ Baining Guo},
73
+ title = {Swin Transformer: Hierarchical Vision Transformer using Shifted Windows},
74
+ journal = {CoRR},
75
+ volume = {abs/2103.14030},
76
+ year = {2021},
77
+ url = {https://arxiv.org/abs/2103.14030},
78
+ eprinttype = {arXiv},
79
+ eprint = {2103.14030},
80
+ timestamp = {Thu, 08 Apr 2021 07:53:26 +0200},
81
+ biburl = {https://dblp.org/rec/journals/corr/abs-2103-14030.bib},
82
+ bibsource = {dblp computer science bibliography, https://dblp.org}
83
+ }
84
+ ```