Code Monkey home page Code Monkey logo

wsddn-pytorch's Introduction

WSDDN PyTorch

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

Architecture

WSDDN

Results

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

Contents

  1. Requirements: software
  2. Requirements: hardware
  3. Basic installation
  4. Installation for training and testing
  5. Extra Downloads (selective search)
  6. Extra Downloads (ImageNet models)
  7. Usage

Requirements: software

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

Requirements: hardware

  • 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.

Basic installation

Clone this repository

git clone https://github.com/CatOneTwo/WSDDN-PyTorch

Installation for training and testing

  1. Create a "data" folder in $WSDDN_ROOT and enter in this folder
    cd $WSDDN_ROOT
    mkdir data
    cd data
  2. 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
  3. Extract all of these tars into one directory named VOCdevkit
    tar xvf VOCtrainval_06-Nov-2007.tar
    tar xvf VOCtest_06-Nov-2007.tar
  4. Download the VOCdevkit evaluation code adapted to octave
    wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/VOCeval_octave.tar
  5. Extract VOCeval_octave
    tar xvf VOCeval_octave.tar
  6. Download pascal annotations in the COCO format
    wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/coco_annotations_VOC.tar
  7. Extract the annotations
    tar xvf coco_annotations_VOC.tar
  8. It should have this basic structure
    $VOC2007/                           
    $VOC2007/annotations
    $VOC2007/JPEGImages
    $VOC2007/VOCdevkit        
    # ... and several other directories ...
  9. [Optional] download and extract PASCAL VOC 2012.
    wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
    tar xvf VOCtrainval_11-May-2012.tar
    Observation: The 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.

Extra Downloads (selective search)

  1. Download the proposals data generated by selective search to data folder
    wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/selective_search_data.tar
  2. Extract the proposals
    tar xvf selective_search_data.tar

Extra Downloads (ImageNet models)

  1. Download the pre-trained VGG16 model to data folder
    wget http://inf.ufrgs.br/~lfazeni/CVPR_deepvision2020/pretrained_model.tar
  2. Extract the pre-trained VGG16 model
    tar xvf pretrained_model.tar

Usage

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 

My model

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.


Notes

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.

References

wsddn-pytorch's People

Contributors

dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

happyconan a-f1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.