DALLE2论文解读及实现(一)

这篇具有很好参考价值的文章主要介绍了DALLE2论文解读及实现(一)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

DALLE2: Hierarchical Text-Conditional Image Generation with CLIP Latents
paper: https://cdn.openai.com/papers/dall-e-2.pdf
github: https://github.com/lucidrains/DALLE2-pytorch
DALLE2概览:
- CLIP模型:
用于生成text embedding zt 和image embedding zi
- prior模型:
1) 模型输入:为 the encoded text,the CLIP text embedding,time_embed,image_embed,learned_queries,(文本整体embedding,文本序列embedding,时间步embedding,当前t步对应的图片embedding,用于输出transformer 结果手动构造用于学习的embedding )
2) 模型: diffusion model使用transformer(不是unet)直接预测x0,然后通过diffusion递推公式生成前一步图片embedding.
3)最终输出:为 image Embedding (不同于上面CLIP生成的image embedding )
- decoder 模型
1)模型输入:为 prior 输出的image Embedding
2)模型:diffusion model使用unet网络,预测噪声z (不同于prior模型直接预测x0)
3)模型输出:经过T步去噪后,最后一步x0即为模型输出

0 Abstract

基于对比学习思想,我们提出了两阶段模型,
①一个先验模型prior:

  • 在给定文本条件下生成CLIP的 image embedding

② 一个decoder模型:

  • 在给定imge embedding 条件下,生成图片

We use diffusion models for the decoder and experiment with both autoregressive and diffusion models for the prior, finding that the latter are computationally more efficient and produce higher quality samples.
我们使用diffusion 模型作为decoder 模型,实验了自回归autoregressive 和diffusion模型作为prior模型,发现diffusion 模型作为先验模型效过更好

1 Introduction

  • 虚线上面的是CLIP模型,通过CLIP模型可以学习到text 和image的embedding,
  • 虚线以下是文本到图片的生成过程,
    ① CLIP的 text embedding 喂给autoregressive或者diffusion模型( prior模型),生成image embedding
    ② 然后根据上面的image embedding喂给decoder 模型,生成最终的图片image

DALLE2论文解读及实现(一),CV,DALLE2,文本生成图片,生成模型
DALLE2论文解读及实现(一),CV,DALLE2,文本生成图片,生成模型

2 Method

  • Our training dataset consists of pairs (x, y) of images x and their corresponding captions y. Given an image x,let zi and zt be its CLIP image and text embeddings, respectively. We design our generative stack to produce images from captions using two components:
  • 我们训练数据集由成对的(x,y)组成,x是图片,y是文本,给定x和y,通过CLIP模型,可以分别生成image 和text embedding,zi和 zt。
  • A prior P(zi|y) that produces CLIP image embeddings zi conditioned on captions y.
    一个prior 模型用在给定文本时,生成image embedding zi.
  • A decoder P(x|zi, y) that produces images x conditioned on CLIP image embeddings zi (and optionally text captions y).
    decoder 模型用于在给定条件zi时,生成最终图片 x。
    整个过程如下所示
    DALLE2论文解读及实现(一),CV,DALLE2,文本生成图片,生成模型

2.1 Decoder

  • We use diffusion models to produce images conditioned on CLIP image embeddings (and optionally text captions).

  • 在prior模型生成的image embedding的基础上, 我们使用 diffusion models生成image。

  • 将image embedding作为条件直接加上timestep embedding(也可以选择添加加text embedding,实验发现用处不大),然后通过下面的diffusion 去噪公式 ,选择unet网络预测噪声,生成最终的图片x
    μ ˉ t = 1 α t ( x t − 1 − α t 1 − α ˉ t z t ) \bar \mu_t=\frac{1 } {\sqrt \alpha_{t}} (x_t -\frac{1-\alpha_t } {\sqrt{1- \bar \alpha_{t}}} z_t) μˉt=α t1(xt1αˉt 1αtzt)

2.2 Prior

• While a decoder can invert CLIP image embeddings zi to produce images x, we need a prior model that produces zi from captions y to enable image generations from text captions.
decoder 模型输入 image embedding zi 生成image x,需要prior模型生成的zi.

• Diffusion prior: The continuous vector zi is directly modelled using a Gaussian diffusion model conditioned on the caption y.
Diffusion prior : 给定文本y(clip 模型生成的文本向量)时,通过Gaussian diffusion model 直接生成 zi。为了改善样本质量,训练时我们随机mask掉10%的文本数据。

DALLE2论文解读及实现(一),CV,DALLE2,文本生成图片,生成模型文章来源地址https://www.toymoban.com/news/detail-722133.html

  • 对于 diffusion prior,我们训练一个 decoder-only的Transformer模型,对输入序列使用causal attention mask。用于预测x0 (重点:不是噪声zt)
  • Transformer模型的输入: the encoded text,the CLIP text embedding,time_embed,image_embed,learned_queries,(文本整体embedding,文本序列embedding,时间步embedding,当前t步对应的图片embedding,用于输出transformer 结果手动构造用于学习的embedding )
  • diffusion 过程: 随机初始化xt,dffusion通过下面公式反向传播公式生成x(t-1)数据(transformer 模型直接生成x0),直到最后一步x0
    μ ˉ t ( x t , x 0 ) = α t ( 1 − α ˉ t − 1 ) 1 − α ˉ t x t + α ˉ t − 1 ( 1 − α t ) 1 − α ˉ t x 0 \bar \mu_t(x_t,x_0)=\frac{\sqrt{\alpha_{t}}(1-\bar \alpha_{t-1} ) } {1- \bar \alpha_{t}} x_t +\frac{\sqrt{\bar \alpha_{t-1}}(1-\alpha_t) } {1- \bar \alpha_{t}} x_0 μˉt(xt,x0)=1αˉtαt (1αˉt1)xt+1αˉtαˉt1 (1αt)x0

