Code for paper "Adversarial score matching and improved sampling for image generation"

Overview

Adversarial score matching and improved sampling for image generation

This repo contains the official implementation for the ICLR 2021 paper Adversarial score matching and improved sampling for image generation. It it a highly extended version of the original repo on score matching.

Discussion and more samples at https://ajolicoeur.wordpress.com/adversarial-score-matching-and-consistent-sampling.


Denoising score matching with Annealed Langevin Sampling (DSM-ALS) is a recent approach to generative modeling. Despite the convincing visual quality of samples, this method appears to perform worse than Generative Adversarial Networks (GANs) under the Frechet Inception Distance, a popular metric forgenerative models. We show that this apparent gap vanishes when denoising thefinal Langevin samples using the score network. In addition, we propose two improvements to DSM-ALS: 1) Consistent Annealed Sampling as a more stable alternative to Annealed Langevin Sampling, and 2) a hybrid training formulation, composed of both denoising score matching and adversarial objectives. By combining both of these techniques and exploring different network architectures, we elevate score matching methods and obtain results competitive with state-of-the-art image generation on CIFAR-10

Adversarial LSUN-Churches


Citation

If you find this code useful please cite us in your work:

@inproceedings{
  jolicoeur-martineau2021adversarial,
  title={Adversarial score matching and improved sampling for image generation},
  author={Alexia Jolicoeur-Martineau and R{\'e}mi Pich{\'e}-Taillefer and Ioannis Mitliagkas and Remi Tachet des Combes},
  booktitle={International Conference on Learning Representations},
  year={2021},
  url={https://openreview.net/forum?id=eLfqMl3z3lq}
}

Setup

Needed

Hyperparameter choice

  • Use "main.py --compute_approximate_sigma_max" to choose model.sigma_begin based on the current dataset (based on Technique 1 from https://arxiv.org/abs/2006.09011)
  • Use calculate_number_of_steps.R to choose model.num_classes (based on Technique 2 from https://arxiv.org/abs/2006.09011)
  • tune sampling.step_lr manually for consistent or non-consistent with n_sigma=1 (see Appendix B for how to extrapolate to n_sigma > 1 from the step_lr at n_sigma = 1)
  • Everything else can be left to default

To Replicate paper

To train a non-adversarial score network

python main.py --config cifar10_9999ema.yml --doc cifar10_bs128_L2_9999ema --ni

Log files will be saved in <exp>/logs/cifar10_bs128_L2_9999ema.

To train an adversarial score network

python main.py --config cifar10_9999ema.yml --doc cifar10_bs128_L2_9999ema_adam0_9_adamD-5_9_LSGAN_ --ni  --adam --adam_beta 0 .9 --D_adam --D_adam_beta -.5 .9 --adversarial

Log files will be saved in <exp>/logs/cifar10_bs128_L2_9999ema_adam0_9_adamD-5_9_LSGAN_.

To sample from a pre-trained score network (ex: cifar10_bs128_L2_9999ema, consistent, nsigma=1)

python main.py --sample --config cifar10_9999ema.yml -i cifar10_bs128_L2_9999ema --ni --consistent --nsigma 1 --step_lr 5.6e-6 --batch_size 100 --begin_ckpt 250000

Samples will be saved in <exp>/image_samples/cifar10_bs128_L2_9999ema.

To compute the FID for a range of checkpoints from a pre-trained score network (ex: cifar10_bs128_L2_9999ema, at 100k to 300k iterations)

python main.py --fast_fid --config cifar10_9999ema.yml -i cifar10_bs128_L2_9999ema --ni --consistent --nsigma 1 --step_lr 5.6e-6 --batch_size 4000 --fid_num_samples 10000 --begin_ckpt 100000 --end_ckpt 300000

FIDs will be saved in {args.fid_folder}/log_FID.txt.

Pretrained Score Network Checkpoints

Link: https://www.dropbox.com/s/dltiobdlsb2vhyo/DSM_ScoreNetwork_Pretrained.zip?dl=0

Download and unzip it to the exp folder.

FID statistics (for FID evaluation)

Link: https://www.dropbox.com/s/nhvp2tf1unxj08g/fid_stats.zip?dl=0

Download and unzip it to the exp/datasets folder.

You might also like...
Draw your telegram bot in draw.io and generate its code
Draw your telegram bot in draw.io and generate its code

README Contents: Draw your bot Install requirements Registering a telegram bot Draw bot Start point Message block Single choice block Functions block

🀟The VC Music Source code of @DaisyXBot ❀️ v3 Out now
🀟The VC Music Source code of @DaisyXBot ❀️ v3 Out now

DAISYXMUSIC V3 🎡 A bot that can play music on telegram group's voice call Available on telegram as @DaisyXbot Whats new πŸ”₯ Thumbnail Support Playlist

β€œ HOLA HUMANS πŸ‘‹ I'M DAISYX 2.0 ❀️ β€ž LATEST VERSION OF DAISYX.. Source Code of @Daisyxbot
β€œ HOLA HUMANS πŸ‘‹ I'M DAISYX 2.0 ❀️ β€ž LATEST VERSION OF DAISYX.. Source Code of @Daisyxbot

❀️ DaisyX 2.0 ❀️ A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon... ⭐️ Thanks to everyone who starred Dais

Aggrokatz is an aggressor plugin extension for Cobalt Strike which enables pypykatz to interface with the beacons remotely and allows it to parse LSASS dump files and registry hive files to extract credentials and other secrets stored without downloading the file and without uploading any suspicious code to the beacon.
A Telegram UserBot to Play Radio in Voice Chats. This is also the source code of the userbot which is being used for playing Radio in @AsmSafone Channel.

Telegram Radio Player UserBot A Telegram UserBot to Play Radio in Channel or Group Voice Chats. This is also the source code of the userbot which is b

This is a Discord script that will provide a QR Code to your scholars for Axie Infinity.

DiscordQRCodeBot This is a Discord script that will provide a QR Code to your Axie Infinity scholars. Setup Run Ubuntu on AWS ec2 instance Dowloads al

A listener for RF = 4.0 that prints a Stack Trace to console to faster find the code section where the failure appears.

robotframework-stacktrace A listener for RF = 4.0 that prints a Stack Trace to console to faster find the code section where the failure appears. Ins

Source Code for our bot that manages time and other functions of the server 3

Komi San wants you to study This repo contains the source code for our bot that manages time and other functions of the server 3 Features Your study

A tool that ensures consistent string quotes in your Python code.

pyquotes Single quotes are superior. And if you disagree, there's an option for this as well. In any case, quotes should be consistent throughout the

Comments
  • A question to max sigma

    A question to max sigma

    Hey, thanks a lot for your code and your help.

    I used your code to find the approximate max sigma value for my dataset. My result is a value of 217. This seems rather high. My dataset contains 31.000 images; each is a screenshot of a website with a resolution of 128x128. Should I just work with that value or is there something I should/can do?

    Thanks

    opened by pbizimis 2
  • how to generate images with a specified label

    how to generate images with a specified label

    if I understand correctly, the generated image with a random label in train dataset, so if I want to generate some images with a specified label, how can I do that, every class label has their own model?

    opened by qingzew 2
Owner
Alexia Jolicoeur-Martineau
I'm a researcher in statistics and machine learning. I am particularly interested in GANs, denoising score-matching, and statistical divergences/metrics.
Alexia Jolicoeur-Martineau
An api, written in Python, for Investopedia's paper trading stock simulator.

investopedia-trading-api An API, written in Python, for Investopedia's paper trading stock simulator. Pull requests welcome. This library is now Pytho

Kirk Thaker 178 Jan 6, 2023
My Advent of Code solutions. I also upload videos of my solves: https://www.youtube.com/channel/UCuWLIm0l4sDpEe28t41WITA

My solutions to adventofcode.com puzzles. I post videos of me solving the puzzles in real-time at https://www.youtube.com/channel/UCuWLIm0l4sDpEe28t41

null 195 Jan 4, 2023
Python Script to download hundreds of images from 'Google Images'. It is a ready-to-run code!

Google Images Download Python Script for 'searching' and 'downloading' hundreds of Google images to the local hard disk! Documentation Documentation H

Hardik Vasa 8.2k Jan 5, 2023
β€œ Hey there πŸ‘‹ I'm Daisy β€ž AI based Advanced Group Management Bot Suit For All Your Needs ❀️.. Source Code of @Daisyxbot

Project still under heavy development Everything will be changed in the release β€œ Hey there ?? I'm Daisy β€ž AI based Advanced telegram Group Management

TeamDaisyX 43 Nov 12, 2022
Source code of u/pekofy_bot from reddit.

pekofy-bot Source code of u/pekofy_bot from reddit. Get more info about the bot here: https://www.reddit.com/user/pekofy_bot/comments/krxxol/pekofy_bo

null 32 Dec 25, 2022
Automatically Edits Videos and Uploads to Tiktok with 1 line of code.

TiktokAutoUploader - Open to code contributions Automatically Edits Videos and Uploads to Tiktok with 1 line of code. Setup pip install -r requirement

Michael Peres 199 Dec 27, 2022
β€œ HOLA HUMANS πŸ‘‹ I'M DAISYX 2.0 β€ž LATEST VERSION OF DAISYX.. Source Code of @Daisyxbot

DaisyX 2.0 A Powerful, Smart And Simple Group Manager ... Written with AioGram , Pyrogram and Telethon... The first AioGram based modified groupmanage

TeamDaisyX 153 Dec 6, 2022
historical code from reddit.com

This repository is archived. This repository is archived and will not receive any updates or accept issues or pull requests. To report bugs in reddit.

The Reddit Archives 16.3k Dec 31, 2022
A code to match you with the perfect Taylor Swift song for your mood and relationship status.

taylorswift A package for matching your current mood and relationship status to a suitable Taylor Swift song. Requirements: Python 2 or 3, and the num

Megan Mansfield 82 Dec 9, 2022