qubvel-hf HF staff commited on
Commit
95be299
·
verified ·
1 Parent(s): fb5532a

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +243 -0
  2. config.json +141 -0
  3. model.safetensors +3 -0
  4. preprocessor_config.json +22 -0
README.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ language:
5
+ - en
6
+ pipeline_tag: keypoint-detection
7
+ ---
8
+
9
+ # Model Card for VitPose
10
+
11
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/ZuIwMdomy2_6aJ_JTE1Yd.png" alt="x" width="400"/>
12
+
13
+ ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation and ViTPose+: Vision Transformer Foundation Model for Generic Body Pose Estimation. It obtains 81.1 AP on MS COCO Keypoint test-dev set.
14
+
15
+ ## Model Details
16
+
17
+ Although no specific domain knowledge is considered in the design, plain vision transformers have shown excellent performance in visual recognition tasks. However, little effort has been made to reveal the potential of such simple structures for
18
+ pose estimation tasks. In this paper, we show the surprisingly good capabilities of plain vision transformers for pose estimation from various aspects, namely simplicity in model structure, scalability in model size, flexibility in training paradigm,
19
+ and transferability of knowledge between models, through a simple baseline model called ViTPose. Specifically, ViTPose employs plain and non-hierarchical vision
20
+ transformers as backbones to extract features for a given person instance and a
21
+ lightweight decoder for pose estimation. It can be scaled up from 100M to 1B
22
+ parameters by taking the advantages of the scalable model capacity and high
23
+ parallelism of transformers, setting a new Pareto front between throughput and performance. Besides, ViTPose is very flexible regarding the attention type, input resolution, pre-training and finetuning strategy, as well as dealing with multiple pose
24
+ tasks. We also empirically demonstrate that the knowledge of large ViTPose models
25
+ can be easily transferred to small ones via a simple knowledge token. Experimental
26
+ results show that our basic ViTPose model outperforms representative methods
27
+ on the challenging MS COCO Keypoint Detection benchmark, while the largest
28
+ model sets a new state-of-the-art, i.e., 80.9 AP on the MS COCO test-dev set. The
29
+ code and models are available at https://github.com/ViTAE-Transformer/ViTPose
30
+
31
+ ### Model Description
32
+
33
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
34
+
35
+ - **Developed by:** Yufei Xu, Jing Zhang, Qiming Zhang, Dacheng Tao
36
+ - **Funded by:** ARC FL-170100117 and IH-180100002.
37
+ - **License:** Apache-2.0
38
+ - **Ported to 🤗 Transformers by:** Sangbum Choi and Niels Rogge
39
+
40
+ ### Model Sources
41
+
42
+ - **Original repository:** https://github.com/ViTAE-Transformer/ViTPose
43
+ - **Paper:** https://arxiv.org/pdf/2204.12484
44
+ - **Demo:** https://huggingface.co/spaces?sort=trending&search=vitpose
45
+
46
+ ## Uses
47
+
48
+ The ViTPose model, developed by the ViTAE-Transformer team, is primarily designed for pose estimation tasks. Here are some direct uses of the model:
49
+
50
+ Human Pose Estimation: The model can be used to estimate the poses of humans in images or videos. This involves identifying the locations of key body joints such as the head, shoulders, elbows, wrists, hips, knees, and ankles.
51
+
52
+ Action Recognition: By analyzing the poses over time, the model can help in recognizing various human actions and activities.
53
+
54
+ Surveillance: In security and surveillance applications, ViTPose can be used to monitor and analyze human behavior in public spaces or private premises.
55
+
56
+ Health and Fitness: The model can be utilized in fitness apps to track and analyze exercise poses, providing feedback on form and technique.
57
+
58
+ Gaming and Animation: ViTPose can be integrated into gaming and animation systems to create more realistic character movements and interactions.
59
+
60
+
61
+ ## Bias, Risks, and Limitations
62
+
63
+ In this paper, we propose a simple yet effective vision transformer baseline for pose estimation,
64
+ i.e., ViTPose. Despite no elaborate designs in structure, ViTPose obtains SOTA performance
65
+ on the MS COCO dataset. However, the potential of ViTPose is not fully explored with more
66
+ advanced technologies, such as complex decoders or FPN structures, which may further improve the
67
+ performance. Besides, although the ViTPose demonstrates exciting properties such as simplicity,
68
+ scalability, flexibility, and transferability, more research efforts could be made, e.g., exploring the
69
+ prompt-based tuning to demonstrate the flexibility of ViTPose further. In addition, we believe
70
+ ViTPose can also be applied to other pose estimation datasets, e.g., animal pose estimation [47, 9, 45]
71
+ and face keypoint detection [21, 6]. We leave them as the future work.
72
+
73
+ ## How to Get Started with the Model
74
+
75
+ Use the code below to get started with the model.
76
+
77
+ ```python
78
+ import torch
79
+ import requests
80
+ import numpy as np
81
+
82
+ from PIL import Image
83
+
84
+ from transformers import (
85
+ AutoProcessor,
86
+ RTDetrForObjectDetection,
87
+ VitPoseForPoseEstimation,
88
+ )
89
+
90
+ device = "cuda" if torch.cuda.is_available() else "cpu"
91
+
92
+ url = "http://images.cocodataset.org/val2017/000000000139.jpg"
93
+ image = Image.open(requests.get(url, stream=True).raw)
94
+
95
+ # ------------------------------------------------------------------------
96
+ # Stage 1. Detect humans on the image
97
+ # ------------------------------------------------------------------------
98
+
99
+ # You can choose detector by your choice
100
+ person_image_processor = AutoProcessor.from_pretrained("PekingU/rtdetr_r50vd_coco_o365")
101
+ person_model = RTDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd_coco_o365", device_map=device)
102
+
103
+ inputs = person_image_processor(images=image, return_tensors="pt").to(device)
104
+
105
+ with torch.no_grad():
106
+ outputs = person_model(**inputs)
107
+
108
+ results = person_image_processor.post_process_object_detection(
109
+ outputs, target_sizes=torch.tensor([(image.height, image.width)]), threshold=0.3
110
+ )
111
+ result = results[0] # take first image results
112
+
113
+ # Human label refers 0 index in COCO dataset
114
+ person_boxes = result["boxes"][result["labels"] == 0]
115
+ person_boxes = person_boxes.cpu().numpy()
116
+
117
+ # Convert boxes from VOC (x1, y1, x2, y2) to COCO (x1, y1, w, h) format
118
+ person_boxes[:, 2] = person_boxes[:, 2] - person_boxes[:, 0]
119
+ person_boxes[:, 3] = person_boxes[:, 3] - person_boxes[:, 1]
120
+
121
+ # ------------------------------------------------------------------------
122
+ # Stage 2. Detect keypoints for each person found
123
+ # ------------------------------------------------------------------------
124
+
125
+ image_processor = AutoProcessor.from_pretrained("usyd-community/vitpose-base")
126
+ model = VitPoseForPoseEstimation.from_pretrained("usyd-community/vitpose-base", device_map=device)
127
+
128
+ inputs = image_processor(image, boxes=[person_boxes], return_tensors="pt").to(device)
129
+
130
+ with torch.no_grad():
131
+ outputs = model(**inputs)
132
+
133
+ pose_results = image_processor.post_process_pose_estimation(outputs, boxes=[person_boxes], threshold=0.3)
134
+ image_pose_result = pose_results[0] # results for first image
135
+
136
+ for i, person_pose in enumerate(image_pose_result):
137
+ print(f"Person #{i}")
138
+ for keypoint, label, score in zip(
139
+ person_pose["keypoints"], person_pose["labels"], person_pose["scores"]
140
+ ):
141
+ keypoint_name = model.config.id2label[label.item()]
142
+ x, y = keypoint
143
+ print(f" - {keypoint_name}: x={x.item():.2f}, y={y.item():.2f}, score={score.item():.2f}")
144
+
145
+ ```
146
+ Output:
147
+ ```
148
+ Person #0
149
+ - Nose: x=428.25, y=170.88, score=0.98
150
+ - L_Eye: x=428.76, y=168.03, score=0.97
151
+ - R_Eye: x=428.09, y=168.15, score=0.82
152
+ - L_Ear: x=433.28, y=167.72, score=0.95
153
+ - R_Ear: x=440.77, y=166.66, score=0.88
154
+ - L_Shoulder: x=440.52, y=177.60, score=0.92
155
+ - R_Shoulder: x=444.64, y=178.11, score=0.70
156
+ - L_Elbow: x=436.64, y=198.21, score=0.92
157
+ - R_Elbow: x=431.42, y=201.19, score=0.76
158
+ - L_Wrist: x=430.96, y=218.39, score=0.98
159
+ - R_Wrist: x=419.95, y=213.27, score=0.85
160
+ - L_Hip: x=445.33, y=222.93, score=0.77
161
+ - R_Hip: x=451.91, y=222.52, score=0.75
162
+ - L_Knee: x=443.31, y=255.61, score=0.83
163
+ - R_Knee: x=451.42, y=255.03, score=0.84
164
+ - L_Ankle: x=447.76, y=287.33, score=0.68
165
+ - R_Ankle: x=456.78, y=286.08, score=0.83
166
+ Person #1
167
+ - Nose: x=398.23, y=181.74, score=0.89
168
+ - L_Eye: x=398.31, y=179.77, score=0.84
169
+ - R_Eye: x=395.99, y=179.46, score=0.91
170
+ - R_Ear: x=388.95, y=180.24, score=0.86
171
+ - L_Shoulder: x=397.35, y=194.22, score=0.73
172
+ - R_Shoulder: x=384.50, y=190.86, score=0.58
173
+ ```
174
+
175
+ ## Training Details
176
+
177
+ ### Training Data
178
+
179
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
180
+
181
+ Dataset details. We use MS COCO [28], AI Challenger [41], MPII [3], and CrowdPose [22] datasets
182
+ for training and evaluation. OCHuman [54] dataset is only involved in the evaluation stage to measure
183
+ the models’ performance in dealing with occluded people. The MS COCO dataset contains 118K
184
+ images and 150K human instances with at most 17 keypoint annotations each instance for training.
185
+ The dataset is under the CC-BY-4.0 license. MPII dataset is under the BSD license and contains
186
+ 15K images and 22K human instances for training. There are at most 16 human keypoints for each
187
+ instance annotated in this dataset. AI Challenger is much bigger and contains over 200K training
188
+ images and 350 human instances, with at most 14 keypoints for each instance annotated. OCHuman
189
+ contains human instances with heavy occlusion and is just used for val and test set, which includes
190
+ 4K images and 8K instances.
191
+
192
+
193
+ #### Training Hyperparameters
194
+
195
+ - **Training regime:** ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/Gj6gGcIGO3J5HD2MAB_4C.png)
196
+
197
+ #### Speeds, Sizes, Times
198
+
199
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/rsCmn48SAvhi8xwJhX8h5.png)
200
+
201
+ ## Evaluation
202
+
203
+ OCHuman val and test set. To evaluate the performance of human pose estimation models on the
204
+ human instances with heavy occlusion, we test the ViTPose variants and representative models on
205
+ the OCHuman val and test set with ground truth bounding boxes. We do not adopt extra human
206
+ detectors since not all human instances are annotated in the OCHuman datasets, where the human
207
+ detector will cause a lot of “false positive” bounding boxes and can not reflect the true ability of
208
+ pose estimation models. Specifically, the decoder head of ViTPose corresponding to the MS COCO
209
+ dataset is used, as the keypoint definitions are the same in MS COCO and OCHuman datasets.
210
+
211
+ MPII val set. We evaluate the performance of ViTPose and representative models on the MPII val
212
+ set with the ground truth bounding boxes. Following the default settings of MPII, we use PCKh
213
+ as metric for performance evaluation.
214
+
215
+ ### Results
216
+
217
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/FcHVFdUmCuT2m0wzB8QSS.png)
218
+
219
+
220
+ ### Model Architecture and Objective
221
+
222
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/kf3e1ifJkVtOMbISvmMsM.png)
223
+
224
+ #### Hardware
225
+
226
+ The models are trained on 8 A100 GPUs based on the mmpose codebase
227
+
228
+
229
+ ## Citation
230
+
231
+ **BibTeX:**
232
+
233
+ ```bibtex
234
+ @article{xu2022vitposesimplevisiontransformer,
235
+ title={ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation},
236
+ author={Yufei Xu and Jing Zhang and Qiming Zhang and Dacheng Tao},
237
+ year={2022},
238
+ eprint={2204.12484},
239
+ archivePrefix={arXiv},
240
+ primaryClass={cs.CV},
241
+ url={https://arxiv.org/abs/2204.12484}
242
+ }
243
+ ```
config.json ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "VitPoseForPoseEstimation"
4
+ ],
5
+ "backbone": null,
6
+ "backbone_config": {
7
+ "model_type": "vitpose_backbone",
8
+ "out_features": [
9
+ "stage12"
10
+ ],
11
+ "out_indices": [
12
+ 12
13
+ ],
14
+ "part_features": 0
15
+ },
16
+ "backbone_kwargs": null,
17
+ "edges": [
18
+ [
19
+ 15,
20
+ 13
21
+ ],
22
+ [
23
+ 13,
24
+ 11
25
+ ],
26
+ [
27
+ 16,
28
+ 14
29
+ ],
30
+ [
31
+ 14,
32
+ 12
33
+ ],
34
+ [
35
+ 11,
36
+ 12
37
+ ],
38
+ [
39
+ 5,
40
+ 11
41
+ ],
42
+ [
43
+ 6,
44
+ 12
45
+ ],
46
+ [
47
+ 5,
48
+ 6
49
+ ],
50
+ [
51
+ 5,
52
+ 7
53
+ ],
54
+ [
55
+ 6,
56
+ 8
57
+ ],
58
+ [
59
+ 7,
60
+ 9
61
+ ],
62
+ [
63
+ 8,
64
+ 10
65
+ ],
66
+ [
67
+ 1,
68
+ 2
69
+ ],
70
+ [
71
+ 0,
72
+ 1
73
+ ],
74
+ [
75
+ 0,
76
+ 2
77
+ ],
78
+ [
79
+ 1,
80
+ 3
81
+ ],
82
+ [
83
+ 2,
84
+ 4
85
+ ],
86
+ [
87
+ 3,
88
+ 5
89
+ ],
90
+ [
91
+ 4,
92
+ 6
93
+ ]
94
+ ],
95
+ "id2label": {
96
+ "0": "Nose",
97
+ "1": "L_Eye",
98
+ "2": "R_Eye",
99
+ "3": "L_Ear",
100
+ "4": "R_Ear",
101
+ "5": "L_Shoulder",
102
+ "6": "R_Shoulder",
103
+ "7": "L_Elbow",
104
+ "8": "R_Elbow",
105
+ "9": "L_Wrist",
106
+ "10": "R_Wrist",
107
+ "11": "L_Hip",
108
+ "12": "R_Hip",
109
+ "13": "L_Knee",
110
+ "14": "R_Knee",
111
+ "15": "L_Ankle",
112
+ "16": "R_Ankle"
113
+ },
114
+ "initializer_range": 0.02,
115
+ "label2id": {
116
+ "L_Ankle": 15,
117
+ "L_Ear": 3,
118
+ "L_Elbow": 7,
119
+ "L_Eye": 1,
120
+ "L_Hip": 11,
121
+ "L_Knee": 13,
122
+ "L_Shoulder": 5,
123
+ "L_Wrist": 9,
124
+ "Nose": 0,
125
+ "R_Ankle": 16,
126
+ "R_Ear": 4,
127
+ "R_Elbow": 8,
128
+ "R_Eye": 2,
129
+ "R_Hip": 12,
130
+ "R_Knee": 14,
131
+ "R_Shoulder": 6,
132
+ "R_Wrist": 10
133
+ },
134
+ "model_type": "vitpose",
135
+ "scale_factor": 4,
136
+ "torch_dtype": "float32",
137
+ "transformers_version": "4.47.0.dev0",
138
+ "use_pretrained_backbone": false,
139
+ "use_simple_decoder": false,
140
+ "use_timm_backbone": false
141
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd9a4e6cefc33c51ddcc32dd509fc4114b5845256463a69a10ea2dfde402b2f8
3
+ size 360007012
preprocessor_config.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_affine_transform": true,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "image_mean": [
6
+ 0.485,
7
+ 0.456,
8
+ 0.406
9
+ ],
10
+ "image_processor_type": "VitPoseImageProcessor",
11
+ "image_std": [
12
+ 0.229,
13
+ 0.224,
14
+ 0.225
15
+ ],
16
+ "normalize_factor": 200.0,
17
+ "rescale_factor": 0.00392156862745098,
18
+ "size": {
19
+ "height": 256,
20
+ "width": 192
21
+ }
22
+ }