Giter Club home page Giter Club logo

klabcmu / kinpoly Goto Github PK

View Code? Open in Web Editor NEW
77.0 8.0 6.0 218.2 MB

Official implementation of NeurIPS 2021 paper: "Dynamics-Regulated Kinematic Policy for Egocentric Pose Estimation". This repo contains a copy of the code for "Universal Humanoid Controller" and "Kinematic Policy".

Home Page: https://zhengyiluo.github.io/projects/kin_poly/

License: BSD 3-Clause "New" or "Revised" License

Python 99.89% Shell 0.11%
physics-simulation humanoid humanoid-control

kinpoly's Introduction

Dynamics-Regulated Kinematic Policy for Egocentric Pose Estimation

[paper] [website] [Video]

News ๐Ÿšฉ

[February 24, 2023] Updating some model loading; please rerun bash download_data.sh to get the newest models ๐Ÿ™๐Ÿป

[Ocotober 20, 2022] Updating to runnable kinemaitc policy

[Ocotober 20, 2021] Code release!

Introduction

In this project, we demonstrate the ability to estimate 3D human pose and human-object interactions from egocentric videos. This code base contains all the necessary files to train and reproduce the results reported in our paper, and contain configuration files and hyperparameters used in our experiments. Some training data (namely, AMASS) and external library (Mujoco) may require additional licence to obtain, and this codebase contains data processing scripts to process these data once obtained.

Dependencies

To create the environment, follow the following instructions:

  1. Create new conda environment and install pytroch:
conda create -n kin_poly python=3.8
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
  1. Download and setup mujoco: Mujoco
wget https://github.com/deepmind/mujoco/releases/download/2.1.0/mujoco210-linux-x86_64.tar.gz
tar -xzf mujoco210-linux-x86_64.tar.gz
mkdir ~/.mujoco
mv mujoco210 ~/.mujoco/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.mujoco/mujoco210/bin
  1. The rest of the dependencies can be found in requirements.txt.
pip install -r requirements.txt

Datasets and trained models

The datasets we use for training and evaluating our method can be found here:

[Real-world dataset][MoCap dataset]

The folders contain the a data file that contains the pre-computed object pose and camera trajectory; another data file contains the pre-computed image features; a meta file is also included for loading the respective datasets.

To download the Mocap dataset, real-world dataset, and trained models, run the following script:

bash download_data.sh

Important files

  • kin_poly/models/traj_ar_smpl_net.py: definition of our kinematic model's network.
  • kin_poly/models/policy_ar.py: wrapper around our kinematic model to form the kinematic policy.
  • kin_poly/envs/humanoid_ar_v1.py: main Mujoco environment for training and evaluating our kinematic policy.
  • scripts/eval_pose_all.py: evaluation code that computes all metrics reported in our paper from a pickled result file.
  • config/kin_poly.yml: the configuration file used to train our kinematic policy.
  • uhc/cfg/uhc.yml: the configuration file used to train our universal humanoid controller.
  • assets/mujoco_models/humanoid_smpl_neutral_mesh_all.xml: the simulation configuration used in our experiments. It contains the definition for the humanoid and the objects (chair, box, table, etc.) for Mujoco.

Training

To train our dynamics-regulated kinematic policy, use the command:

python scripts/train_ar_policy.py --cfg kin_poly  --num_threads 35 

To train our kinematic policy using only supervised learning, use the command:

python scripts/exp_arnet_all.py --cfg kin_poly  

To train our universal humanoid controller, use the command:

python scripts/train_uhc.py.py --cfg uhc --num_threads 35

Evaluation

To evaluate our dynamics-regulated kinematic policy, run:

python scripts/eval_ar_policy.py --cfg kin_poly --iter 750  # Mocal data
python scripts/eval_ar_policy.py --cfg kin_poly --iter 750  --wild # Real-world data

To evalutes our kinematic policy using only supervised learning, run:

python scripts/exp_arnet_all.py --cfg kin_poly  --test --iter 1000

To compute metrics, run:

python scripts/eval_pose_all --cfg kin_poly --algo kin_poly --iter 750

To evaluate our universal humanoid controller, run:

python scripts/eval_uhc.py --cfg uhc --iter 10000

Relationship to the main uhc repository

This repository is self-contained and houses an eariler version of the universal humanoid controller (one that only supports the average neutral SMPL human). For support of all SMPL human models, please refer to the main UHC repository.

Citation

If you find our work useful in your research, please cite our paper kin_poly:

@inproceedings{Luo2021DynamicsRegulatedKP,
  title={Dynamics-Regulated Kinematic Policy for Egocentric Pose Estimation},
  author={Zhengyi Luo and Ryo Hachiuma and Ye Yuan and Kris Kitani},
  booktitle={Advances in Neural Information Processing Systems},
  year={2021}
}

