Created
October 25, 2024 21:25
-
-
Save r4inm4ker/3765e91c30e4c9ed1ecd2a07ac200000 to your computer and use it in GitHub Desktop.
Use flux.1-dev with LoRa in diffusers
This file contains hidden or 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
import torch | |
from diffusers import FluxPipeline | |
base_model = "D:/flux1-dev" | |
pipe = FluxPipeline.from_pretrained(base_model, torch_dtype=torch.bfloat16, local_files_only=True, use_safetensors=True) | |
pipe.enable_model_cpu_offload() | |
lora_path = "D:/training_output/fern.safetensors" | |
prefix = "fern" | |
names = [prefix] | |
weights = [1.0] | |
pipe.load_lora_weights(lora_path, adapter_name=prefix, local_files_only=True, weight_name=prefix) | |
pipe.set_adapters(names, adapter_weights=weights) | |
prompt = "a girl named fernsoso with purple long hair and a black coat and white dress sits in a forest" | |
output = "D:/output.png" | |
image = pipe(prompt=prompt, num_inference_steps=28, guidance_scale=6.5).images[0] | |
image.save(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment