by Dongmin Park1, Sebin Kim2, Taehong Moon1, Minkyu Kim1, Kangwook Lee1,3, Jaewoong Cho1.
1 KRAFTON AI, 2 Seoul National University, 3 University of Wisconsin-Madison
images/ folder.| R2F (Ours) | FLUX-schnell | SD3 | RPG |
![]() | ![]() | ![]() | ![]() |
| Prompt: A furry frog warrior | |||
![]() | ![]() | ![]() | ![]() |
| Prompt: A mustachioed squirrel is holding an ax-shaped guitar on a stage | |||
![]() | ![]() | ![]() | ![]() |
| Prompt: A beautiful wigged octopus is juggling three star-shaped apples | |||
![]() | ![]() | ![]() | ![]() |
| Prompt: A red dragon and a unicorn made of diamond rollerblading through a neon lit cityscape | |||
Therefore, we can unlock the power of diffusion models on rare concepts (even in the tail distribution) !!!
from R2F_Diffusion_xl import R2FDiffusionXLPipeline
from R2F_Diffusion_sd3 import R2FDiffusion3Pipeline
from R2F_Diffusion_flux import R2FFluxPipeline
from diffusers import DPMSolverMultistepScheduler
from gpt.mllm import GPT4_Rare2Frequent, LLaMA3_Rare2Frequent
import torch
api_key = "YOUR_API_KEY"
model = "itercomp"
if model == 'sd3':
pipe = R2FDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium", revision="refs/pr/26")
elif model == "sdxl":
pipe = R2FDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)
elif model == "flux":
pipe = R2FFluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16) # In R2F, we do experiment on FLUX.1-schnell which it requires 4 sampling steps.
elif model == "itercomp":
pipe = R2FDiffusionXLPipeline.from_pretrained("comin/IterComp",torch_dtype=torch.float16, use_safetensors=True)
pipe.to("cuda")
# Demo
prompt= 'A hairy frog'
# Get r2f prompt from LLMs
llm = "gpt4o"
if llm == "gpt4o":
r2f_prompt = GPT4_Rare2Frequent(prompt, key=api_key)
elif llm == "llama3.1":
r2f_prompt = LLaMA3_Rare2Frequent(prompt, model_id="meta-llama/Llama-3.1-8B-Instruct")
print(r2f_prompt)
image = pipe(
r2f_prompts = r2f_prompt,
seed = 42,# random seed
).images[0]
image.save(f"{prompt}_test.png")
### Get r2f_prompts from GPT-4o/LLaMA
cd gpt
bash get_r2f_response.sh
### Generate images
cd ../script/
bash inference_r2f.sh
### Get r2fplus_prompts from GPT-4o/LLaMA
cd gpt
bash get_r2fplus_response.sh
### Generate images
cd ../script/
bash inference_r2fplus.sh
test/original_prompt/rarebench/ folder.test/r2f_prompt/ folder.git clone
cd Rare-to-Frequent
conda create -n r2f python==3.9
conda activate r2f
pip install -r requirements.txt
@article{park2024rare,
title={Rare-to-Frequent: Unlocking Compositional Generation Power of Diffusion Models on Rare Concepts with LLM Guidance},
author={Park, Dongmin and Kim, Sebin and Moon, Taehong and Kim, Minkyu and Lee, Kangwook and Cho, Jaewoong},
journal={The Thirteenth International Conference on Learning Representations},
year={2025}
}
Our R2F is a general LLM-grounded T2I generation framework built on several solid works. Thanks to RPG, LMD, SAM, and diffusers for their wonderful work and codebase!
Python
94.1%
Shell
5.9%
by Dongmin Park1, Sebin Kim2, Taehong Moon1, Minkyu Kim1, Kangwook Lee1,3, Jaewoong Cho1.
1 KRAFTON AI, 2 Seoul National University, 3 University of Wisconsin-Madison
images/ folder.| R2F (Ours) | FLUX-schnell | SD3 | RPG |
![]() | ![]() | ![]() | ![]() |
| Prompt: A furry frog warrior | |||
![]() | ![]() | ![]() | ![]() |
| Prompt: A mustachioed squirrel is holding an ax-shaped guitar on a stage | |||
![]() | ![]() | ![]() | ![]() |
| Prompt: A beautiful wigged octopus is juggling three star-shaped apples | |||
![]() | ![]() | ![]() | ![]() |
| Prompt: A red dragon and a unicorn made of diamond rollerblading through a neon lit cityscape | |||
Therefore, we can unlock the power of diffusion models on rare concepts (even in the tail distribution) !!!
from R2F_Diffusion_xl import R2FDiffusionXLPipeline
from R2F_Diffusion_sd3 import R2FDiffusion3Pipeline
from R2F_Diffusion_flux import R2FFluxPipeline
from diffusers import DPMSolverMultistepScheduler
from gpt.mllm import GPT4_Rare2Frequent, LLaMA3_Rare2Frequent
import torch
api_key = "YOUR_API_KEY"
model = "itercomp"
if model == 'sd3':
pipe = R2FDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3-medium", revision="refs/pr/26")
elif model == "sdxl":
pipe = R2FDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True)
elif model == "flux":
pipe = R2FFluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16) # In R2F, we do experiment on FLUX.1-schnell which it requires 4 sampling steps.
elif model == "itercomp":
pipe = R2FDiffusionXLPipeline.from_pretrained("comin/IterComp",torch_dtype=torch.float16, use_safetensors=True)
pipe.to("cuda")
# Demo
prompt= 'A hairy frog'
# Get r2f prompt from LLMs
llm = "gpt4o"
if llm == "gpt4o":
r2f_prompt = GPT4_Rare2Frequent(prompt, key=api_key)
elif llm == "llama3.1":
r2f_prompt = LLaMA3_Rare2Frequent(prompt, model_id="meta-llama/Llama-3.1-8B-Instruct")
print(r2f_prompt)
image = pipe(
r2f_prompts = r2f_prompt,
seed = 42,# random seed
).images[0]
image.save(f"{prompt}_test.png")
### Get r2f_prompts from GPT-4o/LLaMA
cd gpt
bash get_r2f_response.sh
### Generate images
cd ../script/
bash inference_r2f.sh
### Get r2fplus_prompts from GPT-4o/LLaMA
cd gpt
bash get_r2fplus_response.sh
### Generate images
cd ../script/
bash inference_r2fplus.sh
test/original_prompt/rarebench/ folder.test/r2f_prompt/ folder.git clone
cd Rare-to-Frequent
conda create -n r2f python==3.9
conda activate r2f
pip install -r requirements.txt
@article{park2024rare,
title={Rare-to-Frequent: Unlocking Compositional Generation Power of Diffusion Models on Rare Concepts with LLM Guidance},
author={Park, Dongmin and Kim, Sebin and Moon, Taehong and Kim, Minkyu and Lee, Kangwook and Cho, Jaewoong},
journal={The Thirteenth International Conference on Learning Representations},
year={2025}
}
Our R2F is a general LLM-grounded T2I generation framework built on several solid works. Thanks to RPG, LMD, SAM, and diffusers for their wonderful work and codebase!
Python
94.1%
Shell
5.9%