概述
调高或调低适配器的强度会增强或反转属性,同时尝试保持图像的其余部分不变,并且可以组合数十个滑块。
主要要点
- LoRA 滑块是一种低阶适配器,其比例因子充当扩散模型中一个图像属性的连续刻度盘。
- Concept Sliders 由 Gandikota 及其同事在东北大学和麻省理工学院于 2023 年 11 月发布,并在 ECCV 2024 上发表。
- 使用冻结模型自身的噪声预测作为目标,从提示对(例如老的和年轻的)中训练文本滑块。
- 在该论文的用户研究中,修复手部滑块将 Stable Diffusion XL 上手部扭曲的图像从 62% 削减到 22%。
- 作者报告说,一代中可以组合 50 多个滑块,但属性之间仍然存在一些残留干扰。
深入探讨
A text-to-image diffusion model such as Stable Diffusion XL makes a picture by starting from random noise and removing it step by step, guided by a text prompt. Prompts are a blunt control. Asking for a slightly older person usually changes the face, the pose and the background along with the age, because small prompt changes can produce a very different image from the same random seed. A LoRA slider is a way to get a smooth, targeted dial instead: a small add-on to the model's weights that pushes one attribute up or down by an amount the user chooses, ideally with everything else held still.
The add-on is a LoRA, short for low-rank adaptation, a technique published by Edward Hu and colleagues in June 2021 for cheaply fine-tuning large language models. Instead of changing a full weight matrix W0, LoRA learns an update written as the product of two thin matrices, B times A, whose inner dimension, the rank, is small, such as 4. The original paper reported that, compared with full fine-tuning of GPT-3 175B, LoRA cuts trainable parameters by about 10,000 times and GPU memory by about 3 times, and adds no inference latency because the update can be merged into the original weights. The update is multiplied by a scale factor when it is applied, and that scale is the slider: 0 leaves the model unchanged, positive values apply the learned edit, and negative values apply it in reverse.
Concept Sliders, the method that made this idea well known, was posted to arXiv in November 2023 by Rohit Gandikota, Joanna Materzynska, Tingrui Zhou, Antonio Torralba and David Bau, of Northeastern University, MIT and an independent researcher, and published at ECCV 2024. Training a text slider needs only prompts: a target concept, such as person, and two opposing attributes, such as old and young. The frozen original model is asked to predict noise for each, and the method builds a training target that is the model's normal prediction for person, shifted toward old and away from young by a guidance strength. The LoRA is trained so that, given only the prompt person, the adapted model produces that shifted prediction. In effect, the slider learns to apply a classifier-free-guidance style push permanently, inside the weights.
Two additions make the edits cleaner. First, a single prompt pair can pick up unwanted attributes, so the method adds preservation concepts: when training an age slider, the authors repeat the objective over prompts naming different races, so the slider learns age without shifting ethnicity. The official code exposes this as an attributes option, for example male and female for an age slider. Second, the low rank itself acts as a constraint. The authors report that fine-tuning without the low-rank restriction reduced both edit precision and image quality, while low-rank training found a minimal subspace for the concept.
Sliders can also be defined from images. Given small sets of before and after pictures, the method trains the slider to reproduce the difference between paired images, which lets an artist define a direction by example, or lets the authors transfer a direction found in StyleGAN, an older face-generation model with well-studied editable directions, into Stable Diffusion. At generation time, the authors follow a technique called SDEdit: the first denoising steps run with the slider switched off, so the overall layout is set by the original model, and the slider is applied for the remaining steps, which keeps the edited image structurally close to the unedited one.
Compared with alternatives, sliders trade setup cost for convenience at use time. Prompt editing needs no training but changes too much. Image-editing methods such as Prompt-to-Prompt change cross-attention for one image and need a separate pass for each new edit; the paper reports that its sliders achieve comparable CLIP-score changes, a measure of how well the image matches the requested edit, with smaller LPIPS distance, a measure of perceptual change, from the original image. Once trained, a slider is a small file that works in a single generation pass, can be scaled continuously and can be combined with others.
The limitations are stated in the paper. Disentanglement is imperfect: the authors observed residual effects on other attributes, and sliders trained on a single prompt pair were sometimes entangled with unintended directions. Each slider is tied to the base model it was trained on, so a Stable Diffusion XL slider does not work on another model family, and the project's own repository describes its FLUX.1 support as experimental, with results that may not match SDXL. The fix-hands slider reduced but did not eliminate hand errors, from 62% to 22% in the study. Like any image-editing tool, sliders for faces and bodies can be used to alter images of real people, so the usual consent questions apply.
In practice, the code, data and trained sliders are public through the project site and GitHub repository, along with notebooks for Stable Diffusion 1.x and XL and an inference demo. Training a text slider requires writing a short configuration of target, positive, negative and neutral prompts with settings such as rank 4 and alpha 1, and a GPU that can run the base model.
04工作示例
训练和测试年龄滑块
写一个配置,有目标人,正老,负年轻,还有男性、女性等保存属性。
使用官方文本滑块脚本在 Stable Diffusion XL 上训练 4 级 LoRA,保持基本模型冻结。
使用固定随机种子和滑块刻度 0 作为基线生成咖啡师的图像。
使用相同的种子以负 2、负 1、正 1 和正 2 的比例重新生成,在第一个去噪步骤中保持滑块关闭。
将五张图像并排放置,检查年龄是否稳定变化,而姿势、服装和背景保持不变。
注意其他属性中的任何偏差,例如肤色或性别表现,并在出现时添加保存提示。
它显示了什么
学习者获得一排图像,显示一个人在单一控制下从年轻到年老的平稳衰老。一个好的滑块显示年龄的单调变化,而其他地方几乎没有变化;不相关特征中的可见漂移是本文的保存概念旨在减少的纠缠。
现实世界的实施
文本定义的属性:概念滑块论文根据提示对(例如老人与年轻人)训练年龄、头发、天气、风格和表情的滑块,并且移动滑块负片会在同一图像上产生相反的效果。
修复手部:在一项针对 Stable Diffusion XL 图像的用户研究中,评估者认为 150 张未经编辑的图像中有 62% 的手部扭曲,而使用该论文的修复手部滑块制作的 150 张图像中这一比例为 22%。
一般修复:在 300 个图像对中,评估者更喜欢论文修复滑块的输出,因为在 80.39% 的情况下伪影较少,解决了物体变形等问题。
难以用语言描述的编辑:作者将在面部照片上训练的 StyleGAN 风格空间中的方向转移到扩散滑块中,并针对眉毛形状和眼睛大小等精细属性训练图像对滑块。
堆叠控件:论文报告称,可以同时组合 50 多个独特的滑块,而不会降低输出质量,因此用户可以在一代通道中调整多个属性。
LoRA 滑块用于图像编辑的未来
Concept Sliders turned a fine-tuning technique into an interface idea: one adapter per attribute, each with a dial. The project's own follow-up, SliderSpace, aims to discover sliders automatically, extracting many control directions from a single prompt without manual prompt pairs, which addresses the cost of designing each slider by hand. The official repository has also added experimental support for the FLUX.1 model family and links community integrations such as ControlNet, showing the approach moving to newer base models. Open problems are mostly about reliability. The authors report residual interference between attributes, and entanglement grows harder to detect when sliders are stacked; the paper reports 50 or more sliders composing without quality loss, but which combinations stay disentangled is not fully characterized. Each slider must be retrained for every new base model, and directions found in one model family may not exist in the same form in another. Measuring whether an edit changed only the intended attribute still relies on a mix of automatic scores such as CLIP and LPIPS and human studies. There is also a question of what attributes should be offered. Sliders for age, body shape or ethnicity-related features raise fairness and consent concerns when applied to images of real people, and the paper's use of preservation concepts to keep such attributes stable during other edits is one example of treating them deliberately rather than as side effects.
付诸实践
为什么这很重要
- 速度与规模. 视觉人工智能可以大规模自动化检查、检测和标记任务。
- 构建选择. 创意团队可以通过更少的手动修改更快地构建概念原型。
- 团队与工作流程. 操作可以使用以前难以处理的图像和视频信号。
留意
- 如果出处不明,肖像权和同意可能会成为法律风险。
- 模型性能可能因光照、人口统计和环境的不同而有所不同。
- 除非监控置信阈值,否则误报可能会被忽视。
后续步骤
- 定义精确度、召回率和错误成本的接受标准。
- 使用符合实际生产条件的数据进行测试。
- 为低置信度或高影响力的预测添加人工审核。
- 跟踪模型漂移并在相机或数据集更改后重新验证。
资料来源与延伸阅读
- arXiv (ECCV 2024)概念滑块:用于扩散模型中精确控制的 LoRA 适配器
- Northeastern University Bau Lab概念滑块项目页面
- GitHub概念滑块官方存储库
- arXivLoRA:大型语言模型的低秩适应
不断探索
常见问题
什么是用于图像编辑的 LoRA 滑块?
LoRA 滑块由东北大学和麻省理工学院的研究人员于 2023 年 11 月推出,名为“概念滑块”,是一种小型低阶适配器,可为扩散图像模型提供针对某一属性(例如年龄、微笑或天气)的连续刻度盘。调高或调低适配器的强度会增强或反转属性,同时尝试保持图像的其余部分不变,并且可以组合数十个滑块。
LoRA中的“低等级”指的是什么?
LoRA 将权重更新表示为两个小的低秩矩阵 A 和 B 的乘积,这比更新完整权重矩阵要便宜得多。
为什么可以同时堆叠多个 LoRA 滑块?
每个滑块都是一个应用于冻结基础模型的单独的低级适配器,并且本文演示了在其评估的设置中组合多个滑块。堆叠行为可能取决于模型和实现。
增加滑块的强度值通常会产生什么作用?
滑块标量乘以学习的概念方向,因此较大的正值更强烈地表达属性。
论文报告在不降低输出质量的情况下合成了多少个独特的概念滑块?
Concept Sliders 论文报告称,在其评估的设置中,组合了 50 多个独特的滑块,而不会降低输出质量。结果仅限于该论文和模型设置。
Concept Sliders 作品引入了什么概念?
概念滑块训练与个体属性相关的低等级方向,在推理时显示为强度旋钮。