论文阅读: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
相关推荐
得一录17 小时前
蒸汽、钢铁与无限心智(Steam, Steel, and Infinite Minds)全文
人工智能·aigc
学易1 天前
第二十节.探索新技术:如何自学SD3模型(上)(找官方资料/精读/下载/安装/3款工作流/效果测试)
人工智能·ai作画·stable diffusion·comfyui·工作流·sd3
光的方向_1 天前
ChatGPT提示工程入门 Prompt 03-迭代式提示词开发
人工智能·chatgpt·prompt·aigc
是小蟹呀^1 天前
【论文阅读15】告别死板!ElasticFace 如何用“弹性边缘”提升人脸识别性能
论文阅读·深度学习·分类·elasticface
用户5191495848451 天前
Symfony PATH_INFO 解析缺陷导致授权绕过漏洞修复指南
人工智能·aigc
阿坡RPA1 天前
OpenClaw多Agent协作踩坑实录:从翻车到跑通的全记录
人工智能·aigc
芒果不茫QAQ1 天前
Upstash Vector 免费版完整使用指南
python·aigc·embedding·rag·upstash
晓山清1 天前
【论文阅读】Spectral Representation of Behaviour Primitives for Depression Analysis
论文阅读
Bachnroth2 天前
Stable Diffusion 3.5 FP8镜像负载均衡配置建议
stable diffusion· fp8· 负载均衡
是小蟹呀^2 天前
【论文阅读14】ARoFace:用对抗性对齐误差提升低质量人脸识别
论文阅读