
各位AI绘画的玩家和创作者们!各人有没有遇到过这种情况:现在最新的AI绘画模型(像基于Transformer的DiT,好比FLUX)效果超棒,但是想精确控制它生成的内容,好比固定人物姿势、保留特定人脸、或者控制画面布局,就感觉特别费劲?要么速率慢,要么一加控制,本身喜欢的LoRA模型(好比特定脚色或画风)效果就没了?

没错,虽然之前基于Unet的模型有ControlNet、IP-Adapter这些神器,但轮到更强的DiT模型,高效又灵活的控制就成了大困难。不过现在,重磅好消息来了! 隆重向各人介绍 EasyControl —— 一个专门为解决这个问题而生的全新框架!它的目标就是让DiT模型的条件控制变得 高效、灵活,而且超级方便!

你可以把 EasyControl 理解成一个给DiT这种高级AI绘画引擎量身定做的“万能控制套件”。它能让你在不“大改”AI核心、不断送太多速率的前提下,实现精准的控制。
它是怎么做到的呢?主要靠这三大法宝:
轻量级的“控制插件”(条件注入LoRA模块): 想象一下,EasyControl 提供了一种像“插件”一样的东西。每个插件专门负责一种控制信号(好比姿势、深度、人脸特性)。它能独立工作,即插即用,最关键的是,它不会跟你的基础模型或者其他自定义模型(好比你心爱的人物LoRA、画风LoRA)打架! 就算只练习了单一控制,它也能神奇地在之后零样本组合多种控制(好比姿势+人脸+风格),效果还很和谐!

智慧的“尺寸魔法”(位置感知练习范式): 这个技术让EasyControl在练习时就学会理解差别分辨率的控制图。这意味着什么?意味着你生成图片时,可以自由设定想要的图片尺寸和长宽比,不再被枯燥地限制住,而且还能提高盘算服从!
风驰电掣的“加速器”(因果注意力+KV缓存): EasyControl接纳了一种巧妙的技术(可以理解为缓存关键信息),能够明显减少生成图片时的等待时间,大大提升了服从!

条件信号通过新引入的条件分支注入扩散变动器 (DiT),该分支与轻量级、即插即用的条件注入 LoRA 模块一起对条件标记举行编码。

EasyControl 框架表示图
在练习过程中,每个单独的条件都会被单独练习,其中条件图像会被调整到较低的分辨率,并使用位置感知练习范式举行练习。这种方法可以实现高效灵活的分辨率练习。该框架集成了因果注意力机制,从而能够实现键值 (KV) 缓存,从而明显提升推理服从。此外,如许的设计有助于无缝集成多个条件注入 LoRA 模块,从而实现稳健且和谐的多条件生成。

很多朋友特别喜欢用LoRA模型来还原宫崎骏(吉卜力)那种梦幻的动画风格。但从前经常遇到的问题是,一旦想用ControlNet之类的工具控制姿势,吉卜力画风可能就“跑偏”了,或者效果大打扣头。

EasyControl 的巨大上风就在于它的兼容性! 因为它的控制模块是轻量且独立的,它在施加控制(好比引导姿势、锁定主体)的同时,能够最大限度地保留你加载的自定义LoRA模型的效果。也就是说,你可以用EasyControl来精准控制画面内容,同时让你心爱的宫崎骏画风LoRA完美发挥作用!

最最最冲动人心的是,EasyControl 团队已经把它开源了! 你可以在 GitHub 和 Hugging Face 上找到相关的代码和模型。这意味着,你现在就可以去下载、去实验,把它集成到你的AI绘画工作流里,创作出既精准可控、又充满艺术风格的神奇画作!

总而言之,如果你希望:
对最新的AI绘画模型(DiT架构)举行更精准的控制;
同时使用各种自定义的人物或风格LoRA(好比吉卜力风);
并且希望生成速率更快、更灵活;
那么,EasyControl 绝对是你不能错过的神器! 它高效、灵活、兼容性强,快去试试看,让你的AI创作更上一层楼吧!

