Code Monkey home page Code Monkey logo

hydraplusnet's Introduction

HydraPlus Network

A re-implementation of HydraPlus Net based on Pytorch.
With the help of caffe implementtion from original authors and another pytorch version, the repository implements the network structure the same as the caffe version.

Requirements

pytorch
CUDA 8.0

Dataset

  • PA-100K dataset
  • Download link
  • The directory structure looks like:
.
├── README.md
├── att_vis.py
├── checkpoint
├── data
│   └── PA-100K
│       ├── annotation
│       └── release_data
│           └── release_data
├── lib
├── result
├── test.py
└── train.py

Train

We train the network stagewisely, you can start with MNet (you need to define your GPU card ID and choose suitable batch size, learning rate and number of workers):

CUDA_VISIBLE_DEVICES=$GPU_ID python train.py -m MNet -bs 128 -lr 0.01 -nw 16 -mGPUs

And then we train the attention branch with MNet weights:

CUDA_VISIBLE_DEVICES=$GPU_ID python train.py -m AF1 -mpath checkpoint/MNet_epoch_995 -bs 128 -lr 0.1 -nw 16 -mGPUs
CUDA_VISIBLE_DEVICES=$GPU_ID python train.py -m AF2 -mpath checkpoint/MNet_epoch_995 -bs 128 -lr 0.1 -nw 16 -mGPUs
CUDA_VISIBLE_DEVICES=$GPU_ID python train.py -m AF3 -mpath checkpoint/MNet_epoch_995 -bs 128 -lr 0.1 -nw 16 -mGPUs

Finally, concatenate all the features from above four branches and train the last few layers of hydra-plus net:

CUDA_VISIBLE_DEVICES=$GPU_ID python train.py -m HP -mpath checkpoint/MNet_epoch_995 \
                                                   -af1path checkpoint/AF1_epoch_190 \
                                                   -af2path checkpoint/AF2_epoch_170 \
                                                   -af3path checkpoint/AF3_epoch_175 \
                                                   -bs 512 -lr 0.01 -nw 32 -mGPUs

Test

You can test each branch one by one:

python test.py -m AF3 -p checkpoint/AF3_epoch_175

Or you can test the whole HydraPlus network:

python test.py -m HP -p checkpoint/HP_epoch_175 -att pkl_save

With the arguments -att, you can choose to show the attention images or save them as pickle files.

Results

PA-100K
mA 67.04%
ACC 65.87%
Prec 82.08%
Rec 74.44%
F1 78.08%
  • Attention results:

show

  • You can download the pre-trained checkpoints and attention pickle files from this link.

  • With the pickle files, you can easily have a look at the attention map by:

    python att_vis.py

    Of course, remember to modify the file directory.

hydraplusnet's People

Contributors

tianmingqiu avatar

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.