大数跨境
0
0

OmniConsistency: 一种基于扩散模型的风格一致性插件,用于高质量图像风格化。

OmniConsistency: 一种基于扩散模型的风格一致性插件,用于高质量图像风格化。 AIGC Studio
2025-09-26
2
导读:OmniConsistency 提出一种基于扩散模型的风格一致性插件,通过两阶段训练策略和滚动LoRA 银行




OmniConsistency 提出一种基于扩散模型的风格一致性插件,通过两阶段训练策略和滚动LoRA 银行机制,实现了在多种风格下的风格一致性和内容保真度,性能接近商业级模型 GPT-4o。

在图像风格化领域,我们常常面临一个痛点:现有的方法要么在复杂场景下无法保持风格一致性,要么在图像到图像的转换中出现风格退化,甚至在布局控制上也显得捉襟见肘。

前不久,新加坡国立大学的研究团队开源了一种全新的解决方案——OmniConsistency。它通过两阶段训练策略和滚动 LoRA 机制,成功解决了风格学习与一致性保持之间的冲突,让图像风格化在多种风格下都能实现高度一致性和内容保真度。

OmniConsistency 不仅能够轻松应对未见过的风格模块,还具备极高的效率,仅需极小的计算开销,就能在图像风格化任务中达到接近商业级模型 GPT-4o 的效果。它就像一个强大的“插件”,可以无缝接入任意风格的 LoRA 模块,让风格化创作变得更加灵活高效!

🔗项目地址:https://github.com/showlab/OmniConsistency

🔗Demo:https://huggingface.co/spaces/yiren98/OmniConsistency

🔗数据集地址:https://huggingface.co/datasets/showlab/OmniConsistency

🔗模型地址:https://huggingface.co/showlab/OmniConsistency

🔗ComfyUI-Nodes:https://github.com/lc03lc/Comfyui_OmniConsistency

unsetunset核心技术:unsetunset

OmniConsistency架构,包括风格学习和一致性学习阶段。(a)在风格学习阶段,各个LoRA模块在专用数据集上接受培训,以捕捉独特的风格细节。(b)随后的一致性学习阶段优化了一致性LoRA,以实现不同风格之间的结构和细节连贯性,动态整合了预训练的风格LoRA
OmniConsistency架构,包括风格学习和一致性学习阶段。(a)在风格学习阶段,各个LoRA模块在专用数据集上接受培训,以捕捉独特的风格细节。(b)随后的一致性学习阶段优化了一致性LoRA,以实现不同风格之间的结构和细节连贯性,动态整合了预训练的风格LoRA
  • 两阶段训练策略:第一阶段独立训练风格特定的 LoRA 模块以捕捉风格细节;第二阶段通过滚动加载不同风格的 LoRA 模块,训练一致性模块以保持结构和语义一致性。
  • 滚动 LoRA 银行机制:在一致性训练中动态切换不同风格的 LoRA 模块和对应数据集,确保模型对不同风格的泛化能力。
  • 因果注意力机制:在条件分支中使用因果注意力,避免风格和结构之间的冲突,同时保持风格表达和结构一致性的平衡。
  • 高效条件引导设计:通过条件令牌映射和特征重用技术,优化计算效率,降低内存和推理时间开销。

unsetunset实验效果unsetunset

在多种风格下,OmniConsistency 的风格一致性显著优于现有方法,与 GPT-4o 相当。

  • 内容保真度:在保持风格的同时,能够更好地保留输入图像的语义、结构和细节。
  • 泛化能力:对未见过的风格 LoRA 模块表现出良好的泛化能力,无需重新训练即可直接使用。
  • 效率:相比基础的 Flux 文本到图像管道,仅增加 4.6% 的 GPU 内存使用和 5.3% 的推理时间开销。
img

OmniConsistency可以与可见和不可见的样式LoRA模块相结合,以实现高质量的图像样式化一致性,有效地保留原始图像的语义、结构和精细细节

img

OmniConsistency和基线方法的比较结果。

完整的设置确保了强烈的风格化和一致性,而移除会降低性能。OmniConsistency是即插即用的,很容易与现有的管道和工具(如IP适配器)兼容。

unsetunset本地部署:unsetunset

1、安装依赖环境

# Create a new conda environment
conda create -n omniconsistency python=3.10
conda activate omniconsistency

# Install other dependencies
pip install -r requirements.txt

2、下载模型

模型链接地址🔗:https://huggingface.co/showlab/OmniConsistency

from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/3D_Chibi_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/American_Cartoon_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Chinese_Ink_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Clay_Toy_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Fabric_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Ghibli_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Irasutoya_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Jojo_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/LEGO_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Line_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Macaron_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Oil_Painting_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Origami_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Paper_Cutting_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Picasso_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Pixel_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Poly_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Pop_Art_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Rick_Morty_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Snoopy_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Van_Gogh_rank128_bf16.safetensors", local_dir="./LoRAs")
hf_hub_download(repo_id="showlab/OmniConsistency", filename="LoRAs/Vector_rank128_bf16.safetensors", local_dir="./LoRAs")
from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="showlab/OmniConsistency", filename="OmniConsistency.safetensors", local_dir="./Model")

3、开始运行

1)初始化模型

import time
import torch
from PIL import Image
from src_inference.pipeline import FluxPipeline
from src_inference.lora_helper import set_single_lora

def clear_cache(transformer):
    for name, attn_processor in transformer.attn_processors.items():
        attn_processor.bank_kv.clear()

