Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch
|
| 5 |
+
- diffusers
|
| 6 |
+
- unconditional-image-generation
|
| 7 |
+
- diffusion-models-class
|
| 8 |
+
- medical-imaging
|
| 9 |
+
- brain-mri
|
| 10 |
+
- multiple-sclerosis
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Brain MRI Synthesis with DDPM (64x64)
|
| 14 |
+
|
| 15 |
+
This model is a diffusion-based model for unconditional image generation of **brain MRI FLAIR slices** of size **64x64 pixels**.
|
| 16 |
+
The model was trained using the [DDPM](https://arxiv.org/abs/2006.11239) architecture, with attention mechanisms in the middle of the U-Net.
|
| 17 |
+
It is trained from scratch on a dataset of brain MRI slices, specifically designed for generating synthetic brain images.
|
| 18 |
+
|
| 19 |
+
## Training Details
|
| 20 |
+
|
| 21 |
+
- **Architecture:** DDPM (Denoising Diffusion Probabilistic Model)
|
| 22 |
+
- **Resolution:** 64x64 pixels
|
| 23 |
+
- **Dataset:** Lesion2D VH splitted (FLAIR MRI slices) (70% of the dataset)
|
| 24 |
+
- **Channels:** 1 (grayscale, FLAIR modality)
|
| 25 |
+
- **Epochs:** 50
|
| 26 |
+
- **Batch size:** 32
|
| 27 |
+
- **Optimizer:** AdamW with learning rate of `1.0e-4`
|
| 28 |
+
- **Scheduler:** Cosine with 500 warm-up steps
|
| 29 |
+
- **Gradient Accumulation:** 1 steps
|
| 30 |
+
- **Mixed Precision:** No
|
| 31 |
+
- **Hardware:** Trained on **one NVIDIA GeForce GTX 1080 Ti GPU of 12GB**
|
| 32 |
+
- **Memory Consumption:** Around **11 GB** during training
|
| 33 |
+
|
| 34 |
+
## U-Net Architecture
|
| 35 |
+
- **Down Blocks:** [DownBlock2D, DownBlock2D, AttnDownBlock2D, DownBlock2D]
|
| 36 |
+
- **Up Blocks:** [UpBlock2D, AttnUpBlock2D, UpBlock2D]
|
| 37 |
+
- **Layers per Block:** 2
|
| 38 |
+
- **Block Channels:** [128, 128, 256, 512]
|
| 39 |
+
|
| 40 |
+
## Usage
|
| 41 |
+
You can use the model directly with the `diffusers` library:
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from diffusers import DDPMPipeline
|
| 45 |
+
import torch
|
| 46 |
+
|
| 47 |
+
# Load the model
|
| 48 |
+
pipeline = DDPMPipeline.from_pretrained("benetraco/brain_ddpm_64")
|
| 49 |
+
pipeline.to("cuda") # or "cpu"
|
| 50 |
+
|
| 51 |
+
# Generate an image
|
| 52 |
+
image = pipeline(batch_size=1).images[0]
|
| 53 |
+
|
| 54 |
+
# Display the image
|
| 55 |
+
image.show()
|