Initial snapshot: hand motion pipeline (Dyn-HaMR + dex-retargeting + SPIDER)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 14:13:49 +08:00
commit 7e4ef6f98b
7002 changed files with 1452249 additions and 0 deletions
@@ -0,0 +1 @@
# Copyright (c) OpenMMLab. All rights reserved.
@@ -0,0 +1,477 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "face",
"keypoints": [],
"skeleton": []
}
],
"images": [
{
"id": 197,
"file_name": "indoor_029.png",
"height": 845,
"width": 960
},
{
"id": 565,
"file_name": "indoor_020.png",
"height": 768,
"width": 726
}
],
"annotations": [
{
"image_id": 197,
"id": 197,
"keypoints": [
268.0,
398.882,
1,
285.21,
470.547,
1,
303.994,
540.61,
1,
332.8,
611.274,
1,
376.829,
659.993,
1,
428.904,
701.529,
1,
493.765,
726.48,
1,
566.941,
741.209,
1,
615.5,
733.248,
1,
660.628,
711.888,
1,
693.575,
666.8610000000001,
1,
707.9989999999998,
602.151,
1,
710.0010000000002,
540.7090000000002,
1,
710.702,
482.586,
1,
705.705,
430.128,
1,
698.574,
376.051,
1,
687.17,
325.797,
1,
335.426,
370.217,
1,
352.01,
339.706,
1,
400.98800000000006,
317.285,
1,
449.164,
310.243,
1,
493.34,
314.9120000000001,
1,
548.874,
304.259,
1,
572.625,
284.111,
1,
609.946,
265.0,
1,
650.465,
269.886,
1,
672.5269999999998,
287.694,
1,
531.823,
349.5019999999999,
1,
543.992,
387.47,
1,
557.0459999999998,
425.639,
1,
570.283,
465.089,
1,
521.077,
509.142,
1,
543.5830000000002,
511.647,
1,
569.154,
510.935,
1,
589.758,
504.75,
1,
607.544,
494.626,
1,
372.146,
389.57,
1,
399.878,
370.642,
1,
431.883,
359.838,
1,
465.725,
371.503,
1,
437.99,
384.279,
1,
406.296,
393.511,
1,
571.331,
349.968,
1,
599.158,
324.208,
1,
630.259,
318.067,
1,
656.076,
327.782,
1,
635.32,
340.57199999999995,
1,
607.295,
346.391,
1,
479.066,
604.947,
1,
519.818,
577.8,
1,
547.948,
566.137,
1,
572.52,
568.232,
1,
594.948,
556.586,
1,
621.335,
562.737,
1,
653.6,
571.3580000000002,
1,
623.72,
596.32,
1,
606.549,
604.577,
1,
578.673,
606.798,
1,
554.4830000000002,
609.318,
1,
525.276,
609.497,
1,
494.741,
601.097,
1,
549.953,
585.0319999999998,
1,
573.969,
584.442,
1,
599.372,
575.65,
1,
640.35,
573.788,
1,
599.372,
575.65,
1,
573.969,
584.442,
1,
549.953,
585.0319999999998,
1
],
"num_keypoints": 68,
"bbox": [
223.7298,
217.3791,
531.2424000000001,
571.4508
],
"iscrowd": 0,
"area": 303578.89447392005,
"category_id": 1,
"center": [
489.5,
503.5
],
"scale": 2.385
},
{
"image_id": 565,
"id": 565,
"keypoints": [
70.0,
292.332,
1,
85.978,
359.108,
1,
106.67,
442.2480000000001,
1,
132.174,
524.227,
1,
170.87900000000005,
587.591,
1,
220.419,
640.665,
1,
275.329,
686.7510000000002,
1,
345.149,
712.11,
1,
415.072,
700.013,
1,
455.739,
681.039,
1,
491.441,
646.908,
1,
522.22,
601.67,
1,
545.278,
556.815,
1,
570.101,
495.899,
1,
588.304,
413.976,
1,
595.136,
343.6280000000001,
1,
590.716,
280.211,
1,
118.878,
305.308,
1,
158.248,
281.872,
1,
202.699,
284.469,
1,
246.669,
294.941,
1,
294.485,
316.657,
1,
387.621,
306.5490000000001,
1,
437.315,
274.369,
1,
483.305,
246.679,
1,
531.807,
219.0,
1,
574.753,
226.314,
1,
350.492,
372.72,
1,
354.8180000000001,
422.627,
1,
358.916,
467.076,
1,
364.204,
508.283,
1,
303.536,
510.181,
1,
332.565,
524.2280000000002,
1,
361.282,
537.337,
1,
385.853,
530.722,
1,
410.586,
512.7090000000002,
1,
171.577,
361.551,
1,
203.614,
344.588,
1,
246.448,
345.9380000000001,
1,
288.441,
368.74300000000005,
1,
246.677,
376.513,
1,
202.377,
382.091,
1,
411.996,
361.712,
1,
445.408,
332.093,
1,
485.232,
319.01,
1,
518.47,
328.7990000000001,
1,
492.908,
360.212,
1,
447.886,
364.719,
1,
256.704,
564.955,
1,
306.255,
569.807,
1,
333.68,
566.9019999999998,
1,
360.689,
571.737,
1,
391.088,
565.381,
1,
426.92,
559.18,
1,
476.772,
545.14,
1,
429.904,
606.391,
1,
398.257,
628.13,
1,
361.86,
635.736,
1,
332.214,
631.4259999999998,
1,
300.871,
615.508,
1,
271.028,
570.685,
1,
333.764,
594.513,
1,
360.897,
597.525,
1,
391.282,
594.612,
1,
467.095,
554.192,
1,
391.282,
594.612,
1,
360.897,
597.525,
1,
333.764,
594.513,
1
],
"num_keypoints": 68,
"bbox": [
17.486400000000003,
169.689,
630.1632,
591.7320000000001
],
"iscrowd": 0,
"area": 372887.7306624,
"category_id": 1,
"center": [
333.0,
466.0
],
"scale": 2.63
}
]
}
@@ -0,0 +1,185 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "face",
"keypoints": [],
"skeleton": []
}
],
"images": [
{
"id": 3,
"file_name": "image22568.jpg",
"height": 1280,
"width": 853
},
{
"id": 68,
"file_name": "image04476.jpg",
"height": 500,
"width": 439
}
],
"annotations": [
{
"image_id": 3,
"id": 3,
"keypoints": [
337.28341384863,
205.78904991948002,
1,
370.46215780998,
203.18679549113997,
1,
400.38808373591,
210.99355877617,
1,
481.70853462158,
217.49919484702,
1,
518.7906602254401,
210.99355877617,
1,
549.3671497584501,
223.35426731079,
1,
359.40257648952996,
253.28019323671,
1,
391.28019323671,
254.58132045089002,
1,
419.25442834138,
261.08695652174,
1,
479.10628019324,
259.78582930757005,
1,
507.08051529790976,
255.88244766506,
1,
533.10305958132,
258.4847020934,
1,
404.29146537842,
323.54106280192997,
1,
443.32528180354007,
338.5040257649,
1,
483.66022544283,
327.44444444444,
1,
381.52173913043,
374.28502415459,
1,
443.32528180354007,
376.23671497584996,
1,
507.73107890499,
372.98389694042,
1,
451.0,
478.0,
1
],
"num_keypoints": 19,
"bbox": [
316.07504025764797,
175.70547504025396,
254.50048309178408,
329.7758454106321
],
"iscrowd": 0,
"area": 83928.11196900737,
"category_id": 1,
"center": [
449.0,
321.0
],
"scale": 1.81,
"box_size": 362.0
},
{
"image_id": 68,
"id": 68,
"keypoints": [
126.64745330811,
157.27305603027,
1,
134.30273752013,
153.39452495973998,
1,
145.34465026855,
153.01428222656,
1,
165.48123168945,
146.28958129883,
1,
181.7833404541,
140.24139404297,
1,
198.6918182373,
143.05288696289,
1,
133.90043640137,
167.45462036133,
1,
141.77455716586002,
165.24637681158995,
1,
148.98872785829,
163.70048309178998,
1,
174.96592712402,
157.80386352539,
1,
185.42395019531003,
155.1201171875,
1,
194.88919067383,
154.83345031738,
1,
145.87278582931,
188.89049919485,
1,
152.59581320451,
177.61352657005,
1,
174.75362318841,
185.34299516908,
1,
145.63929146538,
213.68438003221002,
1,
161.87117552335,
211.3655394525,
1,
187.12077294686,
207.24315619968002,
1,
166.0,
244.0,
1
],
"num_keypoints": 19,
"bbox": [
119.443016815191,
129.865533447267,
86.453237915028,
124.51032714843598
],
"iscrowd": 0,
"area": 10764.320935841704,
"category_id": 1,
"center": [
166.0,
185.0
],
"scale": 0.64,
"box_size": 128.0
}
]
}
@@ -0,0 +1,625 @@
{
"info": {
"description": "MMPose example aic dataset",
"version": "1.0",
"year": "2020",
"date_created": "2020/08/25"
},
"licenses": [
{
"url": "",
"id": 1,
"name": ""
}
],
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"Right Shoulder",
"Right Elbow",
"Right Wrist",
"Left Shoulder",
"Left Elbow",
"Left Wrist",
"Right Hip",
"Right Knee",
"Right Ankle",
"Left Hip",
"Left Knee",
"Left Ankle",
"Head top",
"Neck"
],
"skeleton": [
[
3,
2
],
[
2,
1
],
[
1,
14
],
[
14,
4
],
[
4,
5
],
[
5,
6
],
[
9,
8
],
[
8,
7
],
[
7,
10
],
[
10,
11
],
[
11,
12
],
[
13,
14
],
[
1,
7
],
[
4,
10
]
]
}
],
"images": [
{
"url": "http://www.sinaimg.cn/dy/slidenews/4_img/2013_47/704_1154733_789201.jpg",
"file_name": "054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg",
"height": 600,
"width": 900,
"id": 1
},
{
"url": "http://www.sinaimg.cn/dy/slidenews/2_img/2015_26/820_1533617_599302.jpg",
"file_name": "fa436c914fe4a8ec1ec5474af4d3820b84d17561.jpg",
"height": 596,
"width": 900,
"id": 2
},
{
"url": "http://www.sinaimg.cn/dy/slidenews/2_img/2016_39/730_1947359_260964.jpg",
"file_name": "ff945ae2e729f24eea992814639d59b3bdec8bd8.jpg",
"height": 641,
"width": 950,
"id": 3
}
],
"annotations": [
{
"bbox": [
279,
55,
213,
544
],
"keypoints": [
313,
201,
2,
312,
313,
1,
320,
424,
2,
406,
197,
1,
431,
286,
1,
459,
269,
2,
375,
447,
1,
0,
0,
0,
0,
0,
0,
416,
441,
2,
0,
0,
0,
0,
0,
0,
395,
74,
2,
372,
170,
2
],
"num_keypoints": 10,
"image_id": 1,
"category_id": 1,
"id": 4
},
{
"bbox": [
541,
131,
329,
468
],
"keypoints": [
637,
374,
1,
626,
509,
2,
0,
0,
0,
755,
347,
2,
728,
538,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
604,
169,
2,
674,
290,
2
],
"num_keypoints": 6,
"image_id": 1,
"category_id": 1,
"id": 5
},
{
"bbox": [
88,
7,
252,
592
],
"keypoints": [
144,
180,
2,
171,
325,
1,
256,
428,
1,
265,
196,
2,
297,
311,
2,
300,
412,
2,
178,
476,
1,
0,
0,
0,
0,
0,
0,
253,
474,
1,
0,
0,
0,
0,
0,
0,
220,
23,
2,
205,
133,
2
],
"num_keypoints": 10,
"image_id": 1,
"category_id": 1,
"id": 6
},
{
"bbox": [
497,
179,
401,
416
],
"keypoints": [
692,
332,
1,
587,
430,
2,
612,
552,
1,
657,
422,
2,
533,
571,
2,
621,
450,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
564,
212,
2,
656,
362,
2
],
"num_keypoints": 8,
"image_id": 2,
"category_id": 1,
"id": 7
},
{
"bbox": [
336,
26,
177,
254
],
"keypoints": [
368,
142,
2,
365,
237,
1,
415,
271,
1,
487,
147,
2,
493,
240,
2,
431,
265,
2,
393,
296,
1,
326,
306,
1,
339,
390,
1,
449,
297,
1,
373,
315,
1,
376,
389,
1,
435,
43,
2,
430,
131,
2
],
"num_keypoints": 14,
"image_id": 2,
"category_id": 1,
"id": 8
},
{
"bbox": [
0,
109,
473,
486
],
"keypoints": [
68,
333,
2,
215,
408,
2,
376,
427,
2,
169,
280,
1,
166,
386,
1,
146,
462,
2,
39,
545,
2,
0,
0,
0,
0,
0,
0,
136,
515,
1,
292,
531,
1,
0,
0,
0,
181,
147,
2,
127,
269,
2
],
"num_keypoints": 11,
"image_id": 2,
"category_id": 1,
"id": 9
},
{
"bbox": [
681,
3,
267,
607
],
"keypoints": [
846,
98,
1,
862,
223,
1,
794,
282,
2,
824,
134,
2,
875,
241,
2,
842,
329,
2,
903,
296,
1,
766,
397,
1,
777,
562,
2,
886,
299,
2,
757,
399,
2,
871,
514,
2,
761,
29,
2,
813,
87,
2
],
"num_keypoints": 14,
"image_id": 3,
"category_id": 1,
"id": 10
},
{
"bbox": [
484,
7,
162,
481
],
"keypoints": [
544,
96,
2,
506,
161,
2,
542,
208,
2,
606,
93,
2,
615,
151,
1,
622,
187,
2,
571,
251,
2,
553,
361,
2,
556,
458,
2,
591,
251,
1,
581,
363,
2,
587,
456,
2,
587,
21,
2,
578,
80,
2
],
"num_keypoints": 14,
"image_id": 3,
"category_id": 1,
"id": 11
},
{
"bbox": [
33,
73,
493,
566
],
"keypoints": [
254,
203,
2,
169,
203,
2,
111,
187,
2,
391,
204,
2,
425,
276,
2,
475,
346,
2,
272,
376,
2,
185,
485,
2,
126,
607,
1,
357,
383,
2,
359,
459,
2,
350,
561,
2,
338,
111,
2,
325,
180,
1
],
"num_keypoints": 14,
"image_id": 3,
"category_id": 1,
"id": 12
}
]
}
@@ -0,0 +1,281 @@
{
"categories": [
{
"supercategory": "animal",
"id": 1,
"name": "cat",
"keypoints": [
"L_Eye",
"R_Eye",
"L_EarBase",
"R_EarBase",
"Nose",
"Throat",
"TailBase",
"Withers",
"L_F_Elbow",
"R_F_Elbow",
"L_B_Elbow",
"R_B_Elbow",
"L_F_Knee",
"R_F_Knee",
"L_B_Knee",
"R_B_Knee",
"L_F_Paw",
"R_F_Paw",
"L_B_Paw",
"R_B_Paw"
],
"skeleton": [
[
1,
2
],
[
1,
3
],
[
2,
4
],
[
1,
5
],
[
2,
5
],
[
5,
6
],
[
6,
8
],
[
7,
8
],
[
6,
9
],
[
9,
13
],
[
13,
17
],
[
6,
10
],
[
10,
14
],
[
14,
18
],
[
7,
11
],
[
11,
15
],
[
15,
19
],
[
7,
12
],
[
12,
16
],
[
16,
20
]
]
}
],
"images": [
{
"id": 110,
"file_name": "ca110.jpeg",
"height": 240,
"width": 300
},
{
"id": 3105,
"file_name": "ho105.jpeg",
"height": 255,
"width": 300
}
],
"annotations": [
{
"keypoints": [
117.0,
95.0,
2.0,
85.0,
102.0,
2.0,
115.0,
56.0,
2.0,
62.0,
78.0,
2.0,
102.0,
109.0,
2.0,
104.0,
130.0,
2.0,
235.0,
163.0,
2.0,
144.0,
53.0,
2.0,
123.0,
142.0,
2.0,
40.0,
161.0,
2.0,
182.0,
160.0,
2.0,
0.0,
0.0,
0.0,
115.0,
186.0,
2.0,
64.0,
192.0,
2.0,
189.0,
195.0,
2.0,
0.0,
0.0,
0.0,
84.0,
214.0,
2.0,
53.0,
209.0,
2.0,
146.0,
206.0,
2.0,
0.0,
0.0,
0.0
],
"image_id": 110,
"id": 129,
"num_keypoints": 17,
"bbox": [
13.0,
36.0,
284.0,
192.0
],
"iscrowd": 0,
"area": 54528.0,
"category_id": 1
},
{
"keypoints": [
54.0,
36.0,
2.0,
42.0,
33.0,
2.0,
65.0,
21.0,
2.0,
51.0,
18.0,
2.0,
30.0,
59.0,
2.0,
57.0,
62.0,
2.0,
203.0,
109.0,
2.0,
104.0,
82.0,
2.0,
73.0,
141.0,
2.0,
0.0,
0.0,
0.0,
195.0,
157.0,
2.0,
0.0,
0.0,
0.0,
73.0,
185.0,
2.0,
81.0,
183.0,
2.0,
225.0,
204.0,
2.0,
0.0,
0.0,
0.0,
62.0,
221.0,
2.0,
0.0,
0.0,
0.0,
249.0,
242.0,
2.0,
0.0,
0.0,
0.0
],
"image_id": 3105,
"id": 583,
"num_keypoints": 15,
"bbox": [
23.0,
9.0,
256.0,
240.0
],
"iscrowd": 0,
"area": 61440.0,
"category_id": 1
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,221 @@
{
"categories": [
{
"keypoints": [
"left_ear",
"right_ear",
"nose",
"right_shoulder",
"right_front_paw",
"left_shoulder",
"left_front_paw",
"right_hip",
"right_knee",
"right_back_paw",
"left_hip",
"left_knee",
"left_back_paw",
"tail",
"center"
],
"name": "tiger",
"skeleton": [
[
0,
2
],
[
1,
2
],
[
2,
14
],
[
5,
6
],
[
5,
14
],
[
3,
4
],
[
3,
14
],
[
13,
14
],
[
9,
8
],
[
8,
7
],
[
7,
13
],
[
12,
11
],
[
11,
10
],
[
10,
13
]
],
"id": 1
}
],
"images": [
{
"width": 1239,
"height": 731,
"file_name": "003464.jpg",
"id": 3464
},
{
"width": 925,
"height": 1080,
"file_name": "000061.jpg",
"id": 61
}
],
"annotations": [
{
"bbox": [
0,
0,
1239,
731
],
"category_id": 1,
"keypoints": [
225,
215,
2,
285,
194,
2,
191,
368,
2,
417,
428,
2,
308,
594,
2,
536,
401,
2,
642,
638,
2,
893,
419,
2,
974,
494,
2,
885,
584,
2,
925,
328,
2,
1065,
419,
2,
1050,
583,
2,
994,
186,
2,
592,
277,
2
],
"num_keypoints": 15,
"image_id": 3464,
"id": 3464,
"area": 905709,
"iscrowd": 0
},
{
"bbox": [
0,
0,
925,
1080
],
"category_id": 1,
"keypoints": [
324,
571,
2,
158,
568,
2,
246,
806,
2,
217,
806,
2,
359,
805,
2,
447,
657,
2,
362,
911,
2,
539,
546,
2,
369,
552,
2,
546,
612,
2,
638,
358,
2,
722,
332,
2,
712,
507,
2,
593,
121,
2,
419,
463,
2
],
"num_keypoints": 15,
"image_id": 61,
"id": 61,
"area": 999000,
"iscrowd": 0
}
]
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,239 @@
{
"info": {
"description": "MMPose example COFW dataset",
"version": "1.0",
"year": "2020",
"date_created": "2020/12/31"
},
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "face",
"keypoints": [],
"skeleton": []
}
],
"images": [
{
"id": 1766,
"file_name": "001766.jpg",
"height": 322,
"width": 235
},
{
"id": 1805,
"file_name": "001805.jpg",
"height": 253,
"width": 352
}
],
"annotations": [
{
"keypoints": [
46.562534549474826,
120.07575548185008,
2.0,
131.52522111663905,
115.97127786990977,
2.0,
65.8535793255943,
118.02351667587989,
2.0,
105.66701216141516,
114.73993458632765,
2.0,
56.41328081813161,
110.63545697438737,
2.0,
56.41328081813161,
118.43396443707394,
2.0,
119.62223604201218,
111.45635249677541,
2.0,
119.62223604201218,
117.61306891468585,
2.0,
51.89835544499728,
144.29217339229783,
2.0,
129.06253454947486,
143.88172563110376,
2.0,
72.83119126589278,
145.9339644370739,
2.0,
108.12969872857936,
143.47127786990976,
2.0,
62.980444997236056,
136.0832181684172,
2.0,
60.928206191265936,
148.3966510042381,
2.0,
120.03268380320623,
136.90411369080527,
2.0,
120.44313156440026,
147.16530772065602,
2.0,
65.44313156440026,
143.06083010871572,
2.0,
120.44313156440026,
143.06083010871572,
2.0,
65.44313156440026,
184.10560622811872,
2.0,
103.61477335544504,
183.69515846692468,
2.0,
78.5774599226092,
180.0011286161784,
2.0,
79.80880320619127,
190.26232264602916,
2.0,
60.928206191265936,
212.8369495117008,
1.0,
116.74910171365397,
214.4787405564769,
1.0,
83.50283305693756,
207.5011286161784,
1.0,
83.91328081813161,
211.19515846692468,
1.0,
88.83865395245994,
232.94888981020827,
1.0,
88.83865395245994,
239.92650175050676,
1.0,
94.99537037037038,
271.120531601253,
2.0
],
"image_id": 1766,
"id": 1766,
"num_keypoints": 29,
"bbox": [
38.0,
102.0,
105.0,
180.0
],
"iscrowd": 0,
"area": 18900.0,
"category_id": 1
},
{
"keypoints": [
111.02581748226716,
99.60260061678404,
1.0,
203.48326006615514,
99.60260061678402,
2.0,
138.9556699294833,
104.89964159815261,
1.0,
158.69918631458435,
101.04724815715728,
2.0,
124.02764534562637,
98.6395022565352,
1.0,
124.50919452575083,
102.49189569753052,
1.0,
178.44270269968544,
92.37936291491776,
2.0,
178.92425187980987,
97.19485471616193,
2.0,
116.80440764376011,
115.9752727410142,
1.0,
192.40762892329354,
115.9752727410142,
2.0,
137.02947320898565,
120.30921536213394,
2.0,
165.44087483632623,
119.82766618200952,
2.0,
125.47229288599961,
114.04907602051652,
1.0,
126.43539124624846,
120.30921536213394,
1.0,
180.3688994201831,
107.78893667889912,
2.0,
180.3688994201831,
118.8645678217607,
2.0,
125.95384206612407,
118.38301864163628,
1.0,
180.85044860030752,
115.01217438076534,
2.0,
132.69553058786587,
149.68371534972337,
2.0,
162.0700305754553,
152.09146125034545,
2.0,
143.77116173072744,
147.7575186292257,
2.0,
144.2527109108519,
157.388502231714,
2.0,
132.21398140774147,
168.4641333745756,
1.0,
184.22129286117845,
167.9825841944512,
2.0,
149.06820271209602,
165.09328911370469,
2.0,
150.51285025246932,
170.3903300950733,
2.0,
151.95749779284256,
182.42905959818367,
2.0,
153.4021453332158,
188.6891989398011,
2.0,
155.32834205371347,
218.54524810751494,
2.0
],
"image_id": 1805,
"id": 1805,
"num_keypoints": 29,
"bbox": [
102.0,
83.0,
112.0,
146.0
],
"iscrowd": 0,
"area": 16352.0,
"category_id": 1
}
]
}
@@ -0,0 +1,378 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"left_shoulder",
"right_shoulder",
"left_elbow",
"right_elbow",
"left_wrist",
"right_wrist",
"left_hip",
"right_hip",
"left_knee",
"right_knee",
"left_ankle",
"right_ankle",
"head",
"neck"
],
"skeleton": [
[
16,
14
],
[
14,
12
],
[
17,
15
],
[
15,
13
],
[
12,
13
],
[
6,
12
],
[
7,
13
],
[
6,
7
],
[
6,
8
],
[
7,
9
],
[
8,
10
],
[
9,
11
]
]
}
],
"images": [
{
"file_name": "106848.jpg",
"id": 106848,
"height": 425,
"width": 640,
"crowdIndex": 0.33
},
{
"file_name": "103319.jpg",
"id": 103319,
"height": 480,
"width": 640,
"crowdIndex": 0.39
}
],
"annotations": [
{
"num_keypoints": 5,
"iscrowd": 0,
"keypoints": [
0,
0,
0,
208,
108,
2,
0,
0,
0,
278,
158,
2,
262,
206,
2,
348,
98,
2,
0,
0,
0,
173,
299,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
256,
27,
1,
220,
89,
1
],
"image_id": 106848,
"bbox": [
106.01,
13.43,
273.15,
352.42
],
"category_id": 1,
"id": 123803
},
{
"num_keypoints": 0,
"iscrowd": 0,
"keypoints": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"image_id": 106848,
"bbox": [
108.5,
96.78,
35.46,
30.23
],
"category_id": 1,
"id": 131039
},
{
"num_keypoints": 10,
"iscrowd": 0,
"keypoints": [
482,
129,
2,
364,
126,
2,
513,
213,
2,
339,
163,
2,
431,
210,
2,
276,
163,
1,
440,
308,
2,
371,
304,
1,
432,
419,
1,
366,
419,
1,
0,
0,
0,
0,
0,
0,
407,
29,
1,
420,
110,
1
],
"image_id": 106848,
"bbox": [
281.51,
21.92,
244.5,
349.72
],
"category_id": 1,
"id": 147481
},
{
"num_keypoints": 12,
"iscrowd": 0,
"keypoints": [
388,
205,
2,
344,
211,
2,
407,
249,
2,
337,
256,
2,
393,
278,
2,
336,
290,
2,
390,
293,
2,
354,
294,
2,
387,
354,
2,
351,
357,
2,
380,
390,
2,
359,
408,
1,
351,
163,
1,
364,
198,
1
],
"image_id": 103319,
"bbox": [
316.76,
157.3,
100.54,
247.56
],
"category_id": 1,
"id": 127068
},
{
"num_keypoints": 12,
"iscrowd": 0,
"keypoints": [
350,
145,
2,
300,
145,
2,
352,
190,
1,
299,
180,
2,
322,
163,
2,
291,
217,
2,
346,
232,
1,
314,
232,
2,
346,
283,
1,
310,
284,
2,
345,
346,
1,
305,
344,
2,
312,
106,
1,
323,
137,
1
],
"image_id": 103319,
"bbox": [
279.68,
102.17,
81.13,
255.49
],
"category_id": 1,
"id": 129014
}
]
}
@@ -0,0 +1,68 @@
[
{
"bbox": [
120.36583709716797,
30.521512985229492,
244.14288330078125,
328.944580078125
],
"category_id": 1,
"image_id": 106848,
"score": 0.9999284744262695
},
{
"bbox": [
326.6805725097656,
30.76219940185547,
209.03128051757812,
327.80035400390625
],
"category_id": 1,
"image_id": 106848,
"score": 0.9993789196014404
},
{
"bbox": [
109.94915008544922,
95.794677734375,
32.249656677246094,
26.97345733642578
],
"category_id": 1,
"image_id": 106848,
"score": 0.9997813105583191
},
{
"bbox": [
315.21368408203125,
149.79432678222656,
100.7252197265625,
259.96405029296875
],
"category_id": 1,
"image_id": 103319,
"score": 0.9998345375061035
},
{
"bbox": [
282.7766418457031,
100.75929260253906,
76.44869995117188,
261.6209716796875
],
"category_id": 1,
"image_id": 103319,
"score": 0.9998021721839905
},
{
"bbox": [
-0.10778862237930298,
238.81455993652344,
38.23238754272461,
99.21165466308594
],
"category_id": 1,
"image_id": 103319,
"score": 0.9673888683319092
}
]
@@ -0,0 +1,123 @@
{
"info": {
"description": "Fashion Landmark Detection (FLD) test set for full-body clothes generated by MMPose Team.",
"url": "http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion/LandmarkDetection.html",
"version": "1.0",
"year": "2021",
"date_created": "2021/01/02"
},
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "fashion",
"keypoints": [
"left collar",
"right collar",
"left sleeve",
"right sleeve",
"left waistline",
"right waistline",
"left hem",
"right hem"
],
"skeleton": []
}
],
"images": [
{
"id": 128,
"file_name": "img_00000128.jpg",
"height": 250,
"width": 200
},
{
"id": 132,
"file_name": "img_00000132.jpg",
"height": 250,
"width": 200
}
],
"annotations": [
{
"keypoints": [
108.0,
33.0,
1.0,
121.0,
36.0,
1.0,
95.0,
65.0,
2.0,
128.0,
68.0,
1.0,
118.0,
79.0,
2.0,
114.0,
75.0,
1.0,
115.0,
150.0,
2.0,
112.0,
143.0,
1.0
],
"num_keypoints": 8,
"bbox": [
88,
21,
48,
142
],
"iscrowd": 0,
"area": 6816,
"category_id": 1,
"id": 128,
"image_id": 128
},
{
"keypoints": [
71.0,
19.0,
2.0,
127.0,
15.0,
2.0,
37.0,
80.0,
2.0,
162.0,
71.0,
2.0,
60.0,
112.0,
2.0,
145.0,
109.0,
2.0,
0.0,
0.0,
0.0,
172.0,
235.0,
2.0
],
"num_keypoints": 7,
"bbox": [
1,
1,
199,
249
],
"iscrowd": 0,
"area": 49551,
"category_id": 1,
"id": 132,
"image_id": 132
}
]
}
@@ -0,0 +1,385 @@
{
"categories": [
{
"supercategory": "animal",
"id": 1,
"name": "fly",
"keypoints": [
"head",
"eyeL",
"eyeR",
"neck",
"thorax",
"abdomen",
"forelegR1",
"forelegR2",
"forelegR3",
"forelegR4",
"midlegR1",
"midlegR2",
"midlegR3",
"midlegR4",
"hindlegR1",
"hindlegR2",
"hindlegR3",
"hindlegR4",
"forelegL1",
"forelegL2",
"forelegL3",
"forelegL4",
"midlegL1",
"midlegL2",
"midlegL3",
"midlegL4",
"hindlegL1",
"hindlegL2",
"hindlegL3",
"hindlegL4",
"wingL",
"wingR"
],
"skeleton": [
[
2,
1
],
[
3,
1
],
[
4,
1
],
[
5,
4
],
[
6,
5
],
[
8,
7
],
[
9,
8
],
[
10,
9
],
[
12,
11
],
[
13,
12
],
[
14,
13
],
[
16,
15
],
[
17,
16
],
[
18,
17
],
[
20,
19
],
[
21,
20
],
[
22,
21
],
[
24,
23
],
[
25,
24
],
[
26,
25
],
[
28,
27
],
[
29,
28
],
[
30,
29
],
[
31,
4
],
[
32,
4
]
]
}
],
"images": [
{
"id": 1400,
"file_name": "1400.jpg",
"height": 192,
"width": 192
},
{
"id": 1450,
"file_name": "1450.jpg",
"height": 192,
"width": 192
}
],
"annotations": [
{
"keypoints": [
146.0,
95.0,
2.0,
134.0,
80.0,
2.0,
136.0,
112.0,
2.0,
129.0,
97.0,
2.0,
99.0,
97.0,
2.0,
52.0,
95.0,
2.0,
123.0,
107.0,
2.0,
140.0,
114.0,
2.0,
158.0,
109.0,
2.0,
173.0,
109.0,
2.0,
110.0,
106.0,
2.0,
115.0,
127.0,
2.0,
133.0,
127.0,
2.0,
146.0,
138.0,
2.0,
96.0,
106.0,
2.0,
64.18991088867188,
120.96142578125,
2.0,
46.0,
126.0,
2.0,
34.0,
137.0,
2.0,
121.0,
86.0,
2.0,
147.0,
78.0,
2.0,
169.0,
79.0,
2.0,
184.0,
75.0,
2.0,
108.0,
86.0,
2.0,
103.0,
70.0,
2.0,
109.0,
40.0,
2.0,
114.0,
18.0,
2.0,
93.0,
87.0,
2.0,
82.0,
64.0,
2.0,
74.0,
46.0,
2.0,
67.0,
22.0,
2.0,
19.0,
86.0,
2.0,
23.0,
137.0,
2.0
],
"image_id": 1400,
"id": 1400,
"num_keypoints": 32,
"bbox": [
19.0,
18.0,
166.0,
121.0
],
"iscrowd": 0,
"area": 20086.0,
"category_id": 1
},
{
"keypoints": [
147.43026733398438,
96.94955444335938,
2.0,
137.32937622070312,
79.7210693359375,
2.0,
138.43026733398438,
110.86053466796875,
2.0,
128.0,
96.0,
2.0,
98.0,
96.0,
2.0,
49.329376220703125,
94.13946533203125,
2.0,
122.37982177734375,
108.81008911132812,
2.0,
129.43026733398438,
114.18991088867188,
2.0,
138.65875244140625,
114.62017822265625,
2.0,
144.480712890625,
118.7596435546875,
2.0,
112.18991088867188,
109.18991088867188,
2.0,
105.557861328125,
118.43026733398438,
2.0,
95.67062377929688,
121.91098022460938,
2.0,
91.13946533203125,
136.10089111328125,
2.0,
91.46884155273438,
104.2017822265625,
2.0,
73.2403564453125,
117.43026733398438,
2.0,
57.37833786010742,
107.22997283935547,
2.0,
44.87240219116211,
112.96142578125,
2.0,
119.65875244140625,
84.81008911132812,
2.0,
123.78634643554688,
77.94955444335938,
2.0,
132.36795043945312,
76.58160400390625,
2.0,
140.0,
64.0,
2.0,
113.2789306640625,
83.29080200195312,
2.0,
100.08901977539062,
74.98812866210938,
2.0,
98.519287109375,
67.13946533203125,
2.0,
93.62017822265625,
55.810089111328125,
2.0,
94.22848510742188,
85.08901977539062,
2.0,
78.36795043945312,
69.2403564453125,
2.0,
71.60830688476562,
74.58160400390625,
2.0,
60.848663330078125,
68.67062377929688,
2.0,
16.0,
66.0,
2.0,
16.0,
126.0,
2.0
],
"image_id": 1450,
"id": 1450,
"num_keypoints": 32,
"bbox": [
16.0,
55.810089111328125,
132.43026733398438,
81.29080200195312
],
"iscrowd": 0,
"area": 10765.362640912645,
"category_id": 1
}
]
}
@@ -0,0 +1,957 @@
{
"info": {
"description": "FreiHand",
"version": "1.0",
"year": "2020",
"date_created": "2020/09/08"
},
"licenses": "",
"images": [
{
"file_name": "00017620.jpg",
"height": 224,
"width": 224,
"id": 17620
},
{
"file_name": "00050180.jpg",
"height": 224,
"width": 224,
"id": 50180
},
{
"file_name": "00082740.jpg",
"height": 224,
"width": 224,
"id": 82740
},
{
"file_name": "00115300.jpg",
"height": 224,
"width": 224,
"id": 115300
},
{
"file_name": "00000355.jpg",
"height": 224,
"width": 224,
"id": 355
},
{
"file_name": "00032915.jpg",
"height": 224,
"width": 224,
"id": 32915
},
{
"file_name": "00065475.jpg",
"height": 224,
"width": 224,
"id": 65475
},
{
"file_name": "00098035.jpg",
"height": 224,
"width": 224,
"id": 98035
}
],
"annotations": [
{
"bbox": [
62,
82,
104,
63
],
"keypoints": [
75.09007144965095,
114.79035385093314,
1,
88.01978404720953,
109.72359615889864,
1,
98.79950536639522,
109.05442666062974,
1,
110.16327936938085,
114.72375114390456,
1,
121.75826373686846,
122.01572654269421,
1,
126.92528942089982,
93.65489136216958,
1,
144.49316505581498,
94.71206260545628,
1,
152.3510241000562,
102.03474955900822,
1,
159.94413202793353,
111.6105502403288,
1,
136.5822887073417,
102.58162787991249,
1,
153.71181890922904,
105.7627322321249,
1,
158.23785994857087,
113.05793071695886,
1,
159.1827624858022,
122.12860754004963,
1,
131.78312266215684,
118.12603871987666,
1,
144.37435502719956,
122.97613121869307,
1,
144.12850082414747,
130.24233623490562,
1,
138.0058328373116,
135.03475933083362,
1,
123.6128526185571,
130.55957078894423,
1,
126.52617237783046,
135.2764317635352,
1,
123.26857656908544,
138.5518599403549,
1,
118.92147700299864,
140.34319120176468,
1
],
"category_id": 1,
"id": 17620,
"image_id": 17620,
"segmentation": [
[
62,
82,
62,
113.0,
62,
144,
113.5,
144,
165,
144,
165,
113.0,
165,
82,
113.5,
82
]
],
"iscrowd": 0,
"area": 6552
},
{
"bbox": [
62,
82,
104,
63
],
"keypoints": [
75.09007144965095,
114.79035385093314,
1,
88.01978404720953,
109.72359615889864,
1,
98.79950536639522,
109.05442666062974,
1,
110.16327936938085,
114.72375114390456,
1,
121.75826373686846,
122.01572654269421,
1,
126.92528942089982,
93.65489136216958,
1,
144.49316505581498,
94.71206260545628,
1,
152.3510241000562,
102.03474955900822,
1,
159.94413202793353,
111.6105502403288,
1,
136.5822887073417,
102.58162787991249,
1,
153.71181890922904,
105.7627322321249,
1,
158.23785994857087,
113.05793071695886,
1,
159.1827624858022,
122.12860754004963,
1,
131.78312266215684,
118.12603871987666,
1,
144.37435502719956,
122.97613121869307,
1,
144.12850082414747,
130.24233623490562,
1,
138.0058328373116,
135.03475933083362,
1,
123.6128526185571,
130.55957078894423,
1,
126.52617237783046,
135.2764317635352,
1,
123.26857656908544,
138.5518599403549,
1,
118.92147700299864,
140.34319120176468,
1
],
"category_id": 1,
"id": 50180,
"image_id": 50180,
"segmentation": [
[
62,
82,
62,
113.0,
62,
144,
113.5,
144,
165,
144,
165,
113.0,
165,
82,
113.5,
82
]
],
"iscrowd": 0,
"area": 6552
},
{
"bbox": [
62,
82,
104,
63
],
"keypoints": [
75.09007144965095,
114.79035385093314,
1,
88.01978404720953,
109.72359615889864,
1,
98.79950536639522,
109.05442666062974,
1,
110.16327936938085,
114.72375114390456,
1,
121.75826373686846,
122.01572654269421,
1,
126.92528942089982,
93.65489136216958,
1,
144.49316505581498,
94.71206260545628,
1,
152.3510241000562,
102.03474955900822,
1,
159.94413202793353,
111.6105502403288,
1,
136.5822887073417,
102.58162787991249,
1,
153.71181890922904,
105.7627322321249,
1,
158.23785994857087,
113.05793071695886,
1,
159.1827624858022,
122.12860754004963,
1,
131.78312266215684,
118.12603871987666,
1,
144.37435502719956,
122.97613121869307,
1,
144.12850082414747,
130.24233623490562,
1,
138.0058328373116,
135.03475933083362,
1,
123.6128526185571,
130.55957078894423,
1,
126.52617237783046,
135.2764317635352,
1,
123.26857656908544,
138.5518599403549,
1,
118.92147700299864,
140.34319120176468,
1
],
"category_id": 1,
"id": 82740,
"image_id": 82740,
"segmentation": [
[
62,
82,
62,
113.0,
62,
144,
113.5,
144,
165,
144,
165,
113.0,
165,
82,
113.5,
82
]
],
"iscrowd": 0,
"area": 6552
},
{
"bbox": [
62,
82,
104,
63
],
"keypoints": [
75.09007144965095,
114.79035385093314,
1,
88.01978404720953,
109.72359615889864,
1,
98.79950536639522,
109.05442666062974,
1,
110.16327936938085,
114.72375114390456,
1,
121.75826373686846,
122.01572654269421,
1,
126.92528942089982,
93.65489136216958,
1,
144.49316505581498,
94.71206260545628,
1,
152.3510241000562,
102.03474955900822,
1,
159.94413202793353,
111.6105502403288,
1,
136.5822887073417,
102.58162787991249,
1,
153.71181890922904,
105.7627322321249,
1,
158.23785994857087,
113.05793071695886,
1,
159.1827624858022,
122.12860754004963,
1,
131.78312266215684,
118.12603871987666,
1,
144.37435502719956,
122.97613121869307,
1,
144.12850082414747,
130.24233623490562,
1,
138.0058328373116,
135.03475933083362,
1,
123.6128526185571,
130.55957078894423,
1,
126.52617237783046,
135.2764317635352,
1,
123.26857656908544,
138.5518599403549,
1,
118.92147700299864,
140.34319120176468,
1
],
"category_id": 1,
"id": 115300,
"image_id": 115300,
"segmentation": [
[
62,
82,
62,
113.0,
62,
144,
113.5,
144,
165,
144,
165,
113.0,
165,
82,
113.5,
82
]
],
"iscrowd": 0,
"area": 6552
},
{
"bbox": [
48,
81,
111,
73
],
"keypoints": [
72.3863777322552,
118.66396006693559,
1,
94.24833834345874,
103.27814170253427,
1,
110.88311700561579,
95.90395591649063,
1,
126.4579609506009,
94.84947407598384,
1,
150.22575721471514,
90.20807463489129,
1,
101.58391664034835,
95.2364549099302,
1,
123.22957111339275,
99.32947575213643,
1,
139.48821317513102,
106.07413659069489,
1,
157.4869130814403,
114.05678966958038,
1,
102.72641676686953,
113.8112215401411,
1,
124.77010074005784,
117.9386487787441,
1,
138.88096072705787,
120.6828207743196,
1,
153.55692830019055,
122.08891417018086,
1,
101.79667808841384,
132.8686913780324,
1,
122.47431735923229,
131.3244981984239,
1,
136.86479076428296,
129.51781183394235,
1,
147.14149503293044,
124.23211514642553,
1,
103.99186381010902,
143.91615273519855,
1,
119.95852588057097,
140.94459694337758,
1,
130.47757563177504,
137.0559475661833,
1,
140.32638831475907,
128.94416862968552,
1
],
"category_id": 1,
"id": 355,
"image_id": 355,
"segmentation": [
[
48,
81,
48,
117.0,
48,
153,
103.0,
153,
158,
153,
158,
117.0,
158,
81,
103.0,
81
]
],
"iscrowd": 0,
"area": 8103
},
{
"bbox": [
48,
81,
111,
73
],
"keypoints": [
72.3863777322552,
118.66396006693559,
1,
94.24833834345874,
103.27814170253427,
1,
110.88311700561579,
95.90395591649063,
1,
126.4579609506009,
94.84947407598384,
1,
150.22575721471514,
90.20807463489129,
1,
101.58391664034835,
95.2364549099302,
1,
123.22957111339275,
99.32947575213643,
1,
139.48821317513102,
106.07413659069489,
1,
157.4869130814403,
114.05678966958038,
1,
102.72641676686953,
113.8112215401411,
1,
124.77010074005784,
117.9386487787441,
1,
138.88096072705787,
120.6828207743196,
1,
153.55692830019055,
122.08891417018086,
1,
101.79667808841384,
132.8686913780324,
1,
122.47431735923229,
131.3244981984239,
1,
136.86479076428296,
129.51781183394235,
1,
147.14149503293044,
124.23211514642553,
1,
103.99186381010902,
143.91615273519855,
1,
119.95852588057097,
140.94459694337758,
1,
130.47757563177504,
137.0559475661833,
1,
140.32638831475907,
128.94416862968552,
1
],
"category_id": 1,
"id": 32915,
"image_id": 32915,
"segmentation": [
[
48,
81,
48,
117.0,
48,
153,
103.0,
153,
158,
153,
158,
117.0,
158,
81,
103.0,
81
]
],
"iscrowd": 0,
"area": 8103
},
{
"bbox": [
48,
81,
111,
73
],
"keypoints": [
72.3863777322552,
118.66396006693559,
1,
94.24833834345874,
103.27814170253427,
1,
110.88311700561579,
95.90395591649063,
1,
126.4579609506009,
94.84947407598384,
1,
150.22575721471514,
90.20807463489129,
1,
101.58391664034835,
95.2364549099302,
1,
123.22957111339275,
99.32947575213643,
1,
139.48821317513102,
106.07413659069489,
1,
157.4869130814403,
114.05678966958038,
1,
102.72641676686953,
113.8112215401411,
1,
124.77010074005784,
117.9386487787441,
1,
138.88096072705787,
120.6828207743196,
1,
153.55692830019055,
122.08891417018086,
1,
101.79667808841384,
132.8686913780324,
1,
122.47431735923229,
131.3244981984239,
1,
136.86479076428296,
129.51781183394235,
1,
147.14149503293044,
124.23211514642553,
1,
103.99186381010902,
143.91615273519855,
1,
119.95852588057097,
140.94459694337758,
1,
130.47757563177504,
137.0559475661833,
1,
140.32638831475907,
128.94416862968552,
1
],
"category_id": 1,
"id": 65475,
"image_id": 65475,
"segmentation": [
[
48,
81,
48,
117.0,
48,
153,
103.0,
153,
158,
153,
158,
117.0,
158,
81,
103.0,
81
]
],
"iscrowd": 0,
"area": 8103
},
{
"bbox": [
48,
81,
111,
73
],
"keypoints": [
72.3863777322552,
118.66396006693559,
1,
94.24833834345874,
103.27814170253427,
1,
110.88311700561579,
95.90395591649063,
1,
126.4579609506009,
94.84947407598384,
1,
150.22575721471514,
90.20807463489129,
1,
101.58391664034835,
95.2364549099302,
1,
123.22957111339275,
99.32947575213643,
1,
139.48821317513102,
106.07413659069489,
1,
157.4869130814403,
114.05678966958038,
1,
102.72641676686953,
113.8112215401411,
1,
124.77010074005784,
117.9386487787441,
1,
138.88096072705787,
120.6828207743196,
1,
153.55692830019055,
122.08891417018086,
1,
101.79667808841384,
132.8686913780324,
1,
122.47431735923229,
131.3244981984239,
1,
136.86479076428296,
129.51781183394235,
1,
147.14149503293044,
124.23211514642553,
1,
103.99186381010902,
143.91615273519855,
1,
119.95852588057097,
140.94459694337758,
1,
130.47757563177504,
137.0559475661833,
1,
140.32638831475907,
128.94416862968552,
1
],
"category_id": 1,
"id": 98035,
"image_id": 98035,
"segmentation": [
[
48,
81,
48,
117.0,
48,
153,
103.0,
153,
158,
153,
158,
117.0,
158,
81,
103.0,
81
]
],
"iscrowd": 0,
"area": 8103
}
],
"categories": [
{
"supercategory": "hand",
"id": 1,
"name": "hand",
"keypoints": [
"wrist",
"thumb1",
"thumb2",
"thumb3",
"thumb4",
"forefinger1",
"forefinger2",
"forefinger3",
"forefinger4",
"middle_finger1",
"middle_finger2",
"middle_finger3",
"middle_finger4",
"ring_finger1",
"ring_finger2",
"ring_finger3",
"ring_finger4",
"pinky_finger1",
"pinky_finger2",
"pinky_finger3",
"pinky_finger4"
],
"skeleton": [
[
1,
2
],
[
2,
3
],
[
3,
4
],
[
4,
5
],
[
1,
6
],
[
6,
7
],
[
7,
8
],
[
8,
9
],
[
1,
10
],
[
10,
11
],
[
11,
12
],
[
12,
13
],
[
1,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
1,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
]
]
}
]
}
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,302 @@
{
"categories": [
{
"supercategory": "animal",
"id": 1,
"name": "horse",
"keypoints": [
"Nose",
"Eye",
"Nearknee",
"Nearfrontfetlock",
"Nearfrontfoot",
"Offknee",
"Offfrontfetlock",
"Offfrontfoot",
"Shoulder",
"Midshoulder",
"Elbow",
"Girth",
"Wither",
"Nearhindhock",
"Nearhindfetlock",
"Nearhindfoot",
"Hip",
"Stifle",
"Offhindhock",
"Offhindfetlock",
"Offhindfoot",
"Ischium"
],
"skeleton": []
}
],
"images": [
{
"id": 100,
"file_name": "0244.png",
"height": 162,
"width": 288
},
{
"id": 500,
"file_name": "0292.png",
"height": 162,
"width": 288
},
{
"id": 900,
"file_name": "0465.png",
"height": 162,
"width": 288
}
],
"annotations": [
{
"keypoints": [
126.0,
71.1,
2.0,
117.3,
56.4,
2.0,
90.0,
98.7,
2.0,
92.1,
112.8,
2.0,
98.7,
117.3,
2.0,
71.39999999999999,
102.89999999999999,
2.0,
63.599999999999994,
114.0,
2.0,
56.699999999999996,
120.0,
2.0,
80.1,
73.5,
2.0,
78.3,
63.0,
2.0,
67.5,
82.2,
2.0,
65.39999999999999,
82.8,
2.0,
72.0,
52.199999999999996,
2.0,
29.4,
97.5,
2.0,
27.0,
113.39999999999999,
2.0,
31.5,
120.6,
2.0,
36.3,
56.1,
2.0,
37.5,
75.6,
2.0,
38.4,
97.8,
2.0,
46.8,
112.8,
2.0,
51.0,
120.3,
2.0,
23.099999999999998,
63.599999999999994,
2.0
],
"image_id": 100,
"id": 100,
"num_keypoints": 22,
"bbox": [
2,
38,
145,
97
],
"iscrowd": 0,
"area": 14065,
"category_id": 1
},
{
"keypoints": [
267.9,
67.8,
2.0,
265.5,
51.6,
2.0,
200.7,
94.8,
2.0,
190.79999999999998,
106.2,
2.0,
190.2,
114.6,
2.0,
229.5,
97.8,
2.0,
234.0,
111.6,
2.0,
240.6,
118.19999999999999,
2.0,
233.7,
69.0,
2.0,
226.5,
57.599999999999994,
2.0,
219.6,
79.5,
2.0,
213.0,
81.6,
2.0,
216.29999999999998,
48.3,
2.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
182.1,
47.699999999999996,
2.0,
176.1,
72.0,
2.0,
162.0,
92.1,
2.0,
162.9,
111.89999999999999,
2.0,
167.4,
117.6,
2.0,
161.4,
54.9,
2.0
],
"image_id": 500,
"id": 500,
"num_keypoints": 19,
"bbox": [
140,
33,
148,
100
],
"iscrowd": 0,
"area": 14800,
"category_id": 1
},
{
"keypoints": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
286.2,
118.8,
2.0,
282.0,
123.89999999999999,
2.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
252.0,
102.89999999999999,
2.0,
261.9,
119.39999999999999,
2.0,
268.8,
128.1,
2.0,
263.09999999999997,
60.3,
2.0,
253.5,
84.0,
2.0,
236.7,
103.2,
2.0,
230.7,
121.19999999999999,
2.0,
234.6,
129.0,
2.0,
240.29999999999998,
67.5,
2.0
],
"image_id": 900,
"id": 900,
"num_keypoints": 11,
"bbox": [
219,
46,
69,
97
],
"iscrowd": 0,
"area": 6693,
"category_id": 1
}
]
}
@@ -0,0 +1,162 @@
{
"3": {
"campos": {
"400026": [
-415.1940002441406,
132.24954223632812,
59.5650749206543
]
},
"camrot": {
"400026": [
[
0.9201921224594116,
-0.012140202336013317,
-0.39127883315086365
],
[
0.06150508299469948,
0.9915890097618103,
0.11387889832258224
],
[
0.38660526275634766,
-0.1288560926914215,
0.9131990671157837
]
]
},
"focal": {
"400026": [
1261.5291748046875,
1261.6845703125
]
},
"princpt": {
"400026": [
155.8163604736328,
258.8305969238281
]
}
},
"2": {
"campos": {
"400012": [
606.0524291992188,
-174.7548828125,
163.86656188964844
]
},
"camrot": {
"400012": [
[
0.82091224193573,
0.05194839835166931,
0.5686866044998169
],
[
0.05824033170938492,
0.9830448031425476,
-0.17387045919895172
],
[
-0.5680767297744751,
0.17585287988185883,
0.8039680123329163
]
]
},
"focal": {
"400012": [
1270.7069091796875,
1270.5194091796875
]
},
"princpt": {
"400012": [
196.347412109375,
240.42515563964844
]
}
},
"7": {
"campos": {
"410053": [
973.9876098632812,
-151.85047912597656,
576.7235107421875
]
},
"camrot": {
"410053": [
[
0.42785099148750305,
0.07326933741569519,
0.900874674320221
],
[
0.10334496945142746,
0.9862067103385925,
-0.12929096817970276
],
[
-0.8979216814041138,
0.148418128490448,
0.41437748074531555
]
]
},
"focal": {
"410053": [
1272.947021484375,
1272.957275390625
]
},
"princpt": {
"410053": [
187.24343872070312,
243.6494903564453
]
}
},
"4": {
"campos": {
"410028": [
224.87350463867188,
144.3102569580078,
-8.186153411865234
]
},
"camrot": {
"410028": [
[
0.9784372448921204,
0.024140462279319763,
0.2051287442445755
],
[
-0.048440802842378616,
0.9922666549682617,
0.11428194493055344
],
[
-0.2007835954427719,
-0.12175431102514267,
0.972040057182312
]
]
},
"focal": {
"410028": [
1274.1224365234375,
1274.2861328125
]
},
"princpt": {
"410028": [
270.805419921875,
175.498046875
]
}
}
}
@@ -0,0 +1,610 @@
{
"images": [
{
"id": 326750,
"file_name": "image69148.jpg",
"width": 334,
"height": 512,
"capture": 3,
"subject": 3,
"seq_name": "0390_dh_touchROM",
"camera": "400026",
"frame_idx": 69148
},
{
"id": 286291,
"file_name": "image44669.jpg",
"width": 334,
"height": 512,
"capture": 2,
"subject": 2,
"seq_name": "0266_dh_pray",
"camera": "400012",
"frame_idx": 44669
},
{
"id": 680801,
"file_name": "image29590.jpg",
"width": 334,
"height": 512,
"capture": 7,
"subject": 6,
"seq_name": "0115_rocker_backside",
"camera": "410053",
"frame_idx": 29590
},
{
"id": 471953,
"file_name": "image2017.jpg",
"width": 512,
"height": 334,
"capture": 4,
"subject": 0,
"seq_name": "0007_thumbup_normal",
"camera": "410028",
"frame_idx": 2017
}
],
"annotations": [
{
"id": 326750,
"image_id": 326750,
"bbox": [
33.56839370727539,
164.92373657226562,
185.057861328125,
142.7256622314453
],
"joint_valid": [
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
]
],
"hand_type": "interacting",
"hand_type_valid": 1
},
{
"id": 286291,
"image_id": 286291,
"bbox": [
116.43374633789062,
79.66770935058594,
163.1707763671875,
175.00582885742188
],
"joint_valid": [
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
]
],
"hand_type": "interacting",
"hand_type_valid": 1
},
{
"id": 680801,
"image_id": 680801,
"bbox": [
32.624629974365234,
116.9090805053711,
182.95919799804688,
117.79376983642578
],
"joint_valid": [
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
]
],
"hand_type": "left",
"hand_type_valid": 1
},
{
"id": 471953,
"image_id": 471953,
"bbox": [
154.45904541015625,
27.944841384887695,
90.6390380859375,
184.53550720214844
],
"joint_valid": [
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
1
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
],
[
0
]
],
"hand_type": "right",
"hand_type_valid": 1
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,298 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"neck",
"belly",
"head",
"right_shoulder",
"left_shoulder",
"right_hip",
"left_hip",
"right_elbow",
"left_elbow",
"right_knee",
"left_knee",
"right_wrist",
"left_wrist",
"right_ankle",
"left_ankle"
],
"skeleton": [
[
1,
3
],
[
1,
4
],
[
1,
5
],
[
1,
2
],
[
4,
8
],
[
8,
12
],
[
5,
9
],
[
9,
13
],
[
2,
6
],
[
2,
7
],
[
6,
10
],
[
10,
14
],
[
7,
11
],
[
11,
15
]
]
}
],
"images": [
{
"is_labeled": true,
"file_name": "Frisbee_catch_f_cm_np1_ri_med_0/00001.png",
"nframes": 37,
"frame_id": 2280001,
"vid_id": "00228",
"id": 2280001,
"width": 320,
"height": 240
},
{
"is_labeled": true,
"file_name": "Frisbee_catch_f_cm_np1_ri_med_1/00001.png",
"nframes": 40,
"frame_id": 2290001,
"vid_id": "00229",
"id": 2290001,
"width": 320,
"height": 240
},
{
"is_labeled": true,
"file_name": "Goalkeeper_Training_Day_@_7_catch_f_cm_np1_ri_med_0/00001.png",
"nframes": 30,
"frame_id": 2300001,
"vid_id": "00230",
"id": 2300001,
"width": 320,
"height": 240
}
],
"annotations": [
{
"keypoints": [
98.851746,
92.59851,
2.0,
101.382222,
133.488694,
2.0,
100.914365,
79.770933,
2.0,
86.888258,
101.976452,
2.0,
107.314272,
103.37138,
2.0,
96.914279,
145.028519,
2.0,
106.514281,
141.828552,
2.0,
91.779302,
90.131713,
2.0,
111.71446,
119.029127,
2.0,
101.371546,
177.429379,
2.0,
113.428535,
169.257124,
2.0,
90.261035,
71.796419,
2.0,
125.372119,
117.142762,
2.0,
96.68488,
206.18226,
2.0,
87.838304,
191.933582,
2.0
],
"track_id": 0,
"image_id": 2280001,
"bbox": [
79.0,
62.0,
54.0,
159.0
],
"scores": [],
"category_id": 1,
"id": 1000002280001
},
{
"keypoints": [
126.293586,
86.516958,
2.0,
125.127052,
119.880592,
2.0,
128.800121,
77.713852,
2.0,
123.142858,
93.771388,
2.0,
127.599998,
93.314242,
2.0,
125.314285,
126.685723,
2.0,
125.257142,
128.685637,
2.0,
122.857184,
111.302686,
2.0,
128.40003,
107.885918,
2.0,
122.228575,
148.91426,
2.0,
125.600109,
150.403006,
2.0,
141.391708,
106.511998,
2.0,
141.254766,
105.486158,
2.0,
119.657303,
169.255877,
2.0,
127.656398,
173.757251,
2.0
],
"track_id": 0,
"image_id": 2290001,
"bbox": [
114.0,
68.0,
38.0,
115.0
],
"scores": [],
"category_id": 1,
"id": 1000002290001
},
{
"keypoints": [
104.590181,
138.44876,
2.0,
105.733877,
165.843418,
2.0,
104.400092,
130.809558,
2.0,
113.714288,
142.914297,
2.0,
97.999996,
146.228585,
2.0,
110.914299,
173.028594,
2.0,
102.628562,
171.028599,
2.0,
116.687889,
156.478492,
2.0,
94.455572,
157.210571,
2.0,
121.257055,
190.342707,
2.0,
95.200265,
191.484992,
2.0,
120.571144,
170.45612,
2.0,
93.885656,
169.029784,
2.0,
128.177332,
206.720448,
2.0,
90.000104,
209.256786,
2.0
],
"track_id": 0,
"image_id": 2300001,
"bbox": [
84.0,
123.0,
51.0,
94.0
],
"scores": [],
"category_id": 1,
"id": 1000002300001
}
]
}
@@ -0,0 +1,410 @@
{
"categories": [
{
"supercategory": "animal",
"id": 1,
"name": "locust",
"keypoints": [
"head",
"neck",
"thorax",
"abdomen1",
"abdomen2",
"anttipL",
"antbaseL",
"eyeL",
"forelegL1",
"forelegL2",
"forelegL3",
"forelegL4",
"midlegL1",
"midlegL2",
"midlegL3",
"midlegL4",
"hindlegL1",
"hindlegL2",
"hindlegL3",
"hindlegL4",
"anttipR",
"antbaseR",
"eyeR",
"forelegR1",
"forelegR2",
"forelegR3",
"forelegR4",
"midlegR1",
"midlegR2",
"midlegR3",
"midlegR4",
"hindlegR1",
"hindlegR2",
"hindlegR3",
"hindlegR4"
],
"skeleton": [
[
2,
1
],
[
3,
2
],
[
4,
3
],
[
5,
4
],
[
7,
6
],
[
8,
7
],
[
10,
9
],
[
11,
10
],
[
12,
11
],
[
14,
13
],
[
15,
14
],
[
16,
15
],
[
18,
17
],
[
19,
18
],
[
20,
19
],
[
22,
21
],
[
23,
22
],
[
25,
24
],
[
26,
25
],
[
27,
26
],
[
29,
28
],
[
30,
29
],
[
31,
30
],
[
33,
32
],
[
34,
33
],
[
35,
34
]
]
}
],
"images": [
{
"id": 630,
"file_name": "630.jpg",
"height": 160,
"width": 160
},
{
"id": 650,
"file_name": "650.jpg",
"height": 160,
"width": 160
}
],
"annotations": [
{
"keypoints": [
96.50167788139936,
79.08306303388312,
2.0,
88.16894217433088,
80.0,
2.0,
71.83105782566912,
80.0,
2.0,
43.076199694670166,
81.43588116352915,
2.0,
25.32887764003749,
82.27820200265606,
2.0,
110.83265850033396,
64.38260807811851,
2.0,
96.89436603268481,
77.79724180953298,
2.0,
92.64247009206748,
75.90977635533528,
2.0,
83.39926607647823,
72.82433076402732,
2.0,
82.67339213429909,
64.27184461240981,
2.0,
77.6884112016259,
61.04563086937941,
2.0,
77.45675634815713,
53.70793132675738,
2.0,
76.53903805777047,
72.5751936338004,
2.0,
71.96661261225319,
65.52855444465679,
2.0,
71.75442535243388,
57.456652943107045,
2.0,
71.32325166700342,
50.50892818053555,
2.0,
68.30277076791707,
73.75801488839979,
2.0,
53.231016278533986,
76.08684171200879,
2.0,
43.82802063202446,
71.2340227958044,
2.0,
35.106594786098235,
71.66012724670512,
2.0,
106.38084243468204,
93.57855909773465,
2.0,
96.92326999269929,
80.82566265131587,
2.0,
94.00509910253301,
82.81711130561807,
2.0,
86.23508453811776,
87.44135484984199,
2.0,
89.53039251130028,
95.03156856963247,
2.0,
93.56705070950602,
96.78650579864731,
2.0,
95.92358648030009,
102.7013970756846,
2.0,
76.38469744035021,
88.48766220561612,
2.0,
68.9346295215593,
95.07191551878313,
2.0,
61.51609313834261,
101.49429058760627,
2.0,
58.801694058956855,
107.68266252152361,
2.0,
68.60028938490109,
86.4375531155976,
2.0,
49.508565619095066,
85.14994772406058,
2.0,
46.69889605871468,
93.99222310236672,
2.0,
38.16941690562348,
96.27433127807184,
2.0
],
"image_id": 630,
"id": 630,
"num_keypoints": 35,
"bbox": [
25.32887764003749,
50.50892818053555,
86.50378086029647,
58.17373434098806
],
"iscrowd": 0,
"area": 5032.247967257935,
"category_id": 1
},
{
"keypoints": [
97.23191700267623,
80.39325063190708,
2.0,
88.51415643927471,
80.0,
2.0,
71.48584356072527,
80.0,
2.0,
36.905138572570486,
78.04476695194448,
2.0,
16.961673753971056,
75.93092988166644,
2.0,
113.49247835569392,
67.25231199016146,
2.0,
97.64673560186061,
78.62374942355183,
2.0,
94.59207701254518,
76.42905623590133,
2.0,
86.61299882845682,
72.98025939672249,
2.0,
92.79065379033919,
63.557810609540184,
2.0,
98.53306658179334,
60.560826412407806,
2.0,
103.15691560103025,
54.704957013528016,
2.0,
78.15050140841085,
72.0525607684763,
2.0,
67.19679320947252,
63.129491930981956,
2.0,
66.81613570544552,
56.68704758248447,
2.0,
65.81511750771388,
50.30081842401707,
2.0,
68.60029149309025,
71.73022380161136,
2.0,
46.45069339825895,
75.19901789908113,
2.0,
52.58790600614371,
64.54029671009006,
2.0,
43.39186120464909,
61.90008440661086,
2.0,
114.31225140311544,
94.14582220648037,
2.0,
97.0916788683189,
82.39643083701381,
2.0,
93.88962787007102,
84.03290507899544,
2.0,
85.2589207759562,
87.7242665022609,
2.0,
86.20699274387225,
96.23021381618412,
2.0,
85.92496886773941,
99.18054227199636,
2.0,
87.80771669496954,
103.97613146233982,
2.0,
77.42016997828726,
87.49638798189035,
2.0,
70.98251459751503,
98.88127929151817,
2.0,
77.88427189277336,
101.23547565641657,
2.0,
78.23906551163462,
108.63777750516068,
2.0,
68.33776490317005,
85.89688698861642,
2.0,
42.71215070869465,
90.66846983209739,
2.0,
33.419979116798764,
90.66772059057342,
2.0,
23.04868990312741,
92.48441448580822,
2.0
],
"image_id": 650,
"id": 650,
"num_keypoints": 35,
"bbox": [
16.961673753971056,
50.30081842401707,
98.35057764914438,
59.33695908114361
],
"iscrowd": 0,
"area": 5835.824201574118,
"category_id": 1
}
]
}
@@ -0,0 +1,426 @@
{
"categories": [
{
"supercategory": "animal",
"id": 1,
"name": "macaque",
"keypoints": [
"nose",
"left_eye",
"right_eye",
"left_ear",
"right_ear",
"left_shoulder",
"right_shoulder",
"left_elbow",
"right_elbow",
"left_wrist",
"right_wrist",
"left_hip",
"right_hip",
"left_knee",
"right_knee",
"left_ankle",
"right_ankle"
],
"skeleton": [
[
16,
14
],
[
14,
12
],
[
17,
15
],
[
15,
13
],
[
12,
13
],
[
6,
12
],
[
7,
13
],
[
6,
7
],
[
6,
8
],
[
7,
9
],
[
8,
10
],
[
9,
11
],
[
2,
3
],
[
1,
2
],
[
1,
3
],
[
2,
4
],
[
3,
5
],
[
4,
6
],
[
5,
7
]
]
}
],
"images": [
{
"id": 12900,
"file_name": "d47f1b1ee9d3217e.jpg",
"height": 710,
"width": 1024
},
{
"id": 12950,
"file_name": "PRI_1473.jpg",
"height": 1424,
"width": 1728
}
],
"annotations": [
{
"keypoints": [
641.06,
308.89,
2.0,
644.23,
269.75,
2.0,
612.5,
275.04,
2.0,
0.0,
0.0,
0.0,
545.85,
216.86,
2.0,
580.0,
225.0,
2.0,
464.0,
258.0,
2.0,
582.0,
366.0,
2.0,
377.65,
360.73,
2.0,
697.12,
358.61,
2.0,
590.28,
394.58,
2.0,
508.0,
424.0,
2.0,
385.0,
475.0,
2.0,
618.0,
369.0,
2.0,
445.0,
386.0,
2.0,
695.0,
468.0,
2.0,
522.58,
550.08,
2.0
],
"image_id": 12900,
"id": 16169,
"num_keypoints": 16,
"bbox": [
143.87,
147.04,
623.01,
535.22
],
"iscrowd": 0,
"area": 138067.96479999926,
"category_id": 1,
"segmentation": [
[
408.33,
534.21,
465.45,
547.97,
502.48,
587.11,
573.36,
593.45,
652.69,
608.26,
687.6,
578.64,
656.93,
544.79,
616.73,
537.39,
588.17,
501.42,
532.1,
483.44,
518.35,
455.93,
536.33,
426.31,
567.01,
417.85,
629.42,
430.55,
696.07,
437.95,
670.68,
403.04,
705.59,
395.64,
737.32,
413.62,
738.38,
431.6,
765.88,
431.6,
759.54,
379.77,
722.51,
341.69,
654.81,
322.64,
652.69,
271.87,
675.97,
230.61,
651.64,
168.2,
567.01,
147.04,
492.96,
157.62,
423.14,
186.18,
372.36,
243.31,
317.36,
325.82,
307.83,
404.1,
334.28,
469.69,
353.32,
488.73,
290.91,
521.52,
231.67,
563.83,
174.55,
628.36,
143.87,
675.97,
200.99,
681.26,
245.42,
622.02,
307.83,
574.41,
407.27,
536.33
]
]
},
{
"keypoints": [
783.0,
890.0,
2.0,
775.14,
848.5,
2.0,
0.0,
0.0,
0.0,
834.0,
796.0,
2.0,
0.0,
0.0,
0.0,
987.0,
815.0,
2.0,
833.0,
819.0,
2.0,
1132.15,
789.82,
2.0,
887.0,
919.0,
2.0,
1191.0,
852.0,
2.0,
869.0,
1040.0,
2.0,
1177.0,
527.0,
2.0,
1082.0,
513.0,
2.0,
1173.72,
721.35,
2.0,
1086.0,
737.0,
2.0,
1307.0,
678.0,
2.0,
1218.0,
783.0,
2.0
],
"image_id": 12950,
"id": 16227,
"num_keypoints": 15,
"bbox": [
722.61,
393.97,
642.3100000000001,
754.1700000000001
],
"iscrowd": 0,
"area": 242621.70749999955,
"category_id": 1,
"segmentation": [
[
1248.37,
529.25,
1212.77,
474.67,
1179.55,
420.08,
1134.45,
398.72,
1084.61,
393.97,
1053.76,
429.57,
1043.26,
467.44,
996.8,
531.63,
930.35,
607.57,
842.53,
659.79,
806.93,
704.88,
768.96,
728.61,
722.61,
767.77,
727.12,
831.0,
740.67,
878.42,
783.58,
937.13,
812.93,
957.45,
812.93,
1027.46,
799.38,
1072.62,
765.51,
1113.27,
758.74,
1142.62,
803.9,
1147.14,
862.61,
1138.11,
923.58,
1068.1,
950.68,
1000.36,
948.42,
905.52,
1007.13,
891.97,
1083.91,
873.9,
1151.65,
919.07,
1187.78,
957.45,
1223.91,
982.29,
1262.3,
950.68,
1272.11,
901.87,
1264.56,
844.55,
1302.95,
821.96,
1341.34,
779.06,
1363.92,
704.54,
1352.8,
633.68,
1274.48,
598.08
]
]
}
]
}
@@ -0,0 +1,391 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"Right-ankle",
"Right-knee",
"Right-hip",
"Left-hip",
"Left-knee",
"Left-ankle",
"Pelvis",
"Thorax",
"Upper-neck",
"Head-top",
"Right-wrist",
"Right-elbow",
"Right-shoulder",
"Left-shoulder",
"Left-elbow",
"Left-wrist"
],
"skeleton": [
[
1,
2
],
[
2,
3
],
[
3,
7
],
[
7,
4
],
[
4,
5
],
[
5,
6
],
[
7,
8
],
[
8,
9
],
[
9,
10
],
[
11,
12
],
[
12,
13
],
[
13,
9
],
[
9,
14
],
[
14,
15
],
[
15,
16
]
]
}
],
"images": [
{
"license": 0,
"file_name": "10084.jpg",
"height": 299,
"width": 298,
"id": 2889
},
{
"license": 0,
"file_name": "10112.jpg",
"height": 180,
"width": 215,
"id": 3928
}
],
"annotations": [
{
"segmentation": [],
"num_keypoints": 13,
"iscrowd": 0,
"keypoints": [
151.74249267578125,
251.90750122070312,
2.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
156.2274932861328,
136.0449981689453,
2.0,
94.18499755859375,
203.32000732421875,
2.0,
128.57000732421875,
246.6750030517578,
2.0,
119.5999984741211,
143.52000427246094,
2.0,
116.61000061035156,
85.9625015258789,
2.0,
109.13500213623047,
41.86000061035156,
2.0,
108.38749694824219,
7.474999904632568,
2.0,
44.849998474121094,
105.39749908447266,
2.0,
80.7300033569336,
112.125,
2.0,
0.0,
0.0,
0.0,
122.58999633789062,
47.84000015258789,
2.0,
87.4574966430664,
83.72000122070312,
2.0,
35.880001068115234,
97.17500305175781,
2.0
],
"image_id": 2889,
"bbox": [
3.737499952316284,
5.232500076293945,
169.68249821662903,
282.5550060272217
],
"category_id": 1,
"id": 7646,
"face_box": [
96.42749786376953,
12.707500457763672,
35.13249969482422,
29.15250015258789
],
"area": 47944.63930631365
},
{
"segmentation": [],
"num_keypoints": 14,
"iscrowd": 0,
"keypoints": [
0.0,
0.0,
0.0,
254.14999389648438,
219.76499938964844,
2.0,
0.0,
0.0,
0.0,
292.2724914550781,
147.25750732421875,
2.0,
223.50250244140625,
195.09750366210938,
2.0,
242.19000244140625,
276.57501220703125,
2.0,
264.614990234375,
150.9949951171875,
2.0,
233.22000122070312,
81.47750091552734,
2.0,
236.95750427246094,
59.0525016784668,
2.0,
230.9774932861328,
16.44499969482422,
2.0,
142.02499389648438,
66.52749633789062,
2.0,
180.89500427246094,
65.77999877929688,
2.0,
221.25999450683594,
63.537498474121094,
2.0,
260.87750244140625,
59.79999923706055,
2.0,
296.010009765625,
92.69000244140625,
2.0,
281.05999755859375,
146.50999450683594,
2.0
],
"image_id": 2889,
"bbox": [
117.35749816894531,
11.212499618530273,
181.6425018310547,
285.5450077056885
],
"category_id": 1,
"id": 7647,
"face_box": [
210.04750061035156,
19.434999465942383,
31.395004272460938,
38.12249946594238
],
"area": 51867.109585029044
},
{
"segmentation": [],
"num_keypoints": 7,
"iscrowd": 0,
"keypoints": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
38.70000076293945,
117.44999694824219,
2.0,
48.599998474121094,
71.0999984741211,
2.0,
66.5999984741211,
17.549999237060547,
2.0,
0.0,
0.0,
0.0,
3.1500000953674316,
158.39999389648438,
2.0,
3.5999999046325684,
74.69999694824219,
2.0,
97.19999694824219,
76.94999694824219,
2.0,
102.1500015258789,
145.35000610351562,
2.0,
0.0,
0.0,
0.0
],
"image_id": 3928,
"bbox": [
2.25,
10.350000381469727,
114.30000305175781,
169.2000026702881
],
"category_id": 1,
"id": 10379,
"face_box": [
30.600000381469727,
26.100000381469727,
47.24999809265137,
45.89999961853027
],
"area": 19339.56082157136
},
{
"segmentation": [],
"num_keypoints": 7,
"iscrowd": 0,
"keypoints": [
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
147.60000610351562,
126.9000015258789,
2.0,
155.6999969482422,
81.9000015258789,
2.0,
152.5500030517578,
25.200000762939453,
2.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
127.3499984741211,
93.1500015258789,
2.0,
198.4499969482422,
89.0999984741211,
2.0,
198.89999389648438,
163.35000610351562,
2.0,
148.5,
151.64999389648438,
2.0
],
"image_id": 3928,
"bbox": [
112.05000305175781,
18.450000762939453,
96.30000305175781,
161.10000228881836
],
"category_id": 1,
"id": 10380,
"face_box": [
132.3000030517578,
39.150001525878906,
44.55000305175781,
40.04999542236328
],
"area": 15513.930712051399
}
]
}
@@ -0,0 +1,462 @@
[
{
"joints_vis": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"joints": [
[
804.0,
711.0
],
[
816.0,
510.0
],
[
908.0,
438.0
],
[
1040.0,
454.0
],
[
906.0,
528.0
],
[
883.0,
707.0
],
[
974.0,
446.0
],
[
985.0,
253.0
],
[
982.7591,
235.9694
],
[
962.2409,
80.0306
],
[
869.0,
214.0
],
[
798.0,
340.0
],
[
902.0,
253.0
],
[
1067.0,
253.0
],
[
1167.0,
353.0
],
[
1142.0,
478.0
]
],
"image": "005808361.jpg",
"scale": 4.718488,
"center": [
966.0,
340.0
]
},
{
"joints_vis": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"joints": [
[
317.0,
412.0
],
[
318.0,
299.0
],
[
290.0,
274.0
],
[
353.0,
275.0
],
[
403.0,
299.0
],
[
394.0,
409.0
],
[
322.0,
275.0
],
[
327.0,
172.0
],
[
329.9945,
162.1051
],
[
347.0055,
105.8949
],
[
296.0,
135.0
],
[
281.0,
208.0
],
[
296.0,
167.0
],
[
358.0,
177.0
],
[
387.0,
236.0
],
[
392.0,
167.0
]
],
"image": "052475643.jpg",
"scale": 1.761835,
"center": [
316.0,
220.0
]
},
{
"joints_vis": [
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"joints": [
[
-1.0,
-1.0
],
[
1033.0,
649.0
],
[
1072.0,
474.0
],
[
973.0,
496.0
],
[
961.0,
650.0
],
[
-1.0,
-1.0
],
[
1023.0,
485.0
],
[
1031.0,
295.0
],
[
1026.998,
281.6248
],
[
997.002,
181.3752
],
[
988.0,
294.0
],
[
1018.0,
317.0
],
[
1070.0,
290.0
],
[
991.0,
300.0
],
[
912.0,
345.0
],
[
842.0,
330.0
]
],
"image": "051423444.jpg",
"scale": 3.139233,
"center": [
1030.0,
396.0
]
},
{
"joints_vis": [
0,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"joints": [
[
-1.0,
-1.0
],
[
804.0,
659.0
],
[
786.0,
498.0
],
[
868.0,
509.0
],
[
860.0,
693.0
],
[
-1.0,
-1.0
],
[
827.0,
504.0
],
[
840.0,
314.0
],
[
838.9079,
308.9326
],
[
816.0921,
203.0674
],
[
698.0,
264.0
],
[
740.0,
297.0
],
[
790.0,
300.0
],
[
889.0,
328.0
],
[
915.0,
452.0
],
[
906.0,
553.0
]
],
"image": "004645041.jpg",
"scale": 3.248877,
"center": [
809.0,
403.0
]
},
{
"joints_vis": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"joints": [
[
694.0,
684.0
],
[
685.0,
579.0
],
[
670.0,
437.0
],
[
747.0,
421.0
],
[
751.0,
574.0
],
[
768.0,
717.0
],
[
709.0,
429.0
],
[
649.0,
230.0
],
[
642.6337,
217.5659
],
[
591.3663,
117.4341
],
[
488.0,
351.0
],
[
551.0,
307.0
],
[
600.0,
242.0
],
[
698.0,
217.0
],
[
767.0,
310.0
],
[
790.0,
405.0
]
],
"image": "060754485.jpg",
"scale": 3.374796,
"center": [
698.0,
404.0
]
}
]
@@ -0,0 +1,760 @@
{
"info": {
"description": "For TRBMPI testing.",
"year": "2020",
"date_created": "2020/06/20"
},
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"left_shoulder",
"right_shoulder",
"left_elbow",
"right_elbow",
"left_wrist",
"right_wrist",
"left_hip",
"right_hip",
"left_knee",
"right_knee",
"left_ankle",
"right_ankle",
"head",
"neck",
"right_neck",
"left_neck",
"medial_right_shoulder",
"lateral_right_shoulder",
"medial_right_bow",
"lateral_right_bow",
"medial_right_wrist",
"lateral_right_wrist",
"medial_left_shoulder",
"lateral_left_shoulder",
"medial_left_bow",
"lateral_left_bow",
"medial_left_wrist",
"lateral_left_wrist",
"medial_right_hip",
"lateral_right_hip",
"medial_right_knee",
"lateral_right_knee",
"medial_right_ankle",
"lateral_right_ankle",
"medial_left_hip",
"lateral_left_hip",
"medial_left_knee",
"lateral_left_knee",
"medial_left_ankle",
"lateral_left_ankle"
]
}
],
"images": [
{
"file_name": "004645041.jpg",
"height": 720,
"width": 1280,
"id": 4645041
},
{
"file_name": "005808361.jpg",
"height": 720,
"width": 1280,
"id": 5808361
},
{
"file_name": "051423444.jpg",
"height": 720,
"width": 1280,
"id": 51423444
},
{
"file_name": "052475643.jpg",
"height": 480,
"width": 854,
"id": 52475643
},
{
"file_name": "060754485.jpg",
"height": 720,
"width": 1280,
"id": 60754485
}
],
"annotations": [
{
"num_joints": 38,
"keypoints": [
1067.0,
253.0,
2.0,
902.0,
253.0,
2.0,
1167.0,
353.0,
2.0,
798.0,
340.0,
2.0,
1142.0,
478.0,
2.0,
869.0,
214.0,
2.0,
1040.0,
454.0,
2.0,
908.0,
438.0,
2.0,
906.0,
528.0,
2.0,
816.0,
510.0,
2.0,
883.0,
707.0,
2.0,
804.0,
711.0,
2.0,
962.2409,
80.0306,
2.0,
982.7591,
235.9694,
2.0,
895.418,
241.258,
2,
1043.704,
160.177,
2,
901.513,
343.02,
2,
863.72,
263.644,
2,
837.5939,
349.993,
2,
862.766,
257.015,
2,
801.5946,
274.022,
2,
879.233,
196.169,
2,
1110.547,
339.254,
2,
1036.455,
221.547,
2,
1133.252,
424.742,
2,
1157.976,
298.364,
2,
1128.938,
496.521,
2,
1178.462,
418.695,
2,
906.36,
495.814,
2,
886.084,
430.921,
2,
921.047,
497.919,
2,
798.3963,
620.615,
2,
883.956,
622.444,
2,
0,
0,
0,
906.36,
495.814,
2,
1063.55,
427.43,
2,
858.607,
625.533,
2,
998.667,
532.689,
2,
0,
0,
0,
930.346,
637.297,
2
],
"image_id": 5808361,
"center": [
966.0,
340.0
],
"scale": 0.1756068552,
"category_id": 1,
"id": 2736,
"iscrowd": 0
},
{
"num_joints": 40,
"keypoints": [
358.0,
177.0,
2.0,
296.0,
167.0,
2.0,
387.0,
236.0,
2.0,
281.0,
208.0,
2.0,
392.0,
167.0,
2.0,
296.0,
135.0,
2.0,
353.0,
275.0,
2.0,
290.0,
274.0,
2.0,
403.0,
299.0,
2.0,
318.0,
299.0,
2.0,
394.0,
409.0,
2.0,
317.0,
412.0,
2.0,
347.0055,
105.8949,
2.0,
329.9945,
162.1051,
2.0,
288.387,
168.411,
2,
352.646,
153.542,
2,
278.645,
195.766,
2,
272.16,
185.5,
2,
295.672,
202.247,
2,
275.016,
171.472,
2,
297.774,
179.573,
2,
314.8,
136.217,
2,
362.128,
228.378,
2,
343.02,
176.81,
2,
402.3,
211.171,
2,
373.628,
192.749,
2,
389.14,
148.105,
2,
382.448,
186.517,
2,
340.876,
312.739,
2,
271.97,
273.448,
2,
323.194,
285.55,
2,
300.533,
368.868,
2,
328.476,
360.12,
2,
309.13,
434.758,
2,
340.876,
312.739,
2,
362.155,
232.654,
2,
381.581,
365.148,
2,
388.754,
284.757,
2,
396.32,
448.91,
2,
409.878,
357.015,
2
],
"image_id": 52475643,
"center": [
316.0,
220.0
],
"scale": 0.47030507400000005,
"category_id": 1,
"id": 28438,
"iscrowd": 0
},
{
"num_joints": 32,
"keypoints": [
991.0,
300.0,
2.0,
1070.0,
290.0,
2.0,
912.0,
345.0,
2.0,
1018.0,
317.0,
1.0,
842.0,
330.0,
2.0,
988.0,
294.0,
1.0,
973.0,
496.0,
2.0,
1072.0,
474.0,
2.0,
961.0,
650.0,
2.0,
1033.0,
649.0,
2.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
997.002,
181.3752,
2.0,
1026.998,
281.6248,
2.0,
1071.131,
283.036,
2,
969.6,
247.337,
2,
1087.017,
347.51,
2,
1058.52,
305.636,
2,
1026.458,
332.152,
2,
1014.72,
288.149,
2,
995.817,
309.098,
2,
980.493,
294.738,
2,
937.925,
366.241,
2,
987.08,
282.067,
2,
869.4918,
356.925,
2,
931.259,
311.619,
2,
844.2,
326.671,
2,
873.5471,
326.164,
2,
1004.56,
610.365,
2,
1075.26,
526.816,
2,
1005.788,
610.747,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1004.56,
610.365,
2,
935.105,
446.09,
2,
0,
0,
0,
937.158,
604.939,
2,
0,
0,
0,
0,
0,
0
],
"image_id": 51423444,
"center": [
1030.0,
396.0
],
"scale": 0.2639497014,
"category_id": 1,
"id": 27407,
"iscrowd": 0
},
{
"num_joints": 32,
"keypoints": [
889.0,
328.0,
2.0,
790.0,
300.0,
2.0,
915.0,
452.0,
2.0,
740.0,
297.0,
2.0,
906.0,
553.0,
2.0,
698.0,
264.0,
2.0,
868.0,
509.0,
2.0,
786.0,
498.0,
2.0,
860.0,
693.0,
2.0,
804.0,
659.0,
2.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
816.0921,
203.0674,
2.0,
838.9079,
308.9326,
2.0,
790.983,
286.144,
2,
864.959,
243.71,
2,
769.273,
388.686,
2,
780.19,
289.158,
2,
742.1957,
339.679,
2,
729.0975,
277.63,
2,
710.4349,
292.928,
2,
690.765,
253.113,
2,
871.88,
429.244,
2,
861.04,
275.182,
2,
894.319,
509.588,
2,
929.981,
418.01,
2,
901.22,
581.445,
2,
924.708,
508.795,
2,
823.63,
647.69,
2,
769.341,
541.653,
2,
850.322,
625.912,
2,
0,
0,
0,
0,
0,
0,
0,
0,
0,
823.63,
647.69,
2,
905.804,
486.059,
2,
0,
0,
0,
907.2,
647.636,
2,
0,
0,
0,
0,
0,
0
],
"image_id": 4645041,
"center": [
809.0,
403.0
],
"scale": 0.2550422514,
"category_id": 1,
"id": 26901,
"iscrowd": 0
},
{
"num_joints": 39,
"keypoints": [
698.0,
217.0,
2.0,
600.0,
242.0,
2.0,
767.0,
310.0,
2.0,
551.0,
307.0,
2.0,
790.0,
405.0,
2.0,
488.0,
351.0,
2.0,
747.0,
421.0,
2.0,
670.0,
437.0,
2.0,
751.0,
574.0,
2.0,
685.0,
579.0,
2.0,
768.0,
717.0,
2.0,
694.0,
684.0,
2.0,
591.3663,
117.4341,
2.0,
642.6337,
217.5659,
2.0,
584.59,
231.591,
2,
649.816,
141.342,
2,
605.668,
337.961,
2,
566.695,
256.226,
2,
581.685,
330.685,
2,
510.6881,
317.872,
2,
530.2038,
341.493,
2,
481.6367,
358.297,
2,
725.537,
311.805,
2,
651.465,
169.726,
2,
766.905,
363.613,
2,
774.747,
267.874,
2,
784.675,
432.399,
2,
796.495,
356.847,
2,
726.118,
528.068,
2,
649.638,
446.552,
2,
737.496,
516.31,
2,
667.32,
620.422,
2,
736.118,
628.657,
2,
663.697,
699.859,
2,
726.118,
528.068,
2,
799.279,
341.113,
2,
727.888,
644.205,
2,
798.633,
526.499,
2,
0,
0,
0,
799.314,
644.016,
2
],
"image_id": 60754485,
"center": [
698.0,
404.0
],
"scale": 0.24552578040000003,
"category_id": 1,
"id": 26834,
"iscrowd": 0
}
]
}
@@ -0,0 +1,504 @@
{
"categories": [
{
"keypoints": [
"nose",
"left_eye",
"right_eye",
"left_ear",
"right_ear",
"left_shoulder",
"right_shoulder",
"left_elbow",
"right_elbow",
"left_wrist",
"right_wrist",
"left_hip",
"right_hip",
"left_knee",
"right_knee",
"left_ankle",
"right_ankle"
],
"skeleton": [
[
16,
14
],
[
14,
12
],
[
17,
15
],
[
15,
13
],
[
12,
13
],
[
6,
12
],
[
7,
13
],
[
6,
7
],
[
6,
8
],
[
7,
9
],
[
8,
10
],
[
9,
11
],
[
2,
3
],
[
1,
2
],
[
1,
3
],
[
2,
4
],
[
3,
5
],
[
4,
6
],
[
5,
7
]
],
"id": 1,
"supercategory": "person",
"name": "person"
}
],
"images": [
{
"file_name": "003799.jpg",
"width": 900,
"height": 864,
"id": 1
},
{
"file_name": "000817.jpg",
"width": 665,
"height": 1000,
"id": 2
},
{
"file_name": "003896.jpg",
"width": 602,
"height": 900,
"id": 3
}
],
"annotations": [
{
"area": 356725,
"image_id": 1,
"iscrowd": 0,
"category_id": 1,
"bbox": [
250,
112,
475,
751
],
"segmentation": {
"counts": "Zei62gj08I7N2N2N2N1O1O001O1O1O001O1O4L3M3M2N2N1N3N1c_OdNU7]1jHhNQ7Y1nHlNm6V1PIPOk6Q1TITOh6l0fFcNnKf0W=h0kFjNeKc0[=d0oFQO]Ka0`=>SGQO\\Kg0[=9YGQOZKk0X=5^GPOYKS1g9mNoFWOnMk1R6oNYK]1\\9WO\\FnNkNa1T6mNWKd1W9EdEdNIX1U6lNUKe1V9f0`EjNU6kNUKf1S9f0cEjNT6kNUKh1Q9c0fEkNT6kNSKi1_4oMRNc2XLkNT6jNRKk1Z4bNfMo1jLkNT6iNRKm1S4SO]M]1ZMkNS6iNRKn1n3]OYMS1dMjNS6iNPKo1l33dL>]NhNS6nNjJk1l37dL;cNfNS6mNiJn1`3?nL2fNeNR6mNiJP2l2P1_MAiNcNS6lNhJT2[2Z1oMUOkNbNS6jNiJW2U2X1UNVOjNbNS6iNhJZ2Q2T1[NYOiNaNR6iNhJ\\2m1U1]NVOlN`NS6iNgJ^2h1X1[NUOSO]NS6hNfJa2d1Z1gMFLhMS6gNeJd2a1V6gM_HS6hNdJf2^1T6kM_Ho5`MRJW1f0h2Z1S6oM]HP6bMQJU1f0l2V1Q6SN\\HP6dMPJS1f0P3S1n5VNZHR6fMnIS1g0Q3o0m5ZNYHR6gMnIR1f0T3j0m5`NVHR6QOcJP3e0k5fNTHR6QOdJR3?k5kNRHR6QOdJa3N^5\\OPH^5EXKQ>ZOZBZ5I\\Km=ZOZBo44hKa=YO\\Bm44jK`=YO\\Bl45kK_=YO`Ah5Q1PK^=XO_Ai5U1nJn>R5TAmJl>R5VAnJj>Q5VAoJj>Q5WAnJj>R5VAnJi>R5XAmJi>S5WAlJi>U5WAkJi>T5WAlJi>U5WAgJm>X5TAdJX=F_Ag5ja0YJV^Og5ia0ZJU^Oi5ia0XJV^Oj5ia0VJW^Oj5ha0WJX^Oj5ea0RJa^On5l`0dJU_O]5\\`0oJf_OR5m?YKS@h4k?YKV@h4g?XK[@h4c?YK]@i4`?WKa@k4[?WKe@j4Y?WKf@l4X?TKh@n4U?RKm@o4P?RKQAo4l>RKUAP5g>QKZAP5b>RK_Ao4^>QKdAQ5W>PKkAQ5R>oJPBR5n=mJTBU5h=lJYBU5d=kJ^BV5_=jJcBX5Z=iJfBX5W=iJjBX5S=jJmBX5o<jJQCW5l<kJUCU5e<oJ\\CS5^<QKbCQ5Z<QKfCP5W<QKkCP5P<SKPDn4m;TKSDn4k;RKUDP5m;lJTDT5o;gJRD[5P<aJPDa5S<ZJmCg5X<SJhCo5]<jIcCW6b<cI^C_6j<WIVCk6m<PIRCR7n<mHRCV7l<hHUCZ7j<cHXC`7f<]H\\Cf7d<UH^Cn7f<jG[CY8d?2N3M3i_O^Gk=e8PB_Gn=]9TAgFi>_9o@fFU7HBg9RIeFY7O[Oa9UIcF^75UO^:h0eEUO]:j0fESO[:k0hERO[:k0iEROX:m0jEPOX:o0jEoNX:n0kEoNW:P1kEnNV:Q1lEmNV:P1lEnNV:Q1lEmNU:R1mElNU::eFD\\96kFHV94nFJT92QGLP93QGLQ91QGMQ91QGNP90RGNP91QGOo8OTGOn8MUG2l8LVG4j8JXG5i8IYG5i8JXG4k8JUG4n8JTG4n8KSG1Q9MQGOT9OmFOU9NnFOU9OmFOU9NmF1U9MjF1\\9CcFd0b9[O\\Ff0f9YOXFh0j9XOTFg0o9XOPFh0R:TOSEnKlMm4S=ROPEVLjMh4X=QOlD\\LeMf4a=mNhDaLdMc4e=kNeDfLbM`4k=iNbDkL_MY4T>^NiD\\MPMP4_>cN`D`MmLm3g>aNZDh1YMXK_>P3VDf1d<YNZCf1j<YNTCf1P=ZNmBe1W=ZNgBh1Z=XNcBj1^=VN_Bl1b=TN\\BVMRNh3c?RO[BmL_Nl3W?WOaCd0`<\\OdCPMWLU3W`0KnCNV<SOe_OdNY4R2V<XOd_OdNZ4o1T<\\Od_OcN\\4m1Q<^Og_OaN]4l1n;]Ol_OdNX4m1n;^Ol_ObNY4f0eKBW`0V1VESOWKVOe?g1UEoNZ<P1fCPOZ<P1gCnNZ<R1fCmN[<S1fCUNaJ4ia0g1i6O10001O001O001O0O101N1O2O001O000O2O001O001N100O2O0O2O001N2O0O2O1N101O1O0O2O001O1N101O1O001N101O0O2O00000O2O000O101O0O10001O0O10000O2O000O1O2N1N2N2ORhl1OPXSN1O001O1O100O001O1O1O1O001O1O1O1O001O1O1O1O001O1O1O1O001O1O1O001O0O2O00000000000O1000000O2O0000000O100000000O010000000O01000000000O010001O00001O0000002N1O2N2N1O0O100O1O1O1O100000001O2N1N2N3M3N3MShf4",
"size": [
864,
900
]
},
"num_keypoints": 17,
"id": 1,
"keypoints": [
371.5701271305881,
188.86769422623237,
2,
380.9752835872622,
174.5554996182501,
2,
353.4413472938106,
177.5542451551607,
2,
397.6046906555844,
184.91480238212299,
2,
328.49723669132726,
196.90978452976526,
2,
478,
258,
2,
302,
285,
2,
577,
287,
1,
343,
390,
2,
661,
282,
2,
431,
363,
2,
430,
486,
1,
352,
477,
2,
416,
662,
2,
335,
643,
2,
329,
785,
2,
307,
810,
2
]
},
{
"area": 154660,
"image_id": 2,
"iscrowd": 0,
"category_id": 1,
"bbox": [
147,
172,
220,
703
],
"segmentation": {
"counts": "ffn4=bn0=^Ob0]Ob0gNX1I7I7J5J7mNdLRVO`3ki0Q1M3L4G8G:K5K4L5K5K4L5J5L5J5K31Q1oN2M3N2N2N2M3N2N1O1N2O1O2N1O100O2O000O10001N1FhFdZOX9Ze0kFdZOV9Ye0nFfZOS9We0QGgZOj8\\e0g0I8G8I8H8H=B>m\\OaEd`0m:k^OgEd`0f<F;F:F9H9G6K3L5XCX@h9l?lE^@k9n?gE^@R:k?aE`@X:o?WEY@d:Xb0L4M3M3L4M4L3O1N2O1O1O1O1N2O1O10000OYMPFf]O0\\2P:d?WFZ^OIk1P:b?]Fi^OAd1R:V?gF[_OWO]1R:l<WF]BQ1@eNU1S:j<QIVBlLn0S:h<SI^BjLh0S:h:mFWDY2;hLd0Q:k:TKcDkJa0Q:l:RKgDlJ<R:m:QKiDnJ8Q:o:PKkDoJ5Q:P;oJnDPK0Q:R;nJQEPKLR:S;lJgFU5Y9hJjFX5V9lHiCWNg1kNUOS:[;fHgD_Mo0IlNR:];aHkG^M`LR:e;[HSHiMoKl9Y<kGPHT9V9`ERG^:n>N1O2N2N2N010O010O010O0100O0YM_Eh@a:S?iEh@V:T?QFi@P:R?WFl@k9n>[Fo@h9j>^FTAe9e>bFWAb9b>eF[A^9^>iF_AZ9Z>mFbAX9V>nFhAV9P>PGnAS9k=SGRBQ9g=UGWBm8c=YG[Bj8J\\DV<P3mCk8A_DZ<l2SDR9QO\\Dc<h2YDR:b;VFZDk9a;]FXDg9c;`FWDc9c;gFUD^9c;X5H8G8I7I7I7I7I7I7]FgZOP9`e0mFdZOo8_e0nFdZOR9\\e0kFhZOT9fe0M4F:F9@a0L4K5kMnXOnKWg0o3RYOcKVg0Z4QYOZKWg0f4YYOSK^f0o4UYOaKff0`4SYOeKnf0h4bXO[K`g0e4ZXO\\Klg0k56K6J6I8I8H8hKSWOh1Ti0nMYWOi1lh0PNbWOc1bh0XNiWO`1Yh0[NQXO_1Ph0[N[XO_1gg0[NcXO]1`g0]NkXO[1ij0H6J7I8I7J2M3I7JmYZ9",
"size": [
1000,
665
]
},
"num_keypoints": 16,
"id": 2,
"keypoints": [
274.6507065128343,
246.39765980455803,
2,
285.42040464043833,
233.5265571642508,
2,
260.99157718026333,
231.16247708745965,
2,
0,
0,
0,
239.45218092505533,
241.40682408688787,
2,
317,
320,
2,
205,
323,
2,
328,
415,
2,
183,
423,
2,
345,
506,
2,
173,
504,
2,
300,
495,
2,
230,
496,
2,
291,
661,
2,
240,
665,
2,
276,
763,
2,
245,
800,
2
]
},
{
"area": 94308,
"image_id": 2,
"iscrowd": 0,
"category_id": 1,
"bbox": [
143,
235,
174,
542
],
"segmentation": {
"counts": "Sme48on09G8H8H8H8H7I1O2N1^Ob0POP1J6]NeLTWOa3fh0kLmVO[3nh0QMfVOT3Ui0b1K5L3L5L3N3M2N3M4L4L3M4L4K5M2N3M3Mm0SO3N2M3M3M2N3O000O2O0O101O0O100O2O000O2O0O101O0O100O2O000@b0I9H8G9I7g^OWEh=Q;TAQFg>U:V@nFc?a<J5J7J5J7J5J7I7I6J7H7[Ca_OX:f`0ZEh_O_:_`0SEP@T:Pc0J6J4M1N2O0O2N2O1N2O1N2O01000O100000TMjEf@V:n>TFSAl9b>^F`Ab9o;ZFgB>\\1X9_;PGaB2R2n8o:fG[BFh2c8`:RJoChK0V:c;_J_D^KJS:[;iJoDVKAR:`;fJSEZKYOP:c;eJWE^KROl9h;dJZEbKjNj9l;bJ^EfKbNh9P<aJ`EjK\\Ne9T<_JdEnKTNb9X<PI[CUN]2YOmMc9[<[HWD]Nf1GeMa9^<VHdDTNa16ZM`9a<SHoDiM^1d0PMa9n<dGPHmNoJ_9c=oFbGl9P9_ETGa:i>0100O00100O00100O10O01O10O0`MZE_@f:Z?eEb@Z:X?PFe@o9U?\\Ff@f9R?dFk@^9k>lFSAW9e>PGXAS9a>TG\\Ao8]>XG_Al8Z>ZGcAj8V>]GfAg8S>`GiAd8P>cGlAa8m=eGPB_8j=gGSB]8f=iGVB\\8;mCQ<m3`C[86YDk;Qb0J4L3M3L4M3D<E;E;E;E;G;M4K5K4M2M3H7H9F:G900O100YMcYOaL^f0a3aYO^L_f0d3aYOYL`f0i3PYO^J8f1hf0o3mXO_J:`1if0Y4YYOeKhf0[4UYOhKkf0W4SYOkKof0S4oXOPLWg0l3dXOWLcg0d56J4kJVXOb2og0oLaXOl2dg0jLfXOQ3^g0gLkXOT3Yg0dLPYOV3Vg0aLXYOT3mf0eLbYOn2cf0jLnYOi2^i0J1O001gMiSO`1Vm0oNaROKbm0ObRO0am0JcRO5`m0FdRO9^m0AfRO>]m0\\OhROb0Pn0O101N2N3M3K5Kd^R9",
"size": [
1000,
665
]
},
"num_keypoints": 13,
"id": 3,
"keypoints": [
0,
0,
0,
0,
0,
0,
217.01654468945043,
302.1730492658786,
2,
0,
0,
0,
0,
0,
0,
285,
328,
2,
187,
339,
2,
293,
412,
2,
176,
414,
2,
308,
490,
2,
174,
495,
2,
270,
491,
2,
224,
493,
2,
271,
614,
1,
227,
614,
2,
225,
704,
2,
215,
716,
2
]
},
{
"area": 517461,
"image_id": 3,
"iscrowd": 0,
"category_id": 1,
"bbox": [
0,
39,
601,
861
],
"segmentation": {
"counts": "Xj0Y1jj02N101N10001N10000O0100O010O10O0100O02O00001N101O001N2O001O0O2O1O0O2O0UAUN]3l1aLZNY3h1fLXNZ3h1eLYN[3h1dLXN[3j1cLWN]3i1cLWN[EL[=o1XMVNZEN]=m1YMUNWE1_=l1XMSNXE4^=j1XMRNZE6]=i1XMQNZE8]=h1XMPNZE:j<^O_CZ2[:nM\\E<_<JeCm1_:mM]Ea0LXOT<f0nCe1d:mM\\Ei0`;l2RO[L^Ek0];l2TOZL^Ek0\\;m2UOZL]Ej0\\;n2TO[L^Ej0[;m2UOfM;k2CUM<n2CRM;P3EPM9S3GkLdEXN^:o4NhLcE\\N[:P52aLdEbNV:o46\\LdEjNo9BPF\\5]:iLDW3<jLEU3;jLFV39jLIT37lLKS35lLLT33lLOR32mLOS30nL1n22PM0n20QM4k2NSM6g2NVM6d2OYM6c2L[M8a2I_M:\\2IbM;Q20nM3k12TN1j1NVN4h1MXN5f1KZN7d1H]N:a1F_N<^1EcN<Y1FhN<S1FoN;l0HTO:g0H[OYMWNlIZ2l8AcD[Nm7NcJS2n8;\\LfMfJj1P9a0XLjMfJb1S9f0TLkMiJ\\1U9i0PLnMlJU1U9n0mKoMoJo0V9T1gKQNSKh0W9X1bKUNXK?X9\\1]KYN[K8Y9P1dKQOSKK[9S1aKVOUKC\\9U1^K\\OVK\\O]9W1]KAUKUO_9Y1[KFWKmN_9\\1ZKKVKfNb9S1_K=oJ]Nc9S1\\Kg0QKTNc9R1^Km0oJoMd9o0`KU1lJjMd9i0gK_1fJfMc9i0gKe1fJ_Me9i0fKk1fJYMd9l0eKn1gJTMd9n0dKQ2hJoLd9P1cKT2^7lM`HW2^7iM`HZ2_7fM`H]2^7dM`H_2^7aMaHb2]7^MaHe2^7\\M`Hg2^7ZM_Hj2_7VMTHPOkHm3P?TMSHTOhHk3S?RMnGa3P8_LoGd3n7^LQHc3n7^LPHe3n7[LRHg3l7ZLRHi3l7XLRHk3l7ULPHQ4n7PLmGU4R8lKjGY4U8fKjG]4T8dKkG]4U8bKjGa4T8`KjGb4U8_KiGc4W8\\KiGe4V8\\KhGn3WJPKP>S1gGn3^JjJl=W1eGP4cJeJh=\\1dGo3U9PLjFQ4W9oKgFR4Z9nKeFR4\\9mKdFS4\\9nKbFS4_9mK`FS4a9lK_FT4b9lK]FT4d9kK[FV4e9kKZFT4h9kKXFU4i9kKVFU4k9jKUFV4l9iKTFW4l9jKTFU4m9jKTFU4m9jKSFV4n9jKRFU4n9kKSFU4m9kKRFU4o9jKRFU4o9jKRFU4n9lKQFT4o9lKRFS4o9lKQFT4o9mKQFR4o9nKRFQ4o9nKQFR4o9nKRFQ4n9PLQFP4P:oKQFo3P:QLQFn3o9RLQFn3P:RLPFm3P:SLQFl3o9TLRFk3o9SLSFl3m9SLUFk3l9ULUFj3l9VLTFi3l9XLRFi3n9XLoEj3R:VLlEk3U:ULhEm3X:SLgEn3Z:RLdEo3]:QL`EQ4`:PL^EQ4c:oK[ER4e:oKYER4h:nKWER4j:nKTES4l:nKRET4n:lKPEU4P;lKnDU4S;jKmDV4S;kKkDV4U;kKjDU4W;kKgDV4Y;jKfDW4[;iKdDW4\\;jKbDW4^;iKaDX4`;hK_DX4a;iK]DX4c;hK\\DY4e;gKYDZ4g;gKWD[4i;dKVD]4j;dKUD\\4l;dKRD^4m;bKSD^4n;bKPD_4Q<aKmCa4R<`KlCa4U<_KiCb4X<^KgCc4X<^KfCc4[<]K\\Ck4d<VKYCm4g<SKXCm4i<SKUCn4k<SKSCn4n<QKRCo4n<RKnBP5T=PKiBR5W=oJeBS5]=lJaBV5_=kJ`BU5a=kJ^BT5c=lJ\\BU5e=kJZBT5g=mJWBU5i=jJVBW5j=jJTBX5l=hJRBY5n=gJQB[5o=eJcAh5]>XJbAj5^>VJ`Ak5a>UJ]Am5c>SJ[An5f>QJYAQ6g>oIWAR6i>oIUAS6k>mIRAU6o>jIPAW6Q?iIm@X6T?hIj@Y6V?hIg@Z6Z?fIc@]6\\?dIa@^6`?cI\\@_6d?cIY@^6h?cI`_OZN2U8_`0bIZ_ObN0m7f`0cIV_OU7k`0Q2001O1O001O0O2O010O0010O01O10O01O100O1O1000000001O000000001O0000001O0oLUEiDk:W;WEgDi:Y;YEeDh:Z;YEeDg:[;ZEdDf:\\;[EcDf:[;\\EdDd:\\;]EcDc:\\;_EcDa:];_EdDa:Z;aEeD_:[;cEcD^:[;dEdD]:[;dEdD^:Y;dEfD]:Y;dEfD^:W;eEgD[:Y;fEgDZ:h:XFVEh9i:\\FTEe9j:_FSEa9l:dFPE\\9o:kFkDU9U;PGeDP9\\;TG`Dk8a;ZGYDg8g;]GUDb8l;bGoC^8R<eG`Cf8`<]GYCf8b<_DSCQ31d8l<\\310O1O10O01O1;E1O1O00000O2O00M3M3O02O1O01O00001O01ON3Lb0_O5A?L4M4K4L4L4L8H5L1N2N3N100O2O0O100O100O10WL_EnE`:P:dEoE\\:n9gERFX:l9kETFU:i9nEWFR:f9RFYFm9f9VFXFl9oLbEP;0ZEe0f2k9hLeEV;1VEc0k2i9cLgEY;5RE>R3U:k7fEjD7[3Z9`L\\FX;^1YHT8cLZF\\:FkEo1W3o7jLTFm98mEh1\\3k7]7cFSEd1a3h7Y7XIhHf6W7\\IiHc6U7aIkH]6T7eImHY6R7jInHT6Q7nIPIQ6n6RJQIm5n6UJSIi5k6[JUIc5j6_JVI`5g6eJYIZ5a6lJ_IS5X6WKiIg4S6^KmIb4o5bKQJ]4l5gKUJW4h5mKYJQ4f5QLZJo3c5UL]Ji3b5YL^Jf3W1jFTOd5Ec3T1oFoNb5KS4a0]FAc5NS4=\\FAe50P4=^F_Oe54m3<_F]Oh55k3<^F\\Oj58h3;_F[Ok59d3>bFXOk5<\\3`0jFROl5c0R3=SGnNm5j0h29\\GlNn5o0`26cGjNn5T1Y23jGgNo5V1U24mGdNS6T1n1:oGaNZ6P1e1`0RH_N`6k0]1g0SH\\Ng6h0mHbLc7Z4jH[Nh6j0fHdLh7`0oGm2k0SOk6m0]HfLn7;PHP3j0ROm6\\18aLQHR3k0oNo6]14aLRHT3l0mNP7\\12aLTHV3k0lNQ7\\1O`LVHY3j0jNT7\\1LVL_He3a0iNV7[1<DaGeLm0[2X7\\18CdGfLl0[2Z7Z16DeGgLk0[2]7W12SOfGdM1Fj0]2`7R1OTOkGbMOKh0\\2c7P1IXOPH\\MOOe0]2i7j0C^ORHWM13b0]2n7e0]ODcHZM2]2T8`0UOJfHXM2]2V8>ROMgHWM1^2Y8;nN1iHVM0]2[8:mN1iHWM1]2[8:kN1jHWM1]2]88iNfMnGf1S2=W75hNdMRHa1D]N^2X2V74gNbMTHe1DXN^2\\2V73WOYOiId0Q71VO[OjIc0S7OSO]OlIc0S7NQO_OlId0U7KmNBoIb0W7IjNEPJa0W7IhNGRJ`0W7GgNIRJ`0X7GdNJUJ>Y7FbNLVJ>X7EaNNWJ=Y7D_N0YJ<Y7B^NH]GbNl2T2[7_O_NE`GfNg2V2[7]OcN^O`GnNc2V2\\7[OeN[OdJZ1i6YOcN[OgJ\\1g6WOcNYOiJ`1f6TObNZOkJb1d6RObNYOlJe1e6nN`NZOoJh1b6lN`NVOSKn1`6iNU3V1lLgNW3W1kLgNW3X1jLeNY3Y1hLfNZ3Y1gLdNZ3\\1gLbN[3^1fL_N[3a1gL[N\\3e1gLVN[3i1jLQNW3P2_;O100O1N2M3M3M3M201O1O001O1O00100O1O1O1O1O00010O00001O000010O01O100O1O010O010O0100O2O0O100O2N1O00001O0000000O101O0O1O1O1BiNnUOX1Qj0>N10100000000001OO01000000O1O100O1N2N3M2N3M2N3M2K5OO1O20O0000100O1O1O1O1O2N1N3QOnTOh0Xk0N3M2H8M3N3M2NTW3",
"size": [
900,
602
]
},
"num_keypoints": 12,
"id": 4,
"keypoints": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
446,
292,
2,
263,
225,
2,
540,
346,
2,
161,
269,
2,
560,
327,
2,
103,
312,
2,
308,
495,
2,
236,
491,
2,
352,
499,
2,
124,
652,
2,
442,
677,
2,
67,
827,
2
]
},
{
"area": 404028,
"image_id": 3,
"iscrowd": 0,
"category_id": 1,
"bbox": [
84,
45,
516,
783
],
"segmentation": {
"counts": "ln`2?ck04M2M3N2M3N2M3N2M3N2M3M4L3M3N3L5K4L5K5L2M3M2O2O0O2N2O0O2N101N2N2N2O1N2N2O1N2N4M4K4L2O1N2O1O000O10000000O1001N101O001O001O001O001O0010O01O1O001O1O3M;E1O2O0O2N1O2N2N1O2N1O3N2M3M3M3N2R@PKc8o4\\GQKe8o4YGSKh8l4VGUKl8f4e@fJ]6f0o8b4g@fJY6i0P9a4SG`Ko8_4PGaKR9]4mFcKV9\\4iFdKY9[4fFdK\\9[4cFfK_9Y4dARKX3d0W;Y4aATKW3a0[;Z4]AXKU3=`;Z4\\AZKR3;e;Z4YA]KP36k;\\4TAbKm21R<[4RAgKXO1U2Jf=]4m@kKiN>`2TOP>c4g@VMX1XNS>`4e@YMU1ZNY>Z4b@\\MS1[N_>U4_@`Mo0]Ng>o3Y@dMo0^Nl>j3V@hMk0_NT?f3Q@kMi0_N[?b3m_OoMe0`Na?`3i_OQNc0`Ng?]3g_OSN`0`Nk?]3e_OSN=`NR`0[3a_OVN;_NW`0Z3^_OWN7bN\\`0V3^_OXN1eNd`0R3[_OYNMgNj`0o2Z_OZNHjNPa0k2X_O[NDkN[;QO[Ig3gK]N_OlNa;SOWId3jK\\NZOnNh;TOSI`3lK^NUOPOn;UOnH]3oK^NQOROS<VOlHX3QL`NgNXO_<ROhHT3SL9W;eLdHQ3VL8W;iLcHm2WL6Z;mL_Hl2WL3^;SM[Hh2XL2`;VMXHg2XL1c;XMVHe2XL0d;]MSHb2ZL0d;^MSH`2YL2d;_MSH_2YL1e;`MSH]2XL3f;aMQH\\2YL1g;dMQHZ2WL2i;dMPHY2XL2h;fMQHW2WL2i;fMQHX2UL1k;hMQHV2TL0l;jMRHT2RL0o;lMoGT2RLNP<nMPHS2PLMR<PNnGS2oKKU<RNnGQ2nKKV<TNlGQ2mKHZ<WNkGP2kKE^<[NgGP2kKAa<_NeGo1jKAc<`NcGo1jK^Oe<cNaGP2jK[Og<eN_GP2iKYOj<gN^Go1iKjNX=WOPGo1hKhNY=ZOoFn1gKgN[=[OoFm1gKeN\\=_OlFm1hKbN]=AlFm1fKaN_=CkFk1RLTNT=2kFj1]L\\Mk<S1hF`1l;aNUD_1i;cNVD]1i;dNXD\\1f;fNZDZ1d;gN]DX1b;jN]DW1b;iN_DV1a;kN_DU1_;lNaDT1_;mNaDS1^;mNbDT1];mNcDR1\\;oNdDR1[;oNeDQ1Y;POhDo0X;ROgDo0W;ROjDn0U;SOjDn0U;ROlDn0S;ROnDn0j6]MQGe1T2o0l4gMZFi0c1a0X3o0k4jMVFR1\\15c3o0l4lMPF^1T1GQ4o0k4nMlEk1j0YO^4o0l4PNgEY2`0gNn4P1k4RNcEa2;^NW5o0k4UN_Ec2:ZN\\5n0k4WNVEm2>mMa5P1l4b2]E_Lg5o0l4o4UKQKk4o4TKRKl4n4TKRKl4m4UKSKl4l4TKTKl4k4TKVKl4j4TKWKk4h4VKXKk4g4UKYKk4g4TKZKm4d4TK]Kl4b4TK^Kl4a4UK_Kl4`4SKbKl4]4UKcKl4\\4TKeKk4[4UKeKl4Y4TKiKl4V4TKjKl4U4UKkKl4T4TKmKk4R4VKnKj4R4WKnKh4R4XKSIcI^2U;^4ZKQIeI_2Q;`4ZKPIiI^2l:a4]KoHjI]2j:d4\\KnHmI\\2g:f4]KkHPJ\\2d:h4ULTKl3l4VLRKi3n4ZLoJg3Q5[LlJe3T5_LXJR4h5PLkI[4U6gK`Ia4`6cKWIc4i6_KoHg4P7V810O01000O010UKS[O^2md0dMS[O[2md0fMS[OX2md0jMT[OT2ld0nMS[OQ2ld0QNT[Om1md0TNS[Ok1ld0WNT[Og1md0[NS[O\\Nn0S1nc0c0U[OjMc1[1Wc0l0g]OlNZb0T1m]OdNTb0]1S^OZNna0f1W^OTNla0j1X^OQNja0n1Y^OnMia0R2Z^OiMha0V2[^OfMga0Y2]^ObMea0]2_^O^Mca0b2P4O1O2N3N1N2N3M2O2M3_NoUOi0Uj0POoUOP1Sj0hNRVOY1\\j0010O010000O10000O1000]LhNY\\OW1ec0mN[\\OR1bc0RO]\\Om0ac0VO`\\Oi0]c0[Oc\\Od0Zc0_Og\\O`0Ub0nNX[Of0b2<na0WO\\[O`0g28ea0V1\\^OiN_a0\\1a^OdN\\a0^1f^OaNVa0c1k^O]Na`0WOP\\O_2`3ZN^`0W2c_OhM[`0Y2f_OgMX`0[2i_OcMV`0^2k_ObMS`0`2m_O`MQ`0c2n_O\\MQ`0h2m_OXMP`0m2o_OQMP`0S3n_OmLP`0V3o_OjLn?Z3Q@eLn?^3R@aLk?b3V@]Lh?e3Y@YLf?i3[@VL]:[ORGb4bNQLZ:BPG_4gNnKW:FnF_4lNjKS:JoF^4oNfKQ:NlF`4SObKn91hFd4YO[Ko92bFi4_OUKP:1[FP5EoJQ:0UFV5JiJR:1oE\\5NcJS:0mE`50`JS:0jEc53]JS:0hEe55ZJT:0eEh58XJS:0bEj5<VJR:0_El5?TJT:O[Eo5l>PJRAQ6P?oIn@Q6T?oIi@R6Y?nIe@R6]?mIc@S6^?mI`@S6b?mI]@R6e?nIZ@P6i?PJV@j5Q`0VJm_Oh5W`0WJi_Og5Z`0YJe_Od5_`0\\J__Oc5d`0]J\\_O`5g`0_JY_O_5j`0`JV_O]5o`0aJQ_OR5]a0mJc^Oo4ba0QK^^Ok4fa0TKZ^Oh4ka0WKU^Og4S1WKR=1kAf4V1\\Kk<NoAc4Z1cKc<JSB`4]1jK\\<FVB_4`1oKV<AZB^4c1ULn;^O^B[4g1ZLh;ZOaB[4i1^Lc;WOdBX4l1cL^;UOeBV4P2gLf8ROZE10U4Q2iLc8SO\\EOOS4U2lL\\8TOaEMMQ4Y2nLW8VOcEJNo3[2RMP8WOhEHLm3_2UMj7XOkEFKk3c2WMd7ZO]H]32ZM^7[O_HY36\\MX7]OcHT38`MR7^OeHP3<bMl6@hHm2=fMg6_OkHi2a0iMa6_OoHe2c0nMY6@SI`2g0QNS6@VI^2i0SNm5BZIX2l0XNf5A^IU2o0[N_5CaIQ2R1^NY5BfIm1T1aNS5EhIh1X1cNn4FkId1Z1gNg4HnI`1]1hNc4JPJ[1`1kN^4LQJW1e1mNY4LRJT1h1POV4LQJR1l1ROR4MQJo0P2UOn3LRJl0T2XOh3LTJk0V2ZOe3KUJh0Y2^O`3KVJf0]2_O\\3KVJe0`2AX3KXJb0b2DU3JVJc0g2EQ3HVJc0k2Fm2HVJb0n2Hk2FUJ`0T3Ke2EUJ?Y3Na2CUJ<]31^2DTJ8b33[2DSJ7d34[2EoI5j35W2GnI2m37V2FmI0Q49R2HlIMT4;Q2GlIKU4>P2GkIHX4`0n1HSJ\\OQ4l0m1Gf38[LHd38]LHc37^LHb38_LHa37`LH`38aLH_37bLI^36cLI]37dLI\\36eLI\\36eLJZ36fLKZ33hLLY33hLMW33jLLW33jLMU32lLOT30mLOS31nLOR30oLOQ31PMOP3ORM0n20RM1n2NSM2l2MVM2k2MVM3i2LYM3h2KYM6f2J[M6d2I^M6c2I^M7a2HaM7_2IaM8^2GdM9\\2FeM:Z2EhM;W2EjM;V2ClM=T2BmM>R2APN?P2@PNa0P2]ORNc0m1]OTNc0l1[OVNe0j1ZOWNf0h1YOZNg0f1XO[Nh0e1VO]Nj0b1UO`Nl0_1ROcNo0\\1oNeNR1[1lNgNW1V1gNlN]1_CaNY=OZOl1c0SN^Oo1`0oMBS2W=1O1N0`VOlMQi0S2dVOXN]i0W21O1O1O1O010O1O1N2L4L4M2F;L3M4L3M4M2N3L3N3M2N3O0O2O0O2O0O2O0O2O002M5L3M4L_d0",
"size": [
900,
602
]
},
"num_keypoints": 15,
"id": 5,
"keypoints": [
138.28123044948043,
178.42673457794075,
2,
133.4071828533262,
152.16976849543238,
2,
0,
0,
0,
168.78333476089736,
123.08271026031831,
2,
0,
0,
0,
201,
192,
2,
322,
124,
1,
249,
344,
1,
488,
172,
2,
219,
433,
1,
572,
238,
2,
436,
381,
2,
439,
380,
2,
354,
608,
2,
307,
523,
1,
494,
683,
2,
313,
753,
2
]
}
],
"info": {
"description": "MMPose example ochuman dataset",
"version": "1.0",
"year": "2020",
"date_created": "2020/08/31"
}
}
@@ -0,0 +1,541 @@
{
"info": {
"description": "OneHand10K",
"version": "1.0",
"year": "2020",
"date_created": "2020/08/03"
},
"licenses": "",
"images": [
{
"file_name": "9.jpg",
"height": 358,
"width": 238,
"id": 9
},
{
"file_name": "33.jpg",
"height": 346,
"width": 226,
"id": 33
},
{
"file_name": "784.jpg",
"height": 960,
"width": 540,
"id": 784
},
{
"file_name": "1402.jpg",
"height": 339,
"width": 226,
"id": 1402
}
],
"annotations": [
{
"bbox": [
63,
92,
99,
194
],
"keypoints": [
0,
0,
0,
81,
251,
1,
71,
229,
1,
72,
192,
1,
76,
169,
1,
95,
196,
1,
91,
144,
1,
93,
122,
1,
91,
98,
1,
116,
199,
1,
111,
148,
1,
108,
120,
1,
107,
101,
1,
139,
203,
1,
130,
153,
1,
128,
124,
1,
122,
107,
1,
154,
205,
1,
150,
177,
1,
147,
159,
1,
142,
132,
1
],
"category_id": 1,
"id": 9,
"image_id": 9,
"segmentation": [
[
63,
92,
63,
188.5,
63,
285,
112.0,
285,
161,
285,
161,
188.5,
161,
92,
112.0,
92
]
],
"iscrowd": 0,
"area": 19206
},
{
"bbox": [
61,
154,
34,
68
],
"keypoints": [
86,
221,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
92,
176,
1,
90,
168,
1,
90,
160,
1,
92,
189,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
87,
191,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
79,
194,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"category_id": 1,
"id": 33,
"image_id": 33,
"segmentation": [
[
61,
154,
61,
187.5,
61,
221,
77.5,
221,
94,
221,
94,
187.5,
94,
154,
77.5,
154
]
],
"iscrowd": 0,
"area": 2312
},
{
"bbox": [
51,
312,
376,
372
],
"keypoints": [
153,
652,
1,
198,
486,
1,
258,
438,
1,
333,
384,
1,
393,
352,
1,
160,
369,
1,
274,
334,
1,
325,
337,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
412,
418,
1,
0,
0,
0,
334,
454,
1,
303,
492,
1,
270,
540,
1,
0,
0,
0,
325,
508,
1,
295,
544,
1,
258,
562,
1
],
"category_id": 1,
"id": 784,
"image_id": 784,
"segmentation": [
[
51,
312,
51,
497.5,
51,
683,
238.5,
683,
426,
683,
426,
497.5,
426,
312,
238.5,
312
]
],
"iscrowd": 0,
"area": 139872
},
{
"bbox": [
32,
68,
150,
210
],
"keypoints": [
92,
264,
1,
150,
213,
1,
167,
202,
1,
172,
187,
1,
174,
172,
1,
126,
164,
1,
142,
147,
1,
157,
151,
1,
163,
168,
1,
105,
151,
1,
108,
120,
1,
112,
98,
1,
109,
70,
1,
85,
157,
1,
77,
132,
1,
78,
108,
1,
72,
89,
1,
74,
174,
1,
63,
157,
1,
47,
137,
1,
37,
119,
1
],
"category_id": 1,
"id": 1402,
"image_id": 1402,
"segmentation": [
[
32,
68,
32,
172.5,
32,
277,
106.5,
277,
181,
277,
181,
172.5,
181,
68,
106.5,
68
]
],
"iscrowd": 0,
"area": 31500
}
],
"categories": [
{
"supercategory": "hand",
"id": 1,
"name": "hand",
"keypoints": [
"wrist",
"thumb1",
"thumb2",
"thumb3",
"thumb4",
"forefinger1",
"forefinger2",
"forefinger3",
"forefinger4",
"middle_finger1",
"middle_finger2",
"middle_finger3",
"middle_finger4",
"ring_finger1",
"ring_finger2",
"ring_finger3",
"ring_finger4",
"pinky_finger1",
"pinky_finger2",
"pinky_finger3",
"pinky_finger4"
],
"skeleton": [
[
1,
2
],
[
2,
3
],
[
3,
4
],
[
4,
5
],
[
1,
6
],
[
6,
7
],
[
7,
8
],
[
8,
9
],
[
1,
10
],
[
10,
11
],
[
11,
12
],
[
12,
13
],
[
1,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
1,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
]
]
}
]
}
@@ -0,0 +1,565 @@
{
"info": {
"description": "panoptic",
"version": "1.0",
"year": "2020",
"date_created": "2020/09/21"
},
"licenses": "",
"images": [
{
"file_name": "005880453_01_l.jpg",
"height": 720,
"width": 1280,
"id": 100586
},
{
"file_name": "005880453_01_r.jpg",
"height": 720,
"width": 1280,
"id": 100587
},
{
"file_name": "ex2_2.flv_000040_l.jpg",
"height": 300,
"width": 400,
"id": 100520
},
{
"file_name": "ex2_2.flv_000040_r.jpg",
"height": 300,
"width": 400,
"id": 100521
}
],
"annotations": [
{
"bbox": [
720.32470703125,
188.09907531738278,
55.445434570312614,
36.900924682617216
],
"head_size": 140.0,
"center": [
747.5474243164062,
206.0495376586914
],
"keypoints": [
721.0,
224.0,
1.0,
720.32470703125,
216.51248168945315,
1.0,
727.2195434570314,
200.88510131835943,
1.0,
739.107177734375,
194.2553100585938,
1.0,
752.6591186523438,
191.17718505859378,
1.0,
740.0582275390625,
188.09907531738278,
1.0,
757.6519165039061,
189.75651550292972,
1.0,
760.98046875,
196.62309265136716,
1.0,
760.98046875,
202.77932739257812,
1.0,
742.9112548828123,
196.14953613281247,
1.0,
753.3723754882812,
189.75651550292972,
1.0,
765.0222778320311,
199.93798828125,
1.0,
767.6375122070312,
207.04133605957034,
1.0,
747.6663208007811,
202.5425567626953,
1.0,
757.1763916015626,
197.80697631835943,
1.0,
769.3018188476562,
203.72644042968753,
1.0,
772.3925781249999,
209.40911865234378,
1.0,
753.610107421875,
209.17234802246097,
1.0,
761.6937255859375,
205.85745239257815,
1.0,
769.7772827148438,
208.93556213378903,
1.0,
774.7701416015626,
213.43435668945315,
1.0
],
"category_id": 1,
"id": 100586,
"image_id": 100586,
"segmentation": [
[
720.32470703125,
188.09907531738278,
720.32470703125,
206.0495376586914,
720.32470703125,
224.0,
747.5474243164062,
224.0,
774.7701416015626,
224.0,
774.7701416015626,
206.0495376586914,
774.7701416015626,
188.09907531738278,
747.5474243164062,
188.09907531738278
]
],
"iscrowd": 0,
"area": 2045.9878050740865,
"dataset": "mpii"
},
{
"bbox": [
746.0122680664061,
313.11645507812494,
50.4322509765625,
77.21240234375
],
"head_size": 140.0,
"center": [
770.7283935546874,
351.22265624999994
],
"keypoints": [
746.0122680664061,
363.82229614257807,
1.0,
750.3375854492186,
347.22766113281256,
1.0,
766.0941162109375,
330.6329956054688,
1.0,
778.1432495117188,
324.1795349121093,
1.0,
785.2490844726564,
313.11645507812494,
1.0,
787.720703125,
349.3788146972656,
1.0,
795.4445190429686,
349.3788146972656,
1.0,
790.5012817382812,
348.7641906738282,
1.0,
785.5580444335938,
347.5349426269532,
1.0,
787.720703125,
362.90036010742193,
1.0,
793.8997802734376,
360.74920654296875,
1.0,
785.5580444335938,
359.51998901367193,
1.0,
780.9237670898438,
359.2126770019531,
1.0,
783.7043457031251,
374.2707824707031,
1.0,
791.4281616210938,
374.57806396484375,
1.0,
784.3222656249998,
371.5050048828125,
1.0,
778.7611083984374,
370.2757568359375,
1.0,
777.8342895507812,
384.71923828124994,
1.0,
782.1596069335938,
389.32885742187494,
1.0,
774.435791015625,
385.3338623046875,
1.0,
771.9641723632812,
382.87539672851557,
1.0
],
"category_id": 1,
"id": 100587,
"image_id": 100587,
"segmentation": [
[
746.0122680664061,
313.11645507812494,
746.0122680664061,
351.22265624999994,
746.0122680664061,
389.32885742187494,
770.7283935546874,
389.32885742187494,
795.4445190429686,
389.32885742187494,
795.4445190429686,
351.22265624999994,
795.4445190429686,
313.11645507812494,
770.7283935546874,
313.11645507812494
]
],
"iscrowd": 0,
"area": 3893.9952535033226,
"dataset": "mpii"
},
{
"bbox": [
179.84646606445315,
260.29730224609364,
42.822525024414034,
30.21246337890642
],
"head_size": 72.5531,
"center": [
200.75772857666016,
274.9035339355469
],
"keypoints": [
221.6689910888672,
260.29730224609364,
1.0,
211.34570312499997,
260.29730224609364,
1.0,
192.55204772949222,
265.0344543457031,
1.0,
188.31684875488278,
271.0874938964844,
1.0,
180.90525817871094,
275.82464599609375,
1.0,
192.02264404296878,
265.2976379394531,
1.0,
179.84646606445315,
278.7195739746093,
1.0,
186.4639587402344,
279.7722778320313,
1.0,
190.43444824218753,
275.82464599609375,
1.0,
194.4049377441406,
271.6138305664063,
1.0,
187.52275085449222,
284.7726135253906,
1.0,
192.8167419433594,
282.14086914062506,
1.0,
195.72843933105474,
278.4563903808594,
1.0,
201.28712463378906,
277.93005371093744,
1.0,
194.14024353027344,
288.1938781738282,
1.0,
199.6989288330078,
285.0357971191406,
1.0,
202.34593200683594,
282.14086914062506,
1.0,
207.1105194091797,
281.35131835937494,
1.0,
201.28712463378906,
289.50976562500006,
1.0,
204.72822570800778,
286.3516540527344,
1.0,
207.1105194091797,
284.7726135253906,
1.0
],
"category_id": 1,
"id": 100520,
"image_id": 100520,
"segmentation": [
[
179.84646606445315,
260.29730224609364,
179.84646606445315,
274.9035339355469,
179.84646606445315,
289.50976562500006,
200.75772857666016,
289.50976562500006,
221.6689910888672,
289.50976562500006,
221.6689910888672,
274.9035339355469,
221.6689910888672,
260.29730224609364,
200.75772857666016,
260.29730224609364
]
],
"iscrowd": 0,
"area": 1293.7739690924127,
"dataset": "nzsl"
},
{
"bbox": [
186.37617492675776,
196.84266662597656,
46.34579467773443,
44.16563415527344
],
"head_size": 72.5531,
"center": [
209.04907226562497,
218.42548370361328
],
"keypoints": [
186.37617492675776,
232.66671752929688,
1.0,
190.1365051269531,
223.60145568847656,
1.0,
200.65892028808597,
212.39300537109378,
1.0,
212.89080810546878,
203.87417602539062,
1.0,
219.56018066406247,
196.84266662597656,
1.0,
205.30081176757812,
208.3026885986328,
1.0,
217.7982025146484,
207.76916503906244,
1.0,
227.2103424072266,
213.4448394775391,
1.0,
231.7219696044922,
220.28102111816406,
1.0,
198.5165100097656,
212.5708312988281,
1.0,
219.04794311523443,
217.55035400390625,
1.0,
223.4833374023438,
223.01550292968747,
1.0,
226.81802368164062,
230.0469970703125,
1.0,
196.21739196777344,
218.71846008300778,
1.0,
215.47726440429688,
225.73097229003903,
1.0,
219.04794311523443,
232.31103515625,
1.0,
213.47929382324216,
232.78147888183597,
1.0,
200.53286743164062,
233.95339965820318,
1.0,
211.71386718749997,
236.68786621093753,
1.0,
216.81396484374997,
240.00830078125,
1.0,
210.92922973632812,
239.6176605224609,
1.0
],
"category_id": 1,
"id": 100521,
"image_id": 100521,
"segmentation": [
[
186.37617492675776,
196.84266662597656,
186.37617492675776,
218.42548370361328,
186.37617492675776,
240.00830078125,
209.04907226562497,
240.00830078125,
231.7219696044922,
240.00830078125,
231.7219696044922,
218.42548370361328,
231.7219696044922,
196.84266662597656,
209.04907226562497,
196.84266662597656
]
],
"iscrowd": 0,
"area": 2046.8914123722377,
"dataset": "nzsl"
}
],
"categories": [
{
"supercategory": "hand",
"id": 1,
"name": "hand",
"keypoints": [
"wrist",
"thumb1",
"thumb2",
"thumb3",
"thumb4",
"forefinger1",
"forefinger2",
"forefinger3",
"forefinger4",
"middle_finger1",
"middle_finger2",
"middle_finger3",
"middle_finger4",
"ring_finger1",
"ring_finger2",
"ring_finger3",
"ring_finger4",
"pinky_finger1",
"pinky_finger2",
"pinky_finger3",
"pinky_finger4"
],
"skeleton": [
[
1,
2
],
[
2,
3
],
[
3,
4
],
[
4,
5
],
[
1,
6
],
[
6,
7
],
[
7,
8
],
[
8,
9
],
[
1,
10
],
[
10,
11
],
[
11,
12
],
[
12,
13
],
[
1,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
1,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
]
]
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
{ "version": 0.7,
"univTime" :47896.621,
"fpsType" :"hd_29_97",
"bodies" :
[
{ "id": 0,
"joints19": [124.136, -105.991, -30.2854, 0.709717, 104.413, -117.401, -25.8053, 0.686829, 127.045, -63.7183, -29.9739, 0.446899, 120.248, -106.955, -45.6063, 0.575806, 111.254, -82.5488, -60.3606, 0.579651, 97.5534, -67.5661, -41.9563, 0.475403, 124.375, -63.6942, -41.0662, 0.417236, 83.4269, -47.7217, -38.6838, 0.203247, 0, 0, 0, -1, 128.266, -105.85, -14.7877, 0.602417, 127.309, -81.7486, 0.513331, 0.651978, 111.735, -70.4044, -14.4066, 0.506653, 129.716, -63.7424, -18.8814, 0.444885, 96.4134, -42.8902, 0.798849, 0.232483, 69.8839, -9.69057, 2.89286, 0.157349, 104.805, -121.062, -29.0914, 0.532288, 112.683, -122.17, -35.3427, 0.396851, 106.05, -121.316, -23.1694, 0.572449, 115.614, -122.634, -20.4819, 0.516724]
},
{ "id": 1,
"joints19": [5.6087, -91.7251, 5.67075, 0.482361, 9.08691, -85.5182, -11.6583, 0.199097, 1.66692, -67.5066, 46.3826, 0.227905, 19.3811, -92.0237, 9.78557, 0.396667, 16.9647, -71.8503, 24.8387, 0.320435, 12.7281, -59.21, 8.82053, 0.295654, 9.3541, -67.7975, 46.523, 0.236145, 18.8347, -41.2812, 16.8548, 0.281738, 12.0261, -7.27261, 26.7646, 0.333557, -7.55927, -92.2895, 3.18333, 0.382874, -27.683, -73.6808, 6.9749, 0.261841, -13.6486, -60.4171, 9.29562, 0.138, -6.02027, -67.2158, 46.2422, 0.18158, -16.8764, -40.5201, 19.3464, 0.276733, -8.86912, -6.4542, 26.0121, 0.28595, 9.95262, -88.5757, -11.2162, 0.143005, 13.9014, -94.8183, -5.44828, 0.313904, 4.81003, -88.1194, -11.7807, 0.144226, -0.772542, -94.5733, -6.32695, 0.250549]
},
{ "id": 2,
"joints19": [-46.623, -91.9748, -46.2094, 0.432495, -24.8662, -90.1627, -46.21, 0.392395, -75.3649, -54.9062, -38.0726, 0.157349, -43.6166, -91.045, -29.2171, 0.349304, -39.1777, -59.7671, -26.5732, 0.293274, -27.2637, -45.0868, -41.3075, 0.192017, -74.8994, -55.0912, -27.8377, 0.165894, -31.1378, -46.3092, -19.0025, 0.293518, -55.7049, -13.0915, -25.5646, 0.224976, -48.6966, -91.4388, -65.3742, 0.311768, -41.5079, -71.8104, -84.3137, 0.330261, -38.8408, -64.6871, -61.4434, 0.23877, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -24.2805, -94.9466, -43.9519, 0.356812, -31.8517, -101.665, -40.2811, 0.385071, -24.9661, -93.5623, -49.2523, 0.2229, -31.0232, -98.0451, -55.4795, 0.279053]
}
] }
@@ -0,0 +1,15 @@
{ "version": 0.7,
"univTime" :47929.977,
"fpsType" :"hd_29_97",
"bodies" :
[
{ "id": 0,
"joints19": [124.147, -105.973, -30.3072, 0.709717, 104.374, -117.36, -25.733, 0.686829, 127.183, -63.4893, -30.0803, 0.446899, 120.073, -106.823, -45.7773, 0.575806, 111.752, -82.4054, -59.6925, 0.579651, 98.0636, -68.2993, -41.7845, 0.475403, 124.546, -63.5584, -41.3032, 0.417236, 82.7474, -47.6873, -38.9817, 0.203247, 0, 0, 0, -1, 128.539, -105.963, -14.9304, 0.602417, 127.104, -81.4156, 0.247136, 0.651978, 111.693, -68.1563, -14.442, 0.506653, 129.82, -63.4201, -18.8574, 0.444885, 96.2478, -42.7821, 0.805848, 0.232483, 69.9732, -9.8122, 2.74933, 0.157349, 104.724, -121.033, -28.9868, 0.532288, 112.609, -122.205, -35.2695, 0.396851, 105.982, -121.283, -23.115, 0.572449, 115.59, -122.596, -20.5341, 0.516724]
},
{ "id": 1,
"joints19": [5.04299, -94.3889, 5.11889, 0.482361, 7.96533, -87.0756, -12.5883, 0.199097, 1.01761, -67.6827, 45.8372, 0.227905, 18.8279, -94.4092, 9.16816, 0.396667, 16.9833, -73.798, 24.051, 0.320435, 13.7023, -60.619, 8.29119, 0.295654, 9.38785, -67.9091, 45.5134, 0.236145, 18.7713, -41.7337, 15.9782, 0.281738, 12.1838, -7.47727, 26.3543, 0.333557, -8.15184, -94.0344, 2.74916, 0.382874, -27.5733, -74.6123, 6.71778, 0.261841, -11.5391, -62.3807, 6.49904, 0.138, -7.35263, -67.4562, 46.1611, 0.18158, -16.292, -40.381, 19.0151, 0.276733, -8.81955, -6.61585, 25.9785, 0.28595, 9.40427, -90.5736, -11.3424, 0.143005, 13.4035, -96.5672, -5.99329, 0.313904, 3.80369, -90.1657, -12.6569, 0.144226, -1.05309, -95.823, -6.96162, 0.250549]
},
{ "id": 2,
"joints19": [-47.6019, -93.4704, -46.6587, 0.432495, -26.2199, -91.5537, -46.2747, 0.392395, -75.3649, -54.9062, -38.0726, 0.157349, -44.5263, -91.3939, -29.3512, 0.349304, -40.4455, -62.5189, -26.2502, 0.293274, -28.7968, -47.0727, -40.3408, 0.192017, -75.2261, -55.2629, -28.1895, 0.165894, -31.459, -46.5397, -18.7491, 0.293518, -55.7543, -13.1495, -25.2371, 0.224976, -50.2673, -93.2394, -65.8827, 0.311768, -41.5254, -72.5218, -84.4612, 0.330261, -38.9596, -65.8381, -61.5105, 0.23877, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, -1, -25.5114, -96.8998, -43.1621, 0.356812, -33.2547, -102.681, -40.4011, 0.385071, -26.3223, -94.9484, -49.0802, 0.2229, -32.1236, -99.3278, -55.4444, 0.279053]
}
] }
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
{ "version": 0.7,
"univTime" :47884.218,
"fpsType" :"hd_29_97",
"bodies" :
[
{ "id": 0,
"joints19": [112.193, -105.597, -63.2943, 0.681274, 98.5895, -126.086, -55.7911, 0.631165, 109.902, -62.3343, -62.7694, 0.434326, 103.926, -106.634, -77.9832, 0.634766, 96.8314, -78.8763, -80.315, 0.630554, 81.2761, -65.6605, -63.3084, 0.521851, 104.519, -62.7352, -72.4198, 0.444824, 65.6156, -49.5546, -67.2074, 0.308655, 54.2865, -10.3131, -52.1117, 0.236267, 120.42, -105.112, -49.3556, 0.60022, 116.189, -76.1983, -41.2718, 0.653992, 92.821, -64.5032, -42.2247, 0.527283, 115.285, -61.9334, -53.119, 0.411194, 85.1507, -47.7375, -27.3165, 0.324036, 68.5293, -8.10239, -40.0008, 0.237915, 99.4248, -129.754, -59.6533, 0.558838, 105.207, -126.2, -67.7812, 0.423035, 102.014, -129.179, -53.6288, 0.597534, 112.005, -124.794, -53.0751, 0.523254]
},
{ "id": 1,
"joints19": [-75.6724, -98.3814, -40.586, 0.645996, -56.0144, -116.916, -44.6227, 0.601746, -74.2896, -55.1045, -36.5893, 0.251404, -83.9112, -98.0817, -25.7277, 0.517944, -88.2289, -74.2988, -14.0067, 0.396973, -68.2309, -74.1222, -1.47647, 0.329041, -79.1849, -55.0298, -28.0693, 0.249634, -51.5633, -47.6808, -7.04466, 0.285828, -74.7285, -17.5206, -29.2095, 0.225037, -67.3391, -99.4683, -53.6127, 0.477478, -47.0624, -92.1391, -77.8037, 0.564758, -44.4238, -79.2347, -57.8838, 0.42804, -69.3944, -55.1793, -45.1093, 0.227051, -34.6453, -49.6836, -25.2735, 0.309937, -40.5958, -7.8462, -31.1836, 0.256836, -56.8233, -120.322, -40.7627, 0.527283, -62.646, -116.933, -32.5876, 0.487427, -59.8079, -119.867, -46.6254, 0.471802, -69.67, -116.407, -47.7538, 0.328979]
},
{ "id": 2,
"joints19": [-2.94539, -95.1867, 36.3111, 0.628723, 2.07299, -104.457, 17.1551, 0.454163, -7.05924, -50.5435, 42.1746, 0.244141, 9.71628, -93.5102, 43.4675, 0.522705, 12.0947, -69.463, 41.455, 0.387512, 19.2916, -69.8677, 21.9048, 0.328552, 1.02674, -50.5267, 46.2205, 0.253113, 26.6747, -43.1457, 17.5558, 0.371948, 27.6632, -7.91068, 13.5889, 0.338867, -15.3606, -97.7204, 30.3576, 0.512207, -37.812, -87.1386, 18.9922, 0.449524, -22.3384, -73.7289, 12.8309, 0.288696, -15.1452, -50.5603, 38.1288, 0.238159, 5.46492, -46.765, 4.57304, 0.31604, 4.54105, -11.5529, 11.0104, 0.225098, 5.10417, -106.784, 19.1646, 0.338989, 8.38426, -105.863, 28.9746, 0.374878, -0.147999, -108.49, 17.901, 0.389282, -6.41806, -109.461, 25.684, 0.374512]
}
] }
@@ -0,0 +1,15 @@
{ "version": 0.7,
"univTime" :47917.574,
"fpsType" :"hd_29_97",
"bodies" :
[
{ "id": 0,
"joints19": [112.162, -105.636, -63.2601, 0.683655, 98.6079, -126.096, -55.7691, 0.633362, 109.895, -61.989, -62.8249, 0.434998, 103.92, -106.612, -77.9614, 0.633362, 96.8156, -78.8938, -80.3215, 0.628052, 81.2649, -65.6074, -63.3025, 0.5224, 104.579, -62.7546, -72.4201, 0.444275, 65.7338, -49.5044, -67.2157, 0.308167, 54.3536, -10.2596, -52.2195, 0.234131, 120.391, -105.108, -49.299, 0.603271, 116.181, -76.2786, -41.2666, 0.655334, 92.8451, -64.4865, -42.2389, 0.527039, 115.21, -61.2235, -53.2298, 0.411194, 85.1888, -47.835, -27.3393, 0.316833, 68.6198, -8.08162, -40.0417, 0.240723, 99.4313, -129.72, -59.6381, 0.558228, 105.205, -126.164, -67.7647, 0.423279, 102.011, -129.182, -53.6361, 0.597229, 111.982, -124.783, -53.0672, 0.522705]
},
{ "id": 1,
"joints19": [-75.6746, -98.3656, -40.5723, 0.641663, -56.0544, -116.939, -44.5928, 0.603577, -74.4415, -55.0317, -36.6536, 0.252808, -83.918, -98.0843, -25.7209, 0.519165, -88.2603, -74.1941, -13.9948, 0.396057, -68.2309, -74.0839, -1.42833, 0.328918, -79.5003, -55.0092, -28.0401, 0.25, -51.5172, -47.7041, -7.04263, 0.294495, -74.7647, -17.5892, -29.1887, 0.228638, -67.361, -99.4319, -53.7077, 0.481934, -47.0466, -92.2037, -77.7492, 0.570923, -44.4639, -79.2762, -57.8438, 0.434448, -69.3827, -55.0541, -45.2672, 0.228271, -34.7812, -49.6926, -25.257, 0.32843, -40.4408, -8.21801, -31.4407, 0.283936, -56.906, -120.336, -40.6846, 0.523743, -62.7131, -116.956, -32.5538, 0.486816, -59.8485, -119.899, -46.5796, 0.469604, -69.74, -116.42, -47.7167, 0.333618]
},
{ "id": 2,
"joints19": [-2.68829, -95.166, 36.4048, 0.630371, 2.45545, -104.642, 17.3385, 0.4422, -7.03441, -50.7646, 42.0224, 0.242737, 9.85479, -93.5391, 43.7496, 0.508667, 12.1837, -69.2865, 41.4611, 0.386414, 19.4591, -69.7157, 22.0246, 0.327209, 0.906971, -50.8216, 45.9673, 0.251282, 26.7278, -43.1852, 17.6063, 0.375671, 27.6219, -7.85445, 13.6172, 0.336487, -15.0965, -97.8212, 30.3863, 0.518982, -37.313, -87.4077, 18.8649, 0.450623, -22.0828, -73.86, 12.723, 0.291931, -14.9758, -50.7076, 38.0776, 0.235413, 5.50862, -46.8061, 4.64948, 0.321838, 4.38506, -11.3184, 11.4198, 0.237366, 5.50586, -106.921, 19.3049, 0.338745, 8.65006, -105.825, 29.1475, 0.375244, 0.254989, -108.642, 18.0692, 0.389526, -5.97449, -109.525, 25.9132, 0.369568]
}
] }
@@ -0,0 +1,762 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"nose",
"head_bottom",
"head_top",
"left_ear",
"right_ear",
"left_shoulder",
"right_shoulder",
"left_elbow",
"right_elbow",
"left_wrist",
"right_wrist",
"left_hip",
"right_hip",
"left_knee",
"right_knee",
"left_ankle",
"right_ankle"
],
"skeleton": [
[
16,
14
],
[
14,
12
],
[
17,
15
],
[
15,
13
],
[
12,
13
],
[
6,
12
],
[
7,
13
],
[
6,
7
],
[
6,
8
],
[
7,
9
],
[
8,
10
],
[
9,
11
],
[
2,
3
],
[
1,
2
],
[
1,
3
],
[
2,
4
],
[
3,
5
],
[
4,
6
],
[
5,
7
]
]
}
],
"images": [
{
"has_no_densepose": true,
"is_labeled": true,
"file_name": "images/val/003418_mpii_test/000000.jpg",
"nframes": 149,
"frame_id": 10034180000,
"vid_id": "003418",
"ignore_regions_y": [
[
639,
647,
635,
618,
590,
547,
501,
499,
515,
518,
526,
528,
509,
473,
450,
407,
352,
339,
309,
271,
262,
252,
211,
211,
183,
175,
139,
105,
94,
62,
45,
22,
22,
30,
52,
66,
86,
92,
101,
109,
162,
158,
135,
103,
94,
75,
60,
37,
18,
9,
1,
0,
79,
75,
88,
103,
156,
164,
167,
201,
196,
194,
207,
237,
262,
256
],
[
94,
71,
62,
41,
28,
30,
43,
64,
88,
96,
120,
115,
98
],
[
235,
215,
211,
224,
252,
239,
207,
196,
211,
228,
218,
198,
181,
186,
198,
218,
233,
252,
277,
279,
292,
318,
347,
354,
392,
430,
439,
447,
462,
477,
496,
539,
515,
464,
426,
398,
366,
333,
322,
315,
318,
303,
298,
294,
266,
245
],
[
207,
213,
239,
237,
215,
179,
179,
184,
209,
222,
239,
264,
279,
271,
269,
290,
260,
226
],
[
194,
175,
160,
164,
179,
167,
160,
216,
266,
262,
266,
269,
281,
298,
309,
318,
332,
341,
345,
345,
290,
262,
226
],
[
424,
442,
432,
432,
455,
469,
474,
505,
559,
555,
465,
449,
444
],
[
926,
901,
857,
792,
751,
694,
636,
540,
474,
403,
351,
265,
211,
155,
98,
71,
40,
0,
0,
1078,
1078,
1007,
924,
869,
807,
865,
892,
955,
1003,
1057,
1078,
1078,
1030,
961,
926
],
[
1050,
1076,
1078,
1057,
1032,
1013,
998,
982,
971,
951,
936,
913,
888,
844,
799,
763,
732,
723,
713,
753,
784,
817,
830,
871,
911,
930
],
[
478,
461,
423,
405,
394,
263,
257,
265,
290,
315,
334,
342,
344,
411,
448,
448,
448,
430,
424,
423,
421,
409,
444
]
],
"ignore_regions_x": [
[
0,
1,
198,
258,
307,
337,
343,
335,
320,
290,
273,
260,
232,
190,
196,
183,
171,
162,
149,
132,
105,
77,
69,
322,
324,
303,
279,
273,
247,
224,
226,
215,
203,
190,
192,
181,
169,
167,
154,
139,
99,
86,
81,
56,
60,
62,
60,
49,
35,
15,
9,
3,
0,
11,
13,
0,
1,
9,
90,
64,
49,
33,
18,
13,
15,
0
],
[
341,
347,
352,
356,
371,
383,
388,
392,
403,
392,
398,
377,
375
],
[
688,
694,
713,
724,
728,
752,
764,
783,
796,
796,
824,
828,
839,
856,
864,
864,
884,
899,
903,
843,
854,
854,
850,
884,
901,
873,
833,
815,
796,
747,
716,
666,
654,
660,
667,
694,
711,
724,
737,
775,
792,
790,
756,
688,
686,
686
],
[
1047,
1079,
1079,
1088,
1099,
1103,
1122,
1133,
1141,
1164,
1175,
1164,
1181,
1126,
1092,
1077,
1069,
1047
],
[
1252,
1254,
1258,
1277,
1292,
1301,
1322,
1330,
1350,
1322,
1296,
1277,
1256,
1233,
1213,
1198,
1173,
1130,
1098,
1081,
1101,
1198,
1232
],
[
1165,
1184,
1226,
1246,
1238,
1226,
1209,
1215,
1180,
1126,
1057,
1053,
1128
],
[
1455,
1438,
1438,
1444,
1442,
1423,
1426,
1409,
1399,
1390,
1374,
1349,
1330,
1319,
1307,
1309,
1324,
1330,
1919,
1919,
1884,
1855,
1830,
1828,
1776,
1732,
1734,
1726,
1728,
1707,
1713,
1469,
1461,
1459,
1455
],
[
1463,
1411,
1255,
1250,
1246,
1261,
1284,
1280,
1271,
1265,
1275,
1299,
1299,
1296,
1315,
1340,
1365,
1396,
1444,
1428,
1434,
1432,
1446,
1440,
1453,
1455
],
[
1246,
1271,
1313,
1344,
1384,
1346,
1307,
1286,
1255,
1203,
1153,
1096,
1078,
1061,
1036,
1090,
1121,
1148,
1169,
1205,
1228,
1265,
1267
]
],
"id": 10034180000,
"width": 1920,
"height": 1080,
"mask_file": "mask/val/003418_mpii_test/000000.jpg"
}
],
"annotations": [
{
"bbox_head": [
346,
337,
296,
237
],
"keypoints": [
621,
471,
1,
542.2835693,
599.2855835,
1,
457.787323,
347.6607971,
1,
0,
0,
0,
0,
0,
0,
371,
737,
1,
753,
579,
1,
387,
981,
1,
1023,
353,
1,
0,
0,
0,
953,
141,
1,
968,
833,
1,
1152,
843,
1,
0,
0,
0,
1416,
429,
1,
0,
0,
0,
0,
0,
0
],
"track_id": 0,
"image_id": 10034180000,
"bbox": [
214.25,
15.0,
1358.5,
1092.0
],
"scores": [],
"category_id": 1,
"id": 1003418000000,
"iscrowd": false,
"num_keypoints": 11
}
]
}
@@ -0,0 +1,374 @@
{
"categories": [
{
"supercategory": "person",
"id": 1,
"name": "person",
"keypoints": [
"nose",
"head_bottom",
"head_top",
"left_ear",
"right_ear",
"left_shoulder",
"right_shoulder",
"left_elbow",
"right_elbow",
"left_wrist",
"right_wrist",
"left_hip",
"right_hip",
"left_knee",
"right_knee",
"left_ankle",
"right_ankle"
],
"skeleton": [
[
16,
14
],
[
14,
12
],
[
17,
15
],
[
15,
13
],
[
12,
13
],
[
6,
12
],
[
7,
13
],
[
6,
7
],
[
6,
8
],
[
7,
9
],
[
8,
10
],
[
9,
11
],
[
2,
3
],
[
1,
2
],
[
1,
3
],
[
2,
4
],
[
3,
5
],
[
4,
6
],
[
5,
7
]
]
}
],
"images": [
{
"has_no_densepose": true,
"is_labeled": true,
"file_name": "images/val/009473_mpii_test/000000.jpg",
"nframes": 101,
"frame_id": 10094730000,
"vid_id": "009473",
"ignore_regions_y": [
[
228,
237,
243,
230,
220,
230,
228,
232,
220,
211,
226,
258,
364,
417,
475,
562,
615,
646,
656,
637,
649,
645,
603,
585,
547
],
[
0,
1,
137,
130,
166,
235,
309,
384,
452,
526,
583,
658,
694,
709,
599,
684,
707,
733,
660,
679,
762
]
],
"ignore_regions_x": [
[
1907,
1820,
1758,
1662,
1577,
1492,
1375,
1305,
1250,
1177,
1111,
1033,
1047,
1062,
1056,
1130,
1173,
1232,
1282,
1332,
1416,
1471,
1515,
1541,
1909
],
[
0,
257,
284,
407,
450,
505,
562,
592,
613,
626,
639,
639,
594,
454,
371,
343,
269,
152,
88,
35,
3
]
],
"id": 10094730000,
"width": 1920,
"height": 1080,
"mask_file": "mask/val/009473_mpii_test/000000.jpg"
}
],
"annotations": [
{
"bbox_head": [
648,
253,
138,
103
],
"keypoints": [
750,
297.5,
1,
734.1937256,
371.1997375,
1,
704.1047363,
254.4751892,
1,
0,
0,
0,
0,
0,
0,
697,
352.5,
1,
766,
369,
1,
0,
0,
0,
857,
419,
1,
766,
281,
1,
942,
422.5,
1,
722,
525,
1,
792,
544,
1,
783,
697,
1,
755,
699,
1,
808.5,
832.5,
1,
672,
782.5,
1
],
"track_id": 0,
"image_id": 10094730000,
"bbox": [
631.5,
167.77146757999992,
351.0,
751.4322540400001
],
"scores": [],
"category_id": 1,
"id": 1009473000000,
"iscrowd": false,
"num_keypoints": 14
},
{
"bbox_head": [
878,
201,
90,
125
],
"keypoints": [
900,
272,
1,
905.657959,
322.6206665,
1,
936.0065308,
219.1595001,
1,
0,
0,
0,
0,
0,
0,
950,
366,
1,
852,
311,
1,
1021,
428,
1,
759,
303,
1,
986,
422,
1,
704,
374,
1,
912,
516,
1,
856,
524,
1,
876,
663,
1,
908,
680,
1,
849,
828,
1,
959,
804,
1
],
"track_id": 1,
"image_id": 10094730000,
"bbox": [
656.45,
127.83342511500007,
412.0999999999999,
791.4926498699999
],
"scores": [],
"category_id": 1,
"id": 1009473000001,
"iscrowd": false,
"num_keypoints": 15
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,857 @@
{
"info": {
"description": "RHD",
"version": "1.1",
"year": "2021",
"date_created": "2021/03/13"
},
"licenses": "",
"images": [
{
"file_name": "00111.png",
"height": 320,
"width": 320,
"id": 111,
"cam_param": {
"focal": [
299.0,
299.0
],
"princpt": [
160.0,
160.0
]
}
},
{
"file_name": "01111.png",
"height": 320,
"width": 320,
"id": 1111,
"cam_param": {
"focal": [
305.8999938964844,
305.8999938964844
],
"princpt": [
160.0,
160.0
]
}
},
{
"file_name": "11111.png",
"height": 320,
"width": 320,
"id": 11111,
"cam_param": {
"focal": [
263.20001220703125,
263.20001220703125
],
"princpt": [
160.0,
160.0
]
}
}
],
"annotations": [
{
"id": 111,
"image_id": 111,
"category_id": 1,
"iscrowd": 0,
"bbox": [
162.5699920654297,
63.858001708984375,
93.96000671386719,
121.4639892578125
],
"area": 11412.757246157154,
"keypoints": [
[
245.8000030517578,
73.9800033569336,
1
],
[
170.39999389648438,
115.0,
1
],
[
180.39999389648438,
103.69999694824219,
1
],
[
194.10000610351562,
89.16999816894531,
1
],
[
220.0,
82.51000213623047,
1
],
[
193.0,
163.60000610351562,
1
],
[
194.5,
154.1999969482422,
1
],
[
196.6999969482422,
144.39999389648438,
1
],
[
202.39999389648438,
123.69999694824219,
1
],
[
208.39999389648438,
175.1999969482422,
1
],
[
210.6999969482422,
164.3000030517578,
1
],
[
211.60000610351562,
152.10000610351562,
1
],
[
215.60000610351562,
131.5,
1
],
[
228.10000610351562,
167.1999969482422,
1
],
[
228.6999969482422,
159.0,
1
],
[
228.1999969482422,
151.10000610351562,
1
],
[
228.6999969482422,
132.1999969482422,
1
],
[
248.6999969482422,
143.6999969482422,
1
],
[
247.6999969482422,
148.3000030517578,
1
],
[
246.39999389648438,
148.10000610351562,
1
],
[
244.39999389648438,
129.1999969482422,
1
]
],
"joint_cam": [
[
117.9000015258789,
-118.19999694824219,
411.0
],
[
17.09000015258789,
-73.70999908447266,
489.5
],
[
32.540000915527344,
-89.88999938964844,
477.20001220703125
],
[
52.959999084472656,
-110.0,
464.3999938964844
],
[
87.95999908447266,
-113.70000457763672,
438.6999816894531
],
[
56.71000289916992,
6.140999794006348,
514.1000366210938
],
[
56.7599983215332,
-9.583000183105469,
492.1000061035156
],
[
57.97999954223633,
-24.700000762939453,
472.79998779296875
],
[
64.52000427246094,
-55.34000015258789,
455.5
],
[
81.20000457763672,
25.459999084472656,
501.6999816894531
],
[
81.8800048828125,
6.9070000648498535,
483.3999938964844
],
[
80.05999755859375,
-12.220000267028809,
464.1000061035156
],
[
83.37000274658203,
-42.70000076293945,
448.0
],
[
113.20000457763672,
11.960000038146973,
496.6999816894531
],
[
109.0999984741211,
-1.5170000791549683,
475.20001220703125
],
[
103.20000457763672,
-13.480000495910645,
452.6999816894531
],
[
102.0,
-41.32999801635742,
443.79998779296875
],
[
143.09999084472656,
-26.25,
482.3000183105469
],
[
137.0,
-18.23000144958496,
467.29998779296875
],
[
130.60000610351562,
-18.049999237060547,
452.0
],
[
124.9000015258789,
-45.51000213623047,
442.0999755859375
]
],
"hand_type": "left"
},
{
"id": 1111,
"image_id": 1111,
"category_id": 1,
"iscrowd": 0,
"bbox": [
163.91000366210938,
92.3900146484375,
59.88001251220703,
118.91999053955078
],
"area": 7120.930521459843,
"keypoints": [
[
218.8000030517578,
201.39999389648438,
1
],
[
168.89999389648438,
147.89999389648438,
1
],
[
171.5,
161.6999969482422,
1
],
[
182.3000030517578,
178.0,
1
],
[
202.60000610351562,
191.10000610351562,
1
],
[
184.6999969482422,
174.1999969482422,
1
],
[
175.6999969482422,
162.39999389648438,
1
],
[
180.60000610351562,
148.10000610351562,
1
],
[
200.5,
153.3000030517578,
1
],
[
181.5,
173.89999389648438,
1
],
[
180.0,
156.5,
1
],
[
185.10000610351562,
140.89999389648438,
1
],
[
205.6999969482422,
146.6999969482422,
1
],
[
175.39999389648438,
160.3000030517578,
1
],
[
183.60000610351562,
145.3000030517578,
1
],
[
194.89999389648438,
132.6999969482422,
1
],
[
208.8000030517578,
145.6999969482422,
1
],
[
199.39999389648438,
102.30000305175781,
1
],
[
201.89999389648438,
116.19999694824219,
1
],
[
208.10000610351562,
127.4000015258789,
1
],
[
210.60000610351562,
148.5,
1
]
],
"joint_cam": [
[
96.12000274658203,
67.63999938964844,
499.70001220703125
],
[
15.380000114440918,
-20.969999313354492,
528.0
],
[
20.209999084472656,
3.059999942779541,
536.0999755859375
],
[
38.869998931884766,
31.470001220703125,
533.2999877929688
],
[
73.62000274658203,
53.81999969482422,
529.2000122070312
],
[
42.380001068115234,
24.42999839782715,
524.7999877929688
],
[
27.260000228881836,
4.211999893188477,
529.7999877929688
],
[
36.38999938964844,
-21.010000228881836,
540.0999755859375
],
[
71.79000091552734,
-11.949999809265137,
542.7000122070312
],
[
35.5,
22.989999771118164,
505.5999755859375
],
[
33.540000915527344,
-5.878000259399414,
512.9000244140625
],
[
42.69000244140625,
-32.55999755859375,
521.0999755859375
],
[
78.16999816894531,
-22.75,
522.8999633789062
],
[
24.560001373291016,
0.47450000047683716,
487.79998779296875
],
[
38.18000030517578,
-23.760000228881836,
494.1000061035156
],
[
57.27000045776367,
-44.72999954223633,
501.3999938964844
],
[
80.33000183105469,
-23.520000457763672,
503.8999938964844
],
[
58.06999969482422,
-85.06999969482422,
450.8999938964844
],
[
62.619998931884766,
-65.56999969482422,
457.5
],
[
73.29999542236328,
-49.72999954223633,
466.3999938964844
],
[
79.80000305175781,
-18.200000762939453,
482.3000183105469
]
],
"hand_type": "left"
},
{
"id": 11111,
"image_id": 11111,
"category_id": 1,
"iscrowd": 0,
"bbox": [
162.8300018310547,
135.88999938964844,
59.63999557495117,
48.1200065612793
],
"area": 2869.8769783813186,
"keypoints": [
[
167.8000030517578,
154.10000610351562,
1
],
[
217.5,
146.60000610351562,
1
],
[
207.8000030517578,
146.39999389648438,
1
],
[
197.10000610351562,
144.8000030517578,
1
],
[
181.5,
148.0,
1
],
[
206.8000030517578,
167.1999969482422,
1
],
[
206.5,
160.1999969482422,
1
],
[
202.10000610351562,
150.89999389648438,
1
],
[
191.39999389648438,
139.89999389648438,
1
],
[
200.0,
170.0,
1
],
[
200.39999389648438,
163.6999969482422,
1
],
[
198.0,
155.6999969482422,
1
],
[
186.39999389648438,
145.10000610351562,
1
],
[
194.6999969482422,
172.39999389648438,
1
],
[
195.1999969482422,
168.10000610351562,
1
],
[
191.8000030517578,
160.89999389648438,
1
],
[
182.0,
151.6999969482422,
1
],
[
198.1999969482422,
180.0,
1
],
[
195.0,
176.3000030517578,
1
],
[
189.10000610351562,
170.39999389648438,
1
],
[
177.3000030517578,
160.1999969482422,
1
]
],
"joint_cam": [
[
20.479999542236328,
-15.470000267028809,
693.2999877929688
],
[
138.40000915527344,
-32.17000198364258,
633.2000122070312
],
[
118.0,
-33.62999725341797,
649.2000122070312
],
[
94.87999725341797,
-38.78999710083008,
673.699951171875
],
[
56.01000213623047,
-31.309999465942383,
686.2999877929688
],
[
116.80000305175781,
18.049999237060547,
656.7999877929688
],
[
112.80000305175781,
0.48660001158714294,
638.2999877929688
],
[
99.94000244140625,
-21.559999465942383,
625.199951171875
],
[
74.3699951171875,
-47.75,
623.7999877929688
],
[
99.95999908447266,
24.979999542236328,
658.5
],
[
97.34000396728516,
9.000999450683594,
633.4000244140625
],
[
88.5199966430664,
-9.983000755310059,
612.7999877929688
],
[
61.19000244140625,
-34.4900016784668,
609.6000366210938
],
[
86.45000457763672,
31.0,
655.6000366210938
],
[
84.11000061035156,
19.43000030517578,
629.7000122070312
],
[
73.44000244140625,
2.186999797821045,
608.6000366210938
],
[
50.53000259399414,
-19.139999389648438,
605.7000122070312
],
[
91.06999969482422,
47.60000228881836,
626.6000366210938
],
[
81.22000122070312,
37.78000259399414,
610.800048828125
],
[
66.75,
23.989999771118164,
604.0999755859375
],
[
39.94999694824219,
0.4115999937057495,
607.7999877929688
]
],
"hand_type": "right"
}
],
"categories": [
{
"id": 1,
"name": "hand",
"supercategory": "hand",
"keypoints": [
"wrist",
"thumb1",
"thumb2",
"thumb3",
"thumb4",
"forefinger1",
"forefinger2",
"forefinger3",
"forefinger4",
"middle_finger1",
"middle_finger2",
"middle_finger3",
"middle_finger4",
"ring_finger1",
"ring_finger2",
"ring_finger3",
"ring_finger4",
"pinky_finger1",
"pinky_finger2",
"pinky_finger3",
"pinky_finger4"
],
"skeleton": [
[
1,
2
],
[
2,
3
],
[
3,
4
],
[
4,
5
],
[
1,
6
],
[
6,
7
],
[
7,
8
],
[
8,
9
],
[
1,
10
],
[
10,
11
],
[
11,
12
],
[
12,
13
],
[
1,
14
],
[
14,
15
],
[
15,
16
],
[
16,
17
],
[
1,
18
],
[
18,
19
],
[
19,
20
],
[
20,
21
]
]
}
]
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,156 @@
{
"categories": [
{
"supercategory": "animal",
"id": 1,
"name": "zebra",
"keypoints": [
"snout",
"head",
"neck",
"forelegL1",
"forelegR1",
"hindlegL1",
"hindlegR1",
"tailbase",
"tailtip"
],
"skeleton": [
[
2,
1
],
[
3,
2
],
[
4,
3
],
[
5,
3
],
[
6,
8
],
[
7,
8
],
[
8,
3
],
[
9,
8
]
]
}
],
"images": [
{
"id": 810,
"file_name": "810.jpg",
"height": 160,
"width": 160
},
{
"id": 850,
"file_name": "850.jpg",
"height": 160,
"width": 160
}
],
"annotations": [
{
"keypoints": [
121.13823384782104,
64.42827920259212,
2.0,
117.9981442098391,
70.81295036652858,
2.0,
101.74729396479975,
80.0,
2.0,
95.57905809119656,
75.75733930455307,
2.0,
95.2128993293075,
82.7116929245571,
2.0,
62.78126573755127,
75.8747890881429,
2.0,
62.31104503893799,
83.86685797031176,
2.0,
58.25270603520024,
80.0,
2.0,
53.31206457278393,
85.52060239198866,
2.0
],
"image_id": 810,
"id": 810,
"num_keypoints": 9,
"bbox": [
53.31206457278393,
64.42827920259212,
68.8261692750371,
22.092323189396538
],
"iscrowd": 0,
"area": 1520.5299755122337,
"category_id": 1
},
{
"keypoints": [
122.31461535908949,
89.25315845576364,
2.0,
117.81536523827128,
87.97006030862022,
2.0,
101.66067429997881,
80.0,
2.0,
97.88660503356242,
74.70007144842482,
2.0,
96.6342743993913,
81.95450979316085,
2.0,
62.9768902919959,
75.51961961159495,
2.0,
63.64287080847072,
83.46692756256179,
2.0,
58.3393257000212,
80.0,
2.0,
55.41273077187657,
77.94207820202976,
2.0
],
"image_id": 850,
"id": 850,
"num_keypoints": 9,
"bbox": [
55.41273077187657,
74.70007144842482,
67.90188458721292,
15.553087007338817
],
"iscrowd": 0,
"area": 1056.083918947201,
"category_id": 1
}
]
}
@@ -0,0 +1,198 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import numpy as np
from mmpose.apis import (inference_bottom_up_pose_model,
inference_top_down_pose_model, init_pose_model,
process_mmdet_results, vis_pose_result)
from mmpose.datasets import DatasetInfo
def test_top_down_demo():
# COCO demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'coco/res50_coco_256x192.py',
None,
device='cpu')
image_name = 'tests/data/coco/000000000785.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
person_result = []
person_result.append({'bbox': [50, 50, 50, 100]})
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# AIC demo
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'aic/res50_aic_256x192.py',
None,
device='cpu')
image_name = 'tests/data/aic/054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# OneHand10K demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/'
'onehand10k/res50_onehand10k_256x256.py',
None,
device='cpu')
image_name = 'tests/data/onehand10k/9.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# InterHand2DDataset demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/'
'interhand2d/res50_interhand2d_all_256x256.py',
None,
device='cpu')
image_name = 'tests/data/interhand2.6m/image2017.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# Face300WDataset demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/face/2d_kpt_sview_rgb_img/topdown_heatmap/'
'300w/res50_300w_256x256.py',
None,
device='cpu')
image_name = 'tests/data/300w/indoor_020.png'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# FaceAFLWDataset demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/face/2d_kpt_sview_rgb_img/topdown_heatmap/'
'aflw/res50_aflw_256x256.py',
None,
device='cpu')
image_name = 'tests/data/aflw/image04476.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# FaceCOFWDataset demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/face/2d_kpt_sview_rgb_img/topdown_heatmap/'
'cofw/res50_cofw_256x256.py',
None,
device='cpu')
image_name = 'tests/data/cofw/001766.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
def test_bottom_up_demo():
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/associative_embedding/'
'coco/res50_coco_512x512.py',
None,
device='cpu')
image_name = 'tests/data/coco/000000000785.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test'].get(
'dataset_info', None))
pose_results, _ = inference_bottom_up_pose_model(
pose_model, image_name, dataset_info=dataset_info)
# show the results
vis_pose_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# test dataset_info without sigmas
pose_model_copy = copy.deepcopy(pose_model)
pose_model_copy.cfg.data.test.dataset_info.pop('sigmas')
pose_results, _ = inference_bottom_up_pose_model(
pose_model_copy, image_name, dataset_info=dataset_info)
def test_process_mmdet_results():
det_results = [np.array([0, 0, 100, 100])]
det_mask_results = None
_ = process_mmdet_results(
mmdet_results=(det_results, det_mask_results), cat_id=1)
_ = process_mmdet_results(mmdet_results=det_results, cat_id=1)
@@ -0,0 +1,210 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import mmcv
import numpy as np
import pytest
import torch
from mmpose.apis import (extract_pose_sequence, inference_interhand_3d_model,
inference_mesh_model, inference_pose_lifter_model,
init_pose_model, vis_3d_mesh_result,
vis_3d_pose_result)
from mmpose.datasets.dataset_info import DatasetInfo
from tests.utils.mesh_utils import generate_smpl_weight_file
def test_pose_lifter_demo():
# H36M demo
pose_model = init_pose_model(
'configs/body/3d_kpt_sview_rgb_img/pose_lift/'
'h36m/simplebaseline3d_h36m.py',
None,
device='cpu')
pose_det_result = {
'keypoints': np.zeros((17, 3)),
'bbox': [50, 50, 50, 50],
'track_id': 0,
'image_name': 'tests/data/h36m/S1_Directions_1.54138969_000001.jpg',
}
pose_results_2d = [[pose_det_result]]
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
pose_results_2d = extract_pose_sequence(
pose_results_2d, frame_idx=0, causal=False, seq_len=1, step=1)
_ = inference_pose_lifter_model(
pose_model,
pose_results_2d,
dataset_info=dataset_info,
with_track_id=False)
pose_lift_results = inference_pose_lifter_model(
pose_model,
pose_results_2d,
dataset_info=dataset_info,
with_track_id=True)
for res in pose_lift_results:
res['title'] = 'title'
vis_3d_pose_result(
pose_model,
pose_lift_results,
img=pose_results_2d[0][0]['image_name'],
dataset_info=dataset_info)
# test special cases
# Empty 2D results
_ = inference_pose_lifter_model(
pose_model, [[]], dataset_info=dataset_info, with_track_id=False)
if torch.cuda.is_available():
_ = inference_pose_lifter_model(
pose_model.cuda(),
pose_results_2d,
dataset_info=dataset_info,
with_track_id=False)
# test videopose3d
pose_model = init_pose_model(
'configs/body/3d_kpt_sview_rgb_vid/video_pose_lift/h36m/'
'videopose3d_h36m_243frames_fullconv_supervised_cpn_ft.py',
None,
device='cpu')
pose_det_result_0 = {
'keypoints': np.ones((17, 3)),
'bbox': [50, 50, 100, 100],
'track_id': 0,
'image_name': 'tests/data/h36m/S1_Directions_1.54138969_000001.jpg',
}
pose_det_result_1 = {
'keypoints': np.ones((17, 3)),
'bbox': [50, 50, 100, 100],
'track_id': 1,
'image_name': 'tests/data/h36m/S5_SittingDown.54138969_002061.jpg',
}
pose_det_result_2 = {
'keypoints': np.ones((17, 3)),
'bbox': [50, 50, 100, 100],
'track_id': 2,
'image_name': 'tests/data/h36m/S7_Greeting.55011271_000396.jpg',
}
pose_results_2d = [[pose_det_result_0], [pose_det_result_1],
[pose_det_result_2]]
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
seq_len = pose_model.cfg.test_data_cfg.seq_len
pose_results_2d_seq = extract_pose_sequence(
pose_results_2d, 1, causal=False, seq_len=seq_len, step=1)
pose_lift_results = inference_pose_lifter_model(
pose_model,
pose_results_2d_seq,
dataset_info=dataset_info,
with_track_id=True,
image_size=[1000, 1000],
norm_pose_2d=True)
for res in pose_lift_results:
res['title'] = 'title'
vis_3d_pose_result(
pose_model,
pose_lift_results,
img=pose_results_2d[0][0]['image_name'],
dataset_info=dataset_info,
)
def test_interhand3d_demo():
# H36M demo
pose_model = init_pose_model(
'configs/hand/3d_kpt_sview_rgb_img/internet/interhand3d/'
'res50_interhand3d_all_256x256.py',
None,
device='cpu')
image_name = 'tests/data/interhand2.6m/image2017.jpg'
det_result = {
'image_name': image_name,
'bbox': [50, 50, 50, 50], # bbox format is 'xywh'
'camera_param': None,
'keypoints_3d_gt': None
}
det_results = [det_result]
dataset = pose_model.cfg.data['test']['type']
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
pose_results = inference_interhand_3d_model(
pose_model, image_name, det_results, dataset=dataset)
for res in pose_results:
res['title'] = 'title'
vis_3d_pose_result(
pose_model,
result=pose_results,
img=det_results[0]['image_name'],
dataset_info=dataset_info,
)
# test special cases
# Empty det results
_ = inference_interhand_3d_model(
pose_model, image_name, [], dataset=dataset)
if torch.cuda.is_available():
_ = inference_interhand_3d_model(
pose_model.cuda(), image_name, det_results, dataset=dataset)
with pytest.raises(NotImplementedError):
_ = inference_interhand_3d_model(
pose_model, image_name, det_results, dataset='test')
def test_body_mesh_demo():
# H36M demo
config = 'configs/body/3d_mesh_sview_rgb_img/hmr' \
'/mixed/res50_mixed_224x224.py'
config = mmcv.Config.fromfile(config)
config.model.mesh_head.smpl_mean_params = \
'tests/data/smpl/smpl_mean_params.npz'
pose_model = None
with tempfile.TemporaryDirectory() as tmpdir:
config.model.smpl.smpl_path = tmpdir
config.model.smpl.joints_regressor = osp.join(
tmpdir, 'test_joint_regressor.npy')
# generate weight file for SMPL model.
generate_smpl_weight_file(tmpdir)
pose_model = init_pose_model(config, device='cpu')
assert pose_model is not None, 'Fail to build pose model'
image_name = 'tests/data/h36m/S1_Directions_1.54138969_000001.jpg'
det_result = {
'keypoints': np.zeros((17, 3)),
'bbox': [50, 50, 50, 50],
'image_name': image_name,
}
# make person bounding boxes
person_results = [det_result]
dataset = pose_model.cfg.data['test']['type']
# test a single image, with a list of bboxes
pose_results = inference_mesh_model(
pose_model,
image_name,
person_results,
bbox_thr=None,
format='xywh',
dataset=dataset)
vis_3d_mesh_result(pose_model, pose_results, image_name)
@@ -0,0 +1,157 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmpose.apis import (get_track_id, inference_bottom_up_pose_model,
inference_top_down_pose_model, init_pose_model,
vis_pose_tracking_result)
from mmpose.datasets.dataset_info import DatasetInfo
def test_top_down_pose_tracking_demo():
# COCO demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'coco/res50_coco_256x192.py',
None,
device='cpu')
image_name = 'tests/data/coco/000000000785.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
person_result = [{'bbox': [50, 50, 50, 100]}]
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
pose_results, next_id = get_track_id(pose_results, [], next_id=0)
# show the results
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
pose_results_last = pose_results
# AIC demo
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'aic/res50_aic_256x192.py',
None,
device='cpu')
image_name = 'tests/data/aic/054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset_info=dataset_info)
pose_results, next_id = get_track_id(pose_results, pose_results_last,
next_id)
for pose_result in pose_results:
del pose_result['bbox']
pose_results, next_id = get_track_id(pose_results, pose_results_last,
next_id)
# show the results
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# OneHand10K demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/'
'onehand10k/res50_onehand10k_256x256.py',
None,
device='cpu')
image_name = 'tests/data/onehand10k/9.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name, [{
'bbox': [10, 10, 30, 30]
}],
format='xywh',
dataset_info=dataset_info)
pose_results, next_id = get_track_id(pose_results, pose_results_last,
next_id)
# show the results
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
# InterHand2D demo
pose_model = init_pose_model(
'configs/hand/2d_kpt_sview_rgb_img/topdown_heatmap/'
'interhand2d/res50_interhand2d_all_256x256.py',
None,
device='cpu')
image_name = 'tests/data/interhand2.6m/image2017.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name, [{
'bbox': [50, 50, 0, 0]
}],
format='xywh',
dataset_info=dataset_info)
pose_results, next_id = get_track_id(pose_results, [], next_id=0)
# show the results
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
pose_results_last = pose_results
# MPII demo
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'mpii/res50_mpii_256x256.py',
None,
device='cpu')
image_name = 'tests/data/mpii/004645041.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name, [{
'bbox': [50, 50, 0, 0]
}],
format='xywh',
dataset_info=dataset_info)
pose_results, next_id = get_track_id(pose_results, pose_results_last,
next_id)
# show the results
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
def test_bottom_up_pose_tracking_demo():
# COCO demo
# build the pose model from a config file and a checkpoint file
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/associative_embedding/'
'coco/res50_coco_512x512.py',
None,
device='cpu')
image_name = 'tests/data/coco/000000000785.jpg'
dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info'])
pose_results, _ = inference_bottom_up_pose_model(
pose_model, image_name, dataset_info=dataset_info)
pose_results, next_id = get_track_id(pose_results, [], next_id=0)
# show the results
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset_info=dataset_info)
pose_results_last = pose_results
# oks
pose_results, next_id = get_track_id(
pose_results, pose_results_last, next_id=next_id, use_oks=True)
pose_results_last = pose_results
# one_euro
pose_results, next_id = get_track_id(
pose_results, pose_results_last, next_id=next_id, use_one_euro=True)
@@ -0,0 +1,21 @@
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmpose.models.backbones import AlexNet
def test_alexnet_backbone():
"""Test alexnet backbone."""
model = AlexNet(-1)
model.train()
imgs = torch.randn(1, 3, 256, 192)
feat = model(imgs)
assert feat.shape == (1, 256, 7, 5)
model = AlexNet(1)
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == (1, 1)
@@ -0,0 +1,117 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones.utils import (InvertedResidual, SELayer,
channel_shuffle, make_divisible)
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (GroupNorm, _BatchNorm)):
return True
return False
def test_make_divisible():
# test min_value is None
result = make_divisible(34, 8, None)
assert result == 32
# test when new_value > min_ratio * value
result = make_divisible(10, 8, min_ratio=0.9)
assert result == 16
# test min_value = 0.8
result = make_divisible(33, 8, min_ratio=0.8)
assert result == 32
def test_channel_shuffle():
x = torch.randn(1, 24, 56, 56)
with pytest.raises(AssertionError):
# num_channels should be divisible by groups
channel_shuffle(x, 7)
groups = 3
batch_size, num_channels, height, width = x.size()
channels_per_group = num_channels // groups
out = channel_shuffle(x, groups)
# test the output value when groups = 3
for b in range(batch_size):
for c in range(num_channels):
c_out = c % channels_per_group * groups + c // channels_per_group
for i in range(height):
for j in range(width):
assert x[b, c, i, j] == out[b, c_out, i, j]
def test_inverted_residual():
with pytest.raises(AssertionError):
# stride must be in [1, 2]
InvertedResidual(16, 16, 32, stride=3)
with pytest.raises(AssertionError):
# se_cfg must be None or dict
InvertedResidual(16, 16, 32, se_cfg=list())
with pytest.raises(AssertionError):
# in_channeld and out_channels must be the same if
# with_expand_conv is False
InvertedResidual(16, 16, 32, with_expand_conv=False)
# Test InvertedResidual forward, stride=1
block = InvertedResidual(16, 16, 32, stride=1)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert getattr(block, 'se', None) is None
assert block.with_res_shortcut
assert x_out.shape == torch.Size((1, 16, 56, 56))
# Test InvertedResidual forward, stride=2
block = InvertedResidual(16, 16, 32, stride=2)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert not block.with_res_shortcut
assert x_out.shape == torch.Size((1, 16, 28, 28))
# Test InvertedResidual forward with se layer
se_cfg = dict(channels=32)
block = InvertedResidual(16, 16, 32, stride=1, se_cfg=se_cfg)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert isinstance(block.se, SELayer)
assert x_out.shape == torch.Size((1, 16, 56, 56))
# Test InvertedResidual forward, with_expand_conv=False
block = InvertedResidual(32, 16, 32, with_expand_conv=False)
x = torch.randn(1, 32, 56, 56)
x_out = block(x)
assert getattr(block, 'expand_conv', None) is None
assert x_out.shape == torch.Size((1, 16, 56, 56))
# Test InvertedResidual forward with GroupNorm
block = InvertedResidual(
16, 16, 32, norm_cfg=dict(type='GN', num_groups=2))
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
for m in block.modules():
if is_norm(m):
assert isinstance(m, GroupNorm)
assert x_out.shape == torch.Size((1, 16, 56, 56))
# Test InvertedResidual forward with HSigmoid
block = InvertedResidual(16, 16, 32, act_cfg=dict(type='HSigmoid'))
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 16, 56, 56))
# Test InvertedResidual forward with checkpoint
block = InvertedResidual(16, 16, 32, with_cp=True)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert block.with_cp
assert x_out.shape == torch.Size((1, 16, 56, 56))
@@ -0,0 +1,64 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models import CPM
from mmpose.models.backbones.cpm import CpmBlock
def test_cpm_block():
with pytest.raises(AssertionError):
# len(channels) == len(kernels)
CpmBlock(
3, channels=[3, 3, 3], kernels=[
1,
])
# Test CPM Block
model = CpmBlock(3, channels=[3, 3, 3], kernels=[1, 1, 1])
model.train()
imgs = torch.randn(1, 3, 10, 10)
feat = model(imgs)
assert feat.shape == torch.Size([1, 3, 10, 10])
def test_cpm_backbone():
with pytest.raises(AssertionError):
# CPM's num_stacks should larger than 0
CPM(in_channels=3, out_channels=17, num_stages=-1)
with pytest.raises(AssertionError):
# CPM's in_channels should be 3
CPM(in_channels=2, out_channels=17)
# Test CPM
model = CPM(in_channels=3, out_channels=17, num_stages=1)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 256, 192)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([1, 17, 32, 24])
imgs = torch.randn(1, 3, 384, 288)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([1, 17, 48, 36])
imgs = torch.randn(1, 3, 368, 368)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([1, 17, 46, 46])
# Test CPM multi-stages
model = CPM(in_channels=3, out_channels=17, num_stages=2)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 368, 368)
feat = model(imgs)
assert len(feat) == 2
assert feat[0].shape == torch.Size([1, 17, 46, 46])
assert feat[1].shape == torch.Size([1, 17, 46, 46])
@@ -0,0 +1,77 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models import HourglassAENet, HourglassNet
def test_hourglass_backbone():
with pytest.raises(AssertionError):
# HourglassNet's num_stacks should larger than 0
HourglassNet(num_stacks=0)
with pytest.raises(AssertionError):
# len(stage_channels) should equal len(stage_blocks)
HourglassNet(
stage_channels=[256, 256, 384, 384, 384],
stage_blocks=[2, 2, 2, 2, 2, 4])
with pytest.raises(AssertionError):
# len(stage_channels) should larger than downsample_times
HourglassNet(
downsample_times=5,
stage_channels=[256, 256, 384, 384, 384],
stage_blocks=[2, 2, 2, 2, 2])
# Test HourglassNet-52
model = HourglassNet(num_stacks=1)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 256, 256)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([1, 256, 64, 64])
# Test HourglassNet-104
model = HourglassNet(num_stacks=2)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 256, 256)
feat = model(imgs)
assert len(feat) == 2
assert feat[0].shape == torch.Size([1, 256, 64, 64])
assert feat[1].shape == torch.Size([1, 256, 64, 64])
def test_hourglass_ae_backbone():
with pytest.raises(AssertionError):
# HourglassAENet's num_stacks should larger than 0
HourglassAENet(num_stacks=0)
with pytest.raises(AssertionError):
# len(stage_channels) should larger than downsample_times
HourglassAENet(
downsample_times=5, stage_channels=[256, 256, 384, 384, 384])
# num_stack=1
model = HourglassAENet(num_stacks=1)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 256, 256)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([1, 34, 64, 64])
# num_stack=2
model = HourglassAENet(num_stacks=2)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 256, 256)
feat = model(imgs)
assert len(feat) == 2
assert feat[0].shape == torch.Size([1, 34, 64, 64])
assert feat[1].shape == torch.Size([1, 34, 64, 64])
@@ -0,0 +1,187 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models.backbones.hrformer import (HRFomerModule, HRFormer,
HRFormerBlock)
def test_hrformer_module():
norm_cfg = dict(type='BN')
block = HRFormerBlock
# Test multiscale forward
num_channles = (32, 64)
num_inchannels = [c * block.expansion for c in num_channles]
hrmodule = HRFomerModule(
num_branches=2,
block=block,
num_blocks=(2, 2),
num_inchannels=num_inchannels,
num_channels=num_channles,
num_heads=(1, 2),
num_window_sizes=(7, 7),
num_mlp_ratios=(4, 4),
drop_paths=(0., 0.),
norm_cfg=norm_cfg)
feats = [
torch.randn(1, num_inchannels[0], 64, 64),
torch.randn(1, num_inchannels[1], 32, 32)
]
feats = hrmodule(feats)
assert len(str(hrmodule)) > 0
assert len(feats) == 2
assert feats[0].shape == torch.Size([1, num_inchannels[0], 64, 64])
assert feats[1].shape == torch.Size([1, num_inchannels[1], 32, 32])
# Test single scale forward
num_channles = (32, 64)
in_channels = [c * block.expansion for c in num_channles]
hrmodule = HRFomerModule(
num_branches=2,
block=block,
num_blocks=(2, 2),
num_inchannels=num_inchannels,
num_channels=num_channles,
num_heads=(1, 2),
num_window_sizes=(7, 7),
num_mlp_ratios=(4, 4),
drop_paths=(0., 0.),
norm_cfg=norm_cfg,
multiscale_output=False,
)
feats = [
torch.randn(1, in_channels[0], 64, 64),
torch.randn(1, in_channels[1], 32, 32)
]
feats = hrmodule(feats)
assert len(feats) == 1
assert feats[0].shape == torch.Size([1, in_channels[0], 64, 64])
# Test single branch HRFormer module
hrmodule = HRFomerModule(
num_branches=1,
block=block,
num_blocks=(1, ),
num_inchannels=[num_inchannels[0]],
num_channels=[num_channles[0]],
num_heads=(1, ),
num_window_sizes=(7, ),
num_mlp_ratios=(4, ),
drop_paths=(0.1, ),
norm_cfg=norm_cfg,
)
feats = [
torch.randn(1, in_channels[0], 64, 64),
]
feats = hrmodule(feats)
assert len(feats) == 1
assert feats[0].shape == torch.Size([1, in_channels[0], 64, 64])
# Value tests
kwargs = dict(
num_branches=2,
block=block,
num_blocks=(2, 2),
num_inchannels=num_inchannels,
num_channels=num_channles,
num_heads=(1, 2),
num_window_sizes=(7, 7),
num_mlp_ratios=(4, 4),
drop_paths=(0.1, 0.1),
norm_cfg=norm_cfg,
)
with pytest.raises(ValueError):
# len(num_blocks) should equal num_branches
kwargs['num_blocks'] = [2, 2, 2]
HRFomerModule(**kwargs)
kwargs['num_blocks'] = [2, 2]
with pytest.raises(ValueError):
# len(num_blocks) should equal num_branches
kwargs['num_channels'] = [2]
HRFomerModule(**kwargs)
kwargs['num_channels'] = [2, 2]
with pytest.raises(ValueError):
# len(num_blocks) should equal num_branches
kwargs['num_inchannels'] = [2]
HRFomerModule(**kwargs)
kwargs['num_inchannels'] = [2, 2]
def test_hrformer_backbone():
norm_cfg = dict(type='BN')
# only have 3 stages
extra = dict(
drop_path_rate=0.2,
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(2, ),
num_channels=(64, )),
stage2=dict(
num_modules=1,
num_branches=2,
block='HRFORMERBLOCK',
window_sizes=(7, 7),
num_heads=(1, 2),
mlp_ratios=(4, 4),
num_blocks=(2, 2),
num_channels=(32, 64)),
stage3=dict(
num_modules=4,
num_branches=3,
block='HRFORMERBLOCK',
window_sizes=(7, 7, 7),
num_heads=(1, 2, 4),
mlp_ratios=(4, 4, 4),
num_blocks=(2, 2, 2),
num_channels=(32, 64, 128)),
stage4=dict(
num_modules=3,
num_branches=4,
block='HRFORMERBLOCK',
window_sizes=(7, 7, 7, 7),
num_heads=(1, 2, 4, 8),
mlp_ratios=(4, 4, 4, 4),
num_blocks=(2, 2, 2, 2),
num_channels=(32, 64, 128, 256),
multiscale_output=True))
with pytest.raises(ValueError):
# len(num_blocks) should equal num_branches
extra['stage4']['num_branches'] = 3
HRFormer(extra=extra)
extra['stage4']['num_branches'] = 4
# Test HRFormer-S
model = HRFormer(extra=extra, norm_cfg=norm_cfg)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 64, 64)
feats = model(imgs)
assert len(feats) == 4
assert feats[0].shape == torch.Size([1, 32, 16, 16])
assert feats[3].shape == torch.Size([1, 256, 2, 2])
# Test single scale output and model
# without relative position bias
extra['stage4']['multiscale_output'] = False
extra['with_rpe'] = False
model = HRFormer(extra=extra, norm_cfg=norm_cfg)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 64, 64)
feats = model(imgs)
assert len(feats) == 1
assert feats[0].shape == torch.Size([1, 32, 16, 16])
@@ -0,0 +1,129 @@
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import HRNet
from mmpose.models.backbones.hrnet import HRModule
from mmpose.models.backbones.resnet import BasicBlock, Bottleneck
def is_block(modules):
"""Check if is HRModule building block."""
if isinstance(modules, (HRModule, )):
return True
return False
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (_BatchNorm, )):
return True
return False
def all_zeros(modules):
"""Check if the weight(and bias) is all zero."""
weight_zero = torch.equal(modules.weight.data,
torch.zeros_like(modules.weight.data))
if hasattr(modules, 'bias'):
bias_zero = torch.equal(modules.bias.data,
torch.zeros_like(modules.bias.data))
else:
bias_zero = True
return weight_zero and bias_zero
def test_hrmodule():
# Test HRModule forward
block = HRModule(
num_branches=1,
blocks=BasicBlock,
num_blocks=(4, ),
in_channels=[
64,
],
num_channels=(64, ))
x = torch.randn(2, 64, 56, 56)
x_out = block([x])
assert x_out[0].shape == torch.Size([2, 64, 56, 56])
def test_hrnet_backbone():
extra = dict(
stage1=dict(
num_modules=1,
num_branches=1,
block='BOTTLENECK',
num_blocks=(4, ),
num_channels=(64, )),
stage2=dict(
num_modules=1,
num_branches=2,
block='BASIC',
num_blocks=(4, 4),
num_channels=(32, 64)),
stage3=dict(
num_modules=4,
num_branches=3,
block='BASIC',
num_blocks=(4, 4, 4),
num_channels=(32, 64, 128)),
stage4=dict(
num_modules=3,
num_branches=4,
block='BASIC',
num_blocks=(4, 4, 4, 4),
num_channels=(32, 64, 128, 256)))
model = HRNet(extra, in_channels=3)
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([2, 32, 56, 56])
# Test HRNet zero initialization of residual
model = HRNet(extra, in_channels=3, zero_init_residual=True)
model.init_weights()
for m in model.modules():
if isinstance(m, Bottleneck):
assert all_zeros(m.norm3)
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([2, 32, 56, 56])
# Test HRNet with the first three stages frozen
frozen_stages = 3
model = HRNet(extra, in_channels=3, frozen_stages=frozen_stages)
model.init_weights()
model.train()
if frozen_stages >= 0:
assert model.norm1.training is False
assert model.norm2.training is False
for layer in [model.conv1, model.norm1, model.conv2, model.norm2]:
for param in layer.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
if i == 1:
layer = getattr(model, 'layer1')
else:
layer = getattr(model, f'stage{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
if i < 4:
layer = getattr(model, f'transition{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
@@ -0,0 +1,143 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import LiteHRNet
from mmpose.models.backbones.litehrnet import LiteHRModule
from mmpose.models.backbones.resnet import Bottleneck
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (_BatchNorm, )):
return True
return False
def all_zeros(modules):
"""Check if the weight(and bias) is all zero."""
weight_zero = torch.equal(modules.weight.data,
torch.zeros_like(modules.weight.data))
if hasattr(modules, 'bias'):
bias_zero = torch.equal(modules.bias.data,
torch.zeros_like(modules.bias.data))
else:
bias_zero = True
return weight_zero and bias_zero
def test_litehrmodule():
# Test LiteHRModule forward
block = LiteHRModule(
num_branches=1,
num_blocks=1,
in_channels=[
40,
],
reduce_ratio=8,
module_type='LITE')
x = torch.randn(2, 40, 56, 56)
x_out = block([[x]])
assert x_out[0][0].shape == torch.Size([2, 40, 56, 56])
block = LiteHRModule(
num_branches=1,
num_blocks=1,
in_channels=[
40,
],
reduce_ratio=8,
module_type='NAIVE')
x = torch.randn(2, 40, 56, 56)
x_out = block([x])
assert x_out[0].shape == torch.Size([2, 40, 56, 56])
with pytest.raises(ValueError):
block = LiteHRModule(
num_branches=1,
num_blocks=1,
in_channels=[
40,
],
reduce_ratio=8,
module_type='none')
def test_litehrnet_backbone():
extra = dict(
stem=dict(stem_channels=32, out_channels=32, expand_ratio=1),
num_stages=3,
stages_spec=dict(
num_modules=(2, 4, 2),
num_branches=(2, 3, 4),
num_blocks=(2, 2, 2),
module_type=('LITE', 'LITE', 'LITE'),
with_fuse=(True, True, True),
reduce_ratios=(8, 8, 8),
num_channels=(
(40, 80),
(40, 80, 160),
(40, 80, 160, 320),
)),
with_head=True)
model = LiteHRNet(extra, in_channels=3)
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([2, 40, 56, 56])
# Test HRNet zero initialization of residual
model = LiteHRNet(extra, in_channels=3)
model.init_weights()
for m in model.modules():
if isinstance(m, Bottleneck):
assert all_zeros(m.norm3)
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([2, 40, 56, 56])
extra = dict(
stem=dict(stem_channels=32, out_channels=32, expand_ratio=1),
num_stages=3,
stages_spec=dict(
num_modules=(2, 4, 2),
num_branches=(2, 3, 4),
num_blocks=(2, 2, 2),
module_type=('NAIVE', 'NAIVE', 'NAIVE'),
with_fuse=(True, True, True),
reduce_ratios=(8, 8, 8),
num_channels=(
(40, 80),
(40, 80, 160),
(40, 80, 160, 320),
)),
with_head=True)
model = LiteHRNet(extra, in_channels=3)
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([2, 40, 56, 56])
# Test HRNet zero initialization of residual
model = LiteHRNet(extra, in_channels=3)
model.init_weights()
for m in model.modules():
if isinstance(m, Bottleneck):
assert all_zeros(m.norm3)
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 1
assert feat[0].shape == torch.Size([2, 40, 56, 56])
@@ -0,0 +1,257 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import MobileNetV2
from mmpose.models.backbones.mobilenet_v2 import InvertedResidual
def is_block(modules):
"""Check if is ResNet building block."""
if isinstance(modules, (InvertedResidual, )):
return True
return False
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (GroupNorm, _BatchNorm)):
return True
return False
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_mobilenetv2_invertedresidual():
with pytest.raises(AssertionError):
# stride must be in [1, 2]
InvertedResidual(16, 24, stride=3, expand_ratio=6)
# Test InvertedResidual with checkpoint forward, stride=1
block = InvertedResidual(16, 24, stride=1, expand_ratio=6)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 24, 56, 56))
# Test InvertedResidual with expand_ratio=1
block = InvertedResidual(16, 16, stride=1, expand_ratio=1)
assert len(block.conv) == 2
# Test InvertedResidual with use_res_connect
block = InvertedResidual(16, 16, stride=1, expand_ratio=6)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert block.use_res_connect is True
assert x_out.shape == torch.Size((1, 16, 56, 56))
# Test InvertedResidual with checkpoint forward, stride=2
block = InvertedResidual(16, 24, stride=2, expand_ratio=6)
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 24, 28, 28))
# Test InvertedResidual with checkpoint forward
block = InvertedResidual(16, 24, stride=1, expand_ratio=6, with_cp=True)
assert block.with_cp
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 24, 56, 56))
# Test InvertedResidual with act_cfg=dict(type='ReLU')
block = InvertedResidual(
16, 24, stride=1, expand_ratio=6, act_cfg=dict(type='ReLU'))
x = torch.randn(1, 16, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 24, 56, 56))
def test_mobilenetv2_backbone():
with pytest.raises(TypeError):
# pretrained must be a string path
model = MobileNetV2()
model.init_weights(pretrained=0)
with pytest.raises(ValueError):
# frozen_stages must in range(1, 8)
MobileNetV2(frozen_stages=8)
with pytest.raises(ValueError):
# tout_indices in range(-1, 8)
MobileNetV2(out_indices=[8])
# Test MobileNetV2 with first stage frozen
frozen_stages = 1
model = MobileNetV2(frozen_stages=frozen_stages)
model.init_weights()
model.train()
for mod in model.conv1.modules():
for param in mod.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test MobileNetV2 with norm_eval=True
model = MobileNetV2(norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test MobileNetV2 forward with widen_factor=1.0
model = MobileNetV2(widen_factor=1.0, out_indices=range(0, 8))
model.init_weights()
model.train()
assert check_norm_state(model.modules(), True)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 8
assert feat[0].shape == torch.Size((1, 16, 112, 112))
assert feat[1].shape == torch.Size((1, 24, 56, 56))
assert feat[2].shape == torch.Size((1, 32, 28, 28))
assert feat[3].shape == torch.Size((1, 64, 14, 14))
assert feat[4].shape == torch.Size((1, 96, 14, 14))
assert feat[5].shape == torch.Size((1, 160, 7, 7))
assert feat[6].shape == torch.Size((1, 320, 7, 7))
assert feat[7].shape == torch.Size((1, 1280, 7, 7))
# Test MobileNetV2 forward with widen_factor=0.5
model = MobileNetV2(widen_factor=0.5, out_indices=range(0, 7))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 7
assert feat[0].shape == torch.Size((1, 8, 112, 112))
assert feat[1].shape == torch.Size((1, 16, 56, 56))
assert feat[2].shape == torch.Size((1, 16, 28, 28))
assert feat[3].shape == torch.Size((1, 32, 14, 14))
assert feat[4].shape == torch.Size((1, 48, 14, 14))
assert feat[5].shape == torch.Size((1, 80, 7, 7))
assert feat[6].shape == torch.Size((1, 160, 7, 7))
# Test MobileNetV2 forward with widen_factor=2.0
model = MobileNetV2(widen_factor=2.0)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size((1, 2560, 7, 7))
# Test MobileNetV2 forward with out_indices=None
model = MobileNetV2(widen_factor=1.0)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size((1, 1280, 7, 7))
# Test MobileNetV2 forward with dict(type='ReLU')
model = MobileNetV2(
widen_factor=1.0, act_cfg=dict(type='ReLU'), out_indices=range(0, 7))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 7
assert feat[0].shape == torch.Size((1, 16, 112, 112))
assert feat[1].shape == torch.Size((1, 24, 56, 56))
assert feat[2].shape == torch.Size((1, 32, 28, 28))
assert feat[3].shape == torch.Size((1, 64, 14, 14))
assert feat[4].shape == torch.Size((1, 96, 14, 14))
assert feat[5].shape == torch.Size((1, 160, 7, 7))
assert feat[6].shape == torch.Size((1, 320, 7, 7))
# Test MobileNetV2 with GroupNorm forward
model = MobileNetV2(widen_factor=1.0, out_indices=range(0, 7))
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 7
assert feat[0].shape == torch.Size((1, 16, 112, 112))
assert feat[1].shape == torch.Size((1, 24, 56, 56))
assert feat[2].shape == torch.Size((1, 32, 28, 28))
assert feat[3].shape == torch.Size((1, 64, 14, 14))
assert feat[4].shape == torch.Size((1, 96, 14, 14))
assert feat[5].shape == torch.Size((1, 160, 7, 7))
assert feat[6].shape == torch.Size((1, 320, 7, 7))
# Test MobileNetV2 with BatchNorm forward
model = MobileNetV2(
widen_factor=1.0,
norm_cfg=dict(type='GN', num_groups=2, requires_grad=True),
out_indices=range(0, 7))
for m in model.modules():
if is_norm(m):
assert isinstance(m, GroupNorm)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 7
assert feat[0].shape == torch.Size((1, 16, 112, 112))
assert feat[1].shape == torch.Size((1, 24, 56, 56))
assert feat[2].shape == torch.Size((1, 32, 28, 28))
assert feat[3].shape == torch.Size((1, 64, 14, 14))
assert feat[4].shape == torch.Size((1, 96, 14, 14))
assert feat[5].shape == torch.Size((1, 160, 7, 7))
assert feat[6].shape == torch.Size((1, 320, 7, 7))
# Test MobileNetV2 with layers 1, 3, 5 out forward
model = MobileNetV2(widen_factor=1.0, out_indices=(0, 2, 4))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 16, 112, 112))
assert feat[1].shape == torch.Size((1, 32, 28, 28))
assert feat[2].shape == torch.Size((1, 96, 14, 14))
# Test MobileNetV2 with checkpoint forward
model = MobileNetV2(
widen_factor=1.0, with_cp=True, out_indices=range(0, 7))
for m in model.modules():
if is_block(m):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 7
assert feat[0].shape == torch.Size((1, 16, 112, 112))
assert feat[1].shape == torch.Size((1, 24, 56, 56))
assert feat[2].shape == torch.Size((1, 32, 28, 28))
assert feat[3].shape == torch.Size((1, 64, 14, 14))
assert feat[4].shape == torch.Size((1, 96, 14, 14))
assert feat[5].shape == torch.Size((1, 160, 7, 7))
assert feat[6].shape == torch.Size((1, 320, 7, 7))
@@ -0,0 +1,169 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import MobileNetV3
from mmpose.models.backbones.utils import InvertedResidual
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (GroupNorm, _BatchNorm)):
return True
return False
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_mobilenetv3_backbone():
with pytest.raises(TypeError):
# pretrained must be a string path
model = MobileNetV3()
model.init_weights(pretrained=0)
with pytest.raises(AssertionError):
# arch must in [small, big]
MobileNetV3(arch='others')
with pytest.raises(ValueError):
# frozen_stages must less than 12 when arch is small
MobileNetV3(arch='small', frozen_stages=12)
with pytest.raises(ValueError):
# frozen_stages must less than 16 when arch is big
MobileNetV3(arch='big', frozen_stages=16)
with pytest.raises(ValueError):
# max out_indices must less than 11 when arch is small
MobileNetV3(arch='small', out_indices=(11, ))
with pytest.raises(ValueError):
# max out_indices must less than 15 when arch is big
MobileNetV3(arch='big', out_indices=(15, ))
# Test MobileNetv3
model = MobileNetV3()
model.init_weights()
model.train()
# Test MobileNetv3 with first stage frozen
frozen_stages = 1
model = MobileNetV3(frozen_stages=frozen_stages)
model.init_weights()
model.train()
for param in model.conv1.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test MobileNetv3 with norm eval
model = MobileNetV3(norm_eval=True, out_indices=range(0, 11))
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test MobileNetv3 forward with small arch
model = MobileNetV3(out_indices=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 11
assert feat[0].shape == torch.Size([1, 16, 56, 56])
assert feat[1].shape == torch.Size([1, 24, 28, 28])
assert feat[2].shape == torch.Size([1, 24, 28, 28])
assert feat[3].shape == torch.Size([1, 40, 14, 14])
assert feat[4].shape == torch.Size([1, 40, 14, 14])
assert feat[5].shape == torch.Size([1, 40, 14, 14])
assert feat[6].shape == torch.Size([1, 48, 14, 14])
assert feat[7].shape == torch.Size([1, 48, 14, 14])
assert feat[8].shape == torch.Size([1, 96, 7, 7])
assert feat[9].shape == torch.Size([1, 96, 7, 7])
assert feat[10].shape == torch.Size([1, 96, 7, 7])
# Test MobileNetv3 forward with small arch and GroupNorm
model = MobileNetV3(
out_indices=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
norm_cfg=dict(type='GN', num_groups=2, requires_grad=True))
for m in model.modules():
if is_norm(m):
assert isinstance(m, GroupNorm)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 11
assert feat[0].shape == torch.Size([1, 16, 56, 56])
assert feat[1].shape == torch.Size([1, 24, 28, 28])
assert feat[2].shape == torch.Size([1, 24, 28, 28])
assert feat[3].shape == torch.Size([1, 40, 14, 14])
assert feat[4].shape == torch.Size([1, 40, 14, 14])
assert feat[5].shape == torch.Size([1, 40, 14, 14])
assert feat[6].shape == torch.Size([1, 48, 14, 14])
assert feat[7].shape == torch.Size([1, 48, 14, 14])
assert feat[8].shape == torch.Size([1, 96, 7, 7])
assert feat[9].shape == torch.Size([1, 96, 7, 7])
assert feat[10].shape == torch.Size([1, 96, 7, 7])
# Test MobileNetv3 forward with big arch
model = MobileNetV3(
arch='big',
out_indices=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 15
assert feat[0].shape == torch.Size([1, 16, 112, 112])
assert feat[1].shape == torch.Size([1, 24, 56, 56])
assert feat[2].shape == torch.Size([1, 24, 56, 56])
assert feat[3].shape == torch.Size([1, 40, 28, 28])
assert feat[4].shape == torch.Size([1, 40, 28, 28])
assert feat[5].shape == torch.Size([1, 40, 28, 28])
assert feat[6].shape == torch.Size([1, 80, 14, 14])
assert feat[7].shape == torch.Size([1, 80, 14, 14])
assert feat[8].shape == torch.Size([1, 80, 14, 14])
assert feat[9].shape == torch.Size([1, 80, 14, 14])
assert feat[10].shape == torch.Size([1, 112, 14, 14])
assert feat[11].shape == torch.Size([1, 112, 14, 14])
assert feat[12].shape == torch.Size([1, 160, 14, 14])
assert feat[13].shape == torch.Size([1, 160, 7, 7])
assert feat[14].shape == torch.Size([1, 160, 7, 7])
# Test MobileNetv3 forward with big arch
model = MobileNetV3(arch='big', out_indices=(0, ))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 16, 112, 112])
# Test MobileNetv3 with checkpoint forward
model = MobileNetV3(with_cp=True)
for m in model.modules():
if isinstance(m, InvertedResidual):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 96, 7, 7])
@@ -0,0 +1,32 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models import MSPN
def test_mspn_backbone():
with pytest.raises(AssertionError):
# MSPN's num_stages should larger than 0
MSPN(num_stages=0)
with pytest.raises(AssertionError):
# MSPN's num_units should larger than 1
MSPN(num_units=1)
with pytest.raises(AssertionError):
# len(num_blocks) should equal num_units
MSPN(num_units=2, num_blocks=[2, 2, 2])
# Test MSPN's outputs
model = MSPN(num_stages=2, num_units=2, num_blocks=[2, 2])
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 511, 511)
feat = model(imgs)
assert len(feat) == 2
assert len(feat[0]) == 2
assert len(feat[1]) == 2
assert feat[0][0].shape == torch.Size([1, 256, 64, 64])
assert feat[0][1].shape == torch.Size([1, 256, 128, 128])
assert feat[1][0].shape == torch.Size([1, 256, 64, 64])
assert feat[1][1].shape == torch.Size([1, 256, 128, 128])
@@ -0,0 +1,92 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models.backbones import RegNet
regnet_test_data = [
('regnetx_400mf',
dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22,
bot_mul=1.0), [32, 64, 160, 384]),
('regnetx_800mf',
dict(w0=56, wa=35.73, wm=2.28, group_w=16, depth=16,
bot_mul=1.0), [64, 128, 288, 672]),
('regnetx_1.6gf',
dict(w0=80, wa=34.01, wm=2.25, group_w=24, depth=18,
bot_mul=1.0), [72, 168, 408, 912]),
('regnetx_3.2gf',
dict(w0=88, wa=26.31, wm=2.25, group_w=48, depth=25,
bot_mul=1.0), [96, 192, 432, 1008]),
('regnetx_4.0gf',
dict(w0=96, wa=38.65, wm=2.43, group_w=40, depth=23,
bot_mul=1.0), [80, 240, 560, 1360]),
('regnetx_6.4gf',
dict(w0=184, wa=60.83, wm=2.07, group_w=56, depth=17,
bot_mul=1.0), [168, 392, 784, 1624]),
('regnetx_8.0gf',
dict(w0=80, wa=49.56, wm=2.88, group_w=120, depth=23,
bot_mul=1.0), [80, 240, 720, 1920]),
('regnetx_12gf',
dict(w0=168, wa=73.36, wm=2.37, group_w=112, depth=19,
bot_mul=1.0), [224, 448, 896, 2240]),
]
@pytest.mark.parametrize('arch_name,arch,out_channels', regnet_test_data)
def test_regnet_backbone(arch_name, arch, out_channels):
with pytest.raises(AssertionError):
# ResNeXt depth should be in [50, 101, 152]
RegNet(arch_name + '233')
# output the last feature map
model = RegNet(arch_name)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert isinstance(feat, torch.Tensor)
assert feat.shape == (1, out_channels[-1], 7, 7)
# output feature map of all stages
model = RegNet(arch_name, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, out_channels[0], 56, 56)
assert feat[1].shape == (1, out_channels[1], 28, 28)
assert feat[2].shape == (1, out_channels[2], 14, 14)
assert feat[3].shape == (1, out_channels[3], 7, 7)
@pytest.mark.parametrize('arch_name,arch,out_channels', regnet_test_data)
def test_custom_arch(arch_name, arch, out_channels):
# output the last feature map
model = RegNet(arch)
model.init_weights()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert isinstance(feat, torch.Tensor)
assert feat.shape == (1, out_channels[-1], 7, 7)
# output feature map of all stages
model = RegNet(arch, out_indices=(0, 1, 2, 3))
model.init_weights()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, out_channels[0], 56, 56)
assert feat[1].shape == (1, out_channels[1], 28, 28)
assert feat[2].shape == (1, out_channels[2], 14, 14)
assert feat[3].shape == (1, out_channels[3], 7, 7)
def test_exception():
# arch must be a str or dict
with pytest.raises(TypeError):
_ = RegNet(50)
@@ -0,0 +1,44 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models.backbones import ResNeSt
from mmpose.models.backbones.resnest import Bottleneck as BottleneckS
def test_bottleneck():
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
BottleneckS(64, 64, radix=2, reduction_factor=4, style='tensorflow')
# Test ResNeSt Bottleneck structure
block = BottleneckS(
64, 256, radix=2, reduction_factor=4, stride=2, style='pytorch')
assert block.avd_layer.stride == 2
assert block.conv2.channels == 64
# Test ResNeSt Bottleneck forward
block = BottleneckS(64, 64, radix=2, reduction_factor=4)
x = torch.randn(2, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([2, 64, 56, 56])
def test_resnest():
with pytest.raises(KeyError):
# ResNeSt depth should be in [50, 101, 152, 200]
ResNeSt(depth=18)
# Test ResNeSt with radix 2, reduction_factor 4
model = ResNeSt(
depth=50, radix=2, reduction_factor=4, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([2, 256, 56, 56])
assert feat[1].shape == torch.Size([2, 512, 28, 28])
assert feat[2].shape == torch.Size([2, 1024, 14, 14])
assert feat[3].shape == torch.Size([2, 2048, 7, 7])
@@ -0,0 +1,562 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.cnn import ConvModule
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmpose.models.backbones import ResNet, ResNetV1d
from mmpose.models.backbones.resnet import (BasicBlock, Bottleneck, ResLayer,
get_expansion)
def is_block(modules):
"""Check if is ResNet building block."""
if isinstance(modules, (BasicBlock, Bottleneck)):
return True
return False
def all_zeros(modules):
"""Check if the weight(and bias) is all zero."""
weight_zero = torch.equal(modules.weight.data,
torch.zeros_like(modules.weight.data))
if hasattr(modules, 'bias'):
bias_zero = torch.equal(modules.bias.data,
torch.zeros_like(modules.bias.data))
else:
bias_zero = True
return weight_zero and bias_zero
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_get_expansion():
assert get_expansion(Bottleneck, 2) == 2
assert get_expansion(BasicBlock) == 1
assert get_expansion(Bottleneck) == 4
class MyResBlock(nn.Module):
expansion = 8
assert get_expansion(MyResBlock) == 8
# expansion must be an integer or None
with pytest.raises(TypeError):
get_expansion(Bottleneck, '0')
# expansion is not specified and cannot be inferred
with pytest.raises(TypeError):
class SomeModule(nn.Module):
pass
get_expansion(SomeModule)
def test_basic_block():
# expansion must be 1
with pytest.raises(AssertionError):
BasicBlock(64, 64, expansion=2)
# BasicBlock with stride 1, out_channels == in_channels
block = BasicBlock(64, 64)
assert block.in_channels == 64
assert block.mid_channels == 64
assert block.out_channels == 64
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 64
assert block.conv1.kernel_size == (3, 3)
assert block.conv1.stride == (1, 1)
assert block.conv2.in_channels == 64
assert block.conv2.out_channels == 64
assert block.conv2.kernel_size == (3, 3)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
# BasicBlock with stride 1 and downsample
downsample = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=1, bias=False), nn.BatchNorm2d(128))
block = BasicBlock(64, 128, downsample=downsample)
assert block.in_channels == 64
assert block.mid_channels == 128
assert block.out_channels == 128
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 128
assert block.conv1.kernel_size == (3, 3)
assert block.conv1.stride == (1, 1)
assert block.conv2.in_channels == 128
assert block.conv2.out_channels == 128
assert block.conv2.kernel_size == (3, 3)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 128, 56, 56])
# BasicBlock with stride 2 and downsample
downsample = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=1, stride=2, bias=False),
nn.BatchNorm2d(128))
block = BasicBlock(64, 128, stride=2, downsample=downsample)
assert block.in_channels == 64
assert block.mid_channels == 128
assert block.out_channels == 128
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 128
assert block.conv1.kernel_size == (3, 3)
assert block.conv1.stride == (2, 2)
assert block.conv2.in_channels == 128
assert block.conv2.out_channels == 128
assert block.conv2.kernel_size == (3, 3)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 128, 28, 28])
# forward with checkpointing
block = BasicBlock(64, 64, with_cp=True)
assert block.with_cp
x = torch.randn(1, 64, 56, 56, requires_grad=True)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_bottleneck():
# style must be in ['pytorch', 'caffe']
with pytest.raises(AssertionError):
Bottleneck(64, 64, style='tensorflow')
# expansion must be divisible by out_channels
with pytest.raises(AssertionError):
Bottleneck(64, 64, expansion=3)
# Test Bottleneck style
block = Bottleneck(64, 64, stride=2, style='pytorch')
assert block.conv1.stride == (1, 1)
assert block.conv2.stride == (2, 2)
block = Bottleneck(64, 64, stride=2, style='caffe')
assert block.conv1.stride == (2, 2)
assert block.conv2.stride == (1, 1)
# Bottleneck with stride 1
block = Bottleneck(64, 64, style='pytorch')
assert block.in_channels == 64
assert block.mid_channels == 16
assert block.out_channels == 64
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 16
assert block.conv1.kernel_size == (1, 1)
assert block.conv2.in_channels == 16
assert block.conv2.out_channels == 16
assert block.conv2.kernel_size == (3, 3)
assert block.conv3.in_channels == 16
assert block.conv3.out_channels == 64
assert block.conv3.kernel_size == (1, 1)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 64, 56, 56)
# Bottleneck with stride 1 and downsample
downsample = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=1), nn.BatchNorm2d(128))
block = Bottleneck(64, 128, style='pytorch', downsample=downsample)
assert block.in_channels == 64
assert block.mid_channels == 32
assert block.out_channels == 128
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 32
assert block.conv1.kernel_size == (1, 1)
assert block.conv2.in_channels == 32
assert block.conv2.out_channels == 32
assert block.conv2.kernel_size == (3, 3)
assert block.conv3.in_channels == 32
assert block.conv3.out_channels == 128
assert block.conv3.kernel_size == (1, 1)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 128, 56, 56)
# Bottleneck with stride 2 and downsample
downsample = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=1, stride=2), nn.BatchNorm2d(128))
block = Bottleneck(
64, 128, stride=2, style='pytorch', downsample=downsample)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 128, 28, 28)
# Bottleneck with expansion 2
block = Bottleneck(64, 64, style='pytorch', expansion=2)
assert block.in_channels == 64
assert block.mid_channels == 32
assert block.out_channels == 64
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 32
assert block.conv1.kernel_size == (1, 1)
assert block.conv2.in_channels == 32
assert block.conv2.out_channels == 32
assert block.conv2.kernel_size == (3, 3)
assert block.conv3.in_channels == 32
assert block.conv3.out_channels == 64
assert block.conv3.kernel_size == (1, 1)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 64, 56, 56)
# Test Bottleneck with checkpointing
block = Bottleneck(64, 64, with_cp=True)
block.train()
assert block.with_cp
x = torch.randn(1, 64, 56, 56, requires_grad=True)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_basicblock_reslayer():
# 3 BasicBlock w/o downsample
layer = ResLayer(BasicBlock, 3, 32, 32)
assert len(layer) == 3
for i in range(3):
assert layer[i].in_channels == 32
assert layer[i].out_channels == 32
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 32, 56, 56)
# 3 BasicBlock w/ stride 1 and downsample
layer = ResLayer(BasicBlock, 3, 32, 64)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].downsample is not None and len(layer[0].downsample) == 2
assert isinstance(layer[0].downsample[0], nn.Conv2d)
assert layer[0].downsample[0].stride == (1, 1)
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 56, 56)
# 3 BasicBlock w/ stride 2 and downsample
layer = ResLayer(BasicBlock, 3, 32, 64, stride=2)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 2
assert layer[0].downsample is not None and len(layer[0].downsample) == 2
assert isinstance(layer[0].downsample[0], nn.Conv2d)
assert layer[0].downsample[0].stride == (2, 2)
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 28, 28)
# 3 BasicBlock w/ stride 2 and downsample with avg pool
layer = ResLayer(BasicBlock, 3, 32, 64, stride=2, avg_down=True)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 2
assert layer[0].downsample is not None and len(layer[0].downsample) == 3
assert isinstance(layer[0].downsample[0], nn.AvgPool2d)
assert layer[0].downsample[0].stride == 2
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 28, 28)
def test_bottleneck_reslayer():
# 3 Bottleneck w/o downsample
layer = ResLayer(Bottleneck, 3, 32, 32)
assert len(layer) == 3
for i in range(3):
assert layer[i].in_channels == 32
assert layer[i].out_channels == 32
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 32, 56, 56)
# 3 Bottleneck w/ stride 1 and downsample
layer = ResLayer(Bottleneck, 3, 32, 64)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 1
assert layer[0].conv1.out_channels == 16
assert layer[0].downsample is not None and len(layer[0].downsample) == 2
assert isinstance(layer[0].downsample[0], nn.Conv2d)
assert layer[0].downsample[0].stride == (1, 1)
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].conv1.out_channels == 16
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 56, 56)
# 3 Bottleneck w/ stride 2 and downsample
layer = ResLayer(Bottleneck, 3, 32, 64, stride=2)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 2
assert layer[0].conv1.out_channels == 16
assert layer[0].downsample is not None and len(layer[0].downsample) == 2
assert isinstance(layer[0].downsample[0], nn.Conv2d)
assert layer[0].downsample[0].stride == (2, 2)
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].conv1.out_channels == 16
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 28, 28)
# 3 Bottleneck w/ stride 2 and downsample with avg pool
layer = ResLayer(Bottleneck, 3, 32, 64, stride=2, avg_down=True)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 2
assert layer[0].conv1.out_channels == 16
assert layer[0].downsample is not None and len(layer[0].downsample) == 3
assert isinstance(layer[0].downsample[0], nn.AvgPool2d)
assert layer[0].downsample[0].stride == 2
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].conv1.out_channels == 16
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 28, 28)
# 3 Bottleneck with custom expansion
layer = ResLayer(Bottleneck, 3, 32, 32, expansion=2)
assert len(layer) == 3
for i in range(3):
assert layer[i].in_channels == 32
assert layer[i].out_channels == 32
assert layer[i].stride == 1
assert layer[i].conv1.out_channels == 16
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 32, 56, 56)
def test_resnet():
"""Test resnet backbone."""
with pytest.raises(KeyError):
# ResNet depth should be in [18, 34, 50, 101, 152]
ResNet(20)
with pytest.raises(AssertionError):
# In ResNet: 1 <= num_stages <= 4
ResNet(50, num_stages=0)
with pytest.raises(AssertionError):
# In ResNet: 1 <= num_stages <= 4
ResNet(50, num_stages=5)
with pytest.raises(AssertionError):
# len(strides) == len(dilations) == num_stages
ResNet(50, strides=(1, ), dilations=(1, 1), num_stages=3)
with pytest.raises(TypeError):
# pretrained must be a string path
model = ResNet(50)
model.init_weights(pretrained=0)
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
ResNet(50, style='tensorflow')
# Test ResNet50 norm_eval=True
model = ResNet(50, norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test ResNet50 with torchvision pretrained weight
model = ResNet(depth=50, norm_eval=True)
model.init_weights('torchvision://resnet50')
model.train()
assert check_norm_state(model.modules(), False)
# Test ResNet50 with first stage frozen
frozen_stages = 1
model = ResNet(50, frozen_stages=frozen_stages)
model.init_weights()
model.train()
assert model.norm1.training is False
for layer in [model.conv1, model.norm1]:
for param in layer.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test ResNet18 forward
model = ResNet(18, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 64, 56, 56)
assert feat[1].shape == (1, 128, 28, 28)
assert feat[2].shape == (1, 256, 14, 14)
assert feat[3].shape == (1, 512, 7, 7)
# Test ResNet50 with BatchNorm forward
model = ResNet(50, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 256, 56, 56)
assert feat[1].shape == (1, 512, 28, 28)
assert feat[2].shape == (1, 1024, 14, 14)
assert feat[3].shape == (1, 2048, 7, 7)
# Test ResNet50 with layers 1, 2, 3 out forward
model = ResNet(50, out_indices=(0, 1, 2))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == (1, 256, 56, 56)
assert feat[1].shape == (1, 512, 28, 28)
assert feat[2].shape == (1, 1024, 14, 14)
# Test ResNet50 with layers 3 (top feature maps) out forward
model = ResNet(50, out_indices=(3, ))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == (1, 2048, 7, 7)
# Test ResNet50 with checkpoint forward
model = ResNet(50, out_indices=(0, 1, 2, 3), with_cp=True)
for m in model.modules():
if is_block(m):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 256, 56, 56)
assert feat[1].shape == (1, 512, 28, 28)
assert feat[2].shape == (1, 1024, 14, 14)
assert feat[3].shape == (1, 2048, 7, 7)
# zero initialization of residual blocks
model = ResNet(50, out_indices=(0, 1, 2, 3), zero_init_residual=True)
model.init_weights()
for m in model.modules():
if isinstance(m, Bottleneck):
assert all_zeros(m.norm3)
elif isinstance(m, BasicBlock):
assert all_zeros(m.norm2)
# non-zero initialization of residual blocks
model = ResNet(50, out_indices=(0, 1, 2, 3), zero_init_residual=False)
model.init_weights()
for m in model.modules():
if isinstance(m, Bottleneck):
assert not all_zeros(m.norm3)
elif isinstance(m, BasicBlock):
assert not all_zeros(m.norm2)
def test_resnet_v1d():
model = ResNetV1d(depth=50, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
assert len(model.stem) == 3
for i in range(3):
assert isinstance(model.stem[i], ConvModule)
imgs = torch.randn(1, 3, 224, 224)
feat = model.stem(imgs)
assert feat.shape == (1, 64, 112, 112)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 256, 56, 56)
assert feat[1].shape == (1, 512, 28, 28)
assert feat[2].shape == (1, 1024, 14, 14)
assert feat[3].shape == (1, 2048, 7, 7)
# Test ResNet50V1d with first stage frozen
frozen_stages = 1
model = ResNetV1d(depth=50, frozen_stages=frozen_stages)
assert len(model.stem) == 3
for i in range(3):
assert isinstance(model.stem[i], ConvModule)
model.init_weights()
model.train()
check_norm_state(model.stem, False)
for param in model.stem.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
def test_resnet_half_channel():
model = ResNet(50, base_channels=32, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 128, 56, 56)
assert feat[1].shape == (1, 256, 28, 28)
assert feat[2].shape == (1, 512, 14, 14)
assert feat[3].shape == (1, 1024, 7, 7)
@@ -0,0 +1,60 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models.backbones import ResNeXt
from mmpose.models.backbones.resnext import Bottleneck as BottleneckX
def test_bottleneck():
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
BottleneckX(64, 64, groups=32, width_per_group=4, style='tensorflow')
# Test ResNeXt Bottleneck structure
block = BottleneckX(
64, 256, groups=32, width_per_group=4, stride=2, style='pytorch')
assert block.conv2.stride == (2, 2)
assert block.conv2.groups == 32
assert block.conv2.out_channels == 128
# Test ResNeXt Bottleneck forward
block = BottleneckX(64, 64, base_channels=16, groups=32, width_per_group=4)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_resnext():
with pytest.raises(KeyError):
# ResNeXt depth should be in [50, 101, 152]
ResNeXt(depth=18)
# Test ResNeXt with group 32, width_per_group 4
model = ResNeXt(
depth=50, groups=32, width_per_group=4, out_indices=(0, 1, 2, 3))
for m in model.modules():
if isinstance(m, BottleneckX):
assert m.conv2.groups == 32
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([1, 256, 56, 56])
assert feat[1].shape == torch.Size([1, 512, 28, 28])
assert feat[2].shape == torch.Size([1, 1024, 14, 14])
assert feat[3].shape == torch.Size([1, 2048, 7, 7])
# Test ResNeXt with group 32, width_per_group 4 and layers 3 out forward
model = ResNeXt(depth=50, groups=32, width_per_group=4, out_indices=(3, ))
for m in model.modules():
if isinstance(m, BottleneckX):
assert m.conv2.groups == 32
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 2048, 7, 7])
@@ -0,0 +1,35 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models import RSN
def test_rsn_backbone():
with pytest.raises(AssertionError):
# RSN's num_stages should larger than 0
RSN(num_stages=0)
with pytest.raises(AssertionError):
# RSN's num_steps should larger than 1
RSN(num_steps=1)
with pytest.raises(AssertionError):
# RSN's num_units should larger than 1
RSN(num_units=1)
with pytest.raises(AssertionError):
# len(num_blocks) should equal num_units
RSN(num_units=2, num_blocks=[2, 2, 2])
# Test RSN's outputs
model = RSN(num_stages=2, num_units=2, num_blocks=[2, 2])
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 511, 511)
feat = model(imgs)
assert len(feat) == 2
assert len(feat[0]) == 2
assert len(feat[1]) == 2
assert feat[0][0].shape == torch.Size([1, 256, 64, 64])
assert feat[0][1].shape == torch.Size([1, 256, 128, 128])
assert feat[1][0].shape == torch.Size([1, 256, 64, 64])
assert feat[1][1].shape == torch.Size([1, 256, 128, 128])
@@ -0,0 +1,163 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import SCNet
from mmpose.models.backbones.scnet import SCBottleneck, SCConv
def is_block(modules):
"""Check if is SCNet building block."""
if isinstance(modules, (SCBottleneck, )):
return True
return False
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (_BatchNorm, )):
return True
return False
def all_zeros(modules):
"""Check if the weight(and bias) is all zero."""
weight_zero = torch.equal(modules.weight.data,
torch.zeros_like(modules.weight.data))
if hasattr(modules, 'bias'):
bias_zero = torch.equal(modules.bias.data,
torch.zeros_like(modules.bias.data))
else:
bias_zero = True
return weight_zero and bias_zero
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_scnet_scconv():
# Test scconv forward
layer = SCConv(64, 64, 1, 4)
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_scnet_bottleneck():
# Test Bottleneck forward
block = SCBottleneck(64, 64)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_scnet_backbone():
"""Test scnet backbone."""
with pytest.raises(KeyError):
# SCNet depth should be in [50, 101]
SCNet(20)
with pytest.raises(TypeError):
# pretrained must be a string path
model = SCNet(50)
model.init_weights(pretrained=0)
# Test SCNet norm_eval=True
model = SCNet(50, norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test SCNet50 with first stage frozen
frozen_stages = 1
model = SCNet(50, frozen_stages=frozen_stages)
model.init_weights()
model.train()
assert model.norm1.training is False
for layer in [model.conv1, model.norm1]:
for param in layer.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test SCNet with BatchNorm forward
model = SCNet(50, out_indices=(0, 1, 2, 3))
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
model.init_weights()
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([2, 256, 56, 56])
assert feat[1].shape == torch.Size([2, 512, 28, 28])
assert feat[2].shape == torch.Size([2, 1024, 14, 14])
assert feat[3].shape == torch.Size([2, 2048, 7, 7])
# Test SCNet with layers 1, 2, 3 out forward
model = SCNet(50, out_indices=(0, 1, 2))
model.init_weights()
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size([2, 256, 56, 56])
assert feat[1].shape == torch.Size([2, 512, 28, 28])
assert feat[2].shape == torch.Size([2, 1024, 14, 14])
# Test SEResNet50 with layers 3 (top feature maps) out forward
model = SCNet(50, out_indices=(3, ))
model.init_weights()
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([2, 2048, 7, 7])
# Test SEResNet50 with checkpoint forward
model = SCNet(50, out_indices=(0, 1, 2, 3), with_cp=True)
for m in model.modules():
if is_block(m):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([2, 256, 56, 56])
assert feat[1].shape == torch.Size([2, 512, 28, 28])
assert feat[2].shape == torch.Size([2, 1024, 14, 14])
assert feat[3].shape == torch.Size([2, 2048, 7, 7])
# Test SCNet zero initialization of residual
model = SCNet(50, out_indices=(0, 1, 2, 3), zero_init_residual=True)
model.init_weights()
for m in model.modules():
if isinstance(m, SCBottleneck):
assert all_zeros(m.norm3)
model.train()
imgs = torch.randn(2, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([2, 256, 56, 56])
assert feat[1].shape == torch.Size([2, 512, 28, 28])
assert feat[2].shape == torch.Size([2, 1024, 14, 14])
assert feat[3].shape == torch.Size([2, 2048, 7, 7])
@@ -0,0 +1,243 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import AvgPool2d
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import SEResNet
from mmpose.models.backbones.resnet import ResLayer
from mmpose.models.backbones.seresnet import SEBottleneck, SELayer
def all_zeros(modules):
"""Check if the weight(and bias) is all zero."""
weight_zero = torch.equal(modules.weight.data,
torch.zeros_like(modules.weight.data))
if hasattr(modules, 'bias'):
bias_zero = torch.equal(modules.bias.data,
torch.zeros_like(modules.bias.data))
else:
bias_zero = True
return weight_zero and bias_zero
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_selayer():
# Test selayer forward
layer = SELayer(64)
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
# Test selayer forward with different ratio
layer = SELayer(64, ratio=8)
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_bottleneck():
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
SEBottleneck(64, 64, style='tensorflow')
# Test SEBottleneck with checkpoint forward
block = SEBottleneck(64, 64, with_cp=True)
assert block.with_cp
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
# Test Bottleneck style
block = SEBottleneck(64, 256, stride=2, style='pytorch')
assert block.conv1.stride == (1, 1)
assert block.conv2.stride == (2, 2)
block = SEBottleneck(64, 256, stride=2, style='caffe')
assert block.conv1.stride == (2, 2)
assert block.conv2.stride == (1, 1)
# Test Bottleneck forward
block = SEBottleneck(64, 64)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_res_layer():
# Test ResLayer of 3 Bottleneck w\o downsample
layer = ResLayer(SEBottleneck, 3, 64, 64, se_ratio=16)
assert len(layer) == 3
assert layer[0].conv1.in_channels == 64
assert layer[0].conv1.out_channels == 16
for i in range(1, len(layer)):
assert layer[i].conv1.in_channels == 64
assert layer[i].conv1.out_channels == 16
for i in range(len(layer)):
assert layer[i].downsample is None
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
# Test ResLayer of 3 SEBottleneck with downsample
layer = ResLayer(SEBottleneck, 3, 64, 256, se_ratio=16)
assert layer[0].downsample[0].out_channels == 256
for i in range(1, len(layer)):
assert layer[i].downsample is None
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 256, 56, 56])
# Test ResLayer of 3 SEBottleneck with stride=2
layer = ResLayer(SEBottleneck, 3, 64, 256, stride=2, se_ratio=8)
assert layer[0].downsample[0].out_channels == 256
assert layer[0].downsample[0].stride == (2, 2)
for i in range(1, len(layer)):
assert layer[i].downsample is None
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 256, 28, 28])
# Test ResLayer of 3 SEBottleneck with stride=2 and average downsample
layer = ResLayer(
SEBottleneck, 3, 64, 256, stride=2, avg_down=True, se_ratio=8)
assert isinstance(layer[0].downsample[0], AvgPool2d)
assert layer[0].downsample[1].out_channels == 256
assert layer[0].downsample[1].stride == (1, 1)
for i in range(1, len(layer)):
assert layer[i].downsample is None
x = torch.randn(1, 64, 56, 56)
x_out = layer(x)
assert x_out.shape == torch.Size([1, 256, 28, 28])
def test_seresnet():
"""Test resnet backbone."""
with pytest.raises(KeyError):
# SEResNet depth should be in [50, 101, 152]
SEResNet(20)
with pytest.raises(AssertionError):
# In SEResNet: 1 <= num_stages <= 4
SEResNet(50, num_stages=0)
with pytest.raises(AssertionError):
# In SEResNet: 1 <= num_stages <= 4
SEResNet(50, num_stages=5)
with pytest.raises(AssertionError):
# len(strides) == len(dilations) == num_stages
SEResNet(50, strides=(1, ), dilations=(1, 1), num_stages=3)
with pytest.raises(TypeError):
# pretrained must be a string path
model = SEResNet(50)
model.init_weights(pretrained=0)
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
SEResNet(50, style='tensorflow')
# Test SEResNet50 norm_eval=True
model = SEResNet(50, norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test SEResNet50 with torchvision pretrained weight
model = SEResNet(depth=50, norm_eval=True)
model.init_weights('torchvision://resnet50')
model.train()
assert check_norm_state(model.modules(), False)
# Test SEResNet50 with first stage frozen
frozen_stages = 1
model = SEResNet(50, frozen_stages=frozen_stages)
model.init_weights()
model.train()
assert model.norm1.training is False
for layer in [model.conv1, model.norm1]:
for param in layer.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test SEResNet50 with BatchNorm forward
model = SEResNet(50, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([1, 256, 56, 56])
assert feat[1].shape == torch.Size([1, 512, 28, 28])
assert feat[2].shape == torch.Size([1, 1024, 14, 14])
assert feat[3].shape == torch.Size([1, 2048, 7, 7])
# Test SEResNet50 with layers 1, 2, 3 out forward
model = SEResNet(50, out_indices=(0, 1, 2))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size([1, 256, 56, 56])
assert feat[1].shape == torch.Size([1, 512, 28, 28])
assert feat[2].shape == torch.Size([1, 1024, 14, 14])
# Test SEResNet50 with layers 3 (top feature maps) out forward
model = SEResNet(50, out_indices=(3, ))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 2048, 7, 7])
# Test SEResNet50 with checkpoint forward
model = SEResNet(50, out_indices=(0, 1, 2, 3), with_cp=True)
for m in model.modules():
if isinstance(m, SEBottleneck):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([1, 256, 56, 56])
assert feat[1].shape == torch.Size([1, 512, 28, 28])
assert feat[2].shape == torch.Size([1, 1024, 14, 14])
assert feat[3].shape == torch.Size([1, 2048, 7, 7])
# Test SEResNet50 zero initialization of residual
model = SEResNet(50, out_indices=(0, 1, 2, 3), zero_init_residual=True)
model.init_weights()
for m in model.modules():
if isinstance(m, SEBottleneck):
assert all_zeros(m.norm3)
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([1, 256, 56, 56])
assert feat[1].shape == torch.Size([1, 512, 28, 28])
assert feat[2].shape == torch.Size([1, 1024, 14, 14])
assert feat[3].shape == torch.Size([1, 2048, 7, 7])
@@ -0,0 +1,73 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmpose.models.backbones import SEResNeXt
from mmpose.models.backbones.seresnext import SEBottleneck as SEBottleneckX
def test_bottleneck():
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
SEBottleneckX(64, 64, groups=32, width_per_group=4, style='tensorflow')
# Test SEResNeXt Bottleneck structure
block = SEBottleneckX(
64, 256, groups=32, width_per_group=4, stride=2, style='pytorch')
assert block.width_per_group == 4
assert block.conv2.stride == (2, 2)
assert block.conv2.groups == 32
assert block.conv2.out_channels == 128
assert block.conv2.out_channels == block.mid_channels
# Test SEResNeXt Bottleneck structure (groups=1)
block = SEBottleneckX(
64, 256, groups=1, width_per_group=4, stride=2, style='pytorch')
assert block.conv2.stride == (2, 2)
assert block.conv2.groups == 1
assert block.conv2.out_channels == 64
assert block.mid_channels == 64
assert block.conv2.out_channels == block.mid_channels
# Test SEResNeXt Bottleneck forward
block = SEBottleneckX(
64, 64, base_channels=16, groups=32, width_per_group=4)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_seresnext():
with pytest.raises(KeyError):
# SEResNeXt depth should be in [50, 101, 152]
SEResNeXt(depth=18)
# Test SEResNeXt with group 32, width_per_group 4
model = SEResNeXt(
depth=50, groups=32, width_per_group=4, out_indices=(0, 1, 2, 3))
for m in model.modules():
if isinstance(m, SEBottleneckX):
assert m.conv2.groups == 32
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size([1, 256, 56, 56])
assert feat[1].shape == torch.Size([1, 512, 28, 28])
assert feat[2].shape == torch.Size([1, 1024, 14, 14])
assert feat[3].shape == torch.Size([1, 2048, 7, 7])
# Test SEResNeXt with group 32, width_per_group 4 and layers 3 out forward
model = SEResNeXt(
depth=50, groups=32, width_per_group=4, out_indices=(3, ))
for m in model.modules():
if isinstance(m, SEBottleneckX):
assert m.conv2.groups == 32
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 2048, 7, 7])
@@ -0,0 +1,245 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import ShuffleNetV1
from mmpose.models.backbones.shufflenet_v1 import ShuffleUnit
def is_block(modules):
"""Check if is ResNet building block."""
if isinstance(modules, (ShuffleUnit, )):
return True
return False
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (GroupNorm, _BatchNorm)):
return True
return False
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_shufflenetv1_shuffleuint():
with pytest.raises(ValueError):
# combine must be in ['add', 'concat']
ShuffleUnit(24, 16, groups=3, first_block=True, combine='test')
with pytest.raises(AssertionError):
# inplanes must be equal tp = outplanes when combine='add'
ShuffleUnit(64, 24, groups=4, first_block=True, combine='add')
# Test ShuffleUnit with combine='add'
block = ShuffleUnit(24, 24, groups=3, first_block=True, combine='add')
x = torch.randn(1, 24, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 24, 56, 56))
# Test ShuffleUnit with combine='concat'
block = ShuffleUnit(24, 240, groups=3, first_block=True, combine='concat')
x = torch.randn(1, 24, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 240, 28, 28))
# Test ShuffleUnit with checkpoint forward
block = ShuffleUnit(
24, 24, groups=3, first_block=True, combine='add', with_cp=True)
assert block.with_cp
x = torch.randn(1, 24, 56, 56)
x.requires_grad = True
x_out = block(x)
assert x_out.shape == torch.Size((1, 24, 56, 56))
def test_shufflenetv1_backbone():
with pytest.raises(ValueError):
# frozen_stages must be in range(-1, 4)
ShuffleNetV1(frozen_stages=10)
with pytest.raises(ValueError):
# the item in out_indices must be in range(0, 4)
ShuffleNetV1(out_indices=[5])
with pytest.raises(ValueError):
# groups must be in [1, 2, 3, 4, 8]
ShuffleNetV1(groups=10)
with pytest.raises(TypeError):
# pretrained must be str or None
model = ShuffleNetV1()
model.init_weights(pretrained=1)
# Test ShuffleNetV1 norm state
model = ShuffleNetV1()
model.init_weights()
model.train()
assert check_norm_state(model.modules(), True)
# Test ShuffleNetV1 with first stage frozen
frozen_stages = 1
model = ShuffleNetV1(frozen_stages=frozen_stages, out_indices=(0, 1, 2))
model.init_weights()
model.train()
for param in model.conv1.parameters():
assert param.requires_grad is False
for i in range(frozen_stages):
layer = model.layers[i]
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test ShuffleNetV1 forward with groups=1
model = ShuffleNetV1(groups=1, out_indices=(0, 1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 144, 28, 28))
assert feat[1].shape == torch.Size((1, 288, 14, 14))
assert feat[2].shape == torch.Size((1, 576, 7, 7))
# Test ShuffleNetV1 forward with groups=2
model = ShuffleNetV1(groups=2, out_indices=(0, 1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 200, 28, 28))
assert feat[1].shape == torch.Size((1, 400, 14, 14))
assert feat[2].shape == torch.Size((1, 800, 7, 7))
# Test ShuffleNetV1 forward with groups=3
model = ShuffleNetV1(groups=3, out_indices=(0, 1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 240, 28, 28))
assert feat[1].shape == torch.Size((1, 480, 14, 14))
assert feat[2].shape == torch.Size((1, 960, 7, 7))
# Test ShuffleNetV1 forward with groups=4
model = ShuffleNetV1(groups=4, out_indices=(0, 1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 272, 28, 28))
assert feat[1].shape == torch.Size((1, 544, 14, 14))
assert feat[2].shape == torch.Size((1, 1088, 7, 7))
# Test ShuffleNetV1 forward with groups=8
model = ShuffleNetV1(groups=8, out_indices=(0, 1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 384, 28, 28))
assert feat[1].shape == torch.Size((1, 768, 14, 14))
assert feat[2].shape == torch.Size((1, 1536, 7, 7))
# Test ShuffleNetV1 forward with GroupNorm forward
model = ShuffleNetV1(
groups=3,
norm_cfg=dict(type='GN', num_groups=2, requires_grad=True),
out_indices=(0, 1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, GroupNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == torch.Size((1, 240, 28, 28))
assert feat[1].shape == torch.Size((1, 480, 14, 14))
assert feat[2].shape == torch.Size((1, 960, 7, 7))
# Test ShuffleNetV1 forward with layers 1, 2 forward
model = ShuffleNetV1(groups=3, out_indices=(1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 2
assert feat[0].shape == torch.Size((1, 480, 14, 14))
assert feat[1].shape == torch.Size((1, 960, 7, 7))
# Test ShuffleNetV1 forward with layers 2 forward
model = ShuffleNetV1(groups=3, out_indices=(2, ))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert isinstance(feat, torch.Tensor)
assert feat.shape == torch.Size((1, 960, 7, 7))
# Test ShuffleNetV1 forward with checkpoint forward
model = ShuffleNetV1(groups=3, with_cp=True)
for m in model.modules():
if is_block(m):
assert m.with_cp
# Test ShuffleNetV1 with norm_eval
model = ShuffleNetV1(norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
@@ -0,0 +1,204 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import ShuffleNetV2
from mmpose.models.backbones.shufflenet_v2 import InvertedResidual
def is_block(modules):
"""Check if is ResNet building block."""
if isinstance(modules, (InvertedResidual, )):
return True
return False
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (GroupNorm, _BatchNorm)):
return True
return False
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_shufflenetv2_invertedresidual():
with pytest.raises(AssertionError):
# when stride==1, in_channels should be equal to out_channels // 2 * 2
InvertedResidual(24, 32, stride=1)
with pytest.raises(AssertionError):
# when in_channels != out_channels // 2 * 2, stride should not be
# equal to 1.
InvertedResidual(24, 32, stride=1)
# Test InvertedResidual forward
block = InvertedResidual(24, 48, stride=2)
x = torch.randn(1, 24, 56, 56)
x_out = block(x)
assert x_out.shape == torch.Size((1, 48, 28, 28))
# Test InvertedResidual with checkpoint forward
block = InvertedResidual(48, 48, stride=1, with_cp=True)
assert block.with_cp
x = torch.randn(1, 48, 56, 56)
x.requires_grad = True
x_out = block(x)
assert x_out.shape == torch.Size((1, 48, 56, 56))
def test_shufflenetv2_backbone():
with pytest.raises(ValueError):
# groups must be in 0.5, 1.0, 1.5, 2.0]
ShuffleNetV2(widen_factor=3.0)
with pytest.raises(ValueError):
# frozen_stages must be in [0, 1, 2, 3]
ShuffleNetV2(widen_factor=1.0, frozen_stages=4)
with pytest.raises(ValueError):
# out_indices must be in [0, 1, 2, 3]
ShuffleNetV2(widen_factor=1.0, out_indices=(4, ))
with pytest.raises(TypeError):
# pretrained must be str or None
model = ShuffleNetV2()
model.init_weights(pretrained=1)
# Test ShuffleNetV2 norm state
model = ShuffleNetV2()
model.init_weights()
model.train()
assert check_norm_state(model.modules(), True)
# Test ShuffleNetV2 with first stage frozen
frozen_stages = 1
model = ShuffleNetV2(frozen_stages=frozen_stages)
model.init_weights()
model.train()
for param in model.conv1.parameters():
assert param.requires_grad is False
for i in range(0, frozen_stages):
layer = model.layers[i]
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test ShuffleNetV2 with norm_eval
model = ShuffleNetV2(norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test ShuffleNetV2 forward with widen_factor=0.5
model = ShuffleNetV2(widen_factor=0.5, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size((1, 48, 28, 28))
assert feat[1].shape == torch.Size((1, 96, 14, 14))
assert feat[2].shape == torch.Size((1, 192, 7, 7))
# Test ShuffleNetV2 forward with widen_factor=1.0
model = ShuffleNetV2(widen_factor=1.0, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size((1, 116, 28, 28))
assert feat[1].shape == torch.Size((1, 232, 14, 14))
assert feat[2].shape == torch.Size((1, 464, 7, 7))
# Test ShuffleNetV2 forward with widen_factor=1.5
model = ShuffleNetV2(widen_factor=1.5, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size((1, 176, 28, 28))
assert feat[1].shape == torch.Size((1, 352, 14, 14))
assert feat[2].shape == torch.Size((1, 704, 7, 7))
# Test ShuffleNetV2 forward with widen_factor=2.0
model = ShuffleNetV2(widen_factor=2.0, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == torch.Size((1, 244, 28, 28))
assert feat[1].shape == torch.Size((1, 488, 14, 14))
assert feat[2].shape == torch.Size((1, 976, 7, 7))
# Test ShuffleNetV2 forward with layers 3 forward
model = ShuffleNetV2(widen_factor=1.0, out_indices=(2, ))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert isinstance(feat, torch.Tensor)
assert feat.shape == torch.Size((1, 464, 7, 7))
# Test ShuffleNetV2 forward with layers 1 2 forward
model = ShuffleNetV2(widen_factor=1.0, out_indices=(1, 2))
model.init_weights()
model.train()
for m in model.modules():
if is_norm(m):
assert isinstance(m, _BatchNorm)
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 2
assert feat[0].shape == torch.Size((1, 232, 14, 14))
assert feat[1].shape == torch.Size((1, 464, 7, 7))
# Test ShuffleNetV2 forward with checkpoint forward
model = ShuffleNetV2(widen_factor=1.0, with_cp=True)
for m in model.modules():
if is_block(m):
assert m.with_cp
@@ -0,0 +1,153 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmpose.models.backbones import TCN
from mmpose.models.backbones.tcn import BasicTemporalBlock
def test_basic_temporal_block():
with pytest.raises(AssertionError):
# padding( + shift) should not be larger than x.shape[2]
block = BasicTemporalBlock(1024, 1024, dilation=81)
x = torch.rand(2, 1024, 150)
x_out = block(x)
with pytest.raises(AssertionError):
# when use_stride_conv is True, shift + kernel_size // 2 should
# not be larger than x.shape[2]
block = BasicTemporalBlock(
1024, 1024, kernel_size=5, causal=True, use_stride_conv=True)
x = torch.rand(2, 1024, 3)
x_out = block(x)
# BasicTemporalBlock with causal == False
block = BasicTemporalBlock(1024, 1024)
x = torch.rand(2, 1024, 241)
x_out = block(x)
assert x_out.shape == torch.Size([2, 1024, 235])
# BasicTemporalBlock with causal == True
block = BasicTemporalBlock(1024, 1024, causal=True)
x = torch.rand(2, 1024, 241)
x_out = block(x)
assert x_out.shape == torch.Size([2, 1024, 235])
# BasicTemporalBlock with residual == False
block = BasicTemporalBlock(1024, 1024, residual=False)
x = torch.rand(2, 1024, 241)
x_out = block(x)
assert x_out.shape == torch.Size([2, 1024, 235])
# BasicTemporalBlock, use_stride_conv == True
block = BasicTemporalBlock(1024, 1024, use_stride_conv=True)
x = torch.rand(2, 1024, 81)
x_out = block(x)
assert x_out.shape == torch.Size([2, 1024, 27])
# BasicTemporalBlock with use_stride_conv == True and causal == True
block = BasicTemporalBlock(1024, 1024, use_stride_conv=True, causal=True)
x = torch.rand(2, 1024, 81)
x_out = block(x)
assert x_out.shape == torch.Size([2, 1024, 27])
def test_tcn_backbone():
with pytest.raises(AssertionError):
# num_blocks should equal len(kernel_sizes) - 1
TCN(in_channels=34, num_blocks=3, kernel_sizes=(3, 3, 3))
with pytest.raises(AssertionError):
# kernel size should be odd
TCN(in_channels=34, kernel_sizes=(3, 4, 3))
# Test TCN with 2 blocks (use_stride_conv == False)
model = TCN(in_channels=34, num_blocks=2, kernel_sizes=(3, 3, 3))
pose2d = torch.rand((2, 34, 243))
feat = model(pose2d)
assert len(feat) == 2
assert feat[0].shape == (2, 1024, 235)
assert feat[1].shape == (2, 1024, 217)
# Test TCN with 4 blocks and weight norm clip
max_norm = 0.1
model = TCN(
in_channels=34,
num_blocks=4,
kernel_sizes=(3, 3, 3, 3, 3),
max_norm=max_norm)
pose2d = torch.rand((2, 34, 243))
feat = model(pose2d)
assert len(feat) == 4
assert feat[0].shape == (2, 1024, 235)
assert feat[1].shape == (2, 1024, 217)
assert feat[2].shape == (2, 1024, 163)
assert feat[3].shape == (2, 1024, 1)
for module in model.modules():
if isinstance(module, torch.nn.modules.conv._ConvNd):
norm = module.weight.norm().item()
np.testing.assert_allclose(
np.maximum(norm, max_norm), max_norm, rtol=1e-4)
# Test TCN with 4 blocks (use_stride_conv == True)
model = TCN(
in_channels=34,
num_blocks=4,
kernel_sizes=(3, 3, 3, 3, 3),
use_stride_conv=True)
pose2d = torch.rand((2, 34, 243))
feat = model(pose2d)
assert len(feat) == 4
assert feat[0].shape == (2, 1024, 27)
assert feat[1].shape == (2, 1024, 9)
assert feat[2].shape == (2, 1024, 3)
assert feat[3].shape == (2, 1024, 1)
# Check that the model w. or w/o use_stride_conv will have the same
# output and gradient after a forward+backward pass
model1 = TCN(
in_channels=34,
stem_channels=4,
num_blocks=1,
kernel_sizes=(3, 3),
dropout=0,
residual=False,
norm_cfg=None)
model2 = TCN(
in_channels=34,
stem_channels=4,
num_blocks=1,
kernel_sizes=(3, 3),
dropout=0,
residual=False,
norm_cfg=None,
use_stride_conv=True)
for m in model1.modules():
if isinstance(m, nn.Conv1d):
nn.init.constant_(m.weight, 0.5)
if m.bias is not None:
nn.init.constant_(m.bias, 0)
for m in model2.modules():
if isinstance(m, nn.Conv1d):
nn.init.constant_(m.weight, 0.5)
if m.bias is not None:
nn.init.constant_(m.bias, 0)
input1 = torch.rand((1, 34, 9))
input2 = input1.clone()
outputs1 = model1(input1)
outputs2 = model2(input2)
for output1, output2 in zip(outputs1, outputs2):
assert torch.isclose(output1, output2).all()
criterion = nn.MSELoss()
target = torch.rand(output1.shape)
loss1 = criterion(output1, target)
loss2 = criterion(output2, target)
loss1.backward()
loss2.backward()
for m1, m2 in zip(model1.modules(), model2.modules()):
if isinstance(m1, nn.Conv1d):
assert torch.isclose(m1.weight.grad, m2.weight.grad).all()
@@ -0,0 +1,13 @@
# Copyright (c) OpenMMLab. All rights reserved.
import torch
from mmpose.models import builder
def test_v2v_net():
"""Test V2VNet."""
cfg = dict(type='V2VNet', input_channels=17, output_channels=15),
model = builder.build_backbone(*cfg)
input = torch.randn(2, 17, 32, 32, 32)
output = model(input)
assert output.shape == (2, 15, 32, 32, 32)
@@ -0,0 +1,137 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmpose.models.backbones import VGG
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_vgg():
"""Test VGG backbone."""
with pytest.raises(KeyError):
# VGG depth should be in [11, 13, 16, 19]
VGG(18)
with pytest.raises(AssertionError):
# In VGG: 1 <= num_stages <= 5
VGG(11, num_stages=0)
with pytest.raises(AssertionError):
# In VGG: 1 <= num_stages <= 5
VGG(11, num_stages=6)
with pytest.raises(AssertionError):
# len(dilations) == num_stages
VGG(11, dilations=(1, 1), num_stages=3)
with pytest.raises(TypeError):
# pretrained must be a string path
model = VGG(11)
model.init_weights(pretrained=0)
# Test VGG11 norm_eval=True
model = VGG(11, norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test VGG11 forward without classifiers
model = VGG(11, out_indices=(0, 1, 2, 3, 4))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 5
assert feat[0].shape == (1, 64, 112, 112)
assert feat[1].shape == (1, 128, 56, 56)
assert feat[2].shape == (1, 256, 28, 28)
assert feat[3].shape == (1, 512, 14, 14)
assert feat[4].shape == (1, 512, 7, 7)
# Test VGG11 forward with classifiers
model = VGG(11, num_classes=10, out_indices=(0, 1, 2, 3, 4, 5))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 6
assert feat[0].shape == (1, 64, 112, 112)
assert feat[1].shape == (1, 128, 56, 56)
assert feat[2].shape == (1, 256, 28, 28)
assert feat[3].shape == (1, 512, 14, 14)
assert feat[4].shape == (1, 512, 7, 7)
assert feat[5].shape == (1, 10)
# Test VGG11BN forward
model = VGG(11, norm_cfg=dict(type='BN'), out_indices=(0, 1, 2, 3, 4))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 5
assert feat[0].shape == (1, 64, 112, 112)
assert feat[1].shape == (1, 128, 56, 56)
assert feat[2].shape == (1, 256, 28, 28)
assert feat[3].shape == (1, 512, 14, 14)
assert feat[4].shape == (1, 512, 7, 7)
# Test VGG11BN forward with classifiers
model = VGG(
11,
num_classes=10,
norm_cfg=dict(type='BN'),
out_indices=(0, 1, 2, 3, 4, 5))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 6
assert feat[0].shape == (1, 64, 112, 112)
assert feat[1].shape == (1, 128, 56, 56)
assert feat[2].shape == (1, 256, 28, 28)
assert feat[3].shape == (1, 512, 14, 14)
assert feat[4].shape == (1, 512, 7, 7)
assert feat[5].shape == (1, 10)
# Test VGG13 with layers 1, 2, 3 out forward
model = VGG(13, out_indices=(0, 1, 2))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == (1, 64, 112, 112)
assert feat[1].shape == (1, 128, 56, 56)
assert feat[2].shape == (1, 256, 28, 28)
# Test VGG16 with top feature maps out forward
model = VGG(16)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == (1, 512, 7, 7)
# Test VGG19 with classification score out forward
model = VGG(19, num_classes=10)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == (1, 10)
@@ -0,0 +1,99 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
from torch.nn.modules import GroupNorm
from torch.nn.modules.batchnorm import _BatchNorm
from mmpose.models.backbones import ViPNAS_MobileNetV3
from mmpose.models.backbones.utils import InvertedResidual
def is_norm(modules):
"""Check if is one of the norms."""
if isinstance(modules, (GroupNorm, _BatchNorm)):
return True
return False
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_mobilenetv3_backbone():
with pytest.raises(TypeError):
# pretrained must be a string path
model = ViPNAS_MobileNetV3()
model.init_weights(pretrained=0)
with pytest.raises(AttributeError):
# frozen_stages must no more than 21
model = ViPNAS_MobileNetV3(frozen_stages=22)
model.train()
# Test MobileNetv3
model = ViPNAS_MobileNetV3()
model.init_weights()
model.train()
# Test MobileNetv3 with first stage frozen
frozen_stages = 1
model = ViPNAS_MobileNetV3(frozen_stages=frozen_stages)
model.init_weights()
model.train()
for param in model.conv1.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test MobileNetv3 with norm eval
model = ViPNAS_MobileNetV3(norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test MobileNetv3 forward
model = ViPNAS_MobileNetV3()
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 160, 7, 7])
# Test MobileNetv3 forward with GroupNorm
model = ViPNAS_MobileNetV3(
norm_cfg=dict(type='GN', num_groups=2, requires_grad=True))
for m in model.modules():
if is_norm(m):
assert isinstance(m, GroupNorm)
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 160, 7, 7])
# Test MobileNetv3 with checkpoint forward
model = ViPNAS_MobileNetV3(with_cp=True)
for m in model.modules():
if isinstance(m, InvertedResidual):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == torch.Size([1, 160, 7, 7])
test_mobilenetv3_backbone()
@@ -0,0 +1,341 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
import torch
import torch.nn as nn
from mmcv.utils.parrots_wrapper import _BatchNorm
from mmpose.models.backbones import ViPNAS_ResNet
from mmpose.models.backbones.vipnas_resnet import (ViPNAS_Bottleneck,
ViPNAS_ResLayer,
get_expansion)
def is_block(modules):
"""Check if is ViPNAS_ResNet building block."""
if isinstance(modules, (ViPNAS_Bottleneck)):
return True
return False
def all_zeros(modules):
"""Check if the weight(and bias) is all zero."""
weight_zero = torch.equal(modules.weight.data,
torch.zeros_like(modules.weight.data))
if hasattr(modules, 'bias'):
bias_zero = torch.equal(modules.bias.data,
torch.zeros_like(modules.bias.data))
else:
bias_zero = True
return weight_zero and bias_zero
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
return False
return True
def test_get_expansion():
assert get_expansion(ViPNAS_Bottleneck, 2) == 2
assert get_expansion(ViPNAS_Bottleneck) == 1
class MyResBlock(nn.Module):
expansion = 8
assert get_expansion(MyResBlock) == 8
# expansion must be an integer or None
with pytest.raises(TypeError):
get_expansion(ViPNAS_Bottleneck, '0')
# expansion is not specified and cannot be inferred
with pytest.raises(TypeError):
class SomeModule(nn.Module):
pass
get_expansion(SomeModule)
def test_vipnas_bottleneck():
# style must be in ['pytorch', 'caffe']
with pytest.raises(AssertionError):
ViPNAS_Bottleneck(64, 64, style='tensorflow')
# expansion must be divisible by out_channels
with pytest.raises(AssertionError):
ViPNAS_Bottleneck(64, 64, expansion=3)
# Test ViPNAS_Bottleneck style
block = ViPNAS_Bottleneck(64, 64, stride=2, style='pytorch')
assert block.conv1.stride == (1, 1)
assert block.conv2.stride == (2, 2)
block = ViPNAS_Bottleneck(64, 64, stride=2, style='caffe')
assert block.conv1.stride == (2, 2)
assert block.conv2.stride == (1, 1)
# ViPNAS_Bottleneck with stride 1
block = ViPNAS_Bottleneck(64, 64, style='pytorch')
assert block.in_channels == 64
assert block.mid_channels == 16
assert block.out_channels == 64
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 16
assert block.conv1.kernel_size == (1, 1)
assert block.conv2.in_channels == 16
assert block.conv2.out_channels == 16
assert block.conv2.kernel_size == (3, 3)
assert block.conv3.in_channels == 16
assert block.conv3.out_channels == 64
assert block.conv3.kernel_size == (1, 1)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 64, 56, 56)
# ViPNAS_Bottleneck with stride 1 and downsample
downsample = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=1), nn.BatchNorm2d(128))
block = ViPNAS_Bottleneck(64, 128, style='pytorch', downsample=downsample)
assert block.in_channels == 64
assert block.mid_channels == 32
assert block.out_channels == 128
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 32
assert block.conv1.kernel_size == (1, 1)
assert block.conv2.in_channels == 32
assert block.conv2.out_channels == 32
assert block.conv2.kernel_size == (3, 3)
assert block.conv3.in_channels == 32
assert block.conv3.out_channels == 128
assert block.conv3.kernel_size == (1, 1)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 128, 56, 56)
# ViPNAS_Bottleneck with stride 2 and downsample
downsample = nn.Sequential(
nn.Conv2d(64, 128, kernel_size=1, stride=2), nn.BatchNorm2d(128))
block = ViPNAS_Bottleneck(
64, 128, stride=2, style='pytorch', downsample=downsample)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 128, 28, 28)
# ViPNAS_Bottleneck with expansion 2
block = ViPNAS_Bottleneck(64, 64, style='pytorch', expansion=2)
assert block.in_channels == 64
assert block.mid_channels == 32
assert block.out_channels == 64
assert block.conv1.in_channels == 64
assert block.conv1.out_channels == 32
assert block.conv1.kernel_size == (1, 1)
assert block.conv2.in_channels == 32
assert block.conv2.out_channels == 32
assert block.conv2.kernel_size == (3, 3)
assert block.conv3.in_channels == 32
assert block.conv3.out_channels == 64
assert block.conv3.kernel_size == (1, 1)
x = torch.randn(1, 64, 56, 56)
x_out = block(x)
assert x_out.shape == (1, 64, 56, 56)
# Test ViPNAS_Bottleneck with checkpointing
block = ViPNAS_Bottleneck(64, 64, with_cp=True)
block.train()
assert block.with_cp
x = torch.randn(1, 64, 56, 56, requires_grad=True)
x_out = block(x)
assert x_out.shape == torch.Size([1, 64, 56, 56])
def test_vipnas_bottleneck_reslayer():
# 3 Bottleneck w/o downsample
layer = ViPNAS_ResLayer(ViPNAS_Bottleneck, 3, 32, 32)
assert len(layer) == 3
for i in range(3):
assert layer[i].in_channels == 32
assert layer[i].out_channels == 32
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 32, 56, 56)
# 3 ViPNAS_Bottleneck w/ stride 1 and downsample
layer = ViPNAS_ResLayer(ViPNAS_Bottleneck, 3, 32, 64)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 1
assert layer[0].conv1.out_channels == 64
assert layer[0].downsample is not None and len(layer[0].downsample) == 2
assert isinstance(layer[0].downsample[0], nn.Conv2d)
assert layer[0].downsample[0].stride == (1, 1)
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].conv1.out_channels == 64
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 56, 56)
# 3 ViPNAS_Bottleneck w/ stride 2 and downsample
layer = ViPNAS_ResLayer(ViPNAS_Bottleneck, 3, 32, 64, stride=2)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 2
assert layer[0].conv1.out_channels == 64
assert layer[0].downsample is not None and len(layer[0].downsample) == 2
assert isinstance(layer[0].downsample[0], nn.Conv2d)
assert layer[0].downsample[0].stride == (2, 2)
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].conv1.out_channels == 64
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 28, 28)
# 3 ViPNAS_Bottleneck w/ stride 2 and downsample with avg pool
layer = ViPNAS_ResLayer(
ViPNAS_Bottleneck, 3, 32, 64, stride=2, avg_down=True)
assert len(layer) == 3
assert layer[0].in_channels == 32
assert layer[0].out_channels == 64
assert layer[0].stride == 2
assert layer[0].conv1.out_channels == 64
assert layer[0].downsample is not None and len(layer[0].downsample) == 3
assert isinstance(layer[0].downsample[0], nn.AvgPool2d)
assert layer[0].downsample[0].stride == 2
for i in range(1, 3):
assert layer[i].in_channels == 64
assert layer[i].out_channels == 64
assert layer[i].conv1.out_channels == 64
assert layer[i].stride == 1
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 64, 28, 28)
# 3 ViPNAS_Bottleneck with custom expansion
layer = ViPNAS_ResLayer(ViPNAS_Bottleneck, 3, 32, 32, expansion=2)
assert len(layer) == 3
for i in range(3):
assert layer[i].in_channels == 32
assert layer[i].out_channels == 32
assert layer[i].stride == 1
assert layer[i].conv1.out_channels == 16
assert layer[i].downsample is None
x = torch.randn(1, 32, 56, 56)
x_out = layer(x)
assert x_out.shape == (1, 32, 56, 56)
def test_resnet():
"""Test ViPNAS_ResNet backbone."""
with pytest.raises(KeyError):
# ViPNAS_ResNet depth should be in [50]
ViPNAS_ResNet(20)
with pytest.raises(AssertionError):
# In ViPNAS_ResNet: 1 <= num_stages <= 4
ViPNAS_ResNet(50, num_stages=0)
with pytest.raises(AssertionError):
# In ViPNAS_ResNet: 1 <= num_stages <= 4
ViPNAS_ResNet(50, num_stages=5)
with pytest.raises(AssertionError):
# len(strides) == len(dilations) == num_stages
ViPNAS_ResNet(50, strides=(1, ), dilations=(1, 1), num_stages=3)
with pytest.raises(TypeError):
# pretrained must be a string path
model = ViPNAS_ResNet(50)
model.init_weights(pretrained=0)
with pytest.raises(AssertionError):
# Style must be in ['pytorch', 'caffe']
ViPNAS_ResNet(50, style='tensorflow')
# Test ViPNAS_ResNet50 norm_eval=True
model = ViPNAS_ResNet(50, norm_eval=True)
model.init_weights()
model.train()
assert check_norm_state(model.modules(), False)
# Test ViPNAS_ResNet50 with first stage frozen
frozen_stages = 1
model = ViPNAS_ResNet(50, frozen_stages=frozen_stages)
model.init_weights()
model.train()
assert model.norm1.training is False
for layer in [model.conv1, model.norm1]:
for param in layer.parameters():
assert param.requires_grad is False
for i in range(1, frozen_stages + 1):
layer = getattr(model, f'layer{i}')
for mod in layer.modules():
if isinstance(mod, _BatchNorm):
assert mod.training is False
for param in layer.parameters():
assert param.requires_grad is False
# Test ViPNAS_ResNet50 with BatchNorm forward
model = ViPNAS_ResNet(50, out_indices=(0, 1, 2, 3))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 80, 56, 56)
assert feat[1].shape == (1, 160, 28, 28)
assert feat[2].shape == (1, 304, 14, 14)
assert feat[3].shape == (1, 608, 7, 7)
# Test ViPNAS_ResNet50 with layers 1, 2, 3 out forward
model = ViPNAS_ResNet(50, out_indices=(0, 1, 2))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 3
assert feat[0].shape == (1, 80, 56, 56)
assert feat[1].shape == (1, 160, 28, 28)
assert feat[2].shape == (1, 304, 14, 14)
# Test ViPNAS_ResNet50 with layers 3 (top feature maps) out forward
model = ViPNAS_ResNet(50, out_indices=(3, ))
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert feat.shape == (1, 608, 7, 7)
# Test ViPNAS_ResNet50 with checkpoint forward
model = ViPNAS_ResNet(50, out_indices=(0, 1, 2, 3), with_cp=True)
for m in model.modules():
if is_block(m):
assert m.with_cp
model.init_weights()
model.train()
imgs = torch.randn(1, 3, 224, 224)
feat = model(imgs)
assert len(feat) == 4
assert feat[0].shape == (1, 80, 56, 56)
assert feat[1].shape == (1, 160, 28, 28)
assert feat[2].shape == (1, 304, 14, 14)
assert feat[3].shape == (1, 608, 7, 7)
@@ -0,0 +1,415 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import tempfile
import pytest
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_animal_horse10_dataset_compatibility():
dataset = 'AnimalHorse10Dataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=22,
dataset_joints=22,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 21
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 21
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/horse10/test_horse10.json',
img_prefix='tests/data/horse10/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/horse10/test_horse10.json',
img_prefix='tests/data/horse10/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 3
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_animal_fly_dataset_compatibility():
dataset = 'AnimalFlyDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=32,
dataset_joints=32,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
])
data_cfg = dict(
image_size=[192, 192],
heatmap_size=[48, 48],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/fly/test_fly.json',
img_prefix='tests/data/fly/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/fly/test_fly.json',
img_prefix='tests/data/fly/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_animal_locust_dataset_compatibility():
dataset = 'AnimalLocustDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=35,
dataset_joints=35,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
])
data_cfg = dict(
image_size=[160, 160],
heatmap_size=[40, 40],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/locust/test_locust.json',
img_prefix='tests/data/locust/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/locust/test_locust.json',
img_prefix='tests/data/locust/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_animal_zebra_dataset_compatibility():
dataset = 'AnimalZebraDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=9,
dataset_joints=9,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8])
data_cfg = dict(
image_size=[160, 160],
heatmap_size=[40, 40],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/zebra/test_zebra.json',
img_prefix='tests/data/zebra/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/zebra/test_zebra.json',
img_prefix='tests/data/zebra/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_animal_ATRW_dataset_compatibility():
dataset = 'AnimalATRWDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=15,
dataset_joints=15,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/atrw/test_atrw.json',
img_prefix='tests/data/atrw/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/atrw/test_atrw.json',
img_prefix='tests/data/atrw/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
def test_animal_Macaque_dataset_compatibility():
dataset = 'AnimalMacaqueDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/macaque/test_macaque.json',
img_prefix='tests/data/macaque/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/macaque/test_macaque.json',
img_prefix='tests/data/macaque/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
def test_animalpose_dataset_compatibility():
dataset = 'AnimalPoseDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=20,
dataset_joints=20,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/animalpose/test_animalpose.json',
img_prefix='tests/data/animalpose/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/animalpose/test_animalpose.json',
img_prefix='tests/data/animalpose/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
@@ -0,0 +1,266 @@
# Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import numpy as np
import pytest
from mmpose.datasets import DATASETS
from mmpose.datasets.builder import build_dataset
def test_body3d_h36m_dataset_compatibility():
# Test Human3.6M dataset
dataset = 'Body3DH36MDataset'
dataset_class = DATASETS.get(dataset)
# test single-frame input
data_cfg = dict(
num_joints=17,
seq_len=1,
seq_frame_interval=1,
joint_2d_src='pipeline',
joint_2d_det_file=None,
causal=False,
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl')
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
with tempfile.TemporaryDirectory() as tmpdir:
outputs = []
for result in custom_dataset:
outputs.append({
'preds': result['target'][None, ...],
'target_image_paths': [result['target_image_path']],
})
metrics = ['mpjpe', 'p-mpjpe', 'n-mpjpe']
infos = custom_dataset.evaluate(outputs, tmpdir, metrics)
np.testing.assert_almost_equal(infos['MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['N-MPJPE'], 0.0)
# test multi-frame input with joint_2d_src = 'detection'
data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
causal=True,
temporal_padding=True,
joint_2d_src='detection',
joint_2d_det_file='tests/data/h36m/test_h36m_2d_detection.npy',
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl')
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
with tempfile.TemporaryDirectory() as tmpdir:
outputs = []
for result in custom_dataset:
outputs.append({
'preds': result['target'][None, ...],
'target_image_paths': [result['target_image_path']],
})
metrics = ['mpjpe', 'p-mpjpe', 'n-mpjpe']
infos = custom_dataset.evaluate(outputs, tmpdir, metrics)
np.testing.assert_almost_equal(infos['MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['N-MPJPE'], 0.0)
def test_body3d_semi_supervision_dataset_compatibility():
# Test Body3d Semi-supervision Dataset
# load labeled dataset
labeled_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
causall=False,
temporal_padding=True,
joint_2d_src='gt',
subset=1,
subjects=['S1'],
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl')
labeled_dataset = dict(
type='Body3DH36MDataset',
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=labeled_data_cfg,
pipeline=[])
# load unlabled data
unlabeled_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
causal=False,
temporal_padding=True,
joint_2d_src='gt',
subjects=['S5', 'S7', 'S8'],
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl',
need_2d_label=True)
unlabeled_dataset = dict(
type='Body3DH36MDataset',
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=unlabeled_data_cfg,
pipeline=[
dict(
type='Collect',
keys=[('input_2d', 'unlabeled_input')],
meta_name='metas',
meta_keys=[])
])
# combine labeled and unlabeled dataset to form a new dataset
dataset = 'Body3DSemiSupervisionDataset'
dataset_class = DATASETS.get(dataset)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(labeled_dataset, unlabeled_dataset)
item = custom_dataset[0]
assert 'unlabeled_input' in item.keys()
unlabeled_dataset = build_dataset(unlabeled_dataset)
assert len(unlabeled_dataset) == len(custom_dataset)
def test_body3d_mpi_inf_3dhp_dataset_compatibility():
# Test MPI-INF-3DHP dataset
dataset = 'Body3DMpiInf3dhpDataset'
dataset_class = DATASETS.get(dataset)
# Test single-frame input on trainset
single_frame_train_data_cfg = dict(
num_joints=17,
seq_len=1,
seq_frame_interval=1,
joint_2d_src='pipeline',
joint_2d_det_file=None,
causal=False,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_train.pkl')
# Test single-frame input on testset
single_frame_test_data_cfg = dict(
num_joints=17,
seq_len=1,
seq_frame_interval=1,
joint_2d_src='gt',
joint_2d_det_file=None,
causal=False,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_test.pkl')
# Test multi-frame input on trainset
multi_frame_train_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
joint_2d_src='gt',
joint_2d_det_file=None,
causal=True,
temporal_padding=True,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_train.pkl')
# Test multi-frame input on testset
multi_frame_test_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
joint_2d_src='pipeline',
joint_2d_det_file=None,
causal=False,
temporal_padding=True,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_test.pkl')
ann_files = [
'tests/data/mpi_inf_3dhp/test_3dhp_train.npz',
'tests/data/mpi_inf_3dhp/test_3dhp_test.npz'
] * 2
data_cfgs = [
single_frame_train_data_cfg, single_frame_test_data_cfg,
multi_frame_train_data_cfg, multi_frame_test_data_cfg
]
for ann_file, data_cfg in zip(ann_files, data_cfgs):
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file=ann_file,
img_prefix='tests/data/mpi_inf_3dhp',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file=ann_file,
img_prefix='tests/data/mpi_inf_3dhp',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
with tempfile.TemporaryDirectory() as tmpdir:
outputs = []
for result in custom_dataset:
outputs.append({
'preds':
result['target'][None, ...],
'target_image_paths': [result['target_image_path']],
})
metrics = [
'mpjpe', 'p-mpjpe', '3dpck', 'p-3dpck', '3dauc', 'p-3dauc'
]
infos = custom_dataset.evaluate(outputs, tmpdir, metrics)
np.testing.assert_almost_equal(infos['MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['3DPCK'], 100.)
np.testing.assert_almost_equal(infos['P-3DPCK'], 100.)
np.testing.assert_almost_equal(infos['3DAUC'], 30 / 31 * 100)
np.testing.assert_almost_equal(infos['P-3DAUC'], 30 / 31 * 100)
@@ -0,0 +1,325 @@
# Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import numpy as np
import pytest
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
def convert_coco_to_output(coco, is_wholebody=False):
outputs = []
for img_id in coco.getImgIds():
preds = []
scores = []
image = coco.imgs[img_id]
ann_ids = coco.getAnnIds(img_id)
for ann_id in ann_ids:
obj = coco.anns[ann_id]
if is_wholebody:
keypoints = np.array(obj['keypoints'] + obj['foot_kpts'] +
obj['face_kpts'] + obj['lefthand_kpts'] +
obj['righthand_kpts']).reshape(-1, 3)
else:
keypoints = np.array(obj['keypoints']).reshape((-1, 3))
K = keypoints.shape[0]
if sum(keypoints[:, 2]) == 0:
continue
preds.append(
np.concatenate((keypoints[:, :2], np.ones(
[K, 1]), np.ones([K, 1]) * ann_id),
axis=1))
scores.append(1)
image_paths = []
image_paths.append(image['file_name'])
output = {}
output['preds'] = np.stack(preds)
output['scores'] = scores
output['image_paths'] = image_paths
output['output_heatmap'] = None
outputs.append(output)
return outputs
def test_bottom_up_COCO_dataset_compatibility():
dataset = 'BottomUpCocoDataset'
# test COCO datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128, 256],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=2,
scale_aware_sigma=False,
use_nms=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
assert custom_dataset.dataset_name == 'coco'
outputs = convert_coco_to_output(custom_dataset.coco)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_bottom_up_CrowdPose_dataset_compatibility():
dataset = 'BottomUpCrowdPoseDataset'
# test CrowdPose datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=14,
dataset_joints=14,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128, 256],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=2,
scale_aware_sigma=False)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
image_id = 103319
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
assert custom_dataset.dataset_name == 'crowdpose'
outputs = convert_coco_to_output(custom_dataset.coco)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_bottom_up_MHP_dataset_compatibility():
dataset = 'BottomUpMhpDataset'
# test MHP datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
dataset_joints=16,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=1,
scale_aware_sigma=False,
)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
image_id = 2889
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
assert custom_dataset.dataset_name == 'mhp'
outputs = convert_coco_to_output(custom_dataset.coco)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_bottom_up_AIC_dataset_compatibility():
dataset = 'BottomUpAicDataset'
# test MHP datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=14,
dataset_joints=14,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=1,
scale_aware_sigma=False,
)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
image_id = 1
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 3
_ = custom_dataset[0]
outputs = convert_coco_to_output(custom_dataset.coco)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_bottom_up_COCO_wholebody_dataset_compatibility():
dataset = 'BottomUpCocoWholeBodyDataset'
# test COCO-wholebody datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=133,
dataset_joints=133,
dataset_channel=[
list(range(133)),
],
inference_channel=list(range(133)))
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128, 256],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=2,
scale_aware_sigma=False,
)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'coco_wholebody'
image_id = 785
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 4
_ = custom_dataset[0]
outputs = convert_coco_to_output(custom_dataset.coco, is_wholebody=True)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
@@ -0,0 +1,28 @@
# Copyright (c) OpenMMLab. All rights reserved.
import pytest
from mmpose.datasets.datasets.animal.animal_base_dataset import \
AnimalBaseDataset
from mmpose.datasets.datasets.body3d.body3d_base_dataset import \
Body3DBaseDataset
from mmpose.datasets.datasets.bottom_up.bottom_up_base_dataset import \
BottomUpBaseDataset
from mmpose.datasets.datasets.face.face_base_dataset import FaceBaseDataset
from mmpose.datasets.datasets.fashion.fashion_base_dataset import \
FashionBaseDataset
from mmpose.datasets.datasets.hand.hand_base_dataset import HandBaseDataset
from mmpose.datasets.datasets.top_down.topdown_base_dataset import \
TopDownBaseDataset
@pytest.mark.parametrize('BaseDataset',
(AnimalBaseDataset, BottomUpBaseDataset,
FaceBaseDataset, FashionBaseDataset, HandBaseDataset,
TopDownBaseDataset, Body3DBaseDataset))
def test_dataset_base_class(BaseDataset):
with pytest.raises(ImportError):
class Dataset(BaseDataset):
pass
_ = Dataset()
@@ -0,0 +1,170 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import tempfile
from unittest.mock import MagicMock
import pytest
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_face_300W_dataset_compatibility():
dataset = 'Face300WDataset'
# test Face 300W datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=68,
dataset_joints=68,
dataset_channel=[
list(range(68)),
],
inference_channel=list(range(68)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/300w/test_300w.json',
img_prefix='tests/data/300w/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/300w/test_300w.json',
img_prefix='tests/data/300w/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_face_AFLW_dataset_compatibility():
dataset = 'FaceAFLWDataset'
# test Face AFLW datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=19,
dataset_joints=19,
dataset_channel=[
list(range(19)),
],
inference_channel=list(range(19)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/aflw/test_aflw.json',
img_prefix='tests/data/aflw/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/aflw/test_aflw.json',
img_prefix='tests/data/aflw/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_face_WFLW_dataset_compatibility():
dataset = 'FaceWFLWDataset'
# test Face WFLW datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=98,
dataset_joints=98,
dataset_channel=[
list(range(98)),
],
inference_channel=list(range(98)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/wflw/test_wflw.json',
img_prefix='tests/data/wflw/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/wflw/test_wflw.json',
img_prefix='tests/data/wflw/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
@@ -0,0 +1,69 @@
# Copyright (c) OpenMMLab. All rights reserved.
import tempfile
from unittest.mock import MagicMock
import pytest
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_deepfashion_dataset_compatibility():
dataset = 'DeepFashionDataset'
# test JHMDB datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=8,
dataset_joints=8,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
image_thr=0.0,
bbox_file='')
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/fld/test_fld.json',
img_prefix='tests/data/fld/',
subset='full',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'deepfashion_full'
image_id = 128
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
@@ -0,0 +1,388 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import tempfile
import pytest
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_top_down_OneHand10K_dataset_compatibility():
dataset = 'OneHand10KDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/onehand10k/test_onehand10k.json',
img_prefix='tests/data/onehand10k/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/onehand10k/test_onehand10k.json',
img_prefix='tests/data/onehand10k/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_top_down_FreiHand_dataset_compatibility():
dataset = 'FreiHandDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[224, 224],
heatmap_size=[56, 56],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/freihand/test_freihand.json',
img_prefix='tests/data/freihand/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/freihand/test_freihand.json',
img_prefix='tests/data/freihand/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 8
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_top_down_RHD_dataset_compatibility():
dataset = 'Rhd2DDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/rhd/test_rhd.json',
img_prefix='tests/data/rhd/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/rhd/test_rhd.json',
img_prefix='tests/data/rhd/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 3
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_top_down_Panoptic_dataset_compatibility():
dataset = 'PanopticDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/panoptic/test_panoptic.json',
img_prefix='tests/data/panoptic/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/panoptic/test_panoptic.json',
img_prefix='tests/data/panoptic/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir,
['PCKh', 'EPE', 'AUC'])
assert_almost_equal(infos['PCKh'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_top_down_InterHand2D_dataset_compatibility():
dataset = 'InterHand2DDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/'
'test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/'
'test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/'
'test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/'
'test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
assert len(custom_dataset.db) == 6
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK', 'EPE', 'AUC'])
print(infos, flush=True)
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_top_down_InterHand3D_dataset_compatibility():
dataset = 'InterHand3DDataset'
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=42,
dataset_joints=42,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64, 64],
heatmap3d_depth_bound=400.0,
heatmap_size_root=64,
root_depth_bound=400.0,
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/'
'test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/'
'test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/'
'test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/'
'test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
assert len(custom_dataset.db) == 4
_ = custom_dataset[0]
outputs = convert_db_to_output(
custom_dataset.db, keys=['rel_root_depth', 'hand_type'], is_3d=True)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir,
['MRRPE', 'MPJPE', 'Handedness_acc'])
assert_almost_equal(infos['MRRPE'], 0.0, decimal=5)
assert_almost_equal(infos['MPJPE_all'], 0.0, decimal=5)
assert_almost_equal(infos['MPJPE_single'], 0.0, decimal=5)
assert_almost_equal(infos['MPJPE_interacting'], 0.0, decimal=5)
assert_almost_equal(infos['Handedness_acc'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
@@ -0,0 +1,156 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from mmpose.apis import (extract_pose_sequence, get_track_id,
inference_bottom_up_pose_model,
inference_pose_lifter_model,
inference_top_down_pose_model, init_pose_model,
vis_3d_pose_result, vis_pose_result,
vis_pose_tracking_result)
def test_inference_without_dataset_info():
# Top down
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'coco/res50_coco_256x192.py',
None,
device='cpu')
if 'dataset_info' in pose_model.cfg:
_ = pose_model.cfg.pop('dataset_info')
image_name = 'tests/data/coco/000000000785.jpg'
person_result = []
person_result.append({'bbox': [50, 50, 50, 100]})
with pytest.warns(DeprecationWarning):
pose_results, _ = inference_top_down_pose_model(
pose_model, image_name, person_result, format='xywh')
with pytest.warns(DeprecationWarning):
vis_pose_result(pose_model, image_name, pose_results)
with pytest.raises(NotImplementedError):
with pytest.warns(DeprecationWarning):
pose_results, _ = inference_top_down_pose_model(
pose_model,
image_name,
person_result,
format='xywh',
dataset='test')
# Bottom up
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/associative_embedding/'
'coco/res50_coco_512x512.py',
None,
device='cpu')
if 'dataset_info' in pose_model.cfg:
_ = pose_model.cfg.pop('dataset_info')
image_name = 'tests/data/coco/000000000785.jpg'
with pytest.warns(DeprecationWarning):
pose_results, _ = inference_bottom_up_pose_model(
pose_model, image_name)
with pytest.warns(DeprecationWarning):
vis_pose_result(pose_model, image_name, pose_results)
# Top down tracking
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/'
'coco/res50_coco_256x192.py',
None,
device='cpu')
if 'dataset_info' in pose_model.cfg:
_ = pose_model.cfg.pop('dataset_info')
image_name = 'tests/data/coco/000000000785.jpg'
person_result = [{'bbox': [50, 50, 50, 100]}]
with pytest.warns(DeprecationWarning):
pose_results, _ = inference_top_down_pose_model(
pose_model, image_name, person_result, format='xywh')
pose_results, _ = get_track_id(pose_results, [], next_id=0)
with pytest.warns(DeprecationWarning):
vis_pose_tracking_result(pose_model, image_name, pose_results)
with pytest.raises(NotImplementedError):
with pytest.warns(DeprecationWarning):
vis_pose_tracking_result(
pose_model, image_name, pose_results, dataset='test')
# Bottom up tracking
pose_model = init_pose_model(
'configs/body/2d_kpt_sview_rgb_img/associative_embedding/'
'coco/res50_coco_512x512.py',
None,
device='cpu')
if 'dataset_info' in pose_model.cfg:
_ = pose_model.cfg.pop('dataset_info')
image_name = 'tests/data/coco/000000000785.jpg'
with pytest.warns(DeprecationWarning):
pose_results, _ = inference_bottom_up_pose_model(
pose_model, image_name)
pose_results, next_id = get_track_id(pose_results, [], next_id=0)
with pytest.warns(DeprecationWarning):
vis_pose_tracking_result(
pose_model,
image_name,
pose_results,
dataset='BottomUpCocoDataset')
# Pose lifting
pose_model = init_pose_model(
'configs/body/3d_kpt_sview_rgb_img/pose_lift/'
'h36m/simplebaseline3d_h36m.py',
None,
device='cpu')
pose_det_result = {
'keypoints': np.zeros((17, 3)),
'bbox': [50, 50, 50, 50],
'track_id': 0,
'image_name': 'tests/data/h36m/S1_Directions_1.54138969_000001.jpg',
}
if 'dataset_info' in pose_model.cfg:
_ = pose_model.cfg.pop('dataset_info')
pose_results_2d = [[pose_det_result]]
dataset = pose_model.cfg.data['test']['type']
pose_results_2d = extract_pose_sequence(
pose_results_2d, frame_idx=0, causal=False, seq_len=1, step=1)
with pytest.warns(DeprecationWarning):
_ = inference_pose_lifter_model(
pose_model, pose_results_2d, dataset, with_track_id=False)
with pytest.warns(DeprecationWarning):
pose_lift_results = inference_pose_lifter_model(
pose_model, pose_results_2d, dataset, with_track_id=True)
for res in pose_lift_results:
res['title'] = 'title'
with pytest.warns(DeprecationWarning):
vis_3d_pose_result(
pose_model,
pose_lift_results,
img=pose_results_2d[0][0]['image_name'],
dataset=dataset)
with pytest.raises(NotImplementedError):
with pytest.warns(DeprecationWarning):
_ = inference_pose_lifter_model(
pose_model, pose_results_2d, dataset='test')
@@ -0,0 +1,748 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import tempfile
from unittest.mock import MagicMock
import pytest
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_top_down_COCO_dataset_compatibility():
dataset = 'TopDownCocoDataset'
# test COCO datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='tests/data/coco/test_coco_det_AP_H_56.json',
)
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'coco'
image_id = 785
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 4
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_top_down_MHP_dataset_compatibility():
dataset = 'TopDownMhpDataset'
# test MHP datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=16,
dataset_joints=16,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
bbox_thr=1.0,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test det bbox
with pytest.raises(AssertionError):
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
# Test gt bbox
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'mhp'
image_id = 2889
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_top_down_PoseTrack18_dataset_compatibility():
dataset = 'TopDownPoseTrack18Dataset'
# test PoseTrack datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='tests/data/posetrack18/annotations/'
'test_posetrack18_human_detections.json',
)
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/posetrack18/annotations/'
'test_posetrack18_val.json',
img_prefix='tests/data/posetrack18/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/posetrack18/annotations/'
'test_posetrack18_val.json',
img_prefix='tests/data/posetrack18/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/posetrack18/annotations/'
'test_posetrack18_val.json',
img_prefix='tests/data/posetrack18/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'posetrack18'
image_id = 10128340000
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 3
_ = custom_dataset[0]
def test_top_down_CrowdPose_dataset_compatibility():
dataset = 'TopDownCrowdPoseDataset'
# test CrowdPose datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=14,
dataset_joints=14,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='tests/data/crowdpose/test_crowdpose_det_AP_40.json',
)
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'crowdpose'
image_id = 103319
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_top_down_COCO_wholebody_dataset_compatibility():
dataset = 'TopDownCocoWholeBodyDataset'
# test COCO datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=133,
dataset_joints=133,
dataset_channel=[
list(range(133)),
],
inference_channel=list(range(133)))
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='tests/data/coco/test_coco_det_AP_H_56.json',
)
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'coco_wholebody'
image_id = 785
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 4
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_top_down_OCHuman_dataset_compatibility():
dataset = 'TopDownOCHumanDataset'
# test OCHuman datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
with pytest.raises(AssertionError):
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/ochuman/test_ochuman.json',
img_prefix='tests/data/ochuman/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/ochuman/test_ochuman.json',
img_prefix='tests/data/ochuman/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'ochuman'
image_id = 1
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 3
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_top_down_MPII_dataset_compatibility():
dataset = 'TopDownMpiiDataset'
# test COCO datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=16,
dataset_joints=16,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
)
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/mpii/test_mpii.json',
img_prefix='tests/data/mpii/',
data_cfg=data_cfg_copy,
pipeline=[])
assert len(custom_dataset) == 5
assert custom_dataset.dataset_name == 'mpii'
_ = custom_dataset[0]
def test_top_down_MPII_TRB_dataset_compatibility():
dataset = 'TopDownMpiiTrbDataset'
# test MPII TRB datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=40,
dataset_joints=40,
dataset_channel=[list(range(40))],
inference_channel=list(range(40)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
data_cfg_copy = copy.deepcopy(data_cfg)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/mpii/test_mpii_trb.json',
img_prefix='tests/data/mpii/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/mpii/test_mpii_trb.json',
img_prefix='tests/data/mpii/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'mpii_trb'
_ = custom_dataset[0]
def test_top_down_AIC_dataset_compatibility():
dataset = 'TopDownAicDataset'
# test AIC datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=14,
dataset_joints=14,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='')
with pytest.raises(AssertionError):
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'aic'
image_id = 1
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 3
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'PCK')
def test_top_down_JHMDB_dataset_compatibility():
dataset = 'TopDownJhmdbDataset'
# test JHMDB datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=15,
dataset_joints=15,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='')
with pytest.raises(AssertionError):
# Test det bbox
data_cfg_copy = copy.deepcopy(data_cfg)
data_cfg_copy['use_gt_bbox'] = False
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/jhmdb/test_jhmdb_sub1.json',
img_prefix='tests/data/jhmdb/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=True)
with pytest.warns(DeprecationWarning):
_ = dataset_class(
ann_file='tests/data/jhmdb/test_jhmdb_sub1.json',
img_prefix='tests/data/jhmdb/',
data_cfg=data_cfg_copy,
pipeline=[],
test_mode=False)
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/jhmdb/test_jhmdb_sub1.json',
img_prefix='tests/data/jhmdb/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'jhmdb'
image_id = 2290001
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 3
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, ['PCK'])
assert_almost_equal(infos['Mean PCK'], 1.0)
infos = custom_dataset.evaluate(outputs, tmpdir, ['tPCK'])
assert_almost_equal(infos['Mean tPCK'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'mAP')
def test_top_down_h36m_dataset_compatibility():
dataset = 'TopDownH36MDataset'
# test AIC datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test gt bbox
with pytest.warns(DeprecationWarning):
custom_dataset = dataset_class(
ann_file='tests/data/h36m/h36m_coco.json',
img_prefix='tests/data/h36m/',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'h36m'
image_id = 1
assert image_id in custom_dataset.img_ids
_ = custom_dataset[0]
outputs = convert_db_to_output(custom_dataset.db)
with tempfile.TemporaryDirectory() as tmpdir:
infos = custom_dataset.evaluate(outputs, tmpdir, 'EPE')
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(outputs, tmpdir, 'AUC')
@@ -0,0 +1,46 @@
# Copyright (c) OpenMMLab. All rights reserved.
import unittest.mock as mock
import pytest
import torch
from torch.utils.data import DataLoader, Dataset
from mmpose.core import DistEvalHook, EvalHook
class ExampleDataset(Dataset):
def __init__(self):
self.index = 0
self.eval_result = [0.1, 0.4, 0.3, 0.7, 0.2, 0.05, 0.4, 0.6]
def __getitem__(self, idx):
results = dict(imgs=torch.tensor([1]))
return results
def __len__(self):
return 1
@mock.create_autospec
def evaluate(self, results, res_folder=None, logger=None):
pass
def test_old_fashion_eval_hook_parameters():
data_loader = DataLoader(
ExampleDataset(),
batch_size=1,
sampler=None,
num_workers=0,
shuffle=False)
# test argument "key_indicator"
with pytest.warns(DeprecationWarning):
_ = EvalHook(data_loader, key_indicator='AP')
with pytest.warns(DeprecationWarning):
_ = DistEvalHook(data_loader, key_indicator='AP')
# test argument "gpu_collect"
with pytest.warns(DeprecationWarning):
_ = EvalHook(data_loader, save_best='AP', gpu_collect=False)
@@ -0,0 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
# flake8: noqa
import pytest
def test_old_fashion_registry_importing():
with pytest.warns(DeprecationWarning):
from mmpose.models.registry import BACKBONES, HEADS, LOSSES, NECKS, POSENETS # isort: skip
with pytest.warns(DeprecationWarning):
from mmpose.datasets.registry import DATASETS, PIPELINES # noqa: F401
@@ -0,0 +1,54 @@
# Copyright (c) OpenMMLab. All rights reserved.
from os.path import dirname, exists, join, relpath
import torch
from mmcv.runner import build_optimizer
def _get_config_directory():
"""Find the predefined detector config directory."""
try:
# Assume we are running in the source mmdetection repo
repo_dpath = dirname(dirname(__file__))
except NameError:
# For IPython development when this __file__ is not defined
import mmpose
repo_dpath = dirname(dirname(mmpose.__file__))
config_dpath = join(repo_dpath, 'configs')
if not exists(config_dpath):
raise Exception('Cannot find config path')
return config_dpath
def test_config_build_detector():
"""Test that all detection models defined in the configs can be
initialized."""
from mmcv import Config
from mmpose.models import build_posenet
config_dpath = _get_config_directory()
print(f'Found config_dpath = {config_dpath}')
import glob
config_fpaths = list(glob.glob(join(config_dpath, '**', '*.py')))
config_fpaths = [p for p in config_fpaths if p.find('_base_') == -1]
config_names = [relpath(p, config_dpath) for p in config_fpaths]
print(f'Using {len(config_names)} config files')
for config_fname in config_names:
config_fpath = join(config_dpath, config_fname)
config_mod = Config.fromfile(config_fpath)
print(f'Building detector, config_fpath = {config_fpath}')
# Remove pretrained keys to allow for testing in an offline environment
if 'pretrained' in config_mod.model:
config_mod.model['pretrained'] = None
detector = build_posenet(config_mod.model)
assert detector is not None
optimizer = build_optimizer(detector, config_mod.optimizer)
assert isinstance(optimizer, torch.optim.Optimizer)
@@ -0,0 +1,500 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_animal_horse10_dataset():
dataset = 'AnimalHorse10Dataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/horse10.py').dataset_info
channel_cfg = dict(
num_output_channels=22,
dataset_joints=22,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 21
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 21
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/horse10/test_horse10.json',
img_prefix='tests/data/horse10/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/horse10/test_horse10.json',
img_prefix='tests/data/horse10/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'horse10'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 3
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_animal_fly_dataset():
dataset = 'AnimalFlyDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/fly.py').dataset_info
channel_cfg = dict(
num_output_channels=32,
dataset_joints=32,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
])
data_cfg = dict(
image_size=[192, 192],
heatmap_size=[48, 48],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/fly/test_fly.json',
img_prefix='tests/data/fly/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/fly/test_fly.json',
img_prefix='tests/data/fly/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'fly'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_animal_locust_dataset():
dataset = 'AnimalLocustDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/locust.py').dataset_info
channel_cfg = dict(
num_output_channels=35,
dataset_joints=35,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34
])
data_cfg = dict(
image_size=[160, 160],
heatmap_size=[40, 40],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/locust/test_locust.json',
img_prefix='tests/data/locust/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/locust/test_locust.json',
img_prefix='tests/data/locust/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'locust'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_animal_zebra_dataset():
dataset = 'AnimalZebraDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/zebra.py').dataset_info
channel_cfg = dict(
num_output_channels=9,
dataset_joints=9,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8])
data_cfg = dict(
image_size=[160, 160],
heatmap_size=[40, 40],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/zebra/test_zebra.json',
img_prefix='tests/data/zebra/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/zebra/test_zebra.json',
img_prefix='tests/data/zebra/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'zebra'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK'])
assert_almost_equal(infos['PCK'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_animal_ATRW_dataset():
dataset = 'AnimalATRWDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/atrw.py').dataset_info
channel_cfg = dict(
num_output_channels=15,
dataset_joints=15,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/atrw/test_atrw.json',
img_prefix='tests/data/atrw/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/atrw/test_atrw.json',
img_prefix='tests/data/atrw/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'atrw'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric=['PCK'])
def test_animal_Macaque_dataset():
dataset = 'AnimalMacaqueDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/macaque.py').dataset_info
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/macaque/test_macaque.json',
img_prefix='tests/data/macaque/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/macaque/test_macaque.json',
img_prefix='tests/data/macaque/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'macaque'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric=['PCK'])
def test_animalpose_dataset():
dataset = 'AnimalPoseDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/animalpose.py').dataset_info
channel_cfg = dict(
num_output_channels=20,
dataset_joints=20,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/animalpose/test_animalpose.json',
img_prefix='tests/data/animalpose/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/animalpose/test_animalpose.json',
img_prefix='tests/data/animalpose/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'animalpose'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric=['PCK'])
def test_ap10k_dataset():
dataset = 'AnimalAP10KDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/ap10k.py').dataset_info
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='',
)
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/ap10k/test_ap10k.json',
img_prefix='tests/data/ap10k/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/ap10k/test_ap10k.json',
img_prefix='tests/data/ap10k/',
data_cfg=data_cfg_copy,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
assert custom_dataset.dataset_name == 'ap10k'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
for output in results:
# as there is only one box in each image for test
output['bbox_ids'] = [0 for _ in range(len(output['bbox_ids']))]
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric=['PCK'])
@@ -0,0 +1,347 @@
# Copyright (c) OpenMMLab. All rights reserved.
import tempfile
import numpy as np
from mmcv import Config
from mmpose.datasets import DATASETS
from mmpose.datasets.builder import build_dataset
def test_body3d_h36m_dataset():
# Test Human3.6M dataset
dataset = 'Body3DH36MDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/h36m.py').dataset_info
# test single-frame input
data_cfg = dict(
num_joints=17,
seq_len=1,
seq_frame_interval=1,
joint_2d_src='pipeline',
joint_2d_det_file=None,
causal=False,
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl')
_ = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
assert custom_dataset.dataset_name == 'h36m'
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
results = []
for result in custom_dataset:
results.append({
'preds': result['target'][None, ...],
'target_image_paths': [result['target_image_path']],
})
metrics = ['mpjpe', 'p-mpjpe', 'n-mpjpe']
infos = custom_dataset.evaluate(results, metric=metrics)
np.testing.assert_almost_equal(infos['MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['N-MPJPE'], 0.0)
# test multi-frame input with joint_2d_src = 'detection'
data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
causal=True,
temporal_padding=True,
joint_2d_src='detection',
joint_2d_det_file='tests/data/h36m/test_h36m_2d_detection.npy',
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl')
_ = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
dataset_info=dataset_info,
pipeline=[],
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
dataset_info=dataset_info,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
results = []
for result in custom_dataset:
results.append({
'preds': result['target'][None, ...],
'target_image_paths': [result['target_image_path']],
})
metrics = ['mpjpe', 'p-mpjpe', 'n-mpjpe']
infos = custom_dataset.evaluate(results, metric=metrics)
np.testing.assert_almost_equal(infos['MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['N-MPJPE'], 0.0)
def test_body3d_semi_supervision_dataset():
# Test Body3d Semi-supervision Dataset
dataset_info = Config.fromfile(
'configs/_base_/datasets/h36m.py').dataset_info
# load labeled dataset
labeled_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
causall=False,
temporal_padding=True,
joint_2d_src='gt',
subset=1,
subjects=['S1'],
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl')
labeled_dataset_cfg = dict(
type='Body3DH36MDataset',
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=labeled_data_cfg,
dataset_info=dataset_info,
pipeline=[])
# load unlabled data
unlabeled_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
causal=False,
temporal_padding=True,
joint_2d_src='gt',
subjects=['S5', 'S7', 'S8'],
need_camera_param=True,
camera_param_file='tests/data/h36m/cameras.pkl',
need_2d_label=True)
unlabeled_dataset_cfg = dict(
type='Body3DH36MDataset',
ann_file='tests/data/h36m/test_h36m_body3d.npz',
img_prefix='tests/data/h36m',
data_cfg=unlabeled_data_cfg,
dataset_info=dataset_info,
pipeline=[
dict(
type='Collect',
keys=[('input_2d', 'unlabeled_input')],
meta_name='metas',
meta_keys=[])
])
# combine labeled and unlabeled dataset to form a new dataset
dataset = 'Body3DSemiSupervisionDataset'
dataset_class = DATASETS.get(dataset)
custom_dataset = dataset_class(labeled_dataset_cfg, unlabeled_dataset_cfg)
item = custom_dataset[0]
assert custom_dataset.labeled_dataset.dataset_name == 'h36m'
assert 'unlabeled_input' in item.keys()
unlabeled_dataset = build_dataset(unlabeled_dataset_cfg)
assert len(unlabeled_dataset) == len(custom_dataset)
def test_body3d_mpi_inf_3dhp_dataset():
# Test MPI-INF-3DHP dataset
dataset = 'Body3DMpiInf3dhpDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/mpi_inf_3dhp.py').dataset_info
# Test single-frame input on trainset
single_frame_train_data_cfg = dict(
num_joints=17,
seq_len=1,
seq_frame_interval=1,
joint_2d_src='pipeline',
joint_2d_det_file=None,
causal=False,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_train.pkl')
# Test single-frame input on testset
single_frame_test_data_cfg = dict(
num_joints=17,
seq_len=1,
seq_frame_interval=1,
joint_2d_src='gt',
joint_2d_det_file=None,
causal=False,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_test.pkl')
# Test multi-frame input on trainset
multi_frame_train_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
joint_2d_src='gt',
joint_2d_det_file=None,
causal=True,
temporal_padding=True,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_train.pkl')
# Test multi-frame input on testset
multi_frame_test_data_cfg = dict(
num_joints=17,
seq_len=27,
seq_frame_interval=1,
joint_2d_src='pipeline',
joint_2d_det_file=None,
causal=False,
temporal_padding=True,
need_camera_param=True,
camera_param_file='tests/data/mpi_inf_3dhp/cameras_test.pkl')
ann_files = [
'tests/data/mpi_inf_3dhp/test_3dhp_train.npz',
'tests/data/mpi_inf_3dhp/test_3dhp_test.npz'
] * 2
data_cfgs = [
single_frame_train_data_cfg, single_frame_test_data_cfg,
multi_frame_train_data_cfg, multi_frame_test_data_cfg
]
for ann_file, data_cfg in zip(ann_files, data_cfgs):
_ = dataset_class(
ann_file=ann_file,
img_prefix='tests/data/mpi_inf_3dhp',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
custom_dataset = dataset_class(
ann_file=ann_file,
img_prefix='tests/data/mpi_inf_3dhp',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
results = []
for result in custom_dataset:
results.append({
'preds': result['target'][None, ...],
'target_image_paths': [result['target_image_path']],
})
metrics = ['mpjpe', 'p-mpjpe', '3dpck', 'p-3dpck', '3dauc', 'p-3dauc']
infos = custom_dataset.evaluate(results, metric=metrics)
np.testing.assert_almost_equal(infos['MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['P-MPJPE'], 0.0)
np.testing.assert_almost_equal(infos['3DPCK'], 100.)
np.testing.assert_almost_equal(infos['P-3DPCK'], 100.)
np.testing.assert_almost_equal(infos['3DAUC'], 30 / 31 * 100)
np.testing.assert_almost_equal(infos['P-3DAUC'], 30 / 31 * 100)
def test_body3dmview_direct_panoptic_dataset():
# Test Mview-Panoptic dataset
dataset = 'Body3DMviewDirectPanopticDataset'
dataset_class = DATASETS.get(dataset)
dataset_info = Config.fromfile(
'configs/_base_/datasets/panoptic_body3d.py').dataset_info
space_size = [8000, 8000, 2000]
space_center = [0, -500, 800]
cube_size = [80, 80, 20]
train_data_cfg = dict(
image_size=[960, 512],
heatmap_size=[[240, 128]],
space_size=space_size,
space_center=space_center,
cube_size=cube_size,
num_joints=15,
seq_list=['160906_band1', '160906_band2'],
cam_list=[(0, 12), (0, 6)],
num_cameras=2,
seq_frame_interval=1,
subset='train',
need_2d_label=True,
need_camera_param=True,
root_id=2)
test_data_cfg = dict(
image_size=[960, 512],
heatmap_size=[[240, 128]],
num_joints=15,
space_size=space_size,
space_center=space_center,
cube_size=cube_size,
seq_list=['160906_band1', '160906_band2'],
cam_list=[(0, 12), (0, 6)],
num_cameras=2,
seq_frame_interval=1,
subset='validation',
need_2d_label=True,
need_camera_param=True,
root_id=2)
with tempfile.TemporaryDirectory() as tmpdir:
_ = dataset_class(
ann_file=tmpdir + '/tmp_train.pkl',
img_prefix='tests/data/panoptic_body3d/',
data_cfg=train_data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
with tempfile.TemporaryDirectory() as tmpdir:
test_dataset = dataset_class(
ann_file=tmpdir + '/tmp_validation.pkl',
img_prefix='tests/data/panoptic_body3d',
data_cfg=test_data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
import copy
gt_num = test_dataset.db_size // test_dataset.num_cameras
results = []
for i in range(gt_num):
index = test_dataset.num_cameras * i
db_rec = copy.deepcopy(test_dataset.db[index])
joints_3d = db_rec['joints_3d']
joints_3d_vis = db_rec['joints_3d_visible']
num_gts = len(joints_3d)
gt_pose = -np.ones((1, 10, test_dataset.num_joints, 5))
if num_gts > 0:
gt_pose[0, :num_gts, :, :3] = np.array(joints_3d)
gt_pose[0, :num_gts, :, 3] = np.array(joints_3d_vis)[:, :, 0] - 1.0
gt_pose[0, :num_gts, :, 4] = 1.0
results.append(dict(pose_3d=gt_pose, sample_id=[i]))
_ = test_dataset.evaluate(results, metric=['mAP', 'mpjpe'])
@@ -0,0 +1,334 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
def convert_coco_to_output(coco, is_wholebody=False):
results = []
for img_id in coco.getImgIds():
preds = []
scores = []
image = coco.imgs[img_id]
ann_ids = coco.getAnnIds(img_id)
for ann_id in ann_ids:
obj = coco.anns[ann_id]
if is_wholebody:
keypoints = np.array(obj['keypoints'] + obj['foot_kpts'] +
obj['face_kpts'] + obj['lefthand_kpts'] +
obj['righthand_kpts']).reshape(-1, 3)
else:
keypoints = np.array(obj['keypoints']).reshape((-1, 3))
K = keypoints.shape[0]
if sum(keypoints[:, 2]) == 0:
continue
preds.append(
np.concatenate((keypoints[:, :2], np.ones(
[K, 1]), np.ones([K, 1]) * ann_id),
axis=1))
scores.append(1)
image_paths = []
image_paths.append(image['file_name'])
output = {}
output['preds'] = np.stack(preds)
output['scores'] = scores
output['image_paths'] = image_paths
output['output_heatmap'] = None
results.append(output)
return results
def test_bottom_up_COCO_dataset():
dataset = 'BottomUpCocoDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/coco.py').dataset_info
# test COCO datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128, 256],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=2,
scale_aware_sigma=False,
use_nms=True)
_ = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.dataset_name == 'coco'
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
results = convert_coco_to_output(custom_dataset.coco)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='PCK')
def test_bottom_up_CrowdPose_dataset():
dataset = 'BottomUpCrowdPoseDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/crowdpose.py').dataset_info
# test CrowdPose datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=14,
dataset_joints=14,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128, 256],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=2,
scale_aware_sigma=False)
_ = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/crowdpose/test_crowdpose.json',
img_prefix='tests/data/crowdpose/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.dataset_name == 'crowdpose'
image_id = 103319
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
results = convert_coco_to_output(custom_dataset.coco)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='PCK')
def test_bottom_up_MHP_dataset():
dataset = 'BottomUpMhpDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/mhp.py').dataset_info
# test MHP datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
dataset_joints=16,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=1,
scale_aware_sigma=False,
)
_ = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/mhp/test_mhp.json',
img_prefix='tests/data/mhp/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.dataset_name == 'mhp'
image_id = 2889
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
results = convert_coco_to_output(custom_dataset.coco)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='PCK')
def test_bottom_up_AIC_dataset():
dataset = 'BottomUpAicDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/aic.py').dataset_info
# test MHP datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=14,
dataset_joints=14,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=1,
scale_aware_sigma=False,
)
_ = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/aic/test_aic.json',
img_prefix='tests/data/aic/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.dataset_name == 'aic'
image_id = 1
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 3
_ = custom_dataset[0]
results = convert_coco_to_output(custom_dataset.coco)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='PCK')
def test_bottom_up_COCO_wholebody_dataset():
dataset = 'BottomUpCocoWholeBodyDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/coco_wholebody.py').dataset_info
# test COCO-wholebody datasets
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=133,
dataset_joints=133,
dataset_channel=[
list(range(133)),
],
inference_channel=list(range(133)))
data_cfg = dict(
image_size=512,
base_size=256,
base_sigma=2,
heatmap_size=[128, 256],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
num_scales=2,
scale_aware_sigma=False,
)
_ = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'coco_wholebody'
image_id = 785
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 4
_ = custom_dataset[0]
results = convert_coco_to_output(custom_dataset.coco, is_wholebody=True)
infos = custom_dataset.evaluate(results, metric='mAP')
assert_almost_equal(infos['AP'], 1.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='PCK')
@@ -0,0 +1,77 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmpose.datasets import DatasetInfo
def test_dataset_info():
dataset_info = dict(
dataset_name='zebra',
paper_info=dict(
author='Graving, Jacob M and Chae, Daniel and Naik, Hemal and '
'Li, Liang and Koger, Benjamin and Costelloe, Blair R and '
'Couzin, Iain D',
title='DeepPoseKit, a software toolkit for fast and robust '
'animal pose estimation using deep learning',
container='Elife',
year='2019',
homepage='https://github.com/jgraving/DeepPoseKit-Data',
),
keypoint_info={
0:
dict(name='snout', id=0, color=[255, 255, 255], type='', swap=''),
1:
dict(name='head', id=1, color=[255, 255, 255], type='', swap=''),
2:
dict(name='neck', id=2, color=[255, 255, 255], type='', swap=''),
3:
dict(
name='forelegL1',
id=3,
color=[255, 255, 255],
type='',
swap='forelegR1'),
4:
dict(
name='forelegR1',
id=4,
color=[255, 255, 255],
type='',
swap='forelegL1'),
5:
dict(
name='hindlegL1',
id=5,
color=[255, 255, 255],
type='',
swap='hindlegR1'),
6:
dict(
name='hindlegR1',
id=6,
color=[255, 255, 255],
type='',
swap='hindlegL1'),
7:
dict(
name='tailbase', id=7, color=[255, 255, 255], type='',
swap=''),
8:
dict(
name='tailtip', id=8, color=[255, 255, 255], type='', swap='')
},
skeleton_info={
0: dict(link=('head', 'snout'), id=0, color=[255, 255, 255]),
1: dict(link=('neck', 'head'), id=1, color=[255, 255, 255]),
2: dict(link=('forelegL1', 'neck'), id=2, color=[255, 255, 255]),
3: dict(link=('forelegR1', 'neck'), id=3, color=[255, 255, 255]),
4:
dict(link=('hindlegL1', 'tailbase'), id=4, color=[255, 255, 255]),
5:
dict(link=('hindlegR1', 'tailbase'), id=5, color=[255, 255, 255]),
6: dict(link=('tailbase', 'neck'), id=6, color=[255, 255, 255]),
7: dict(link=('tailtip', 'tailbase'), id=7, color=[255, 255, 255])
},
joint_weights=[1.] * 9,
sigmas=[])
dataset_info = DatasetInfo(dataset_info)
assert dataset_info.keypoint_num == len(dataset_info.flip_index)
@@ -0,0 +1,67 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmcv import Config
from mmpose.datasets.builder import build_dataset
def test_concat_dataset():
# build COCO-like dataset config
dataset_info = Config.fromfile(
'configs/_base_/datasets/coco.py').dataset_info
channel_cfg = dict(
num_output_channels=17,
dataset_joints=17,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
bbox_file='tests/data/coco/test_coco_det_AP_H_56.json',
)
dataset_cfg = dict(
type='TopDownCocoDataset',
ann_file='tests/data/coco/test_coco.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info)
dataset = build_dataset(dataset_cfg)
# Case 1: build ConcatDataset explicitly
concat_dataset_cfg = dict(
type='ConcatDataset', datasets=[dataset_cfg, dataset_cfg])
concat_dataset = build_dataset(concat_dataset_cfg)
assert len(concat_dataset) == 2 * len(dataset)
# Case 2: build ConcatDataset from cfg sequence
concat_dataset = build_dataset([dataset_cfg, dataset_cfg])
assert len(concat_dataset) == 2 * len(dataset)
# Case 3: build ConcatDataset from ann_file sequence
concat_dataset_cfg = dataset_cfg.copy()
for key in ['ann_file', 'type', 'img_prefix', 'dataset_info']:
val = concat_dataset_cfg[key]
concat_dataset_cfg[key] = [val] * 2
for key in ['num_joints', 'dataset_channel']:
val = concat_dataset_cfg['data_cfg'][key]
concat_dataset_cfg['data_cfg'][key] = [val] * 2
concat_dataset = build_dataset(concat_dataset_cfg)
assert len(concat_dataset) == 2 * len(dataset)
@@ -0,0 +1,284 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
from unittest.mock import MagicMock
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_face_300W_dataset():
dataset = 'Face300WDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/300w.py').dataset_info
# test Face 300W datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=68,
dataset_joints=68,
dataset_channel=[
list(range(68)),
],
inference_channel=list(range(68)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/300w/test_300w.json',
img_prefix='tests/data/300w/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/300w/test_300w.json',
img_prefix='tests/data/300w/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == '300w'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='mAP')
def test_face_coco_wholebody_dataset():
dataset = 'FaceCocoWholeBodyDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/coco_wholebody_face.py').dataset_info
# test Face wholebody datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=68,
dataset_joints=68,
dataset_channel=[
list(range(68)),
],
inference_channel=list(range(68)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='mAP')
def test_face_AFLW_dataset():
dataset = 'FaceAFLWDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/aflw.py').dataset_info
# test Face AFLW datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=19,
dataset_joints=19,
dataset_channel=[
list(range(19)),
],
inference_channel=list(range(19)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/aflw/test_aflw.json',
img_prefix='tests/data/aflw/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/aflw/test_aflw.json',
img_prefix='tests/data/aflw/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'aflw'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='mAP')
def test_face_WFLW_dataset():
dataset = 'FaceWFLWDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/wflw.py').dataset_info
# test Face WFLW datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=98,
dataset_joints=98,
dataset_channel=[
list(range(98)),
],
inference_channel=list(range(98)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/wflw/test_wflw.json',
img_prefix='tests/data/wflw/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/wflw/test_wflw.json',
img_prefix='tests/data/wflw/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'wflw'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='mAP')
def test_face_COFW_dataset():
dataset = 'FaceCOFWDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/cofw.py').dataset_info
# test Face COFW datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=29,
dataset_joints=29,
dataset_channel=[
list(range(29)),
],
inference_channel=list(range(29)))
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/cofw/test_cofw.json',
img_prefix='tests/data/cofw/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/cofw/test_cofw.json',
img_prefix='tests/data/cofw/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'cofw'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['NME'])
assert_almost_equal(infos['NME'], 0.0)
with pytest.raises(KeyError):
_ = custom_dataset.evaluate(results, metric='mAP')
@@ -0,0 +1,70 @@
# Copyright (c) OpenMMLab. All rights reserved.
from unittest.mock import MagicMock
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_deepfashion_dataset():
dataset = 'DeepFashionDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/deepfashion_full.py').dataset_info
# test JHMDB datasets
dataset_class = DATASETS.get(dataset)
dataset_class.load_annotations = MagicMock()
dataset_class.coco = MagicMock()
channel_cfg = dict(
num_output_channels=8,
dataset_joints=8,
dataset_channel=[
[0, 1, 2, 3, 4, 5, 6, 7],
],
inference_channel=[0, 1, 2, 3, 4, 5, 6, 7])
data_cfg = dict(
image_size=[192, 256],
heatmap_size=[48, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'],
soft_nms=False,
nms_thr=1.0,
oks_thr=0.9,
vis_thr=0.2,
use_gt_bbox=True,
det_bbox_thr=0.0,
image_thr=0.0,
bbox_file='')
# Test gt bbox
custom_dataset = dataset_class(
ann_file='tests/data/fld/test_fld.json',
img_prefix='tests/data/fld/',
subset='full',
data_cfg=data_cfg,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
assert custom_dataset.test_mode is True
assert custom_dataset.dataset_name == 'deepfashion_full'
image_id = 128
assert image_id in custom_dataset.img_ids
assert len(custom_dataset.img_ids) == 2
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
@@ -0,0 +1,456 @@
# Copyright (c) OpenMMLab. All rights reserved.
import copy
import pytest
from mmcv import Config
from numpy.testing import assert_almost_equal
from mmpose.datasets import DATASETS
from tests.utils.data_utils import convert_db_to_output
def test_OneHand10K_dataset():
dataset = 'OneHand10KDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/onehand10k.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/onehand10k/test_onehand10k.json',
img_prefix='tests/data/onehand10k/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/onehand10k/test_onehand10k.json',
img_prefix='tests/data/onehand10k/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'onehand10k'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_hand_coco_wholebody_dataset():
dataset = 'HandCocoWholeBodyDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/coco_wholebody_hand.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/coco/test_coco_wholebody.json',
img_prefix='tests/data/coco/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_FreiHand2D_dataset():
dataset = 'FreiHandDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/freihand2d.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[224, 224],
heatmap_size=[56, 56],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/freihand/test_freihand.json',
img_prefix='tests/data/freihand/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/freihand/test_freihand.json',
img_prefix='tests/data/freihand/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'freihand'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 8
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_RHD2D_dataset():
dataset = 'Rhd2DDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/rhd2d.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/rhd/test_rhd.json',
img_prefix='tests/data/rhd/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/rhd/test_rhd.json',
img_prefix='tests/data/rhd/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'rhd2d'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 3
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK', 'EPE', 'AUC'])
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_Panoptic2D_dataset():
dataset = 'PanopticDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/panoptic_hand2d.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/panoptic/test_panoptic.json',
img_prefix='tests/data/panoptic/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/panoptic/test_panoptic.json',
img_prefix='tests/data/panoptic/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'panoptic_hand2d'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCKh', 'EPE', 'AUC'])
assert_almost_equal(infos['PCKh'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_InterHand2D_dataset():
dataset = 'InterHand2DDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/interhand2d.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=21,
dataset_joints=21,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64],
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'interhand2d'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
assert len(custom_dataset.db) == 6
_ = custom_dataset[0]
results = convert_db_to_output(custom_dataset.db)
infos = custom_dataset.evaluate(results, metric=['PCK', 'EPE', 'AUC'])
print(infos, flush=True)
assert_almost_equal(infos['PCK'], 1.0)
assert_almost_equal(infos['AUC'], 0.95)
assert_almost_equal(infos['EPE'], 0.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
def test_InterHand3D_dataset():
dataset = 'InterHand3DDataset'
dataset_info = Config.fromfile(
'configs/_base_/datasets/interhand3d.py').dataset_info
dataset_class = DATASETS.get(dataset)
channel_cfg = dict(
num_output_channels=42,
dataset_joints=42,
dataset_channel=[
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41
],
],
inference_channel=[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41
])
data_cfg = dict(
image_size=[256, 256],
heatmap_size=[64, 64, 64],
heatmap3d_depth_bound=400.0,
heatmap_size_root=64,
root_depth_bound=400.0,
num_output_channels=channel_cfg['num_output_channels'],
num_joints=channel_cfg['dataset_joints'],
dataset_channel=channel_cfg['dataset_channel'],
inference_channel=channel_cfg['inference_channel'])
# Test
data_cfg_copy = copy.deepcopy(data_cfg)
_ = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=True)
custom_dataset = dataset_class(
ann_file='tests/data/interhand2.6m/test_interhand2.6m_data.json',
camera_file='tests/data/interhand2.6m/test_interhand2.6m_camera.json',
joint_file='tests/data/interhand2.6m/test_interhand2.6m_joint_3d.json',
img_prefix='tests/data/interhand2.6m/',
data_cfg=data_cfg_copy,
pipeline=[],
dataset_info=dataset_info,
test_mode=False)
assert custom_dataset.dataset_name == 'interhand3d'
assert custom_dataset.test_mode is False
assert custom_dataset.num_images == 4
assert len(custom_dataset.db) == 4
_ = custom_dataset[0]
results = convert_db_to_output(
custom_dataset.db, keys=['rel_root_depth', 'hand_type'], is_3d=True)
infos = custom_dataset.evaluate(
results, metric=['MRRPE', 'MPJPE', 'Handedness_acc'])
assert_almost_equal(infos['MRRPE'], 0.0, decimal=5)
assert_almost_equal(infos['MPJPE_all'], 0.0, decimal=5)
assert_almost_equal(infos['MPJPE_single'], 0.0, decimal=5)
assert_almost_equal(infos['MPJPE_interacting'], 0.0, decimal=5)
assert_almost_equal(infos['Handedness_acc'], 1.0)
with pytest.raises(KeyError):
infos = custom_dataset.evaluate(results, metric='mAP')
@@ -0,0 +1,127 @@
# Copyright (c) OpenMMLab. All rights reserved.
import tempfile
from mmpose.datasets import DATASETS
def test_mesh_Mosh_dataset():
# test Mosh dataset
dataset = 'MoshDataset'
dataset_class = DATASETS.get(dataset)
custom_dataset = dataset_class(
ann_file='tests/data/mosh/test_mosh.npz', pipeline=[])
_ = custom_dataset[0]
def test_mesh_H36M_dataset():
# test H36M dataset
dataset = 'MeshH36MDataset'
dataset_class = DATASETS.get(dataset)
data_cfg = dict(
image_size=[256, 256],
iuv_size=[64, 64],
num_joints=24,
use_IUV=True,
uv_type='BF')
_ = dataset_class(
ann_file='tests/data/h36m/test_h36m.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[],
test_mode=False)
custom_dataset = dataset_class(
ann_file='tests/data/h36m/test_h36m.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[],
test_mode=True)
assert custom_dataset.test_mode is True
_ = custom_dataset[0]
# test evaluation
outputs = []
for item in custom_dataset:
pred = dict(
keypoints_3d=item['joints_3d'][None, ...],
image_path=item['image_file'])
outputs.append(pred)
with tempfile.TemporaryDirectory() as tmpdir:
eval_result = custom_dataset.evaluate(outputs, tmpdir)
assert 'MPJPE' in eval_result
assert 'MPJPE-PA' in eval_result
def test_mesh_Mix_dataset():
# test mesh Mix dataset
dataset = 'MeshMixDataset'
dataset_class = DATASETS.get(dataset)
data_cfg = dict(
image_size=[256, 256],
iuv_size=[64, 64],
num_joints=24,
use_IUV=True,
uv_type='BF')
custom_dataset = dataset_class(
configs=[
dict(
ann_file='tests/data/h36m/test_h36m.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[]),
dict(
ann_file='tests/data/h36m/test_h36m.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[]),
],
partition=[0.6, 0.4])
_ = custom_dataset[0]
def test_mesh_Adversarial_dataset():
# test mesh Adversarial dataset
# load train dataset
data_cfg = dict(
image_size=[256, 256],
iuv_size=[64, 64],
num_joints=24,
use_IUV=True,
uv_type='BF')
train_dataset = dict(
type='MeshMixDataset',
configs=[
dict(
ann_file='tests/data/h36m/test_h36m.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[]),
dict(
ann_file='tests/data/h36m/test_h36m.npz',
img_prefix='tests/data/h36m',
data_cfg=data_cfg,
pipeline=[]),
],
partition=[0.6, 0.4])
# load adversarial dataset
adversarial_dataset = dict(
type='MoshDataset',
ann_file='tests/data/mosh/test_mosh.npz',
pipeline=[])
# combine train and adversarial dataset to form a new dataset
dataset = 'MeshAdversarialDataset'
dataset_class = DATASETS.get(dataset)
custom_dataset = dataset_class(train_dataset, adversarial_dataset)
item = custom_dataset[0]
assert 'mosh_theta' in item.keys()
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,258 @@
# Copyright (c) OpenMMLab. All rights reserved.
import os.path as osp
import tempfile
import unittest.mock as mock
from collections import OrderedDict
from unittest.mock import MagicMock, patch
import pytest
import torch
import torch.nn as nn
from mmcv.runner import EpochBasedRunner, build_optimizer
from mmcv.utils import get_logger
from torch.utils.data import DataLoader, Dataset
from mmpose.core import DistEvalHook, EvalHook
class ExampleDataset(Dataset):
def __init__(self):
self.index = 0
self.eval_result = [0.1, 0.4, 0.3, 0.7, 0.2, 0.05, 0.4, 0.6]
def __getitem__(self, idx):
results = dict(imgs=torch.tensor([1]))
return results
def __len__(self):
return 1
@mock.create_autospec
def evaluate(self, results, res_folder=None, logger=None):
pass
class EvalDataset(ExampleDataset):
def evaluate(self, results, res_folder=None, logger=None):
acc = self.eval_result[self.index]
output = OrderedDict(acc=acc, index=self.index, score=acc)
self.index += 1
return output
class ExampleModel(nn.Module):
def __init__(self):
super().__init__()
self.conv = nn.Linear(1, 1)
self.test_cfg = None
def forward(self, imgs, return_loss=False):
return imgs
def train_step(self, data_batch, optimizer, **kwargs):
outputs = {
'loss': 0.5,
'log_vars': {
'accuracy': 0.98
},
'num_samples': 1
}
return outputs
@pytest.mark.skipif(
not torch.cuda.is_available(), reason='requires CUDA support')
@patch('mmpose.apis.single_gpu_test', MagicMock)
@patch('mmpose.apis.multi_gpu_test', MagicMock)
@pytest.mark.parametrize('EvalHookCls', (EvalHook, DistEvalHook))
def test_eval_hook(EvalHookCls):
with pytest.raises(TypeError):
# dataloader must be a pytorch DataLoader
test_dataset = ExampleDataset()
data_loader = [
DataLoader(
test_dataset,
batch_size=1,
sampler=None,
num_worker=0,
shuffle=False)
]
EvalHookCls(data_loader)
with pytest.raises(KeyError):
# rule must be in keys of rule_map
test_dataset = ExampleDataset()
data_loader = DataLoader(
test_dataset,
batch_size=1,
sampler=None,
num_workers=0,
shuffle=False)
EvalHookCls(data_loader, save_best='auto', rule='unsupport')
with pytest.raises(ValueError):
# save_best must be valid when rule_map is None
test_dataset = ExampleDataset()
data_loader = DataLoader(
test_dataset,
batch_size=1,
sampler=None,
num_workers=0,
shuffle=False)
EvalHookCls(data_loader, save_best='unsupport')
optimizer_cfg = dict(
type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
test_dataset = ExampleDataset()
loader = DataLoader(test_dataset, batch_size=1)
model = ExampleModel()
optimizer = build_optimizer(model, optimizer_cfg)
data_loader = DataLoader(test_dataset, batch_size=1)
eval_hook = EvalHookCls(data_loader, save_best=None)
with tempfile.TemporaryDirectory() as tmpdir:
logger = get_logger('test_eval')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger,
max_epochs=1)
runner.register_hook(eval_hook)
runner.run([loader], [('train', 1)])
assert runner.meta is None or 'best_score' not in runner.meta[
'hook_msgs']
assert runner.meta is None or 'best_ckpt' not in runner.meta[
'hook_msgs']
# when `save_best` is set to 'auto', first metric will be used.
loader = DataLoader(EvalDataset(), batch_size=1)
model = ExampleModel()
data_loader = DataLoader(EvalDataset(), batch_size=1)
eval_hook = EvalHookCls(data_loader, interval=1, save_best='auto')
with tempfile.TemporaryDirectory() as tmpdir:
logger = get_logger('test_eval')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger,
max_epochs=8)
runner.register_checkpoint_hook(dict(interval=1))
runner.register_hook(eval_hook)
runner.run([loader], [('train', 1)])
real_path = osp.join(tmpdir, 'best_acc_epoch_4.pth')
assert runner.meta['hook_msgs']['best_ckpt'] == osp.realpath(real_path)
assert runner.meta['hook_msgs']['best_score'] == 0.7
loader = DataLoader(EvalDataset(), batch_size=1)
model = ExampleModel()
data_loader = DataLoader(EvalDataset(), batch_size=1)
eval_hook = EvalHookCls(data_loader, interval=1, save_best='acc')
with tempfile.TemporaryDirectory() as tmpdir:
logger = get_logger('test_eval')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger,
max_epochs=8)
runner.register_checkpoint_hook(dict(interval=1))
runner.register_hook(eval_hook)
runner.run([loader], [('train', 1)])
real_path = osp.join(tmpdir, 'best_acc_epoch_4.pth')
assert runner.meta['hook_msgs']['best_ckpt'] == osp.realpath(real_path)
assert runner.meta['hook_msgs']['best_score'] == 0.7
data_loader = DataLoader(EvalDataset(), batch_size=1)
eval_hook = EvalHookCls(
data_loader, interval=1, save_best='score', rule='greater')
with tempfile.TemporaryDirectory() as tmpdir:
logger = get_logger('test_eval')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger)
runner.register_checkpoint_hook(dict(interval=1))
runner.register_hook(eval_hook)
runner.run([loader], [('train', 1)], 8)
real_path = osp.join(tmpdir, 'best_score_epoch_4.pth')
assert runner.meta['hook_msgs']['best_ckpt'] == osp.realpath(real_path)
assert runner.meta['hook_msgs']['best_score'] == 0.7
data_loader = DataLoader(EvalDataset(), batch_size=1)
eval_hook = EvalHookCls(data_loader, save_best='acc', rule='less')
with tempfile.TemporaryDirectory() as tmpdir:
logger = get_logger('test_eval')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger,
max_epochs=8)
runner.register_checkpoint_hook(dict(interval=1))
runner.register_hook(eval_hook)
runner.run([loader], [('train', 1)])
real_path = osp.join(tmpdir, 'best_acc_epoch_6.pth')
assert runner.meta['hook_msgs']['best_ckpt'] == osp.realpath(real_path)
assert runner.meta['hook_msgs']['best_score'] == 0.05
data_loader = DataLoader(EvalDataset(), batch_size=1)
eval_hook = EvalHookCls(data_loader, save_best='acc')
with tempfile.TemporaryDirectory() as tmpdir:
logger = get_logger('test_eval')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger,
max_epochs=2)
runner.register_checkpoint_hook(dict(interval=1))
runner.register_hook(eval_hook)
runner.run([loader], [('train', 1)])
real_path = osp.join(tmpdir, 'best_acc_epoch_2.pth')
assert runner.meta['hook_msgs']['best_ckpt'] == osp.realpath(real_path)
assert runner.meta['hook_msgs']['best_score'] == 0.4
resume_from = osp.join(tmpdir, 'latest.pth')
loader = DataLoader(ExampleDataset(), batch_size=1)
eval_hook = EvalHookCls(data_loader, save_best='acc')
runner = EpochBasedRunner(
model=model,
batch_processor=None,
optimizer=optimizer,
work_dir=tmpdir,
logger=logger,
max_epochs=8)
runner.register_checkpoint_hook(dict(interval=1))
runner.register_hook(eval_hook)
runner.resume(resume_from)
runner.run([loader], [('train', 1)])
real_path = osp.join(tmpdir, 'best_acc_epoch_4.pth')
assert runner.meta['hook_msgs']['best_ckpt'] == osp.realpath(real_path)
assert runner.meta['hook_msgs']['best_score'] == 0.7
@@ -0,0 +1,102 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import torch
from mmpose.core import (aggregate_scale, aggregate_stage_flip,
flip_feature_maps, get_group_preds, split_ae_outputs)
def test_split_ae_outputs():
fake_outputs = [torch.zeros((1, 4, 2, 2))]
heatmaps, tags = split_ae_outputs(
fake_outputs,
num_joints=4,
with_heatmaps=[False],
with_ae=[True],
select_output_index=[0])
def test_flip_feature_maps():
fake_outputs = [torch.zeros((1, 4, 2, 2))]
_ = flip_feature_maps(fake_outputs, None)
_ = flip_feature_maps(fake_outputs, flip_index=[1, 0])
def test_aggregate_stage_flip():
fake_outputs = [torch.zeros((1, 4, 2, 2))]
fake_flip_outputs = [torch.ones((1, 4, 2, 2))]
output = aggregate_stage_flip(
fake_outputs,
fake_flip_outputs,
index=-1,
project2image=True,
size_projected=(4, 4),
align_corners=False,
aggregate_stage='concat',
aggregate_flip='average')
assert isinstance(output, list)
output = aggregate_stage_flip(
fake_outputs,
fake_flip_outputs,
index=-1,
project2image=True,
size_projected=(4, 4),
align_corners=False,
aggregate_stage='average',
aggregate_flip='average')
assert isinstance(output, list)
output = aggregate_stage_flip(
fake_outputs,
fake_flip_outputs,
index=-1,
project2image=True,
size_projected=(4, 4),
align_corners=False,
aggregate_stage='average',
aggregate_flip='concat')
assert isinstance(output, list)
output = aggregate_stage_flip(
fake_outputs,
fake_flip_outputs,
index=-1,
project2image=True,
size_projected=(4, 4),
align_corners=False,
aggregate_stage='concat',
aggregate_flip='concat')
assert isinstance(output, list)
def test_aggregate_scale():
fake_outputs = [torch.zeros((1, 4, 2, 2)), torch.zeros((1, 4, 2, 2))]
output = aggregate_scale(
fake_outputs, align_corners=False, aggregate_scale='average')
assert isinstance(output, torch.Tensor)
assert output.shape == fake_outputs[0].shape
output = aggregate_scale(
fake_outputs, align_corners=False, aggregate_scale='unsqueeze_concat')
assert isinstance(output, torch.Tensor)
assert len(output.shape) == len(fake_outputs[0].shape) + 1
def test_get_group_preds():
fake_grouped_joints = [np.array([[[0, 0], [1, 1]]])]
results = get_group_preds(
fake_grouped_joints,
center=np.array([0, 0]),
scale=np.array([1, 1]),
heatmap_size=np.array([2, 2]))
assert not results == []
results = get_group_preds(
fake_grouped_joints,
center=np.array([0, 0]),
scale=np.array([1, 1]),
heatmap_size=np.array([2, 2]),
use_udp=True)
assert not results == []
@@ -0,0 +1,14 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
from numpy.testing import assert_array_almost_equal
from mmpose.core import compute_similarity_transform
def test_compute_similarity_transform():
source = np.random.rand(14, 3)
tran = np.random.rand(1, 3)
scale = 0.5
target = source * scale + tran
source_transformed = compute_similarity_transform(source, target)
assert_array_almost_equal(source_transformed, target)
@@ -0,0 +1,49 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from mmpose.core import keypoint_3d_auc, keypoint_3d_pck
def test_keypoint_3d_pck():
target = np.random.rand(2, 5, 3)
output = np.copy(target)
mask = np.ones((output.shape[0], output.shape[1]), dtype=bool)
with pytest.raises(ValueError):
_ = keypoint_3d_pck(output, target, mask, alignment='norm')
pck = keypoint_3d_pck(output, target, mask, alignment='none')
np.testing.assert_almost_equal(pck, 100)
output[0, 0, :] = target[0, 0, :] + 1
pck = keypoint_3d_pck(output, target, mask, alignment='none')
np.testing.assert_almost_equal(pck, 90, 5)
output = target * 2
pck = keypoint_3d_pck(output, target, mask, alignment='scale')
np.testing.assert_almost_equal(pck, 100)
output = target + 2
pck = keypoint_3d_pck(output, target, mask, alignment='procrustes')
np.testing.assert_almost_equal(pck, 100)
def test_keypoint_3d_auc():
target = np.random.rand(2, 5, 3)
output = np.copy(target)
mask = np.ones((output.shape[0], output.shape[1]), dtype=bool)
with pytest.raises(ValueError):
_ = keypoint_3d_auc(output, target, mask, alignment='norm')
auc = keypoint_3d_auc(output, target, mask, alignment='none')
np.testing.assert_almost_equal(auc, 30 / 31 * 100)
output = target * 2
auc = keypoint_3d_auc(output, target, mask, alignment='scale')
np.testing.assert_almost_equal(auc, 30 / 31 * 100)
output = target + 2
auc = keypoint_3d_auc(output, target, mask, alignment='procrustes')
np.testing.assert_almost_equal(auc, 30 / 31 * 100)
@@ -0,0 +1,213 @@
# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np
import pytest
from numpy.testing import assert_array_almost_equal
from mmpose.core import (keypoint_auc, keypoint_epe, keypoint_pck_accuracy,
keypoints_from_heatmaps, keypoints_from_heatmaps3d,
multilabel_classification_accuracy, pose_pck_accuracy)
def test_pose_pck_accuracy():
output = np.zeros((1, 5, 64, 64), dtype=np.float32)
target = np.zeros((1, 5, 64, 64), dtype=np.float32)
mask = np.array([[True, True, False, False, False]])
# first channel
output[0, 0, 20, 20] = 1
target[0, 0, 10, 10] = 1
# second channel
output[0, 1, 30, 30] = 1
target[0, 1, 30, 30] = 1
acc, avg_acc, cnt = pose_pck_accuracy(output, target, mask)
assert_array_almost_equal(acc, np.array([0, 1, -1, -1, -1]), decimal=4)
assert abs(avg_acc - 0.5) < 1e-4
assert abs(cnt - 2) < 1e-4
def test_keypoints_from_heatmaps():
heatmaps = np.ones((1, 1, 64, 64), dtype=np.float32)
heatmaps[0, 0, 31, 31] = 2
center = np.array([[127, 127]])
scale = np.array([[64 / 200.0, 64 / 200.0]])
udp_heatmaps = np.ones((32, 17, 64, 64), dtype=np.float32)
udp_heatmaps[:, :, 31, 31] = 2
udp_center = np.tile([127, 127], (32, 1))
udp_scale = np.tile([32, 32], (32, 1))
preds, maxvals = keypoints_from_heatmaps(heatmaps, center, scale)
assert_array_almost_equal(preds, np.array([[[126, 126]]]), decimal=4)
assert_array_almost_equal(maxvals, np.array([[[2]]]), decimal=4)
assert isinstance(preds, np.ndarray)
assert isinstance(maxvals, np.ndarray)
with pytest.raises(AssertionError):
# kernel should > 0
_ = keypoints_from_heatmaps(
heatmaps, center, scale, post_process='unbiased', kernel=0)
preds, maxvals = keypoints_from_heatmaps(
heatmaps, center, scale, post_process='unbiased')
assert_array_almost_equal(preds, np.array([[[126, 126]]]), decimal=4)
assert_array_almost_equal(maxvals, np.array([[[2]]]), decimal=4)
assert isinstance(preds, np.ndarray)
assert isinstance(maxvals, np.ndarray)
# test for udp dimension problem
preds, maxvals = keypoints_from_heatmaps(
udp_heatmaps,
udp_center,
udp_scale,
post_process='default',
target_type='GaussianHeatMap',
use_udp=True)
assert_array_almost_equal(preds, np.tile([76, 76], (32, 17, 1)), decimal=0)
assert_array_almost_equal(maxvals, np.tile([2], (32, 17, 1)), decimal=4)
assert isinstance(preds, np.ndarray)
assert isinstance(maxvals, np.ndarray)
preds1, maxvals1 = keypoints_from_heatmaps(
heatmaps,
center,
scale,
post_process='default',
target_type='GaussianHeatMap',
use_udp=True)
preds2, maxvals2 = keypoints_from_heatmaps(
heatmaps,
center,
scale,
post_process='default',
target_type='GaussianHeatmap',
use_udp=True)
assert_array_almost_equal(preds1, preds2, decimal=4)
assert_array_almost_equal(maxvals1, maxvals2, decimal=4)
assert isinstance(preds2, np.ndarray)
assert isinstance(maxvals2, np.ndarray)
def test_keypoint_pck_accuracy():
output = np.zeros((2, 5, 2))
target = np.zeros((2, 5, 2))
mask = np.array([[True, True, False, True, True],
[True, True, False, True, True]])
thr = np.full((2, 2), 10, dtype=np.float32)
# first channel
output[0, 0] = [10, 0]
target[0, 0] = [10, 0]
# second channel
output[0, 1] = [20, 20]
target[0, 1] = [10, 10]
# third channel
output[0, 2] = [0, 0]
target[0, 2] = [-1, 0]
# fourth channel
output[0, 3] = [30, 30]
target[0, 3] = [30, 30]
# fifth channel
output[0, 4] = [0, 10]
target[0, 4] = [0, 10]
acc, avg_acc, cnt = keypoint_pck_accuracy(output, target, mask, 0.5, thr)
assert_array_almost_equal(acc, np.array([1, 0.5, -1, 1, 1]), decimal=4)
assert abs(avg_acc - 0.875) < 1e-4
assert abs(cnt - 4) < 1e-4
acc, avg_acc, cnt = keypoint_pck_accuracy(output, target, mask, 0.5,
np.zeros((2, 2)))
assert_array_almost_equal(acc, np.array([-1, -1, -1, -1, -1]), decimal=4)
assert abs(avg_acc) < 1e-4
assert abs(cnt) < 1e-4
acc, avg_acc, cnt = keypoint_pck_accuracy(output, target, mask, 0.5,
np.array([[0, 0], [10, 10]]))
assert_array_almost_equal(acc, np.array([1, 1, -1, 1, 1]), decimal=4)
assert abs(avg_acc - 1) < 1e-4
assert abs(cnt - 4) < 1e-4
def test_keypoint_auc():
output = np.zeros((1, 5, 2))
target = np.zeros((1, 5, 2))
mask = np.array([[True, True, False, True, True]])
# first channel
output[0, 0] = [10, 4]
target[0, 0] = [10, 0]
# second channel
output[0, 1] = [10, 18]
target[0, 1] = [10, 10]
# third channel
output[0, 2] = [0, 0]
target[0, 2] = [0, -1]
# fourth channel
output[0, 3] = [40, 40]
target[0, 3] = [30, 30]
# fifth channel
output[0, 4] = [20, 10]
target[0, 4] = [0, 10]
auc = keypoint_auc(output, target, mask, 20, 4)
assert abs(auc - 0.375) < 1e-4
def test_keypoint_epe():
output = np.zeros((1, 5, 2))
target = np.zeros((1, 5, 2))
mask = np.array([[True, True, False, True, True]])
# first channel
output[0, 0] = [10, 4]
target[0, 0] = [10, 0]
# second channel
output[0, 1] = [10, 18]
target[0, 1] = [10, 10]
# third channel
output[0, 2] = [0, 0]
target[0, 2] = [-1, -1]
# fourth channel
output[0, 3] = [40, 40]
target[0, 3] = [30, 30]
# fifth channel
output[0, 4] = [20, 10]
target[0, 4] = [0, 10]
epe = keypoint_epe(output, target, mask)
assert abs(epe - 11.5355339) < 1e-4
def test_keypoints_from_heatmaps3d():
heatmaps = np.ones((1, 1, 64, 64, 64), dtype=np.float32)
heatmaps[0, 0, 10, 31, 40] = 2
center = np.array([[127, 127]])
scale = np.array([[64 / 200.0, 64 / 200.0]])
preds, maxvals = keypoints_from_heatmaps3d(heatmaps, center, scale)
assert_array_almost_equal(preds, np.array([[[135, 126, 10]]]), decimal=4)
assert_array_almost_equal(maxvals, np.array([[[2]]]), decimal=4)
assert isinstance(preds, np.ndarray)
assert isinstance(maxvals, np.ndarray)
def test_multilabel_classification_accuracy():
output = np.array([[0.7, 0.8, 0.4], [0.8, 0.1, 0.1]])
target = np.array([[1, 0, 0], [1, 0, 1]])
mask = np.array([[True, True, True], [True, True, True]])
thr = 0.5
acc = multilabel_classification_accuracy(output, target, mask, thr)
assert acc == 0
output = np.array([[0.7, 0.2, 0.4], [0.8, 0.1, 0.9]])
thr = 0.5
acc = multilabel_classification_accuracy(output, target, mask, thr)
assert acc == 1
thr = 0.3
acc = multilabel_classification_accuracy(output, target, mask, thr)
assert acc == 0.5
mask = np.array([[True, True, False], [True, True, True]])
acc = multilabel_classification_accuracy(output, target, mask, thr)
assert acc == 1

Some files were not shown because too many files have changed in this diff Show More