到了这里,关于DALLE2论文解读及实现(一)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 一行文本生成4D动态场景——Meta AI MAV3D论文解读

    论文链接:https://arxiv.org/pdf/2301.1128

    2024年02月12日
    浏览(28)
  • AI写代码修Bug画画写诗,ChatGPT&DALLE2试用攻略

    ChatGPTDALLE2是OpenAI的最新研究成果,在量子位看到他的强大功能后,就自己试玩了一下,比如我让ChatGPT帮我写一个GraphSage模型,ChatGPT先简单解释了一下GraphSage,然后写出了不错的PyTorch代码 (详见见示例一),是不是很神奇? 在我将量子位的公众号文章转发朋友圈之后,很多人

    2024年02月11日
    浏览(33)
  • 大模型 Dalle2 学习三部曲(一)Latent Diffusion Models学习

    Diffusion model 大获成功,但是它的短板也很明显,需要大量的计算资源,并且推理速度比较慢。如何才能提升Diffusion model的计算效率。业界有各种各样的改进,无疑 Latent Diffusion Models(潜在扩散模型,LDMs) 是比较成功的一篇,那就来学习一下LDMS是怎么做的吧 1,与基于变换

    2024年01月18日
    浏览(27)
  • dalle2:hierarchical text-conditional image generation with clip

    DALL·E 2【论文精读】_哔哩哔哩_bilibili 更多论文:https://github.com/mli/paper-reading, 视频播放量 30350、弹幕量 256、点赞数 1767、投硬币枚数 1318、收藏人数 751、转发人数 344, 视频作者 跟李沐学AI, 作者简介 ,相关视频:博一研究生 求偶视频,如何做好文献阅读及笔记整理,在线求

    2024年02月16日
    浏览(73)
  • AI art 实验:同样的Prompt, DALLE2 跟 Disco Diffusion 的创作大比拼

    关门测试的 DALL·E 2 昨日放出消息,说刚向社区投放了 1000 个内测名额,赶紧奔去查我的邮箱!没有!还是没有,向几位我认识搞机器学习的大佬们托了人情也不行,没有插队的!(奔走掩面甩泪) 为什么那么多人在翘首期盼 DALL·E 2,看看下面这个创作实验就明白了。 这个

    2024年02月09日
    浏览(32)
  • Java原来可以这么玩!CV实现多张图片生成视频

    比如我像将几张图片变成一个视频的形式发不到短视频平台,虽然短视频平台也有上传图片变成视频的功能,但是我想要具体控制每张图片显示多久后切换到下一个图片,短视频平台目前无法实现,于是乎,我用java代码实现了这个功能。 生成视频展示 多张图片生成视频 Ja

    2024年01月17日
    浏览(32)
  • 用python实现文本/图片生成视频

    使用Python来生成视频通常涉及到使用一些专门的库,比如 OpenCV 或者 moviepy。下面是一个简单的例子,使用OpenCV和PIL(Python Imaging Library)来创建一个视频。 python复制代码 import cv2 import numpy as np from PIL import Image import os # 图片路径列表 image_list = [\\\'img1.jpg\\\', \\\'img2.jpg\\\', \\\'img3.jpg\\\'] # 视频

    2024年01月17日
    浏览(73)
  • DALL·E 2 解读 | 结合预训练CLIP和扩散模型实现文本-图像生成

      论文标题: 《Hierarchical Text-Conditional Image Generation with CLIP Latents》 作者/单位:Aditya Ramesh et al. / Open AI 论文链接: http://arxiv.org/abs/2204.06125 论文中文对照版:论文笔记:DALL-E2:Hierarchical Text-ConditionalImage Generation with CLIP Latents详解_nocol.的博客-CSDN博客 代码链接: 非官方实现 h

    2024年02月11日
    浏览(31)
  • 基于 transformers 的 generate() 方法实现多样化文本生成:参数含义和算法原理解读

    最近在做文本生成,用到huggingface transformers库的文本生成 generate() 函数,是 GenerationMixin 类的实现( class transformers.generation_utils.GenerationMixin ),是自回归文本生成预训练模型相关参数的集大成者。因此本文解读一下这些参数的含义以及常用的 Greedy Search 、 Beam Search 、 Sampli

    2024年02月02日
    浏览(36)
  • LLMs之LLaMA-2:源码解读(generation.py文件)—Llama类实现基于预训练模型的文本生成功能(基于单轮提示实现文本补全/多轮对话生成)=build函数构建Llama实例+init

    LLMs之LLaMA-2:源码解读(generation.py文件)—Llama类实现基于预训练模型的文本生成功能(基于单轮提示实现文本补全/多轮对话生成)=build函数构建Llama实例+init函数初始化模型和词表对象+generate函数基于提示文本生成文本序列+sample_top_p辅助函数实现了控制随机性的核心采样策略top

    2024年02月07日
    浏览(31)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包