Attention-Based Prompting and Verifier-Based Selection for Layout-to-Image Generation
RDiffusion-AMV is a layout-to-image generation framework built on top of GLIGEN and Stable Diffusion.
The project improves spatial grounding and object consistency using:
- Spatial-aware conditioning
- Depth-aware embeddings
- Relation-aware embeddings
- Attention masking
- Region-aware prompt augmentation
- Verifier-based candidate selection
The system generates multiple candidate images and automatically selects the best layout-faithful output using a weighted verifier scoring pipeline.
- Spatial encoding using bounding boxes
- Depth-aware conditioning using MiDaS depth priors
- Relation-aware scene encoding
- Unified scene embedding generation
- Prompt augmentation with spatial instructions
- Better object placement guidance
- Improved grounding consistency
- Uses pretrained GLIGEN diffusion backbone
- No retraining of Stable Diffusion backbone
- Lightweight conditioning extensions
- Generates multiple candidates using different seeds
- Improves diversity and selection quality
Candidates are evaluated using:
- IoU (Spatial Alignment)
- OCS (Object-Centric Spatial Consistency)
- CLIP Similarity
- RSS (Relation Satisfaction Score)
- Boundary Sharpness
The best candidate is selected using weighted verifier scoring.
- Gradio-based frontend
- User-defined prompts
- Bounding-box control
- Depth-aware object placement
RDiffusion-AMV/
│
├── RDiffusion_AMV_Final_GitHub_Notebook.ipynb
├── README.md
├── requirements.txt
│
├── assets/
│ ├── architecture.png
│ └── sample_outputs/
│
├── outputs/
├── checkpoints/
└── data/
---
# Results Summary
| Model Variant | Images Generated | Scenes |
| -------------------------------------- | ---------------: | -----: |
| SD Baseline | 100 | 0 |
| GLIGEN Vanilla | 804 | 100 |
| GLIGEN Enriched | 796 | 100 |
| GLIGEN Refined Bounding Box | 800 | 100 |
| RDiffusion Trained | 264 | 33 |
| RDiffusion Attention Masked | 256 | 32 |
| RDiffusion Attention Masked + Verifier | 32 | 32 |
| RDiffusion True Attention Masked | 202 | 26 |
---
# Setup Instructions
## Environment
Recommended:
* Google Colab A100 GPU
* Python 3.10+
* CUDA-enabled environment
---
## Install Dependencies
```bash
pip install -r requirements.txt
Large datasets and checkpoints are not uploaded due to GitHub size limitations.
You must manually place the following in your Google Drive:
/content/drive/MyDrive/RDiffusion/
│
├── GLIGEN/
├── checkpoints/
├── data/
├── outputs/
Required assets include:
- GLIGEN checkpoints
- Stable Diffusion weights
- Trained tokenizer checkpoints
- COCO/VG datasets
- Preprocessed scene JSON files
Open:
RDiffusion_AMV_Final_GitHub_Notebook.ipynb
in Google Colab.
from google.colab import drive
drive.mount('/content/drive')Run:
- imports
- GLIGEN patching
- tokenizer definitions
- preprocessing utilities
The notebook supports:
- Stable Diffusion baseline generation
- GLIGEN generation
- RDiffusion generation
- Attention masked generation
- Verifier-based selection
The notebook includes a Gradio frontend for interactive generation.
Features:
- Prompt input
- Bounding box controls
- Depth-aware conditioning
- Multi-candidate generation
If Gradio throws an InvalidPathError, use:
demo.launch(
share=True,
debug=True,
allowed_paths=[
"/content/drive/MyDrive/RDiffusion/outputs/frontend_rdiffusion_amv"
]
)To reproduce results:
- Prepare datasets and checkpoints
- Run preprocessing cells
- Run tokenizer loading/setup
- Run generation pipeline
- Run evaluation pipeline
- Run verifier-based selection
Generated outputs will be saved to:
/content/drive/MyDrive/RDiffusion/outputs/
- Existing generated outputs are automatically skipped during reruns.
- The notebook supports interrupted runtime recovery.
- Designed primarily for Google Colab execution.
This project builds upon and adapts components from:
- GLIGEN
- Stable Diffusion
- Hugging Face Transformers
- OpenAI CLIP
Official GLIGEN repository: https://github.com/gligen/GLIGEN
