xingyizhou / StarMap

StarMap for Category-Agnostic Keypoint and Viewpoint Estimation
GNU General Public License v3.0
104 stars 19 forks source link
keypoint-estimation pose-estimation viewpoint-estimation

StarMap for Category-Agnostic Keypoint and Viewpoint Estimation

PyTorch implementation for category-agnostic keypoint and viewpoint estimation.

Xingyi Zhou, Arjun Karpur, Linjie Luo, Qixing Huang,
StarMap for Category-Agnostic Keypoint and Viewpoint Estimation
ECCV 2018 (arXiv:1803.09331)

Supplementary material with more qualitative results and higer resulution can be found here.

Contact: zhouxy2017@gmail.com. Any questions or discussions are welcomed!

Abstract

Previous methods for keypoints can only be applied to one specific category of fixed topology. As a result, this keypoint representation is not suitable when objects have a varying number of parts, e.g. chairs with varying number of legs. We propose a category-agnostic keypoint representation encoded with their 3D locations in the canonical object views. Our intuition is that the 3D locations of the keypoints in canonical object views contain rich semantic and compositional information. Our representation thus consists of a single channel, multi-peak heatmap (StarMap) for all the keypoints and their corresponding features as 3D locations in the canonical object view (CanViewFeature). Additionally, we show that when augmented with an additional depth channel (DepthMap) to lift the 2D keypoints to 3D, our representation can achieve state-of-the-art results in viewpoint estimation.

Installation

The code was tested with Anaconda Python 2.7 and PyTorch v0.1.12. After install Anaconda and Pytorch:

  1. Clone the repo:
STARMAP_ROOT=/path/to/clone/StarMap
git clone https://github.com/xingyizhou/StarMap STARMAP_ROOT
  1. Install dependencies (h5py, opencv, and progressbar):
conda install h5py
conda install --channel https://conda.anaconda.org/menpo opencv
conda install --channel https://conda.anaconda.org/auto progress
  1. Optionally, install tensorboard for visializing training.
pip install tensorflow

Demo

cd STARMAP_ROOT/tools
python demo.py -demo /path/to/image [-loadModel /path/to/model/] [-GPU 0]

The demo code runs in CPU by default.

We provide example images in STARMAP_ROOT/images/. The results are shown with predicted canonical view (triangle), the predicted 3D keypoints (cross), and the rotated keypoints with the estimated viewpoint (star). If setup correctly, the output will look like:

We also provide some custom images of novel categories in STARMAP_ROOT/images/. The expected results should be:

Setup Datasets

If you want to reproduce the results in the paper for benchmark evaluation and training, you will need to setup dataset.

  1. Download and extract Pascal3D+ dataset (~7.5G).
cd STARMAP_ROOT/data
wget ftp://cs.stanford.edu/cs/cvgl/PASCAL3D+_release1.1.zip
unzip PASCAL3D+_release1.1.zip
  1. Setup the path.
mv STARMAP_ROOT/lib/paths.py.examples STARMAP_ROOT/lib/paths.py

You can change the dataset path in STARMAP_ROOT/lib/paths.py in put the dataset elsewhere.

  1. Convert the annotation.
cd STARMAP_ROOT/tools
python getPascal3DDataset.py

Optionally, setup the ObjectNet3D dataset (~7G) following the similar commands and run python getObjectNet3DDataset.py

Benchmark Evaluation

cd STARMAP_ROOT/tools
python main.py -expID Pascal3D -task starembdep -loadModel ../models/Pascal3D-cpu.pth -test
python EvalViewPoint.py ../exp/Pascal3DTEST/preds.pth
 cd STARMAP_ROOT/tools
 python EvalPTPCK.py ../exp/Pascal3DTEST/preds.pth
cd STARMAP_ROOT/tools
python main.py -expID ObjectNet -dataset ObjectNet3D -task starembdep -loadModel ../models/ObjectNet3D-all-cpu.pth -test
python EvalViewPointObjectNet3D.py ../exp/ObjectNet3DTEST/preds.pth

Training

cd STARMAP_ROOT/tools
  1. Train the Starmap: log, model
python main.py -expID Pstar -task star
  1. Train Starmap and CanviewFeature: log, model
python main.py -expID Pstaremb -task staremb -loadModel ../exp/Pstar/model_last.pth -dropLR 60
  1. Train Starmap, CanviewFeature, and DepthMap: log, model
python main.py -expID Pstarembdep -task starembdep -loadModel ../exp/Pstaremb/model_last.pth -dropLR 60

Citation

@InProceedings{zhou2018starmap,
author = {Zhou, Xingyi and Karpur, Arjun and Luo, Linjie and Huang, Qixing},
title = {StarMap for Category-Agnostic Keypoint and Viewpoint Estimation},
journal={European Conference on Computer Vision (ECCV)},
year={2018}
}