本模型(MAR)通过消除对矢量量化的需求,提出了一种新颖的自回归图像生成方法。
该模型不依赖离散标记,而是采用扩散过程在连续值空间中运作,以建模每个标记的概率分布。
通过使用扩散损失函数,该模型实现了高效且高质量的图像生成,同时受益于自回归序列建模的速度优势。
这种方法简化了生成过程,使其适用于图像合成之外更广泛的连续值领域。
该方法基于此篇论文
您可通过 Hugging Face 的 DiffusionPipeline 轻松加载本模型,并可选择自定义各类参数,如模型类型、步数及类别标签等。
from diffusers import DiffusionPipeline
# load the pretrained model
pipeline = DiffusionPipeline.from_pretrained("jadechoghari/mar", trust_remote_code=True, custom_pipeline="jadechoghari/mar")
# generate an image with the model
generated_image = pipeline(
model_type="mar_huge", # choose from 'mar_base', 'mar_large', or 'mar_huge'
seed=42, # set a seed for reproducibility
num_ar_steps=64, # number of autoregressive steps
class_labels=[207, 360, 388], # provide valid ImageNet class labels
cfg_scale=4, # classifier-free guidance scale
output_dir="./images", # directory to save generated images
cfg_schedule = "constant", # choose between 'constant' (suggested) and 'linear'
)
# display the generated image
generated_image.show()
此代码加载模型,配置其进行图像生成,并将输出保存至指定目录。
我们提供三种预训练的 MAR 模型,格式为 safetensors:
mar-base.safetensorsmar-large.safetensorsmar-huge.safetensors这是论文《无需向量量化的自回归图像生成》(Autoregressive Image Generation without Vector Quantization) 的 Hugging Face Diffusers/GPU 实现。
官方 PyTorch 实现发布于此代码库中。
@article{li2024autoregressive,
title={Autoregressive Image Generation without Vector Quantization},
author={Li, Tianhong and Tian, Yonglong and Li, He and Deng, Mingyang and He, Kaiming},
journal={arXiv preprint arXiv:2406.11838},
year={2024}
}我们感谢邓琮岳(Congyue Deng)和陈新雷(Xinlei Chen)提供的宝贵讨论。感谢 Google TPU Research Cloud (TRC) 为我们提供 TPU 访问权限,以及 Google Cloud Platform 提供的 GPU 资源支持。
本代码库中的大部分代码基于 MAE、MAGE 和 DiT 实现。
如有任何疑问,欢迎通过电子邮件(tianhong@mit.edu)与我联系。祝使用愉快!