Home

Awesome

Cross-Attention-Based-Style-Distribution

The source code for our paper "Cross Attention Based Style Distribution for Controllable Person Image Synthesis" (ECCV2022).

<p align='center'> <img src='https://github.com/xyzhouo/CASD/blob/main/head_img3_00.png' width='1000'/> </p>

Installation

Requirements

Conda Installation

# 1. Create a conda virtual environment.
conda create -n CASD python=3.6
conda activate CASD
conda install -c pytorch pytorch=1.7.0 torchvision=0.8.0 cudatoolkit=10.2

# 2. Install other dependencies.
pip install -r requirements.txt

Data Preperation

The dataset structure is recommended as:

+—dataset
|   +—fashion
|       +--train (person images in 'train.lst')
|       +--test (person images in 'test.lst')
|       +--train_resize (resized person images in 'train.lst')
|       +--test_resize (resized person images in 'test.lst')
|       +--trainK(keypoints of person images)
|       +--testK(keypoints of person images)
|       +—semantic_merge3(semantic masks of person images)
|   +—fashion-resize-pairs-train.csv
|   +—fashion-resize-pairs-test.csv
|   +—fasion-resize-annotation-pairs-train.csv
|   +—fasion-resize-annotation-pairs-test.csv
|   +—train.lst
|   +—test.lst
|   +—vgg19-dcbb9e9d.pth
|   +—vgg_conv.pth
|   +—vgg.pth
...
  1. Person images
  1. Keypoints files
  1. Segmentation files

Training

python train.py --dataroot ./dataset/fashion --dirSem ./dataset/fashion --pairLst ./dataset/fashion/fashion-resize-pairs-train.csv --name CASD_test --batchSize 16 --gpu_ids 0,1 --which_model_netG CASD --checkpoints_dir ./checkpoints

The models are save in ./checkpoints.

Testing

Download our pretrained model from Google Drive. Put the obtained checkpoints under ./checkpoints/CASD_test. Modify your data path and launch

python test.py --dataroot ./dataset/fashion --dirSem ./dataset/fashion --pairLst ./dataset/fashion/fashion-resize-pairs-test.csv --checkpoints_dir ./checkpoints --results_dir ./results --name CASD_test --phase test  --batchSize 1  --gpu_ids 0,0 --which_model_netG CASD --which_epoch 1000

The result images are save in ./results.

Citation

If you use this code for your research, please cite

@article{zhou2022casd,
  title={Cross Attention Based Style Distribution for Controllable Person Image Synthesis},
  author={Zhou, Xinyue and Yin, Mingyu and Chen, Xinyuan and Sun, Li and Gao, Changxin and Li, Qingli},
  journal={arXiv preprint arXiv:2208.00712},
  year={2022}
}