Home

Awesome

DeepIM-PyTorch: A PyTorch Implementation of the DeepIM Framework for 6D Object Pose Estimation

Introduction

We implement DeepIM in PyTorch in this project.

DeepIM is a deep neural network for 6D pose matching. Given an initial pose estimation, DeepIM is able to iteratively refine the pose by matching the rendered image against the observed image. The network is trained to predict a relative pose transformation using an untangled representation of 3D location and 3D orientation and an iterative training process. pdf, Project

<p align="center"><img src="./data/pics/intro.png" width="640" height="240"/></p>

License

DeepIM-PyTorch is released under the NVIDIA Source Code License (refer to the LICENSE file for details).

Citation

If you find DeepIM useful in your research, please consider citing:

@inproceedings{li2017deepim,
    Author = {Yi Li and Gu Wang and Xiangyang Ji and Yu Xiang and Dieter Fox},
    Title = {{DeepIM}: Deep Iterative Matching for {6D} Pose Estimation},
    booktitle = {European Conference Computer Vision (ECCV)},
    Year = {2018}
}

Required environment

Installation

Use python3. If ROS is needed, compile with python2.

  1. Install PyTorch.

  2. Install python packages

    pip install -r requirement.txt
    
  3. Initialize the submodules in ycb_render

    git submodule update --init --recursive
    
  4. Compile the point matching loss layer in $ROOT/lib.

    cd $ROOT/lib/point_matching_loss
    sudo python setup.py install
    
  5. Compile cython components

    cd $ROOT/lib/utils
    python setup.py build_ext --inplace
    
  6. Compile the ycb_render in $ROOT/ycb_render

    cd $ROOT/ycb_render
    sudo python setup.py develop
    

Download

Running the demo

  1. Download 3D models and our pre-trained checkpoints first.

  2. run the following script

    # testing on color
    ./experiments/scripts/demo.sh
    
    # testing on RGB-D
    ./experiments/scripts/demo_rgbd.sh
    
<p align="center"><img src="./data/pics/deepim.png" width="640" height="400"/></p>

Training your own models with synthetic data for YCB objects

  1. Download background images, and save to $ROOT/data or use symbol links.

    • COCO 2014 images for training on RGB data here
    • SUN RGB-D images for training on RGB-D data here
    • Or use your own background images.
  2. Download the pre-trained FlowNetSimple weights from here (148M). Put the weight file to $ROOT/data/checkpoints. If our pre-trained models are already downloaded, the FlowNetSimpe checkpoint should be in $ROOT/data/checkpoints already.

  3. Training and testing for 20 YCB objects with synthetic data. Modify the configuration file for training on a subset of these objects.

    cd $ROOT
    
    # multi-gpu training, we used 4 GPUs
    ./experiments/scripts/ycb_object_flow_train.sh
    
    # testing, $GPU_ID can be 0, 1, etc.
    ./experiments/scripts/ycb_object_flow_test.sh $GPU_ID $EPOCH
    
    

Training and testing on the YCB-Video dataset

  1. Download the YCB-Video dataset from here.

  2. Create a symlink for the YCB-Video dataset

    cd $ROOT/data/YCB_Video
    ln -s $ycb_data data
    
  3. Download the PoseCNN results on the keyframes from here. Save to $ROOT/data/YCB_Video.

  4. Training and testing on the YCB-Video dataset

    cd $ROOT
    
    # multiple GPU training, we used 4 GPUs
    ./experiments/scripts/ycb_video_flow_train.sh
    
    # testing, $GPU_ID can be 0, 1, etc.
    ./experiments/scripts/ycb_video_flow_test.sh $GPU_ID $EPOCH
    
    

Training and testing on the DexYCB dataset

  1. Download the DexYCB dataset from here.

  2. Download PoseCNN results on the DexYCB dataset from here.

  3. Create a symlink for the DexYCB dataset and the PoseCNN results

    cd $ROOT/data/DEX_YCB
    ln -s $dex_ycb_data data
    ln -s $results_posecnn_data results_posecnn
    
  4. Training and testing on the DexYCB dataset

    cd $ROOT
    
    # multi-gpu training for different splits, we used 4 GPUs
    ./experiments/scripts/dex_ycb_flow_train_s0.sh
    ./experiments/scripts/dex_ycb_flow_train_s1.sh
    ./experiments/scripts/dex_ycb_flow_train_s2.sh
    ./experiments/scripts/dex_ycb_flow_train_s3.sh
    
    # use RGB and depth
    ./experiments/scripts/dex_ycb_flow_rgbd_train_s0.sh
    ./experiments/scripts/dex_ycb_flow_rgbd_train_s1.sh
    ./experiments/scripts/dex_ycb_flow_rgbd_train_s2.sh
    ./experiments/scripts/dex_ycb_flow_rgbd_train_s3.sh
    
    # testing, $GPU_ID can be 0, 1, etc.
    # our trained models are in checkpoints.zip
    ./experiments/scripts/dex_ycb_flow_test_s0.sh $GPU_ID $EPOCH
    ./experiments/scripts/dex_ycb_flow_test_s1.sh $GPU_ID $EPOCH
    ./experiments/scripts/dex_ycb_flow_test_s2.sh $GPU_ID $EPOCH
    ./experiments/scripts/dex_ycb_flow_test_s3.sh $GPU_ID $EPOCH
    
    # test RGB-D version
    ./experiments/scripts/dex_ycb_flow_rgbd_test_s0.sh $GPU_ID $EPOCH
    ./experiments/scripts/dex_ycb_flow_rgbd_test_s1.sh $GPU_ID $EPOCH
    ./experiments/scripts/dex_ycb_flow_rgbd_test_s2.sh $GPU_ID $EPOCH
    ./experiments/scripts/dex_ycb_flow_rgbd_test_s3.sh $GPU_ID $EPOCH
    
    

Running with ROS on a Realsense Camera for real-world pose estimation with PoseCNN

# start realsense
roslaunch realsense2_camera rs_aligned_depth.launch tf_prefix:=measured/camera

# start PoseCNN

# run deepim with color only, $GPU_ID can be 0, 1, etc.
./experiments/scripts/ros_ycb_object_test.sh $GPU_ID

# or run deepim with RGB-D, $GPU_ID can be 0, 1, etc.
./experiments/scripts/ros_ycb_object_rgbd_test.sh $GPU_ID

Our example:

<p align="center"><img src="./data/pics/deepim.gif"/></p>