固然EasyControl已经开源了,喜欢代码的小同伴可以直接到 GitHub 上面参考代码举行当地模型的生成与摆设。如下是吉卜力风格图片的代码,可以上传本身的图片举行吉卜力风格的图片生成以及控制。
- import spaces
- import os
- import json
- import time
- import torch
- from PIL import Image
- from tqdm import tqdm
- import gradio as gr
- from safetensors.torch import save_file
- from src.pipeline import FluxPipeline
- from src.transformer_flux import FluxTransformer2DModel
- from src.lora_helper import set_single_lora, set_multi_lora, unset_lora
- base_path = "black-forest-labs/FLUX.1-dev"
- lora_base_path = "./checkpoints/models"
- pipe = FluxPipeline.from_pretrained(base_path, torch_dtype=torch.bfloat16)
- transformer = FluxTransformer2DModel.from_pretrained(base_path, subfolder="transformer", torch_dtype=torch.bfloat16)
- pipe.transformer = transformer
- pipe.to("cuda")
- def clear_cache(transformer):
- for name, attn_processor in transformer.attn_processors.items():
- attn_processor.bank_kv.clear()
- @spaces.GPU()
- def single_condition_generate_image(prompt, spatial_img, height, width, seed, control_type):
- if control_type == "Ghibli":
- lora_path = os.path.join(lora_base_path, "Ghibli.safetensors")
- set_single_lora(pipe.transformer, lora_path, lora_weights=[1], cond_size=512)
- spatial_imgs = [spatial_img] if spatial_img else []
- image = pipe(
- prompt,
- height=int(height),
- width=int(width),
- guidance_scale=3.5,
- num_inference_steps=25,
- max_sequence_length=512,
- generator=torch.Generator("cpu").manual_seed(seed),
- subject_images=[],
- spatial_images=spatial_imgs,
- cond_size=512,
- ).images[0]
- clear_cache(pipe.transformer)
- return image
- control_types = ["Ghibli"]
- with gr.Blocks() as demo:
- gr.Markdown("# Ghibli Studio Control Image Generation with EasyControl")
- gr.Markdown("The model is trained on **only 100 real Asian faces** paired with **GPT-4o-generated Ghibli-style counterparts**, and it preserves facial features while applying the iconic anime aesthetic.")
- gr.Markdown("Generate images using EasyControl with Ghibli control LoRAs.(Due to hardware constraints, only low-resolution images can be generated. For high-resolution (1024+), please set up your own environment.)")
- gr.Markdown("**[Attention!!]**:The recommended prompts for using Ghibli Control LoRA should include the trigger words: `Ghibli Studio style, Charming hand-drawn anime-style illustration`")
- gr.Markdown("If you like this demo, please give us a star (github: [EasyControl](https://github.com/Xiaojiu-z/EasyControl))")
- with gr.Tab("Ghibli Condition Generation"):
- with gr.Row():
- with gr.Column():
- prompt = gr.Textbox(label="Prompt", value="Ghibli Studio style, Charming hand-drawn anime-style illustration")
- spatial_img = gr.Image(label="Ghibli Image", type="pil") # 上传图像文件
- height = gr.Slider(minimum=256, maximum=1024, step=64, label="Height", value=768)
- width = gr.Slider(minimum=256, maximum=1024, step=64, label="Width", value=768)
- seed = gr.Number(label="Seed", value=42)
- control_type = gr.Dropdown(choices=control_types, label="Control Type")
- single_generate_btn = gr.Button("Generate Image")
- with gr.Column():
- single_output_image = gr.Image(label="Generated Image")
- single_generate_btn.click(
- single_condition_generate_image,
- inputs=[prompt, spatial_img, height, width, seed, control_type],
- outputs=single_output_image)
- demo.queue().launch()
复制代码 固然 easy control 尚有其他方面的控制,好比图片尺寸控制,人体姿态控制,以及可以使用素描画生成对应的图片等等,更多出色应用可以参考官方 GitHub地址以及 hugging face 开源模型自行使用。

- huggingface:EasyControl_Ghibli
- GitHub:EasyControl
复制代码
- 更多transformer,VIT,swin tranformer
- 参考头条号:人工智能研究所
- v号:人工智能研究Suo, 启示AI科技
复制代码 动画详解transformer 在线教程
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
|