Official implementation of Teaching Humans Subtle Differences with DIFFusion.
We illustrate the counterfactual results from our methods on the Butterfly dataset, the Black
Hole dataset, and the Retina dataset. In the Butterfly dataset, the Viceroy has a cross-sectional line (
Create conda environment:
$ conda create -n diff-usion python=3.9
$ conda activate diff-usionClone and install requirements:
$ git clone https://github.com/cvlab-columbia/diff-usion
$ cd diff-usion
$ pip install -r requirements.txtWe've made a gradio demo that automatically runs our method end-to-end given just your dataset (extracts embeds, trains classifiers, finetune's the diffusion model, and runs our arithmetic edit!). To run it in reasonable time, it requires GPUs, so we've provided the gradio demo code for you to run on your own machine. Alternatively, you can run the code yourself via the next sections.
To run the gradio demo, run:
$ python gradio_diff-usion_demo.pyFirst, download the datasets: AFHQ, Retina. The Butterfly dataset was obtained from iNaturalist and the KikiBouba dataset was generated from the Kiki Bouba generative model repository, but we have provided the compressed folders in the google drive links for ease of use. We are not able to release the black hole dataset publicly.
Next, download the fine-tuned lora weights, clip embeddings, and ensemble classifiers from here. Place the results folder in the root directory.
Then, run the following commands to reproduce our results:
$ python eval.py --config_path configs/edit/retina.yaml
$ python make_gif.py --config_path configs/edit/retina.yamlYou can also reproduce our results on our datasets without downloading anything beyond the datasets by reproducing the clip embeddings, ensemble classifiers, and lora weights yourself via the instructions in the next section.
To use your own dataset, add a dataset class to the datasets.py file. This dataset should return a tuple of (image, label, filename). There should only be two classes, and the labels should be 0 or 1. You will also need to modify the get_cls_dataset_by_name function to return your dataset, and create a config file for each folder in the configs folder: one for fine-tuning lora (optional) the diffusion model (lora), one for training the ensemble classifiers (ensemble), and one for editing (edit). You can copy the structure from the existing configs for the Retina dataset.
To finetune our diffusion decoder on a new dataset, modify the example config file according to your dataset location and run:
$ python kandinsky_lora_train.py --config_path configs/lora/retina.yamlTo save CLIP features for YOUR own dataset, run:
$ python scripts/save_embeds.pyTo train our set of ensemble classifiers, run:
$ python scripts/ensemble_train.py --config_path configs/ensemble/retina.yamlNote that classifiers are not strictly necessary to generate fine-grained edits. The classifier is used to determine the highest tskip while also still flipping the prediction from the classifiers, but you could also simply pick the tskip that you prefer.
The image editing config file is in configs/edit folder, and we have provided an example one for the retina dataset.
$ python eval.py --config_path configs/edit/retina.yaml$ python make_gif.py --config_path configs/edit/retina.yamlYou might also want to see how the strength of the manipulation scalar affects the interpolation. To do this, run:
$ python eval_save_interp.py --config_path configs/edit/retina.yamlIf our code or models aided your research, please cite our paper:
@misc{chiquier2025teaching,
title={Teaching Humans Subtle Differences with DIFFusion},
author={Chiquier, Mia and Avrech, Orr and Gandelsman, Yossi and Feng, Berthy and Bouman, Katherine and Vondrick, Carl},
journal={arXiv preprint arXiv:2504.08046},
year={2025}
}