Last active
December 9, 2024 06:26
-
-
Save linoytsaban/aec23eee5cc168726f594c04413ead7a to your computer and use it in GitHub Desktop.
Flux with CFG and negative prompts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# download FluxCFGPipline | |
!wget https://raw.githubusercontent.com/linoytsaban/diffusers/refs/heads/dreambooth-lora-flux-exploration/examples/community/pipeline_flux_with_cfg.py | |
# load pipeline | |
import diffusers | |
import torch | |
from pipeline_flux_with_cfg import FluxCFGPipeline | |
pipe = FluxCFGPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", | |
torch_dtype=torch.bfloat16) | |
pipe.enable_model_cpu_offload() | |
### original output, w/o cfg | |
prompt = "an impressionist painting of a magnificant macaron" | |
torch.manual_seed(0) | |
pipe(prompt).images[0].resize((512,512)) | |
### with cfg (true_cfg > 1) and empty negative prompt | |
prompt = "an impressionist painting of a magnificant macaron" | |
negative_prompt = "" | |
torch.manual_seed(0) | |
pipe(prompt=prompt, negative_prompt=negative_prompt, true_cfg=3, guidance_scale=1).images[0].resize((512,512)) | |
### with cfg (true_cfg > 1) and negative prompt | |
prompt = "an impressionist painting of a magnificant macaron" | |
negative_prompt = "photo, photorealistic" | |
torch.manual_seed(0) | |
pipe(prompt=prompt, negative_prompt=negative_prompt, true_cfg=4, guidance_scale=1).images[0].resize((512,512)) |
The wget link is dead, here is the correct link
https://raw.githubusercontent.com/linoytsaban/diffusers/refs/heads/dreambooth-lora-flux-exploration/examples/community/pipeline_flux_with_cfg.py
Thanks @remixer-dec! updated the link to be the right one :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output examples:
