Giter Club home page Giter Club logo

cad's Introduction

Don’t drop your samples! Coherence-aware training benefits Conditional diffusion

Nicolas Dufour, Victor Besnier, Vicky Kalogeiton, David Picard

CAD

This repo has the code for the paper "Dont Drop Your samples: Coherence-aware training benefits Condition Diffusion" accepted at CVPR 2024 as a Highlight.

The core idea is that diffusion model is usually trained on noisy data. The usual solution is to filter massive datapools. We propose a new training method that leverages the coherence of the data to improve the training of diffusion models. We show that this method improves the quality of the generated samples on several datasets.

Project website: https://nicolas-dufour.github.io/cad

Install

To install, first create a conda env with python 3.9/3.10

conda create -n cad python=3.10

Activate the env

conda activate cad

Then run

pip install -r requirements.txt

Depending of your CUDA version be careful installing torch.

This repo is based around Hydra and requires to specify an override such as:

python train.py overrides=imagenet_64_rin **Other hydra args**

You can use the default or create your own override to train the desired model.

Datasets

Downlowad the datasets and add them in /datasets. A few presets are already defined in the configs/data folder (Imagenet, CIFAR-10, LAION Aesthetic 6+ and CC12M)

To add a custom dataset, create a new config file in configs/data and add the dataset to the datasets folder.

This repo supports both Pytorch Datasets and Webdatasets.

LAION and CC12m preprocessing

To preprocess the LAION Aesthetic 6+ and CC12M datasets, you can use the following command:

python data/processing_scripts/preprocess_data.py --src path_to_src_wds --dest path_to_dst_wds --shard_id number_of_the_shard 

This is better used with a cluster to preprocess the data in parallel with job array.

Training class-conditional models

To train CAD on Imagenet you can use the following command:

python train.py overrides=imagenet_64_rin_cad

For CIFAR-10:

python train.py overrides=cifar10_rin_cad

Training text-conditional models

As a side contribution, we also provide a new text-to-image model called TextRIN. This model is based on RIN and is conditioned on text. TextRIN

To train TextRIN with CAD on LAION Aesthetic 6+ and CC12M you can use the following command:

python train.py overrides=cc12m_256_rin_tiny_ldm_cad

TextRIN without CAD

To train TextRIN without CAD on LAION Aesthetic 6+ and CC12M you can use the following command:

python train.py overrides=cc12m_256_rin_tiny_ldm

Reproduction of RIN

This repo also features a reproduction of RIN for Imagenet-64 and CIFAR-10. To train RIN on Imagenet-64 you can use the following command:

python train.py overrides=imagenet_64_rin

For CIFAR-10:

python train.py overrides=cifar10_rin

Pretrained models

Coming soon

Citation

If you happen to use this repo in your experiments, you can acknowledge us by citing the following paper:

@article{dufour2024dont,
  title={Don’t drop your samples! Coherence-aware training benefits Conditional diffusion},
  author={Nicolas Dufour and Victor Besnier and Vicky Kalogeiton and David Picard},
  journal={CVPR}
  year={2024}
}

cad's People

Contributors

nicolas-dufour avatar

Stargazers

StevenLiuWen avatar Grégoire Petit avatar Loic Landrieu avatar Zeynep Sonat Baltacı avatar ccorneanu avatar Pencoded avatar Léo Milecki avatar  avatar  avatar Van Nguyen Nguyen avatar  avatar  avatar Fronk Supakorn avatar ~Cc avatar 唐国梁Tommy avatar  avatar Jean-Philippe Deblonde avatar Mitchell Mosure avatar  avatar Antoine GUEDON avatar  avatar  avatar  avatar  avatar Victor Besnier avatar Syrine avatar Lucas Degeorge avatar 爱可可-爱生活 avatar Deeraj Manjaray avatar Said avatar  avatar Thanos Delatolas avatar Lucas Ventura avatar Mike avatar Xi WANG avatar  avatar Vicky Kalogeiton avatar Elliot Vincent avatar David Picard avatar Julie  avatar Monika Wysoczanska avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.