Related work:

@inproceedings{yuan2020residual,
    title={Residual Force Control for Agile Human Behavior Imitation and Extended Motion Synthesis},
    author={Yuan, Ye and Kitani, Kris},
    booktitle={Advances in Neural Information Processing Systems},
    year={2020}
}

@inproceedings{yuan2019ego,
    title={Ego-Pose Estimation and Forecasting as Real-Time PD Control},
    author={Yuan, Ye and Kitani, Kris},
    booktitle={Proceedings of the IEEE International Conference on Computer Vision (ICCV)},
    year={2019},
    pages={10082--10092}
}

References

This repository is based on the following repositories:

  • Part of the UHC code is from: rfc
  • SMPL models and layer is from: SMPL-X model
  • Feature extractors are from: SPIN
  • NN modules are from (khrylib): DLOW

kinpoly's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kinpoly's Issues

A problem with the training time

In the paper you mentioned that using RTX2080ti, 35 threads training UHC takes a day. But when I restored this experiment, it was prompted that it would take at least 27 days. It is true that the number of training in this code is 30,000 times, but if it takes about ten days to train 10,000 times, how can I solve it?

copycat 0 T_s 58.10 T_u 18.62 ETA 26 days, 15:23:14 expert_R_avg 0.5640 [0.7173,0.6135,0.4504,0.3766,0.9420] expert_R_range (0.0454, 0.9716) eps_len 33.11
copycat 1 T_s 60.72 T_u 18.07 ETA 27 days, 8:31:45 expert_R_avg 0.5612 [0.7094,0.6027,0.4505,0.3825,0.9423] expert_R_range (0.0455, 0.9695) eps_len 32.06

How to convert original npy file into expert data

The SMPL+H Body Data from AMASS website is a list of npy files in different folders. And in copycat/data_process, there are scripts like 'amass_to_qpos.py'. However, these scripts directly load a pickle file, instead of npy file. We need to infer the data structure needed for 'amass_to_qpos.py, and also self-implement how to filter those unsuitable motions.

So I want to ask that is there another script to preprocess a list npy file in different folders into the expected data structure, which could therefore be fed into 'amass_to_qpos.py'. If so, it would be very useful if the preprocess script is released.

Also if we can see some simple example in the repo that shows how to convert npy file into the data we want, (just like in Khrylx / RFC, we could see how to convert amc file into expert data), it would be more straight forward.

Many thanks for sharing the code by the way, it is a wonderful work~

Question on processing the AMASS data.

Thank you for sharing the code!
Hi, I follow the process process_amass_raw.py > amass_to_qpos.py > augment_amass.py and get an expert dict, but each sequence only contains length 140. May I ask which line did it downsample the sequence?
And may I ask where can I find the amass_copycat_occlusion.pkl for filtering the unsuitable motions?

Kinematic Policy Code

Thanks for the released codes! It's a great work! I wonder if you plan to release a runnable version of kinematic policy part. That would be really helpful for this research direction. Thanks!

Missing AMASS dataset files

Where is the download link for amass_copy_occlusion.pkl?

I'm currently trying to process AMASS data for training and evaluation, following process_amass_raw.py > amass_to_qpos.py > augment amass.py. In augment_amass.py, amass_copycat_occlusion.pkl is required to generate amass_take4.pkl. But I cannot find the download link for this file. Any idea where to find it or which script to generate it?

Thank you!

Can mujoco module accelerated by CUDA?

Great job! I found that the training process is very slow because the physical forward process is fully applied on CPU. Can the forward process of mujoco modules accelerated by CUDA?

The pretrained model is inconsistent with the model structure in the code

Download and train the model model_kin_poly.p and place it in "kin-poly/results/all/statear/kin_poly/models_policy". Running "python scripts/eval_ar_policy.py" to evaluate the model, I get the error:

RuntimeError: Error(s) in loading state_dict for PolicyAR:
size mismatch for traj_ar_net.action_rnn.rnn_f.weight_ih: copying a param with shape torch.Size([3072, 105]) from checkpoint, the shape in current model is torch.Size([3072, 101]).
size mismatch for traj_ar_net.action_mlp.affine_layers.0.weight: copying a param with shape torch.Size([1024, 1129]) from checkpoint, the shape in current model is torch.Size([1024, 1125]).

There was a problem with the processing of the AMASS dataset

After I downloaded the required AMASS dataset in SMPL-H format, I got the "amass_db_smplx.pt" file after running "process_amass_raw.py".
When I then run "amass_to_qpos.py" I get the following error:

 pose_seq_6d = convert_aa_to_orth6d(torch.tensor(pose_aa)).reshape(-1, 144)
RuntimeError: shape '[-1, 144]' is invalid for input of size 134160

Do you know how to solve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.