# Initialize model
device = "cuda"
base_path = "/path/to/black-forest-labs/FLUX.1-dev"
pipe = FluxPipeline.from_pretrained(base_path, torch_dtype=torch.bfloat16).to("cuda")

# Load OmniConsistency model
set_single_lora(pipe.transformer, 
                "/path/to/OmniConsistency.safetensors"
                lora_weights=[1], cond_size=512)

# Load external LoRA
pipe.unload_lora_weights()
pipe.load_lora_weights("/path/to/lora_folder"
                       weight_name="lora_name.safetensors")

2)风格推理

image_path1 = "figure/test.png"
prompt = "3D Chibi style, Three individuals standing together in the office."

subject_images = []
spatial_image = [Image.open(image_path1).convert("RGB")]

width, height = 10241024

start_time = time.time()

image = pipe(
    prompt,
    height=height,
    width=width,
    guidance_scale=3.5,
    num_inference_steps=25,
    max_sequence_length=512,
    generator=torch.Generator("cpu").manual_seed(5),
    spatial_images=spatial_image,
    subject_images=subject_images,
    cond_size=512,
).images[0]

end_time = time.time()
elapsed_time = end_time - start_time
print(f"code running time: {elapsed_time} s")

# Clear cache after generation
clear_cache(pipe.transformer)

image.save("results/output.png")

论文标题:《OmniConsistency: Learning Style-Agnostic Consistency from Paired Stylization Data[1]》

论文地址:https://arxiv.org/pdf/2505.18445

相关技术论文汇总(2025年):

  1. 《ICAS: IP Adapter and ControlNet-based Attention Structure for Multi-Subject Style Transfer Optimization》[2]

🔗https://arxiv.org/pdf/2504.13224v1.pdf

ICAS(IP-Adapter和ControlNet基础的注意力结构)是一种新型的多主体风格迁移优化框架,通过选择性微调预训练扩散模型的内容注入分支,并结合IP-Adapter的自适应风格注入与ControlNet的结构约束,实现了高效的多主体风格迁移,同时在结构保真、风格一致性和推理效率方面表现出色。

2. 《LLM-Enabled Style and Content Regularization for Personalized Text-to-Image Generation》[3]

🔗https://arxiv.org/pdf/2504.15309

该技术提出了一种基于视觉语言模型(VLM)推理的个性化文本到图像生成方法,通过风格细化策略和内容保护策略,优化风格嵌入并增强文本可控性,从而实现更准确的风格表示和内容一致性,提升了个性化文本到图像生成的效果。

3. 《InstantCharacter: Personalize Any Characters with a Scalable Diffusion Transformer Framework》[4]

🔗https://arxiv.org/pdf/2504.12395

InstantCharacter是一种可扩展的扩散变换器框架,能够实现跨多种角色外观、姿态和风格的个性化图像生成,同时保持高保真度和文本可控性。

4. 《OmniStyle: Filtering High Quality Style Transfer Data at Scale》[5]

🔗https://arxiv.org/pdf/2505.14028

OmniStyle 是一种基于扩散变换器(DiT)架构的高质量、高效风格迁移框架,通过 OmniStyle-1M 大规模配对数据集和 OmniFilter 质量评估框架,支持指令引导和图像引导的风格迁移任务,能够生成高分辨率且细节丰富的风格化图像。

5. 《StyleAR: Customizing Multimodal Autoregressive Model for Style-Aligned Text-to-Image Generation》[6]

🔗https://arxiv.org/pdf/2505.19874v1.pdf

StyleAR是一种创新的多模态自回归模型方法,通过结合特殊设计的数据整理方法和改进的自回归模型,利用文本-图像二元数据实现风格对齐的文本到图像生成,解决了获取大规模风格化三元组数据的难题。

6. 《A Training-Free Style-aligned Image Generation with Scale-wise Autoregressive Model》[7]

🔗https://arxiv.org/pdf/2504.06144v1.pdf

该技术提出了一种基于尺度自回归模型的无训练风格对齐图像生成方法,通过初始特征替换、关键特征插值和动态风格注入三个关键组件,在无需额外训练的情况下实现了快速推理,并显著提高了生成图像的风格一致性。

7. 《FlexIP: Dynamic Control of Preservation and Personality for Customized Image Generation》[8]

🔗https://arxiv.org/pdf/2504.07405

FlexIP 是一种新型的图像生成框架,通过引入个性化适配器和保护适配器,实现了在图像生成中身份保持与个性化编辑的动态平衡,显著提升了身份保持精度和编辑灵活性。

unsetunset



感谢你看到这里,也欢迎点击关注下方公众号并添加公众号小助手加入官方读者交流群,一个有趣有AI的AIGC公众号:关注AI、深度学习、计算机视觉、AIGC、Stable Diffusion、Sora等相关技术,欢迎一起交流学习💗~



【声明】内容源于网络
0
0
AIGC Studio
一个有趣有AI的AIGC公众号:关注AI、深度学习、计算机视觉、AIGC、Stable Diffusion、Sora等相关技术。这里不仅有简单易懂的AIGC理论实践和AI学习路线,还有大厂工作经历和体会分享。如果有幸能给你一些帮助就更好啦!
内容 876
粉丝 0
AIGC Studio 一个有趣有AI的AIGC公众号:关注AI、深度学习、计算机视觉、AIGC、Stable Diffusion、Sora等相关技术。这里不仅有简单易懂的AIGC理论实践和AI学习路线,还有大厂工作经历和体会分享。如果有幸能给你一些帮助就更好啦!
总阅读231
粉丝0
内容876