Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
tags:
|
| 5 |
+
- diffusion
|
| 6 |
+
- ddpm
|
| 7 |
+
- retinal-fundus
|
| 8 |
+
- image-generation
|
| 9 |
+
---
|
| 10 |
+
# Model Card for ddpm-unet-retinal-fundus-image-generator
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
A **U-Net–based Denoising Diffusion Probabilistic Model (DDPM)** trained to generate **retinal fundus images**. This model can be used for synthetic medical image generation to augment datasets for training diagnostic models or other biomedical tasks.
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## Model Architecture
|
| 18 |
+
|
| 19 |
+
- **Base**: [`UNet2DModel`](https://huggingface.co/docs/diffusers/main/en/api/models/unet2d)
|
| 20 |
+
- **Scheduler**: [`DDPMScheduler`](https://huggingface.co/docs/diffusers/main/en/api/schedulers/ddpm)
|
| 21 |
+
- **Resolution**: `128x128`
|
| 22 |
+
- **Channels**: `RGB (3)`
|
| 23 |
+
- **Attention**: Spatial self-attention in mid-resolution blocks
|
| 24 |
+
- **Framework**: [🤗 Diffusers](https://github.com/huggingface/diffusers) + PyTorch
|
| 25 |
+
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
## Dataset
|
| 29 |
+
|
| 30 |
+
- **Source**: [Kaggle - Retinal Fundus Images](https://www.kaggle.com/datasets/kssanjaynithish03/retinal-fundus-images)
|
| 31 |
+
- **Subset Used**: `train/Moderate Diabetic Retinopathy`
|
| 32 |
+
- **Preprocessing**:
|
| 33 |
+
- Resized to `128x128`
|
| 34 |
+
- Normalized to `[-1, 1]`
|
| 35 |
+
- Random horizontal flip
|
| 36 |
+
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
+
## Training Configuration
|
| 40 |
+
|
| 41 |
+
| Setting | Value |
|
| 42 |
+
|----------------------------|--------------------|
|
| 43 |
+
| Epochs | 35 |
|
| 44 |
+
| Batch size | 16 |
|
| 45 |
+
| Optimizer | AdamW |
|
| 46 |
+
| Learning rate | 1e-4 |
|
| 47 |
+
| Scheduler | Cosine w/ warmup |
|
| 48 |
+
| Precision | Mixed (fp16) |
|
| 49 |
+
| Diffusion Timesteps | 1000 |
|
| 50 |
+
| Image Samples Saved | Every 10 epochs |
|
| 51 |
+
|
| 52 |
+
Training was done using 🤗 Accelerate and TensorBoard logging.
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## How to Use
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
from diffusers import DDPMPipeline
|
| 60 |
+
import torch
|
| 61 |
+
import matplotlib.pyplot as plt
|
| 62 |
+
|
| 63 |
+
pipeline = DDPMPipeline.from_pretrained("GS-23/ddpm-unet-retinal-fundus-image-generator")
|
| 64 |
+
images = pipeline(batch_size=1, generator=torch.manual_seed(0)).images
|
| 65 |
+
|
| 66 |
+
for img in images:
|
| 67 |
+
plt.imshow(img)
|
| 68 |
+
plt.axis("off")
|
| 69 |
+
plt.show()
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
---
|
| 73 |
+
|
| 74 |
+
## 📌 Use Cases
|
| 75 |
+
|
| 76 |
+
- Data augmentation for diabetic retinopathy classifiers
|
| 77 |
+
- Retinal pathology simulation and training
|
| 78 |
+
- Medical generative AI research
|
| 79 |
+
- Domain-specific image synthesis
|