论文阅读:Forget-Me-Not: Learning to Forget in Text-to-Image Diffusion Models

Forget-Me-Not: Learning to Forget in Text-to-Image Diffusion Models

论文链接
代码链接

这篇文章提出了Forget-Me-Not (FMN),用来消除文生图扩散模型中的特定内容。FMN的流程图如下:

可以看到,FMN的损失函数是最小化要消除的概念对应的attention map的 L 2 L_2 L2范数。这里需要补充一些关于diffusion model的知识。

首先,以Stable Diffusion为代表的模型使用U-Net对图片的低维嵌入进行建模。文本条件在被CLIP的text encoder编码为文本嵌入后,通过U-Net中的cross-attention layers输入到U-Net中。cross-attention层的具体映射过程是一个QKV (Query-Key-

Value)结构,如上图的中间所示。其中,Q代表图片的视觉信息,K和V都是文本嵌入经过线性层后计算得到的( k i = W k c i a n d v i = W v c i k_i = W_kc_i~and~v_i = W_vc_i ki=Wkci and vi=Wvci)。而FMN损失函数中的attention map的计算过程如下:

然而,attention map还不是cross attention层的输出,其输出通过以下公式计算:

上面两个公式,也就是图3中间方框中的内容,可以用下面的公式概括,

从FMN的源码中可以看到对应的部分如下:

python 复制代码
class AttnController:
        def __init__(self) -> None:
            self.attn_probs = []
            self.logs = []
        def __call__(self, attn_prob, m_name) -> Any:
            bs, _ = self.concept_positions.shape
            head_num = attn_prob.shape[0] // bs
            target_attns = attn_prob.masked_select(self.concept_positions[:,None,:].repeat(head_num, 1, 1)).reshape(-1, self.concept_positions[0].sum())
            self.attn_probs.append(target_attns)
            self.logs.append(m_name)
        def set_concept_positions(self, concept_positions):
            self.concept_positions = concept_positions
        def loss(self):
            return torch.cat(self.attn_probs).norm()
        def zero_attn_probs(self):
            self.attn_probs = []
            self.logs = []
            self.concept_positions = None
相关推荐
墨风如雪20 小时前
MiniMax Music 1.5:AI 谱写新篇章,音乐创作告别Demo时代
aigc
川川子溢21 小时前
【论文阅读】MEDDINOV3:如何调整视觉基础模型用于医学图像分割?
论文阅读
袁庭新1 天前
职场人为什么必须学AI?
人工智能·aigc
Mintopia1 天前
长文本 AIGC:Web 端大篇幅内容生成的技术优化策略
前端·javascript·aigc
几米哥1 天前
AI学习工具三剑客:NotebookLM、Gemini Guided Learning与ChatGPT Study深度对比
aigc
过河卒_zh15667661 天前
9.13AI简报丨哈佛医学院开源AI模型,Genspark推出AI浏览器
人工智能·算法·microsoft·aigc·算法备案·生成合成类算法备案
Xy-unu1 天前
[VL|RIS] RSRefSeg 2
论文阅读·人工智能·transformer·论文笔记·分割
张较瘦_1 天前
[论文阅读] 告别“数量为王”:双轨道会议模型+LS,破解AI时代学术交流困局
论文阅读·人工智能
Jagger_1 天前
用AI偷懒:我做了个一键切换网络的工具
aigc·ai编程
贝塔实验室1 天前
两种常用的抗单粒子翻转动态刷新方法
论文阅读·经验分享·笔记·科技·学习·程序人生·fpga开发