LoRAFusion-preview-FLUX.1-dev

270 downloads 1 likes on ModelScope updated

Model card

LoRA 融合器(FLUX.1-dev)

本模型用于调和多 LoRA 模型同时加载时的互斥关系,防止出现画面崩坏。

细节请参考我们的论文:AutoLoRA: Automatic LoRA Retrieval and Fine-Grained Gated Fusion for Text-to-Image Generation

我们仍在优化这一模型,此版本模型在部分 LoRA 上的效果仍不稳定,敬请期待我们后续的更新。

效果展示

提示词:a cat

LoRA 1 LoRA 2 LoRA 3 LoRA 4
LoRA 1
LoRA 2
LoRA 3
LoRA 4

提示词:a car

LoRA 1 LoRA 2 LoRA 3 LoRA 4
LoRA 1
LoRA 2
LoRA 3
LoRA 4

推理代码

git clone https://github.com/modelscope/DiffSynth-Studio.git  
cd DiffSynth-Studio
pip install -e .
import torch
from diffsynth.pipelines.flux_image_new import FluxImagePipeline, ModelConfig

        
pipe = FluxImagePipeline.from_pretrained(
    torch_dtype=torch.bfloat16,
    device="cuda",
    model_configs=[
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="flux1-dev.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder/model.safetensors"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="text_encoder_2/"),
        ModelConfig(model_id="black-forest-labs/FLUX.1-dev", origin_file_pattern="ae.safetensors"),
        ModelConfig(model_id="DiffSynth-Studio/LoRAFusion-preview-FLUX.1-dev", origin_file_pattern="model.safetensors"),
    ],
)
pipe.enable_lora_magic()

pipe.load_lora(
    pipe.dit,
    ModelConfig(model_id="cancel13/cxsk", origin_file_pattern="30.safetensors"),
    hotload=True,
)
pipe.load_lora(
    pipe.dit,
    ModelConfig(model_id="DiffSynth-Studio/ArtAug-lora-FLUX.1dev-v1", origin_file_pattern="merged_lora.safetensors"),
    hotload=True,
)
image = pipe(prompt="a cat", seed=0)
image.save("image_fused.jpg")