This is the official Pytorch implementation of the paper Improving Text-to-Image Synthesis Using Contrastive Learning
Linux
Python ≥ 3.6
PyTorch ≥ 1.4.0
Download the preprocessed datasets from AttnGAN
Alternatively, another site is from DM-GAN
Pretrain DAMSM+CL:
python pretrain_DAMSM.py --cfg cfg/DAMSM/bird.yml --gpu 0
python pretrain_DAMSM.py --cfg cfg/DAMSM/coco.yml --gpu 0
Train AttnGAN+CL:
python main.py --cfg cfg/bird_attn2.yml --gpu 0
python main.py --cfg cfg/coco_attn2.yml --gpu 0
Train DM-GAN+CL:
python main.py --cfg cfg/bird_DMGAN.yml --gpu 0
python main.py --cfg cfg/coco_DMGAN.yml --gpu 0
DAMSMencoders/
DAMSMencoders/
models/
models/
models/
models/
Sampling and get the R-precision:
python main.py --cfg cfg/eval_bird.yml --gpu 0
python main.py --cfg cfg/eval_coco.yml --gpu 0
Inception score:
python inception_score_bird.py --image_folder fake_images_bird
python inception_score_coco.py fake_images_coco
FID:
python fid_score.py --gpu 0 --batch-size 50 --path1 real_images_bird --path2 fake_images_bird
python fid_score.py --gpu 0 --batch-size 50 --path1 real_images_coco --path2 fake_images_coco
If you find this work useful in your research, please consider citing:
@article{ye2021improving,
title={Improving Text-to-Image Synthesis Using Contrastive Learning},
author={Ye, Hui and Yang, Xiulong and Takac, Martin and Sunderraman, Rajshekhar and Ji, Shihao},
journal={The 32nd British Machine Vision Conference (BMVC)},
year={2021}
}
Our work is based on the following works: