Giter VIP home page Giter VIP logo

dexmv-sim's Introduction

DexMV: Imitation Learning for Dexterous Manipulation from Human Videos

DexMV: Imitation Learning for Dexterous Manipulation from Human Videos, Yuzhe Qin*, Yueh-Hua Wu*, Shaowei Liu, Hanwen Jiang, Ruihan Yang, Yang Fu, Xiaolong Wang, ECCV 2022.

DexMV is a novel system and pipeline for learning dexterous manipulation from human demonstration videos. This repo contains the simulated environment and retargeting code for DexMV. The learning part for DexMV is maintained in dexmv-learn.

Pretrained model are provided to try our environment without training. Demonstrations generated by DexMV pipeline are also provided if you want to try from scratch.

DexMV Teaser

Bibtex

@misc{qin2021dexmv,
      title={DexMV: Imitation Learning for Dexterous Manipulation
      from Human Videos},
      author={Qin, Yuzhe and Wu, Yueh-Hua and Liu, Shaowei and Jiang, Hanwen, 
      and Yang, Ruihan and Fu, Yang and Wang, Xiaolong},
      year={2021},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
      }

Installation

  1. Install the MuJoCo. It is recommended to use conda to manage python package:

Install MuJoCo from: http://www.mujoco.org/ and put your MuJoCo licence to your install directory. If you already have MuJoCo on your computer, please skip this step. Note that we use MuJoCo 2.0 for our experiments.

  1. Install Python dependencies Create a conda env with all the Python dependencies.
# Download the code from this repo for the simulated environment, retargeting and examples
git clone https://github.com/yzqin/dexmv-sim
export DEXMV_PACKAGE_PATH=`pwd`
cd dexmv-sim

# The provoided package version in the yml is our testing environment, you do not need to follow the version of each python package precisely to run this code.
conda env create -f environment.yml 
conda activate dexmv
pip install -e .

# Download the code from dexmv-learn repo for the RL/Imitation algorithm.
# dexmv-learn is necessary in order to test on pretrained model or train from scratch, either with RL or with imitation.
cd $DEXMV_PACKAGE_PATH
git clone https://github.com/yzqin/dexmv-learn
cd dexmv-learn
pip install -e .
cd mjrl
pip install -e .
  1. The file structure is listed as follows:

dexmv-sim/hand_imitation/: environments, kinematics retargeting, and demonstration generation

dexxmv-sim/hand_imitation/hand_imitation/kinematics: kinematics retargeting and demonstration generation

examples/: example code to try DexMV

dexmv-learn/: training and inference for RL/Imitation learning algorithm

Additional docs other than this README: Demonstration Generation, Environment

Visualize Pretrained Policy

Relocate

You may need to setup the MuJoCo related environment variables, e.g. LD_LIBRARY_PATH before running the code.

cd DEXMV_PACKAGE_PATH/examples
python visualize_policy.py --env_name=relocate --object_name=tomato_soup_can # for relocate task

You can also try different object_name: mug, sugar_box, large_clamp, mustard_bottle, potted_meat_can, foam_brick

If it does not work for you, please check the GitHub issues for more discussion: openai/mujoco-py#268

Pour and Place Inside

python visualize_policy.py --env_name=pour # run this in the `example` directory
python visualize_policy.py --env_name=place_inside

Troubleshooting

If you encounter the following error:

ERROR: GLEW initalization error: Missing GL version

This is an issue related to MuJoCo OpenGL renderer. A quick fix is modifying the dynamic library loading order by:

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so

Train from scratch

Download processed demonstrations

First download the demonstrations from the Google Drive and place all the .pkl file in the dexmv-sim/demonstrations directory.

Training config

We use a config system to specify the training parameters, including task, object, imitation learning algorithm or RL only. For convenience, we have provided several config files for you.

Training

For example, if you want to train relocate mug task using DAPG with demonstrations:

# Download processed demonstrations first before training
python train.py --cfg configs/dapg-mug-example.yaml  # run this in the `example` directory

Similarly, there are several config files for other tasks and algorithms in the example/configs directory you can use for training.

