This repository contains the PyTorch implementation of paper Weakly Supervised Deep Detection Networks
(CVPR 2016).
- Implementation differences: Spatial regulariser isn't added
- Related code: OICR-PyTorch
VOC2007 test
aero | bike | bird | boat | bottle | bus | car | cat | chair | cow | table | dog | horse | mbike | person | plant | sheep | sofa | train | tv | mAP | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Ap | 41.4 | 44.2 | 25.8 | 12.2 | 10.9 | 56.3 | 39.0 | 27.8 | 7.0 | 25.5 | 16.6 | 24.4 | 18.0 | 51.5 | 1.1 | 11.2 | 17.9 | 10.6 | 48.0 | 42.2 | 26.6 |
VOC2007 trainval
aero | bike | bird | boat | bottle | bus | car | cat | chair | cow | table | dog | horse | mbike | person | plant | sheep | sofa | train | tv | mean | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CorLoc | 68.8 | 62.4 | 54.7 | 33.5 | 39.7 | 68.0 | 67.7 | 49.1 | 35.3 | 54.8 | 33.8 | 38.8 | 37.4 | 77.1 | 7.54 | 43.2 | 60.8 | 24.5 | 68.8 | 63.1 | 49.5 |
- Requirements: software
- Requirements: hardware
- Basic installation
- Installation for training and testing
- Extra Downloads (selective search)
- Extra Downloads (ImageNet models)
- Usage
Python3 packages and versions used (listed using freeze frin pip) are in requirements.txt.
You can create a new virtual environment and then install thses packages from requirements.txt.
conda create -n env_name python=3.6
pip install -r $WSDDN_ROOT/requirements.txt
You can also install these packages by yourself.
Besides, you should install Octave, which is mostly compatible with MATLAB.
sudo apt-get install octave
- I used cuda 9.0 and cudnn 7.0 on Ubuntu 16.04
- We used an Nvidia GeForce GTX with 10.9G of memory. But it shold be ok to train if you have a GPU with at least 8Gb.
- NOTICE: different versions of Pytorch have different memory usages.
Clone this repository
git clone https://github.com/CatOneTwo/WSDDN-PyTorch
- Create a "data" folder in $WSDDN_ROOT and enter in this folder
cd $WSDDN_ROOT mkdir data cd data
- Download the training, validation, test data, and VOCdevkit
wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
- Extract all of these tars into one directory named
VOCdevkit
tar xvf VOCtrainval_06-Nov-2007.tar tar xvf VOCtest_06-Nov-2007.tar
- Download the VOCdevkit evaluation code adapted to octave
wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/VOCeval_octave.tar
- Extract VOCeval_octave
tar xvf VOCeval_octave.tar
- Download pascal annotations in the COCO format
wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/coco_annotations_VOC.tar
- Extract the annotations
tar xvf coco_annotations_VOC.tar
- It should have this basic structure
$VOC2007/ $VOC2007/annotations $VOC2007/JPEGImages $VOC2007/VOCdevkit # ... and several other directories ...
- [Optional] download and extract PASCAL VOC 2012.
Observation: The
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar tar xvf VOCtrainval_11-May-2012.tar
2012 test set
is only available in the PASCAL VOC Evaluation Server to download. You must create a user and download it by yourself. After downloading, you can extract it in the data folder.
- Download the proposals data generated by selective search to data folder
wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/selective_search_data.tar
- Extract the proposals
tar xvf selective_search_data.tar
- Download the pre-trained VGG16 model to data folder
wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/pretrained_model.tar
- Extract the pre-trained VGG16 model
tar xvf pretrained_model.tar
To Train the WSDDN network on VOC 2007 trainval set:
python3 code/tasks/train.py --cfg configs/baselines/vgg16_voc2007.yaml --model midn
To Evaluate the WSDDN network on VOC 2007:
On trainval (corloc)
python3 code/tasks/test.py --cfg configs/baselines/vgg16_voc2007.yaml --dataset voc2007trainval --model midn --load_ckpt snapshots/midn/<some-running-date-time>/ckpt/model_step24999.pth
On test (detection mAP)
python3 code/tasks/test.py --cfg configs/baselines/vgg16_voc2007.yaml --dataset voc2007test --model midn --load_ckpt snapshots/midn/<some-running-date-time>/ckpt/model_step24999.pth
To Visualize the detection results:
After evaluating WSDDN on test dataset, you will get detections.pkl
. Then you can run the visualization script to show the results in a openCV window.
python3 code/tasks/visualize.py --cfg configs/baselines/vgg16_voc2007.yaml --dataset voc2007test --detections snapshots/midn/<some-running-date-time>/test/model_step24999/detections.pkl
You can also save the visualizations as images. First create a folder to save the outputs and pass it with the --output argument
mkdir output
python3 code/tasks/visualize.py --cfg configs/baselines/vgg16_voc2007.yaml --dataset voc2007test --detections snapshots/midn/<some-running-date-time>/test/model_step24999/detections.pkl --output output
You can download my model by baidu netdisk:
Link: https://pan.baidu.com/s/1pEpmh4AYgPxW5hVBkJ7Kfw Code: zcn5
Put this folder in your $WSDDN_ROOT, then test and visualize model.
Note <some-running-date-time>
is replaced by final
in this folder, so you should also make changes when you run the code.
Below is the code structure
- code
- datasets: VOC dataset file
- layers: layer and loss files
- models: WSDDN model based on layers
- tasks: train, test and visualize files
- utils: files used for other directories
- configs
- baselines: config files for model and dataset
- data
- pretrained_model: VGG16 model weights
- selective_search_data: selective search for VOC data
- VOCdevikit: VOC dataset
All code files are in code
directory. If you want to design a model based on WSDDN, you can modify layers
and model
.