Home

Awesome

StarMap for Category-Agnostic Keypoint and Viewpoint Estimation

PyTorch implementation for category-agnostic keypoint and viewpoint estimation.

<img src='readme/Framework.jpg' align="center" width="700px">

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:

<img src='readme/demo_benchmark.png' align="center" width="700px">

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

<img src='readme/demo_custom.png' align="center" width="700px">

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
aeroplanebicycleboatbottlebuscarchairdiningtablemotorbikesofatraintvmonitorMean
Acc100.49820.34750.14660.57370.88960.67860.45490.28570.27940.46150.59290.37390.4851
Acc300.82180.85590.50430.92430.97400.91560.79100.61900.87500.92310.76990.82880.8235
Mid10.0514.5029.429.023.026.2911.1323.6614.2310.977.4113.1410.38
 cd STARMAP_ROOT/tools
 python EvalPTPCK.py ../exp/Pascal3DTEST/preds.pth
aeroplanebicycleboatbottlebuscarchairdiningtablemotorbikesofatraintvmonitorMean
Acc0.75050.83430.55290.87180.94390.89840.75450.58020.68670.79010.53850.86100.7858
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
 python main.py -expID cls -task cls -arch resnet18 -trainBatch 32 -LR 0.01 -dropLR 20
 python main.py -expID clsSpec -task cls -arch resnet18 -trainBatch 32 -LR 0.01 -dropLR 20 -specificView

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