Keypoint Detection
Transformers
Safetensors
vitpose
Inference Endpoints
nielsr HF staff commited on
Commit
9f36d7a
·
verified ·
1 Parent(s): 5545c37

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +186 -135
README.md CHANGED
@@ -1,77 +1,174 @@
1
  ---
2
  library_name: transformers
3
- tags: []
 
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
  ## Model Details
13
 
14
- ### Model Description
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
 
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
 
50
- [More Information Needed]
51
 
52
- ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
 
56
- [More Information Needed]
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
  ## How to Get Started with the Model
71
 
72
  Use the code below to get started with the model.
73
 
74
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Training Details
77
 
@@ -79,121 +176,75 @@ Use the code below to get started with the model.
79
 
80
  <!-- 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. -->
81
 
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
 
91
 
92
 
93
  #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
 
101
- [More Information Needed]
102
 
103
  ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
 
 
126
 
127
  ### Results
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
-
133
-
134
-
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
-
141
- ## Environmental Impact
142
-
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
-
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
-
153
- ## Technical Specifications [optional]
154
 
155
  ### Model Architecture and Objective
156
 
157
- [More Information Needed]
158
-
159
- ### Compute Infrastructure
160
-
161
- [More Information Needed]
162
 
163
  #### Hardware
164
 
165
- [More Information Needed]
166
-
167
- #### Software
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
-
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
  **BibTeX:**
176
 
177
- [More Information Needed]
178
-
179
- **APA:**
180
-
181
- [More Information Needed]
182
-
183
- ## Glossary [optional]
184
-
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
-
187
- [More Information Needed]
188
-
189
- ## More Information [optional]
190
-
191
- [More Information Needed]
192
-
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
-
197
- ## Model Card Contact
198
-
199
- [More Information Needed]
 
1
  ---
2
  library_name: transformers
3
+ license: apache-2.0
4
+ pipeline_tag: keypoint-detection
5
  ---
6
 
7
+ # Model Card for VitPose
 
 
8
 
9
+ <img src="https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/ZuIwMdomy2_6aJ_JTE1Yd.png" alt="x" width="400"/>
10
 
11
+ 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.
12
 
13
  ## Model Details
14
 
15
+ 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
16
+ 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,
17
+ and transferability of knowledge between models, through a simple baseline model called ViTPose. Specifically, ViTPose employs plain and non-hierarchical vision
18
+ transformers as backbones to extract features for a given person instance and a
19
+ lightweight decoder for pose estimation. It can be scaled up from 100M to 1B
20
+ parameters by taking the advantages of the scalable model capacity and high
21
+ 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
22
+ tasks. We also empirically demonstrate that the knowledge of large ViTPose models
23
+ can be easily transferred to small ones via a simple knowledge token. Experimental
24
+ results show that our basic ViTPose model outperforms representative methods
25
+ on the challenging MS COCO Keypoint Detection benchmark, while the largest
26
+ model sets a new state-of-the-art, i.e., 80.9 AP on the MS COCO test-dev set. The
27
+ code and models are available at https://github.com/ViTAE-Transformer/ViTPose
28
 
29
+ ### Model Description
30
 
31
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
32
 
33
+ - **Developed by:** Yufei Xu, Jing Zhang, Qiming Zhang, Dacheng Tao
34
+ - **Funded by:** ARC FL-170100117 and IH-180100002.
35
+ - **License:** Apache-2.0
36
+ - **Ported to 🤗 Transformers by:** Sangbum Choi and Niels Rogge
 
 
 
 
 
37
 
38
+ ### Model Sources
39
 
40
+ - **Original repository:** https://github.com/ViTAE-Transformer/ViTPose
41
+ - **Paper:** https://arxiv.org/pdf/2204.12484
42
+ - **Demo:** https://huggingface.co/spaces?sort=trending&search=vitpose
43
 
44
  ## Uses
45
 
46
+ The ViTPose model, developed by the ViTAE-Transformer team, is primarily designed for pose estimation tasks. Here are some direct uses of the model:
 
 
 
 
 
 
47
 
48
+ 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.
49
 
50
+ Action Recognition: By analyzing the poses over time, the model can help in recognizing various human actions and activities.
51
 
52
+ Surveillance: In security and surveillance applications, ViTPose can be used to monitor and analyze human behavior in public spaces or private premises.
53
 
54
+ Health and Fitness: The model can be utilized in fitness apps to track and analyze exercise poses, providing feedback on form and technique.
55
 
56
+ Gaming and Animation: ViTPose can be integrated into gaming and animation systems to create more realistic character movements and interactions.
57
 
 
58
 
59
  ## Bias, Risks, and Limitations
60
 
