Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yeliudev/consnet

πŸš΄β€β™‚οΈ ConsNet: Learning Consistency Graph for Zero-Shot Human-Object Interaction Detection (MM 2020)
https://github.com/yeliudev/consnet

human-object-interaction pytorch

Last synced: about 5 hours ago
JSON representation

πŸš΄β€β™‚οΈ ConsNet: Learning Consistency Graph for Zero-Shot Human-Object Interaction Detection (MM 2020)

Awesome Lists containing this project

README

        

# ConsNet

[![DOI](https://badgen.net/badge/DOI/10.1145%2F3394171.3413600/blue?cache=300)](https://doi.org/10.1145/3394171.3413600)
[![arXiv](https://badgen.net/badge/arXiv/2008.06254/red?cache=300)](https://arxiv.org/abs/2008.06254)
[![PyPI](https://badgen.net/pypi/v/consnet?label=PyPI&cache=300)](https://pypi.org/project/consnet)
[![License](https://badgen.net/github/license/yeliudev/ConsNet?label=License&color=cyan&cache=300)](https://github.com/yeliudev/ConsNet/blob/main/LICENSE)

This repository maintains the official implementation of the paper **ConsNet: Learning Consistency Graph for Zero‐Shot Human‐Object Interaction Detection** by [Ye Liu](https://yeliu.dev/), [Junsong Yuan](https://cse.buffalo.edu/~jsyuan/) and [Chang Wen Chen](https://web.comp.polyu.edu.hk/chencw/), which has been accepted by [ACM Multimedia 2020](https://2020.acmmm.org/).

## Installation

The ConsNet package could be installed directly from PyPI or manually from source for different uses. Please refer to the following environmental settings that we use.

- CUDA 10.2 Update 2
- CUDNN 8.0.5.39
- Python 3.9.2
- PyTorch 1.8.1
- [MMDetection](https://github.com/open-mmlab/mmdetection) 2.11.0
- [AllenNLP](https://github.com/allenai/allennlp) 2.2.0
- [NNCore](https://github.com/yeliudev/nncore) 0.2.4

### Install from PyPI

You may install ConsNet from PyPI and import it in your own project as a Python package. This library implements several useful functionalities including [Pair IoU](https://consnet.readthedocs.io/en/latest/consnet.api.bbox.html#consnet.api.bbox.pair_iou), [Pair NMS](https://consnet.readthedocs.io/en/latest/consnet.api.bbox.html#consnet.api.bbox.pair_nms) and [unified APIs for HICO-DET dataset](https://consnet.readthedocs.io/en/latest/consnet.api.data.html).

Simply run the following command to install the latest version of ConsNet.

```
pip install consnet
```

For more details about `consnet.api`, please refer to our [documentation](https://consnet.readthedocs.io/).

### Install from source

By installing ConsNet from source, you may access the full capabilities of this project, including pooling object features, constructing the consistency graph and benchmarking the ConsNet model.

1. Clone the repository from GitHub.

```
git clone https://github.com/yeliudev/ConsNet.git
cd ConsNet
```

2. Install full dependencies and the package.

```
pip install -e .[full]
```

## Getting Started

We pre-extract the visual features of all the humans and objects in the dataset and save them for training as well as testing. These features are also used to construct the consistency graph. Please refer to our paper for more details about feature extraction and data sampling.

### Build dataset and construct the consistency graph

1. Download the checkpoints of object detector and ELMo.

```shell
ROOT='https://s3-us-west-2.amazonaws.com/allennlp/models/elmo'
ELMO='2x4096_512_2048cnn_2xhighway_5.5B'

# Download object detector checkpoints
wget https://huggingface.co/yeliudev/ConsNet/resolve/main/faster_rcnn_r50_fpn_3x_coco-26df6f6b.pth
wget https://huggingface.co/yeliudev/ConsNet/resolve/main/faster_rcnn_r50_fpn_20e_hico_det-77b91312.pth

# Download ELMo options and weights
wget ${ROOT}/${ELMO}/elmo_${ELMO}_options.json
wget ${ROOT}/${ELMO}/elmo_${ELMO}_weights.hdf5
```

2. Download [HICO-DET](http://www-personal.umich.edu/~ywchao/hico/) dataset and prepare the files in the following structure.

```
ConsNet
β”œβ”€β”€ configs
β”œβ”€β”€ consnet
β”œβ”€β”€ tools
β”œβ”€β”€ checkpoints
β”‚ β”œβ”€β”€ faster_rcnn_r50_fpn_3x_coco-26df6f6b.pth
β”‚ β”œβ”€β”€ faster_rcnn_r50_fpn_20e_hico_det-77b91312.pth
β”‚ β”œβ”€β”€ elmo_2x4096_512_2048cnn_2xhighway_5.5B_options.json
β”‚ └── elmo_2x4096_512_2048cnn_2xhighway_5.5B_weights.hdf5
β”œβ”€β”€ data
β”‚ └── hico_20160224_det
β”‚ β”œβ”€β”€ anno_bbox.mat
β”‚ └── images
β”‚ β”œβ”€β”€ train2015
β”‚ └── test2015
β”œβ”€β”€ README.md
β”œβ”€β”€ setup.py
└── Β·Β·Β·
```

3. Convert the annotations to COCO format. The results will be saved in `data/hico_det/annotations`.

```
python tools/convert_anno.py
```

4. Build dataset and construct the consistency graph. The results will be saved in `data/hico_det`.

```
python tools/build_dataset.py --checkpoint
```

### Train a model

Run the following command to train a model using specified configs.

```
python tools/launch.py --config
```

### Test a model and evaluate results

Run the following command to test a model and evaluate results.

```
python tools/launch.py --config --checkpoint --eval
```

## Model Zoo

We provide multiple HICO-DET pre-trained models here. All the models are trained using a single NVIDIA Tesla V100-SXM2 GPU and are evaluated under the `default` metric of HICO-DET dataset.


Detector
Model
Type
Performance (mAP)
Download


Full
Rare
Non-Rare
Seen
Unseen



COCO


ConsNet

UC
19.78
14.43
21.37
20.69
16.13

model |
metrics




ConsNet

UO
20.71
16.81
21.87
20.99
19.27

model |
metrics




ConsNet

UA
19.04
14.54
20.38
20.02
14.12

model |
metrics




ConsNet

GT
53.04
38.79
57.3
β€”
β€”

model |
metrics




ConsNet

β€”
22.15
17.55
23.52
β€”
β€”



HICO-DET


ConsNet-F

β€”
25.94
19.35
27.91
β€”
β€”

model |
metrics

Note that: Type `UC`, `UO`, `UA` and `GT` represent unseen action-object combination, unseen object, unseen action and ground truth scenarios respectively.

## Customization

Thanks to the modulized implementation based on [NNCore](https://github.com/yeliudev/nncore), this project is highly customizable with a number of replaceable modules. You may play with the hyperparameters in `configs` or construct your own HOI detection pipeline by replacing the dataset, detector, embedder, etc. Please check the [documentation](https://nncore.readthedocs.io/) of NNCore for more details about customizing the engine and modules.

## Citation

If you find this project useful for your research, please kindly cite our paper.

```bibtex
@inproceedings{liu2020consnet,
title={ConsNet: Learning Consistency Graph for Zero-Shot Human-Object Interaction Detection},
author={Liu, Ye and Yuan, Junsong and Chen, Chang Wen},
booktitle={Proceedings of The ACM International Conference on Multimedia (MM)},
pages={4235--4243},
year={2020}
}
```