Diffusion Models as Data Mining Tools
59
stars
34
commits
Python
primary language
May 12, 2025
updated

Official PyTorch implementation of Diffusion Models as Data Mining Tools, which has been accepted in ECCV'24.
Our approach allows you to take a large labelled input dataset, and mine the patches that are important for each label. It involves three steps:
Our codebase is mainly developed on diffusers implementation of LDMs.
conda env create -f environment.yaml
conda activate diff-mining
We apply our method in 5 different types of datasets: cars (CarDB), faces (FTT), street-view images (G^3), scenes (Places, high-res) and X-rays (ChestX-ray):
python scripts/download-cardb.py
We share our models on huggingface which you can access through the handles:
or download them locally using:
python scripts/download-models.py
A full walkthrough of the pipeline can be seen in scripts: scripts/training.sh and scripts/typicality.sh.
diffmining/finetuning/.diffmining/typicality/compute.py.diffmining/typicality/cluster.pyWe test our typicality measure in two different approaches which we properly discuss in our paper.
Using our diffusion model, we can translate each image, e.g. in the case of geography, from one country to another. We use PnP which is the only method we found that was relatively robust in keeping a consistency between translated objects (i.e., windows would remain windows). You can launch this translation by running:
source scripts/parallel.sh translate
Afterwards you need to compute typicality for all elements:
source scripts/parallel.sh compute
and then cluster them using:
source scripts/parallel.sh cluster
As typicality is connected to a binary classifier of the conditional vs the null conditioning, it can be used to "spatialize" information related to the condition on the input image. We test this on X-ray images and show how typicality is improved after finetuning. To reproduce our results and evaluations run:
source scripts/xray.sh
We provide a minimal optimized implementation of the algorithm of "What makes Paris look like Paris?" under doersch/.
Running the code should only require:
python doersch.py --which geo --category 'Italy'
yet you will probably have to adjust it to the dataset of choice.
@article{diff-mining,
title = {Diffusion Models as Data Mining Tools},
author = {Siglidis, Ioannis and Holynski, Aleksander and Efros, A. Alexei and Aubry, Mathieu and Ginosar, Shiry},
journal = {ECCV},
year = {2024},
}
This work was partly supported by the European Research Council (ERC project DISCOVER, number 101076028) and leveraged the HPC resources of IDRIS under the allocation AD011012905R1, AD0110129052 made by GENCI. We would like to thank Grace Luo for data, code, and discussion; Loic Landreu and David Picard for insights on geographical representations and diffusion; Karl Doersch, for project advice and implementation insights; Sophia Koepke for feedback on our manuscript.
Python
98.1%
Shell
1.9%
Diffusion Models as Data Mining Tools
59
stars
34
commits
Python
primary language
May 12, 2025
updated

Official PyTorch implementation of Diffusion Models as Data Mining Tools, which has been accepted in ECCV'24.
Our approach allows you to take a large labelled input dataset, and mine the patches that are important for each label. It involves three steps:
Our codebase is mainly developed on diffusers implementation of LDMs.
conda env create -f environment.yaml
conda activate diff-mining
We apply our method in 5 different types of datasets: cars (CarDB), faces (FTT), street-view images (G^3), scenes (Places, high-res) and X-rays (ChestX-ray):
python scripts/download-cardb.py
We share our models on huggingface which you can access through the handles:
or download them locally using:
python scripts/download-models.py
A full walkthrough of the pipeline can be seen in scripts: scripts/training.sh and scripts/typicality.sh.
diffmining/finetuning/.diffmining/typicality/compute.py.diffmining/typicality/cluster.pyWe test our typicality measure in two different approaches which we properly discuss in our paper.
Using our diffusion model, we can translate each image, e.g. in the case of geography, from one country to another. We use PnP which is the only method we found that was relatively robust in keeping a consistency between translated objects (i.e., windows would remain windows). You can launch this translation by running:
source scripts/parallel.sh translate
Afterwards you need to compute typicality for all elements:
source scripts/parallel.sh compute
and then cluster them using:
source scripts/parallel.sh cluster
As typicality is connected to a binary classifier of the conditional vs the null conditioning, it can be used to "spatialize" information related to the condition on the input image. We test this on X-ray images and show how typicality is improved after finetuning. To reproduce our results and evaluations run:
source scripts/xray.sh
We provide a minimal optimized implementation of the algorithm of "What makes Paris look like Paris?" under doersch/.
Running the code should only require:
python doersch.py --which geo --category 'Italy'
yet you will probably have to adjust it to the dataset of choice.
@article{diff-mining,
title = {Diffusion Models as Data Mining Tools},
author = {Siglidis, Ioannis and Holynski, Aleksander and Efros, A. Alexei and Aubry, Mathieu and Ginosar, Shiry},
journal = {ECCV},
year = {2024},
}
This work was partly supported by the European Research Council (ERC project DISCOVER, number 101076028) and leveraged the HPC resources of IDRIS under the allocation AD011012905R1, AD0110129052 made by GENCI. We would like to thank Grace Luo for data, code, and discussion; Loic Landreu and David Picard for insights on geographical representations and diffusion; Karl Doersch, for project advice and implementation insights; Sophia Koepke for feedback on our manuscript.
Python
98.1%
Shell
1.9%