This code implement the Cascaded Pyramid Network for Multi-Person Pose Estimation in Pytorch to detect key points of clothing including five types: blouse, dress, outwear, skirt and trousers. It was started before offical code released so there are some differences. A variety of modifications on CPN are tested. ResNet-152 backbone and SENet-154 backbone show better results.
Example output of CPN with ResNet-152 backbone
Download FashionAI dataset and put files in such structure:
DATA_DIR/
|-- wu_train/
| |-- Annotations/
| | |-- annotations.csv
| |-- Images/
| | |-- blouse
| | |-- ...
|-- r1_train/
| |-- Annotations/
| | |-- annotations.csv
| |-- Images/
| | |-- blouse
| | |-- ...
|-- ...
DATA_DIR is the root path of the fashionAI Dataset.
In config.py
, please specify a directory proj_path
to save the data, checkpoints and results. Specify data_dir
as DATA_DIR
.
Pre-trained ResNet152 and SENet154 are used. Normally, the download will start automatically when the pretrained weight is needed.
Hyperparameters such as batch size
, cuda devices
, learning rate
can be set in config.py
python3 src/stage2/trainval.py -c {clothing type}
Use -c
or --clothes
to choose the clothing type. It should be one of the following five types: blouse, dress, outware, skirt, trousers.
You can also run
bash src/stage2/autorun.sh
It actually runs stage2/trainval.py
five times for five clothing types.
python3 src/stage2/trainval.py -c {clothing type} -r {path/to/the/checkpoint}
When resume the training, step count, learning rate and optimizer state will also be restored from the checkpoint. For SGD optimizer, optimizer state contains the momentum for each trainable parameter.
Data preprocessing is performed in stage2/data_generator.py
which is called during the training
Two networks are used during this challenge, which are stage2/cascaded_pyramid_network.py
and stage2v9/cascaded_pyramid_network_v9.py
. The final score results from ensemble learning. The two networks share the same architecture with different backbones.
All other versions are failed experiments and can be ignored for now.
To test a single model, run
python3 src/stage2/predict_one.py -c {clothing type} -g {gpu index} -m {path/to/the/model} -v {True/False}
To test ensemble performance of two models, run
python3 src/stage2/predict_ensemble.py -c {clothing type} -g {gpu index} -m1 {path/to/the/model1} -m2 {path/to/the/model2} -v {True/False}
A normalized error will be printed at the end of the program.
To test a single model, run
python3 src/kpdetector/predict_one.py -c {clothing type} -g {gpu index} -m {path/to/the/model} -v {True/False}
To test ensemble performance of two models, run
python3 src/kpdetector/predict_ensemble.py -c {clothing type} -g {gpu index} -m1 {path/to/the/model1} -m2 {path/to/the/model2} -v {True/False}
run python3 src/kpdetector/concatenate_results.py
to merge all results in a .csv
file for submission.
(x+2, y+2)
where (x, y)
is max value coordinate (-0.4%)This solution achieved LB 3.82% in Tianchi FashionAI Global Challenge, 17th place out 2322 teams. Check the leaderboard here.