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.
pytorch
CUDA 8.0
- 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
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
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.
PA-100K | |
---|---|
mA | 67.04% |
ACC | 65.87% |
Prec | 82.08% |
Rec | 74.44% |
F1 | 78.08% |
- Attention results:
-
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.