All Projects → tohinz → Semantic Object Accuracy For Generative Text To Image Synthesis

tohinz / Semantic Object Accuracy For Generative Text To Image Synthesis

Licence: mit
Code for "Semantic Object Accuracy for Generative Text-to-Image Synthesis" (TPAMI 2020)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Semantic Object Accuracy For Generative Text To Image Synthesis

Awesome-ICCV2021-Low-Level-Vision
A Collection of Papers and Codes for ICCV2021 Low Level Vision and Image Generation
Stars: ✭ 163 (+108.97%)
Mutual labels:  gan, image-generation
Dcgan Tensorflow
A Tensorflow implementation of Deep Convolutional Generative Adversarial Networks trained on Fashion-MNIST, CIFAR-10, etc.
Stars: ✭ 70 (-10.26%)
Mutual labels:  gan, image-generation
Inpainting gmcnn
Image Inpainting via Generative Multi-column Convolutional Neural Networks, NeurIPS2018
Stars: ✭ 256 (+228.21%)
Mutual labels:  gan, image-generation
MNIST-invert-color
Invert the color of MNIST images with PyTorch
Stars: ✭ 13 (-83.33%)
Mutual labels:  gan, image-generation
Apdrawinggan
Code for APDrawingGAN: Generating Artistic Portrait Drawings from Face Photos with Hierarchical GANs (CVPR 2019 Oral)
Stars: ✭ 510 (+553.85%)
Mutual labels:  gan, image-generation
lecam-gan
Regularizing Generative Adversarial Networks under Limited Data (CVPR 2021)
Stars: ✭ 127 (+62.82%)
Mutual labels:  gan, image-generation
Consingan
PyTorch implementation of "Improved Techniques for Training Single-Image GANs" (WACV-21)
Stars: ✭ 294 (+276.92%)
Mutual labels:  gan, image-generation
mSRGAN-A-GAN-for-single-image-super-resolution-on-high-content-screening-microscopy-images.
Generative Adversarial Network for single image super-resolution in high content screening microscopy images
Stars: ✭ 52 (-33.33%)
Mutual labels:  gan, image-generation
Sean
SEAN: Image Synthesis with Semantic Region-Adaptive Normalization (CVPR 2020, Oral)
Stars: ✭ 387 (+396.15%)
Mutual labels:  gan, image-generation
Anycost Gan
[CVPR 2021] Anycost GANs for Interactive Image Synthesis and Editing
Stars: ✭ 367 (+370.51%)
Mutual labels:  gan, image-generation
ADL2019
Applied Deep Learning (2019 Spring) @ NTU
Stars: ✭ 20 (-74.36%)
Mutual labels:  gan, image-generation
Congan
Continious Generative Adversarial Network
Stars: ✭ 41 (-47.44%)
Mutual labels:  gan, image-generation
Deep-Exemplar-based-Video-Colorization
The source code of CVPR 2019 paper "Deep Exemplar-based Video Colorization".
Stars: ✭ 180 (+130.77%)
Mutual labels:  gan, image-generation
AsymmetricGAN
[ACCV 2018 Oral] Dual Generator Generative Adversarial Networks for Multi-Domain Image-to-Image Translation
Stars: ✭ 42 (-46.15%)
Mutual labels:  gan, image-generation
automatic-manga-colorization
Use keras.js and cyclegan-keras to colorize manga automatically. All computation in browser. Demo is online:
Stars: ✭ 20 (-74.36%)
Mutual labels:  gan, image-generation
Anime Face Dataset
🖼 A collection of high-quality anime faces.
Stars: ✭ 272 (+248.72%)
Mutual labels:  gan, image-generation
Pytorch Cyclegan And Pix2pix
Image-to-Image Translation in PyTorch
Stars: ✭ 16,477 (+21024.36%)
Mutual labels:  gan, image-generation
Semantic Pyramid for Image Generation
PyTorch reimplementation of the paper: "Semantic Pyramid for Image Generation" [CVPR 2020].
Stars: ✭ 45 (-42.31%)
Mutual labels:  gan, image-generation
Few Shot Patch Based Training
The official implementation of our SIGGRAPH 2020 paper Interactive Video Stylization Using Few-Shot Patch-Based Training
Stars: ✭ 313 (+301.28%)
Mutual labels:  gan, image-generation
Hidt
Official repository for the paper "High-Resolution Daytime Translation Without Domain Labels" (CVPR2020, Oral)
Stars: ✭ 513 (+557.69%)
Mutual labels:  gan, image-generation

Semantic Object Accuracy for Generative Text-to-Image Synthesis

Code for our paper Semantic Object Accuracy for Generative Text-to-Image Synthesis (Arxiv Version) published in TPAMI 2020.

Summary in our blog post.

Semantic Object Accuracy (SOA) is a score we introduce to evaluate the quality of generative text-to-image models. For this, we provide captions from the MS-COCO data set from which the evaluated model should generate images. We then use a pre-trained object detector to check whether the generated images contain the object that was specified in the caption. E.g. when an image is generated from the caption a car is driving down the street we check if the generated image actually contains a car. For more details check section 4 of our paper.

We also perform a user study in which humans rate the images generated by several state-of-the art models trained on the MS-COCO dataset. We then compare the ranking obtained through our user study with the rankings obtained by different quantitative evaluation metrics. We show that popular metrics, such as e.g. the Inception Score, do not correlate with how humans rate the generated images, whereas SOA strongly correlates with human judgement.

Contents:

Calculate SOA Scores (Semantic Object Accuracy)

How to calculate the SOA scores for a model:

  1. Go to SOA. The captions are in SOA/captions

    1. each file is named label_XX_XX.pkl describing for which labels the captions in the file are
    2. load the file with pickle
      •    import pickle 
           with open(label_XX_XX.pkl, "rb") as f:
               captions = pickle.load(f)
        
    3. each file is a list and each entry in the list is a dictionary containing information about the caption:
      •   [{'image_id': XX, 'id': XX, 'idx': [XX, XX], 'caption': u'XX'}, ...]
        
      • where 'idx': [XX, XX] gives the indices for the validation captions in the commonly used captions file from AttnGAN
  2. Use your model to generate images from the specified captions

    1. each caption file contains the relevant captions for the given label
    2. create a new and empty folder
    3. use each caption file to generate images for each caption and save the images in a folder within the previously created empty folder, i.e. for each of the labels (0-79) there should be a new folder in the previously created folder and the folder structure should look like this
      • images
        • label_00 -> folder contains images generated from captions for label 0
        • label_01 -> folder contains images generated from captions for label 1
        • ...
        • label_79 -> folder contains images generated from captions for label 79
    4. each new folder (that contains generated images) should contain the string "label_XX" somewhere in its name (make sure that integers are formated to two digits, e.g. "0", "02", ...) -> ideally give the folders the same name as the label files
    5. generate three images for each caption in each file
      • exception: for label "00" (person) randomly sample 30,000 captions and generate one image each for a total of 30,000 images
    6. in the end you should have 80 folders in the folder created in the step (2.ii), each folder should have the string "label_XX" in it for identification, and each folder should contain the generated images for this label
  3. Once you have generated images for each label you can calculate the SOA scores:

    1. Install requirements from SOA/requirements.txt (we use Python 3.5.2)
    2. download the YOLOv3 weights file and save it as SOA/yolov3.weights
    3. run python calculate_soa.py --images path/to/folder/created-in-step-2ii --output path/to/folder/where-results-are-saved --gpu 0
  4. If you also want to calculate IoU values check the detailed instructions here

  5. Calculating the SOA scores takes about 30-45 minutes (tested with a NVIDIA GTX 1080TI) depending on your hardware (not including the time it takes to generate the images)

  6. More detailed information (if needed) here

Use Our Model (OP-GAN)

Dependencies

  • python 3.8.5
  • pytorch 1.7.1

Go to OP-GAN. Please add the project folder to PYTHONPATH and install the required dependencies:

conda env create -f environment.yml

Data

  • MS-COCO:
    • download our preprocessed data (bounding boxes, bounding box labels, preprocessed captions), save to data/ and extract
      • the preprocessed captions are obtained from and are the same as in the AttnGAN implementation
      • the generateod bounding boxes for evaluating at test time were generated with code from the Obj-GAN
    • obtain the train and validation images from the 2014 split here, extract and save them in data/train/ and data/test/
    • download the pre-trained DAMSM for COCO model from here, put it into models/ and extract

Training

  • to start training run sh train.sh gpu-ids where you choose which gpus to train on
    • e.g. sh train.sh 0,1,2,3
  • training parameters can be adapted via code/cfg/dataset_train.yml, if you train on more/fewer GPUs or have more VRAM adjust the batch sizes as needed
  • make sure the DATA_DIR in the respective code/cfg/cfg_file_train.yml points to the correct path
  • results are stored in output/

Evaluating

  • update the eval cfg file in code/cfg/dataset_eval.yml and adapt the path of NET_G to point to the model you want to use (default path is to the pretrained model linked below)
  • run sh sample.sh gpu-ids to generate images using the specified model
    • e.g. sh sample.sh 0

Pretrained Models

Acknowledgement

  • Code and preprocessed metadata for the experiments on MS-COCO are adapted from AttnGAN and AttnGAN+OP.
  • Code to generate bounding boxes for evaluation at test time is from the Obj-GAN implementation.
  • Code for using YOLOv3 is adapted from here, here, and here.

Citing

If you find our model useful in your research please consider citing:

@article{hinz2019semantic,
title     = {Semantic Object Accuracy for Generative Text-to-Image Synthesis},
author    = {Tobias Hinz and Stefan Heinrich and Stefan Wermter},
journal   = {arXiv preprint arXiv:1910.13321},
year      = {2019},
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].