Fork of Text-to-image model editing (TIME) 🤗
This is a forked version of the diffusers 🤗 implementation of Text-to-image model editing (TIME, Editing Implicit Assumptions in Text-to-Image Diffusion Models).
The code in this repository is managed at py-img-gen/diffusers-text-to-model-editing.
Here are the minor changes:
- Changes due to the renaming of the
CrossAttention
class to theAttention
class - Removed the
restart_params
with large side effects from theedit_model
function
import torch
from diffusers import DiffusionPipeline
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
pipe = DiffusionPipeline.from_pretrained(
"stable-diffusion-v1-5/stable-diffusion-v1-5"
custom_pipeline="py-img-gen/stable-diffusion-text-to-model-editing",
)
pipe = pipe.to(device)
prompt = "A field of roses"
source_prompt = "A pack of roses"
destination_prompt = "A pack of blue roses"
pipe.edit_model(
source_prompt=source_prompt,
destination_prompt=destination_prompt,
)
output = pipe(prompt=prompt)
image_edited = output.images[0]
image_edited
You can find the notebook example in notebooks/run_pipeline.ipynb.
- Prompt:
A field of roses
- Source Prompt:
A pack of roses
- Destination Prompt:
A pack of blue roses
Original | TIME |
---|---|
The code in this repository is based on the Text-to-image model editing (TIME) implementation by 🤗 diffusers.