fabro66 / GAST-Net-3DPoseEstimation

A Graph Attention Spatio-temporal Convolutional Networks for 3D Human Pose Estimation in Video (GAST-Net)
MIT License
313 stars 70 forks source link

Help with OpenPose keypoints output(JSON) #1

Closed vsantosu closed 4 years ago

vsantosu commented 4 years ago

Hello there,

First of all, this is an amazing work! Thanks for the contribution.

I want to run the inference on a custom 2D keypoints + video I first passed through OpenPose. I have a set of JSON files that looks like the following:

[
    {
        "image_id":0,
        "category_id":1,
        "keypoints":[
            517.006,168.796,1,-1,-1,0,517.948,162.885,1,-1,-1,0,505.21,159.923,1,477.852,169.76,1,479.818,179.519,1,464.164,209.855,1,469.072,227.451,1,-1,-1,0,472.992,268.505,1,413.319,200.031,1,420.175,205.896,1,456.347,246.018,1,457.288,250.919,1,437.767,296.897,1,430.914,306.671,1
        ],
        "score":0.568171
    },
    {
        "image_id":1,
        "category_id":1,
        "keypoints":[
            517.983,183.369,1,-1,-1,0,518.931,176.537,1,-1,-1,0,506.25,168.798,1,478.827,176.592,1,481.743,190.29,1,-1,-1,0,474.921,238.219,1,-1,-1,0,480.787,278.286,1,414.285,206.875,1,420.171,210.823,1,462.224,247.976,1,463.203,251.904,1,438.734,298.858,1,430.923,307.629,1
        ],
        "score":0.587186
    },

How do I convert these files in a single npz archive(I'm guessing is a numpy seriealized object), like the one in the command line?(keypoints.npz).

Thanks in advanced!

fabro66 commented 4 years ago

Hi~ If you have a .json file in the following format, you can load keypoints like this.

 {data: [{
        "image_id":0,
        "category_id":1,
        "keypoints":[517.006,168.796,1,-1,-1,0,517.948,162.885,1,-1,-1,0,505.21,159.923,1,477.852,169.76,1,479.818,179.519,1,464.164,209.855,1,469.072,227.451,1,-1,-1,0,472.992,268.505,1,413.319,200.031,1,420.175,205.896,1,456.347,246.018,1,457.288,250.919,1,437.767,296.897,1,430.914,306.671,1],
        "score":0.568171},
    {
        "image_id":1,
        "category_id":1,
        "keypoints":[517.983,183.369,1,-1,-1,0,518.931,176.537,1,-1,-1,0,506.25,168.798,1,478.827,176.592,1,481.743,190.29,1,-1,-1,0,474.921,238.219,1,-1,-1,0,480.787,278.286,1,414.285,206.875,1,420.171,210.823,1,462.224,247.976,1,463.203,251.904,1,438.734,298.858,1,430.923,307.629,1],
        "score":0.587186}
]}
def load_json(file_path):
    with open(file_path, 'r') as fr:
        video_info = json.load(fr)

    data = video_info['data']
    tem = len(data)
    keypoints = np.zeros((tem, 17, 2), dtype=np.float32)
    for i, frame_info in enumerate(data):
        keypoints[i] = frame_info['keypoints']

    # Convert 'Openpose' format to MSCOCO
    order_coco = [i for i in range(17) if i != 1]
    keypoints = keypoints[:, order_coco]
    keypoints = coco_h36m(keypoints)

    return keypoints
vsantosu commented 4 years ago

Thanks so much! I will give it a try and I will report back.

vsantosu commented 4 years ago

Hi there,

I'm trying to clone the repo to give the inference example a try. I'm trying to get the following files but the links are broken or the files are not listed:

python reconstruction.py -c epoch_60.bin -k ../keypoints.npz -vi ../sittingdown.mp4 -vo ./output/output_animation.mp4 -kf coco

fabro66 commented 4 years ago

Hi there,

I'm trying to clone the repo to give the inference example a try. I'm trying to get the following files but the links are broken or the files are not listed:

  • The pre-trained models links are broken.
  • For the example inference, can you provide the sample files?

python reconstruction.py -c epoch_60.bin -k ../keypoints.npz -vi ../sittingdown.mp4 -vo ./output/output_animation.mp4 -kf coco

Hi~

please check it.