DF-GAN

tobran长期未更新

DF-GAN 是 CVPR2022 提出的文本到图像生成基线,用简洁的 GAN 结构从文字描述合成图像,效果稳定且易于复现。

[CVPR2022 oral] A Simple and Effective Baseline for Text-to-Image Synthesis

暂无版本327star68fork同步于 2026-11-07 07:30 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/tobran/DF-GAN
pip install -r requirements.txt
cd DF-GAN/code/
硬件要求按 README 说明

至少 1 块 12GB 显存的 NVIDIA GPU;README 未说明是否支持 CPU 运行或其他 GPU 厂商。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

CVPR2022 Oral 的文本到图像 GAN 基线,结构简单、易复现,适合做 T2I 研究对照

DF-GAN 是 CVPR2022 提出的文本到图像生成基线,用简洁的 GAN 结构从文字描述合成图像,效果稳定且易于复现。

核心能力

  • 用单级 GAN 直接由文本描述合成图像,省去多阶段堆叠
  • 提供 birds 与 coco 两套配置及训练、采样、FID 评估脚本
  • 支持训练中自动计算 FID 并写入 TensorBoard
  • 发布预训练模型,CUB-FID 12.10、COCO-FID 15.41
  • 可替换 example_captions 中的文本,用自己的描述生成图像

容易踩的坑

需先自行下载 birds/coco 预处理元数据与原始图像并放到 data/ 对应目录;评估和采样前要单独下载预训练模型到 ./code/saved_models/ 下;评估代码默认不保存生成的约 3 万张图像,需在 YAML 中设 save_image: True。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Visitors License CC BY-NC-SA 4.0 Python 3.8 Packagist Last Commit Maintenance Ask Me Anything !

    DF-GAN: A Simple and Effective Baseline for Text-to-Image Synthesis (CVPR 2022 Oral)

    Official Pytorch implementation for our paper DF-GAN: A Simple and Effective Baseline for Text-to-Image Synthesis by Ming Tao, Hao Tang, Fei Wu, Xiao-Yuan Jing, Bing-Kun Bao, Changsheng Xu.


    News!

    [CVPR2023]Our new simple and effective model GALIP (paper link, code link) achieves comparable results to Large Pretrained Diffusion Models! Furthermore, our GALIP is training-efficient which only requires 3% training data, 6% learnable parameters. Our GALIP achieves ~120 x faster synthesis speed and can be inferred on CPU.

    GALIP significantly lowers the hardware threshold for training and inference. We hope that more users can find the interesting of AIGC.


    Requirements

    • python 3.8
    • Pytorch 1.9
    • At least 1x12GB NVIDIA GPU

    Installation

    Clone this repo.

    git clone https://github.com/tobran/DF-GAN
    pip install -r requirements.txt
    cd DF-GAN/code/
    

    Preparation

    Datasets

    1. Download the preprocessed metadata for birds coco and extract them to data/
    2. Download the birds image data. Extract them to data/birds/
    3. Download coco2014 dataset and extract the images to data/coco/images/

    Training

    cd DF-GAN/code/
    

    Train the DF-GAN model

    • For bird dataset: bash scripts/train.sh ./cfg/bird.yml
    • For coco dataset: bash scripts/train.sh ./cfg/coco.yml

    Resume training process

    If your training process is interrupted unexpectedly, set resume_epoch and resume_model_path in train.sh to resume training.

    TensorBoard

    Our code supports automate FID evaluation during training, the results are stored in TensorBoard files under ./logs. You can change the test interval by changing test_interval in the YAML file.

    • For bird dataset: tensorboard --logdir=./code/logs/bird/train --port 8166
    • For coco dataset: tensorboard --logdir=./code/logs/coco/train --port 8177

    Evaluation

    Download Pretrained Model

    Evaluate DF-GAN models

    We synthesize about 3w images from the test descriptions and evaluate the FID between synthesized images and test images of each dataset.

    cd DF-GAN/code/
    
    • For bird dataset: bash scripts/calc_FID.sh ./cfg/bird.yml
    • For coco dataset: bash scripts/calc_FID.sh ./cfg/coco.yml
    • We compute inception score for models trained on birds using StackGAN-inception-model.

    Some tips

    • Our evaluation codes do not save the synthesized images (about 3w images). If you want to save them, set save_image: True in the YAML file.
    • Since we find that the IS can be overfitted heavily through Inception-V3 jointed training, we do not recommend the IS metric for text-to-image synthesis.

    Performance

    The released model achieves better performance than the CVPR paper version.

    ModelCUB-FID↓COCO-FID↓NOP↓
    DF-GAN(paper)14.8119.3219M
    DF-GAN(pretrained model)12.1015.4118M

    Sampling

    cd DF-GAN/code/
    

    Synthesize images from example captions

    • For bird dataset: bash scripts/sample.sh ./cfg/bird.yml
    • For coco dataset: bash scripts/sample.sh ./cfg/coco.yml

    Synthesize images from your text descriptions

    • Replace your text descriptions into the ./code/example_captions/dataset_name.txt
    • For bird dataset: bash scripts/sample.sh ./cfg/bird.yml
    • For coco dataset: bash scripts/sample.sh ./cfg/coco.yml

    The synthesized images are saved at ./code/samples.


    Citing DF-GAN

    If you find DF-GAN useful in your research, please consider citing our paper:

    @inproceedings{tao2022df,
      title={DF-GAN: A Simple and Effective Baseline for Text-to-Image Synthesis},
      author={Tao, Ming and Tang, Hao and Wu, Fei and Jing, Xiao-Yuan and Bao, Bing-Kun and Xu, Changsheng},
      booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
      pages={16515--16525},
      year={2022}
    }
    

    The code is released for academic research use only. For commercial use, please contact Ming Tao.

    Reference