61
+ In this paper, we propose a simple yet effective vision transformer baseline for pose estimation,
62
+ i.e., ViTPose. Despite no elaborate designs in structure, ViTPose obtains SOTA performance
63
+ on the MS COCO dataset. However, the potential of ViTPose is not fully explored with more
64
+ advanced technologies, such as complex decoders or FPN structures, which may further improve the
65
+ performance. Besides, although the ViTPose demonstrates exciting properties such as simplicity,
66
+ scalability, flexibility, and transferability, more research efforts could be made, e.g., exploring the
67
+ prompt-based tuning to demonstrate the flexibility of ViTPose further. In addition, we believe
68
+ ViTPose can also be applied to other pose estimation datasets, e.g., animal pose estimation [47, 9, 45]
69
+ and face keypoint detection [21, 6]. We leave them as the future work.
70
 
71
  ## How to Get Started with the Model
72
 
73
  Use the code below to get started with the model.
74
 
75
+ ```python
76
+ import torch
77
+ import requests
78
+ import numpy as np
79
+
80
+ from PIL import Image
81
+
82
+ from transformers import (
83
+ AutoProcessor,
84
+ RTDetrForObjectDetection,
85
+ VitPoseForPoseEstimation,
86
+ )
87
+
88
+ device = "cuda" if torch.cuda.is_available() else "cpu"
89
+
90
+ url = "http://images.cocodataset.org/val2017/000000000139.jpg"
91
+ image = Image.open(requests.get(url, stream=True).raw)
92
+
93
+ # ------------------------------------------------------------------------
94
+ # Stage 1. Detect humans on the image
95
+ # ------------------------------------------------------------------------
96
+
97
+ # You can choose detector by your choice
98
+ person_image_processor = AutoProcessor.from_pretrained("PekingU/rtdetr_r50vd_coco_o365")
99
+ person_model = RTDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd_coco_o365", device_map=device)
100
+
101
+ inputs = person_image_processor(images=image, return_tensors="pt").to(device)
102
+
103
+ with torch.no_grad():
104
+ outputs = person_model(**inputs)
105
+
106
+ results = person_image_processor.post_process_object_detection(
107
+ outputs, target_sizes=torch.tensor([(image.height, image.width)]), threshold=0.3
108
+ )
109
+ result = results[0] # take first image results
110
+
111
+ # Human label refers 0 index in COCO dataset
112
+ person_boxes = result["boxes"][result["labels"] == 0]
113
+ person_boxes = person_boxes.cpu().numpy()
114
+
115
+ # Convert boxes from VOC (x1, y1, x2, y2) to COCO (x1, y1, w, h) format
116
+ person_boxes[:, 2] = person_boxes[:, 2] - person_boxes[:, 0]
117
+ person_boxes[:, 3] = person_boxes[:, 3] - person_boxes[:, 1]
118
+
119
+ # ------------------------------------------------------------------------
120
+ # Stage 2. Detect keypoints for each person found
121
+ # ------------------------------------------------------------------------
122
+
123
+ image_processor = AutoProcessor.from_pretrained("usyd-community/vitpose-plus-huge")
124
+ model = VitPoseForPoseEstimation.from_pretrained("usyd-community/vitpose-plus-huge", device_map=device)
125
+
126
+ inputs = image_processor(image, boxes=[person_boxes], return_tensors="pt").to(device)
127
+
128
+ with torch.no_grad():
129
+ outputs = model(**inputs)
130
+
131
+ pose_results = image_processor.post_process_pose_estimation(outputs, boxes=[person_boxes], threshold=0.3)
132
+ image_pose_result = pose_results[0] # results for first image
133
+
134
+ for i, person_pose in enumerate(image_pose_result):
135
+ print(f"Person #{i}")
136
+ for keypoint, label, score in zip(
137
+ person_pose["keypoints"], person_pose["labels"], person_pose["scores"]
138
+ ):
139
+ keypoint_name = model.config.id2label[label.item()]
140
+ x, y = keypoint
141
+ print(f" - {keypoint_name}: x={x.item():.2f}, y={y.item():.2f}, score={score.item():.2f}")
142
+
143
+ ```
144
+ Output:
145
+ ```
146
+ Person #0
147
+ - Nose: x=428.25, y=170.88, score=0.98
148
+ - L_Eye: x=428.76, y=168.03, score=0.97
149
+ - R_Eye: x=428.09, y=168.15, score=0.82
150
+ - L_Ear: x=433.28, y=167.72, score=0.95
151
+ - R_Ear: x=440.77, y=166.66, score=0.88
152
+ - L_Shoulder: x=440.52, y=177.60, score=0.92
153
+ - R_Shoulder: x=444.64, y=178.11, score=0.70
154
+ - L_Elbow: x=436.64, y=198.21, score=0.92
155
+ - R_Elbow: x=431.42, y=201.19, score=0.76
156
+ - L_Wrist: x=430.96, y=218.39, score=0.98
157
+ - R_Wrist: x=419.95, y=213.27, score=0.85
158
+ - L_Hip: x=445.33, y=222.93, score=0.77
159
+ - R_Hip: x=451.91, y=222.52, score=0.75
160
+ - L_Knee: x=443.31, y=255.61, score=0.83
161
+ - R_Knee: x=451.42, y=255.03, score=0.84
162
+ - L_Ankle: x=447.76, y=287.33, score=0.68
163
+ - R_Ankle: x=456.78, y=286.08, score=0.83
164
+ Person #1
165
+ - Nose: x=398.23, y=181.74, score=0.89
166
+ - L_Eye: x=398.31, y=179.77, score=0.84
167
+ - R_Eye: x=395.99, y=179.46, score=0.91
168
+ - R_Ear: x=388.95, y=180.24, score=0.86
169
+ - L_Shoulder: x=397.35, y=194.22, score=0.73
170
+ - R_Shoulder: x=384.50, y=190.86, score=0.58
171
+ ```
172
 
173
  ## Training Details
174
 
 
176
 
177
  <!-- 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. -->
178
 
179
+ Dataset details. We use MS COCO [28], AI Challenger [41], MPII [3], and CrowdPose [22] datasets
180
+ for training and evaluation. OCHuman [54] dataset is only involved in the evaluation stage to measure
181
+ the models’ performance in dealing with occluded people. The MS COCO dataset contains 118K
182
+ images and 150K human instances with at most 17 keypoint annotations each instance for training.
183
+ The dataset is under the CC-BY-4.0 license. MPII dataset is under the BSD license and contains
184
+ 15K images and 22K human instances for training. There are at most 16 human keypoints for each
185
+ instance annotated in this dataset. AI Challenger is much bigger and contains over 200K training
186
+ images and 350 human instances, with at most 14 keypoints for each instance annotated. OCHuman
187
+ contains human instances with heavy occlusion and is just used for val and test set, which includes
188
+ 4K images and 8K instances.
189
 
190
 
191
  #### Training Hyperparameters
192
 
193
+ - **Training regime:** ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/Gj6gGcIGO3J5HD2MAB_4C.png)
 
 
194
 
195
+ #### Speeds, Sizes, Times
196
 
197
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/rsCmn48SAvhi8xwJhX8h5.png)
198
 
199
  ## Evaluation
200
 
201
+ OCHuman val and test set. To evaluate the performance of human pose estimation models on the
202
+ human instances with heavy occlusion, we test the ViTPose variants and representative models on
203
+ the OCHuman val and test set with ground truth bounding boxes. We do not adopt extra human
204
+ detectors since not all human instances are annotated in the OCHuman datasets, where the human
205
+ detector will cause a lot of “false positive” bounding boxes and can not reflect the true ability of
206
+ pose estimation models. Specifically, the decoder head of ViTPose corresponding to the MS COCO
207
+ dataset is used, as the keypoint definitions are the same in MS COCO and OCHuman datasets.
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
+ MPII val set. We evaluate the performance of ViTPose and representative models on the MPII val
210
+ set with the ground truth bounding boxes. Following the default settings of MPII, we use PCKh
211
+ as metric for performance evaluation.
212
 
213
  ### Results
214
 
215
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/FcHVFdUmCuT2m0wzB8QSS.png)
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
  ### Model Architecture and Objective
219
 
220
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579e0eaa9e58aec614e9d97/kf3e1ifJkVtOMbISvmMsM.png)
 
 
 
 
221
 
222
  #### Hardware
223
 
224
+ The models are trained on 8 A100 GPUs based on the mmpose codebase
 
 
225
 
 
226
 
227
+ ## Citation
 
 
228
 
229
  **BibTeX:**
230
 
231
+ ```bibtex
232
+ @article{xu2022vitposesimplevisiontransformer,
233
+ title={ViTPose: Simple Vision Transformer Baselines for Human Pose Estimation},
234
+ author={Yufei Xu and Jing Zhang and Qiming Zhang and Dacheng Tao},
235
+ year={2022},
236
+ eprint={2204.12484},
237
+ archivePrefix={arXiv},
238
+ primaryClass={cs.CV},
239
+ url={https://arxiv.org/abs/2204.12484}
240
+ }
241
+ @misc{xu2023vitposevisiontransformergeneric,
242
+ title={ViTPose++: Vision Transformer for Generic Body Pose Estimation},
243
+ author={Yufei Xu and Jing Zhang and Qiming Zhang and Dacheng Tao},
244
+ year={2023},
245
+ eprint={2212.04246},
246
+ archivePrefix={arXiv},
247
+ primaryClass={cs.CV},
248
+ url={https://arxiv.org/abs/2212.04246},
249
+ }
250
+ ```