InstantID: Zero-shot Identity-Preserving Generation in Seconds

文章介绍了国内首创的图像生成项目InstantID,它利用Zero-shot技术和预训练模型实现实时、高保真的身份保持。项目通过人脸特征提取、Cross-Attention机制和IdentityNet提升生成图像的语义准确性和ID一致性,同时保持良好的文本控制能力。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

记录由国内首创的一个好玩的小项目,图像生成领域的新进展。但我希望现阶段计算机视觉领域的研究能更聚焦在 语义分割 和 三维视觉 上,这样能更方便与机器人等产品和工业实体结合。

Introduction

InstantID 是一个基于扩散模型的图像生成解决方案,能实现从单一参考图像到多样化风格化写真的快速生成。用户只需上传一张自拍,20 秒就能得到定制版 AI 写真。

无论是古典油画中的贵族,或是未来都市中的赛博朋克英雄,多种风格,切换自如。

体验Demo直达:https://huggingface.co/spaces/InstantX/InstantID

在这里插入图片描述

Main

该开源项目的核心在于其 Zero-shot 技术,整个过程无需训练 LoRA 模型,就能实现高保真的 ID 保持。

根据论文《InstantID: Zero-shot Identity-Preserving Generation in Seconds》,InstantID 是一个高效、轻量级、可插拔的适配器,它为预训练的文本到图像扩散模型赋予了强大的身份信息保留能力。

InstantID 不训练文生图模型的 UNet 部分,仅训练可插拔模块,在推理过程中无需 test-time tuning,在几乎不影响文本控制能力的情况下,实现高保真 ID 保持。

在这里插入图片描述
如图所示,其技术实现主要基于三个关键组成部分:

1、人脸特征提取:利用预训练的人脸编码器(如 InsightFace 的 antelopev2 模型)提取强语义的人脸特征,以增强图像生成的语义准确性。由于 CLIP 只提供了弱语义表征,无法在人脸等强语义场景下直接应用,考虑了人脸识别领域已经相当成熟,小红书采用预训练的人脸编码器来提取人脸特征。

2、Cross-Attention 机制:通过解耦的交叉注意力机制,将人脸特征(而非 CLIP 表征)作为 Image Prompt 嵌入,增强文本提示的效果,同时保持对生成图像的精细控制。

3、IdentityNet:引入 IdentityNet 对人脸图像进行编码,通过强语义和弱空间的条件控制,进一步提升 ID 的保真度。在实现中,IdentityNet 采用与 ControlNet 一致的残差结构,从而保持原始模型的兼容性。

在 IdentityNet 中,主要有两个对于原版 ControlNet 的修改:

一方面,InstantID 只使用五个面部关键点,而不是细粒度的 OpenPose 面部关键点 (两个用于眼睛,一个用于鼻子,两个用于嘴巴)用于条件输入。

另一方面,InstantID 消除文本提示并使用 ID 嵌入作为条件加入到 ControlNet 中的交叉注意力层。


InstantID 在多个方面展现出其独特优势,主要贡献如下:

  1. 作为一种全新的 ID 保留方法,有效弥补了训练效率与 ID 保真度之间的差距。
  2. 它是可插拔的,与目前社区内文生图基础模型、LoRAs、ControlNets 等完全兼容,可以零成本地在推理过程中保持人物 ID 属性。此外,InstantID 保持了良好的文本编辑能力,使 ID 能够丝滑地嵌入到各种风格当中。加装饰、改发色、换套装,都毫无问题。
  3. 实验结果表明,InstantID 不仅超越目前基于单张图片特征进行嵌入的方法(IP-Adapter-FaceID),还与 ROOP、LoRAs 等方法在特定场景下不分伯仲,成本还低。

在这里插入图片描述
InstantID 的推出,为视图合成领域带来了显著的效率提升,它不仅能够快速生成风格多样的 AI 写真,而且确保了原图身份特征的完整性。

除了低成本快速生成真人写真,InstantID 还有非常多的玩法,比如允许用户进行五官夸张定制,与宠物的趣味合体,以及实现多身份和风格的创意合成。

Reference

项目主页:https://instantid.github.io

论文地址:https://arxiv.org/abs/2401.07519

代码地址:https://github.com/InstantID/InstantID

Demo 体验:https://huggingface.co/spaces/InstantX/InstantID

### Zero-Shot Evaluation in Machine Learning In machine learning, zero-shot evaluation refers to a scenario where models are evaluated on tasks or data that were not seen during training. This approach tests the model's ability to generalize knowledge from known categories to previously unseen ones without any additional training examples specific to these new classes[^1]. For instance, consider a multilingual pre-trained language model designed to understand multiple languages. If such a model can accurately perform question answering or translation for a language it was never explicitly trained on, this would exemplify successful zero-shot capability. A key aspect of achieving effective zero-shot performance lies in how well the underlying algorithms capture generalizable features within the training phase. Techniques like structured pruning may enhance efficiency while preserving critical information necessary for transferring learned patterns across different contexts. Moreover, when dealing with sequential data, positional encoding (PE) plays an important role by providing relative position information between tokens. Even though initial words might have fixed positions indicated as zeros, subsequent processing stages still benefit significantly from encoded positional details provided through mechanisms similar to those described for calculating PE values based on index parity and vector dimensions[^2]. #### Example Code Demonstrating Positional Encoding Calculation ```python import numpy as np def calculate_positional_encoding(pos, i, d_model=5): angle_rads = pos / np.power(10000, (2 * (i//2)) / np.float32(d_model)) if i % 2 == 0: pe_value = np.sin(angle_rads) else: pe_value = np.cos(angle_rads) return pe_value ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猛码Memmat

欢迎支持,随缘打赏 ~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值