aifeifei798's picture
Update feifeilib/feifeimodload.py
8d33464 verified
raw
history blame
1.05 kB
import torch
import spaces
from diffusers import (
DiffusionPipeline,
AutoencoderTiny,
FluxImg2ImgPipeline
)
from huggingface_hub import hf_hub_download
def feifeimodload():
dtype = torch.bfloat16
device = "cuda" if torch.cuda.is_available() else "cpu"
#pipe = DiffusionPipeline.from_pretrained(
# "aifeifei798/DarkIdol-flux-v1", torch_dtype=dtype
#).to(device)
pipe = DiffusionPipeline.from_pretrained(
"black-forest-labs/FLUX.1-schnell", torch_dtype=dtype
).to(device)
pipe.load_lora_weights(
hf_hub_download("aifeifei798/feifei-flux-lora-v1.1", "feifei-v1.1.safetensors"),
adapter_name="feifei",
)
#pipe.set_adapters(
# ["feifei"],
# adapter_weights=[0.85],
#)
#pipe.fuse_lora(
# adapter_name=["feifei"],
# lora_scale=1.0,
#)
#pipe.enable_sequential_cpu_offload()
pipe.vae.enable_slicing()
pipe.vae.enable_tiling()
# pipe.unload_lora_weights()
torch.cuda.empty_cache()
return pipe