diffusion-models_master
This repository contains the code derived from the writing of the master thesis project on mammographic image generation using diffusion models.
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 1 DOI reference(s) in README -
✓Academic publication links
Links to: mdpi.com -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.6%) to scientific vocabulary
Keywords
Repository
This repository contains the code derived from the writing of the master thesis project on mammographic image generation using diffusion models.
Basic Info
Statistics
- Stars: 6
- Watchers: 1
- Forks: 3
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
MAM-E: Mammographic synthetic image generation with diffusion models
Running GUI
Access our GUI for the inference of the models here!
Note: The availability of the GUI is not guaranteed 24/7.
Main contributors
- ### Ricardo Montoya-del-Angel
- ### Robert Martí
Research group
- ### Computer Vision and Robotics Institute (ViCOROB) of the University of Girona (UdG)

This repository contains the source code for the Master thesis project on mammographic image generation using diffusion models. This project was developed under the Joint Master's degree in Medical Imaging and Applications (MAIA) teaching program, at the University of Girona (Spain), the University of Cassino and Southern Lazio (Italy) and the University of Bourgogne (France).
Description
In this work, we propose exploring the use of diffusion models for the generation of high quality full-field digital mammograms using state-of-the-art conditional diffusion pipelines. Additionally, we propose using stable diffusion models for the inpainting of synthetic lesions on healthy mammograms. We introduce MAM-E, a pipeline of generative models for high quality mammography synthesis controlled by a text prompt and capable of generating synthetic lesions on specific sections of the breast.
Main documentation
The paper of this project can be found here: MAM-E: Mammographic Synthetic Image Generation with Diffusion Models.
Additionally, the report of the project, the slides of the presentation and the poster can be found in the documentation folder.
Set up the environment (updated 2025)
To create the mame environment we suggest mamba/conda using our yaml file:
- Create conda environment:
bash
mamba env create -f envs/requirements_mamba.yaml
mamba activate mame
This will create a conda environment named mame. Before creating it, make sure that the cuda version of pytorch is being installed.
- After activating the environment, install the bitsandbytes library individually:
bash
mamba install bitsandbytes -c conda-forge
This is done because the bitsandbytes library may try to install the pytorch cpu version if included in the requirements file.
Using other environment managers
You may also install all the libraries using other environment managers, like pip. Just open the yaml file, explore the libraries and install them using your prefered manager.
Running the code
Full-field mammogram generation
- Edit the configuration file you choose with the desired parameters. For example, you can change the number of epochs, the batch size, the learning rate, etc (example)
- It is important to define the training data location and the name of the experiment
- For special configuration settings (e.g. xformer usage, wandb logging, etc.), refer to the corresponding documentation.
Results will be saved in the
resultsfolder, in the repository root.Run the experiment:
```bash cd experiments/sd2
python traindreambooth.py --configpath=configfiles/<yourconfig_file>.yaml ```
Note: The fusion model using batch size of 16 (with variable graident accumulation steps), 512x512 image, with xformers activated, 8 bit adam, gradient checkpointing and fp16 mixed precision training, requires around 20GB of GPU memory.
Lesion Inpainting
Edit the appropriate inpainting configuration file. Notice the additional parameters for inpainting such as validation image and mask paths (example).
Run the inpainting experiment:
bash
cd experiments/sd2
python train_inpainting.py --config_path=config_files/<your_config_file>.yaml
Repository structure
The repository is structured as follows: - assessment: code for qualitative and quantitative assessment of the generated images. - data (not included in the repository): contains the data used for training the models. - The training data location as well as the results directory are be defined in the configuration file. - This means you can have virtually any directory structure that you want for your data. - datasetanalysis: code for the analysis of the dataset. This includes constructing the dataset metadata, saving png files, creating masks, prompt, etc. - datasetslocal: contains useful functions for the dataset creation. - documentation: contains the report, slides and poster of the project. - envs: contains the conda (and pip) environment files. - experiments: contains the code for the main experiments. It is divided in old experiments (original code) and updated code (duch as sd2). - figures: contains the figures used in the README. - generation (future work): for the use of synthetic images in the training of CAD systems. - results (not included in the repository): contains the weights, pipeline configuration files and some logging files for the experiments. (The same information can be found in the Hugging Face repository of the first author).
Citation
If you find this project useful, please consider citing it:
@Article{s24072076,
AUTHOR = {Montoya-del-Angel, Ricardo and Sam-Millan, Karla and Vilanova, Joan C. and Martí, Robert},
TITLE = {MAM-E: Mammographic Synthetic Image Generation with Diffusion Models},
JOURNAL = {Sensors},
VOLUME = {24},
YEAR = {2024},
NUMBER = {7},
ARTICLE-NUMBER = {2076},
URL = {https://www.mdpi.com/1424-8220/24/7/2076},
ISSN = {1424-8220},
DOI = {10.3390/s24072076}
}
Owner
- Name: Ricardo Montoya-del-Angel
- Login: Likalto4
- Kind: user
- Location: Girona, Spain
- Company: VICOROB Lab
- Repositories: 8
- Profile: https://github.com/Likalto4
Computational biophysicist ready to rumble
Citation (CITATION.cff)
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: >-
MAM-E: Mammographic synthetic image generation with
diffusion models
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Ricardo
family-names: Montoya-del-Angel
email: ricardo.montoya.da@gmail.com
affiliation: University of Girona
- given-names: Robert
family-names: Martí
email: robert.marti@udg.edu
affiliation: University of Girona
repository-code: 'https://github.com/VICTORIA-project/mam-e'
GitHub Events
Total
- Watch event: 1
- Delete event: 5
- Push event: 17
- Pull request event: 11
- Create event: 4
Last Year
- Watch event: 1
- Delete event: 5
- Push event: 17
- Pull request event: 11
- Create event: 4
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 0
- Total pull requests: 33
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Total issue authors: 0
- Total pull request authors: 2
- Average comments per issue: 0
- Average comments per pull request: 0.03
- Merged pull requests: 33
- Bot issues: 0
- Bot pull requests: 18
Past Year
- Issues: 0
- Pull requests: 6
- Average time to close issues: N/A
- Average time to close pull requests: less than a minute
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 6
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- dependabot[bot] (27)
- Likalto4 (19)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- SimpleITK *
- omidb ==0.7.0
- pandas *
- pydicom ==1.4.1
- pyyaml *
- tqdm *