Awesome
Balanced and Hierarchical Relation Learning for One-shot Object Detection
This repository is an official implementation of the CVPR 2022 paper "Balanced and Hierarchical Relation Learning for One-shot Object Detection", based on mmdetection.
Installation
- Create a conda virtual environment and activate it
conda create -n BHRL python=3.7 -y
conda activate BHRL
- Install PyTorch and torchvision
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.2 -c pytorch
- Install mmcv
pip install mmcv-full==1.3.3 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.7.0/index.html
- Install build requirements and then install MMDetection.
pip install -r requirements/build.txt
pip install -v -e .
Datasets Preparation
Download coco dataset and voc dataset from the official websites.
Download voc_annotation from this link.
Download ref_ann_file from this link.
We expect the directory structure to be the following:
BHRL
├── data
│ ├──coco
│ │ ├── annotations
│ │ ├── train2017
│ │ ├── val2017
│ ├──VOCdevkit
│ │ ├── voc_annotation
│ │ ├── VOC2007
│ │ ├── VOC2012
├── ref_ann_file
...
Backbone Weight Preparation
Download the ResNet50 model for training from this link.
BHRL
├── resnet_model
│ ├──res50_loadfrom.pth
Inference with a pretrained model
./tools/dist_test.sh ${CONFIG} ${CHECKPOINT} ${GPUS} --out ${RESULTS} --eval bbox --average ${EVALUATION_NUMBER}
# e.g.,
# test unseen classes
./tools/dist_test.sh configs/coco/split1/BHRL.py checkpoints/model_split1.pth 8 --out results.pkl --eval bbox --average 5
# test seen classes
./tools/dist_test.sh configs/coco/split1/BHRL.py checkpoints/model_split1.pth 8 --out results.pkl --eval bbox --average 5 --test_seen_classes
Download the pretrained models for inferencing from this link.
Train a model
./tools/dist_train.sh ${CONFIG} ${GPUS} --no-validate
# e.g.,
./tools/dist_train.sh configs/coco/split1/BHRL.py 8 --no-validate
Note: we observe an obvious variation of the performance for different runs on the VOC dataset due to its small amount of data, and we are still investigating possible solutions to stabilize the results. Moreover, the variation of performance on unseen classes is normal because the model is not trained on unseen classes.
Contact
For any questions, please contact hanqing.yang@zju.edu.cn
Citation
If you find our work useful in your research, please consider citing:
@InProceedings{BHRL,
author = {Yang, Hanqing and Cai, Sijia and Sheng, Hualian and Deng, Bing and Huang, Jianqiang and Hua, Xiansheng and Tang, Yong and Zhang, Yu},
title = {Balanced and Hierarchical Relation Learning for One-shot Object Detection},
booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
month = {June},
year = {2022}
}