Hand Motion Retargeting

In this repo, we provide an minimal example for retargeting the human hand to robot hand. The pose data of an example trajectory are also provided here for convenience.

The following code takes the human hand pose estimation results and retargets it to robot joint position sequence. The result sequence will be saved as example_retargeting.pkl

python retarget_human_hand.py --hand_dir=./retargeting_source/relocate_mustard_example_seq/hand_pose --output_file=example_retargeting.pkl

To visualize the retargeted robot trajectory along with the object, you can run the following:

python visualize_retargeting.py --retargeting_result=example_retargeting.p --object_dir=./retargeting_source/relocate_mustard_example_seq/object_pose

Note: Demonstration generation is more than hand motion retargeting. It also involves trajectory generation, time alignment, inverse dynamics and hindsight, to match the state and action space defined by RL environment. Please check the demo_generation.md

Retargeting

Environment

If you want to use our simulated environment for your own research, check the env.md

Demonstration Generation

For more details about demonstration generation, check the demo_generation.md

Acknowledge

Some file in this repository is modified based on the code from robosuite, soil, dapg , dm_control, py-min-jerk. We gratefully thank the authors of these amazing projects.

We also thank for Jiashun Wang for insightful discussions for the connection between human and robot hand, and thanks the DexPilot authors for their detailed explanation of their method.

dexmv-sim's People

Contributors

yzqin avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dexmv-sim's Issues

About object / hand pose estimation

Hi,
I'm currently trying to get the object / hand pose estimation output from Raw video images. If I'm correct, your work used

  1. PVN3D model for object pose estimation
  2. this model for hand pose estimation.
    Could you let me know the code lines where the outputs of these pose estimations are?
    Also, does these outputs contain 6D / 3D hand poses and 6D object poses too?

I would really appreciate your help.

Best regards,
Joe

question about action estimation

Hello, yuzhe! Thank you for open-sourcing your code, it has been extremely helpful to me. I have a question to ask. In dexmv and dapg, the action_space is defined as 30-d position actuators. Your code uses inverse kinematics to solve for qfrc, which is then converted into actuation as motor commands. This is about physical quantities related to force.However, in subsequent steps, the act_mean and act_rng (span) used are quantities of position actuator joint angles. Could you please explain why the demonstration's action_space is calculated this way? Thank you!

Hosting models and demo on Hugging Face

Hello! Thank you for open-sourcing this work, and congrats on having it accepted at ECCV 2022!

I was wondering if you'd be interested in mirroring the model weights over on the Hugging Face model hub. I'm sure our community would love to see your work, and (among other things) hosting checkpoints on the Hub helps a lot with discoverability. We've got a guide here on how to upload models, but I'm also happy to help out with it if you'd like!

There's also the possibility of publishing an interactive demo on Hugging Face Spaces to showcase your work, which we've found to be really successful. Some demos have even gone quite viral, like Stable Diffusion. If that's something that you're interested in, let me know!

Hand retargeting - What are the results_global_#.npy files?

I'm trying to use your code for hand retargeting, and am attempting to use other hand pose estimation methods (E.g Frankmocap, etc.) to gather MANO hand poses that can be retargeted using your code.

The demo retargeting_human_hand file uses two different types of files as input for the retargeting: joints_#.npy and results_global_#.npy.

I understand that joints_*.npy are the 21 joint positions (x, y, z), but I am unsure what the significance is of the results_global_#.npy files. I see these contain 16 4x4 matrices per file, but I'm unsure how they are being used or how they were gathered.

I would appreciate any help you have to offer!

P.S. I am also unsure what the mano_#.npy files signify. They don't seem to be used for retargeting, but I would love to know in any case. They seem to consistently contain arrays of size 61.

Hand joint frames needed

Hi Yuzhe, I am trying to understand this project via reproducing the code, but during that I need the .npy files of the videos. How can I get these files?

YCB object file format

