MVIG-SJTU / AlphaPose

Real-Time and Accurate Full-Body Multi-Person Pose Estimation&Tracking System
http://mvig.org/research/alphapose.html
Other
8.05k stars 1.98k forks source link

How to switch COCO mode to MPII mode #1103

Open thoth000 opened 1 year ago

thoth000 commented 1 year ago

I want to generate JSON files with MPII keypoint order, not COCO.

So I ran the following command. I changed --format coco to --format MPII.

python scripts/demo_inference.py \
--cfg configs/coco/resnet/256x192_res50_lr1e-3_1x-simple.yaml \
--checkpoint pretrained_models/simple_res50_256x192.pth \
--video example.mp4 \
--outdir examples/res \
--detbatch 1 \
--posebatch 30 \
--detector tracker \
--showbox \
--format MPII \
--save_video

However, a portion of the output data shows that the number of elements in keypoints is 51, which is keypoints in COCO.

{
        "image_id": "0.jpg",
        "category_id": 1,
        "keypoints": [
            1470.4735107421875,
            167.3895721435547,
            0.9206457138061523,
            1473.953857421875,
            163.9093017578125,
            0.9169428944587708,
            1466.9932861328125,
            163.9093017578125,
            0.9339861273765564,
            1480.9144287109375,
            165.64944458007812,
            0.8938273787498474,
            1463.512939453125,
            165.64944458007812,
            0.9008600115776062,
            1487.8748779296875,
            184.79098510742188,
            0.9028074145317078,
            1461.7728271484375,
            186.5311279296875,
            0.8846182823181152,
            1482.654541015625,
            209.15293884277344,
            0.8575469255447388,
            1458.2926025390625,
            209.15293884277344,
            0.887753427028656,
            1468.7333984375,
            230.0346221923828,
            0.881260097026825,
            1458.2926025390625,
            230.0346221923828,
            0.8903049826622009,
            1482.654541015625,
            236.9951934814453,
            0.8013991713523865,
            1465.2530517578125,
            236.9951934814453,
            0.8115606904029846,
            1480.9144287109375,
            273.53814697265625,
            0.8705073595046997,
            1465.2530517578125,
            273.53814697265625,
            0.8841249942779541,
            1484.3946533203125,
            308.3409423828125,
            0.8712695240974426,
            1465.2530517578125,
            306.6007995605469,
            0.9167873859405518
        ],
        "score": 3.051330089569092,
        "box": [
            1437.9459228515625,
            145.28985595703125,
            70.275634765625,
            178.19027709960938
        ],
        "idx": 2.0
    },

How can I output the JSON file for the MPII case?

nistring commented 1 year ago

--format in option only offers 'cmu' or 'open' otherwise it'll give coco formatted json results. If you want to save in MP2 format, I think you'll need to modifiy write_json function in alphapose/utils/pPose_nms.py. In addition, in order to visualize skeletons in MP2 format, you have to modifiy the variable format='coco' in vis_frame function in alphapose/utils/vis.py.

This would be helpful. https://github.com/MVIG-SJTU/AlphaPose/blob/43c81cb478c4af85172fcf21a3d0223e7b69333b/docs/output.md