Hi Yuzhe!
I am trying to add other YCB objects that are not included in the assets under hand_imitation directory. The YCB objects downloaded from http://ycb-benchmarks.s3-website-us-east-1.amazonaws.com/ come with formats such as .stl, .dae, .obj, and .mtl, but in the visual directory, the file formats are .msh. I am wondering how you got the .msh files? I have tried to convert other formats to .msh using meshio but turned out not working...

Thanks in advance!

Dataset of the hand files acquirement

Hi Yzqin, I am trying to understand this project via reproducing the code. But I found that I do not have the original video files, which are necessary to this work. How can I get them?

Something went wrong when setting up the hand simulation

Hello! Thank you for open-sourcing this work.
Something went wrong when setting up the hand simulation
The information is as follows. And the full command output in the attached file
ERROR: Command errored out with exit status 1:
command: /home/majiajun/softwares/anaconda/envs/dexmv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/remote-home/2210974/study/dexmv-sim/setup.py'"'"'; file='"'"'/remote-home/2210974/study/dexmv-sim/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps
cwd: /remote-home/2210974/study/dexmv-sim/
Complete output (3 lines):
running develop
running egg_info
error: [Errno 13] Permission denied
----------------------------------------
ERROR: Command errored out with exit status 1: /home/majiajun/softwares/anaconda/envs/dexmv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/remote-home/2210974/study/dexmv-sim/setup.py'"'"'; file='"'"'/remote-home/2210974/study/dexmv-sim/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

It has been bothering me for a long time, can you give me some advice?
nohup.txt

The collision file generation for YCB objects

Hi @yzqin,

Thank you for sharing the code for this great work!
I would like to know how to generate the collsion files (in stl format) for YCB objects. I find that sometimes collision files for a certain object (e.g., mug) consist of many parts of its mesh (here). Could you please share some tips or codes about how to decompose the mesh and generate these collsion files?
I notice there is a closed issue #8 related to the YCB format, but I guess it is mainly about how to generate the visual mesh.
Thanks in advance!

Best,
Zerui

Some issues with PVN3D

Hi@yzqin,
Thanks for your great work!
I have encountered some problems in the process of using PVN3D. I would like to know if you used the original parameters of PVN3D, or did further training.
Thanks in advance!

Hand pose frame

Hello

It seems the optimization function "solver.retarget()" accepts two inputs of hand_joint_seq and hand_frame_seq.
The hand_joint_seq can simply be acquired by 3rd-party libraries such as mediapipe, however, I wonder how did you get the hand_frame_seq, which represents the transformations between hand landmarks.

It would be appreciate if you let me know the way you get the hand_frame_seq, whether you get it from other libraries or any other implementation code is inside this repository.

Best regards

Some import errors in examples/train.py

Hi,

Thanks for your great work!

I think there are some typos in the imports in examples/train.py

In line 15,

from mjrl.algos.behavior_cloning_2 import BC

is the file supposed to be mjrl.algos.behavior_cloning instead of mjrl.algos.behavior_cloning_2?

in line 17,
from mjrl.algos.density_onpg, the file doesn't exist.

Is the dexmv-learn repo out of sync?

Thanks!

The global pose of the hand

Hi, Yuzhe. I would like to know what is the global pose of the hand in each frame, since from the paper statement, the pose of palm is the global pose, but I am not sure about it.

perform the evaluation on the trained policy.

Hi Yuzhe,

Thank you for open-sourcing this great project!
I would like to know how to perform the evaluation on a trained policy (i.e., compute success rates for different tasks). It would be great if you could share some testing/evaluation tips or scripts.
Have a great day!

Best,
Zerui

Question about joint control and action process

Hi Yuzhe, thank you for open-sourcing this amazing project! I successfully made the examples run under your comprehensive instructions but have a few detailed questions.

  1. When I step the MujocoEnv with a handcraft action and print the state, there are always some offsets (some of them are in the magnitude of 0.1) between the action and the stabilized state, I was wondering if this situation is normal?
  2. When I set the hand to move along the z-axis for a small distance, the hand swings along that axis a bit before it stabilizes in the expected location (I noticed that the demo videos also have this phenomenon), is this expected due to the inertia of the hand and are there any ways to avoid this?

Thank you very much in advance!

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.