文章目录

一、背景二、方法2.1 A Unified VL Formulation and Architecture2.2 GLIPv2 pre-training2.3 将 GLIPv2 迁移到 Localization 和 VL task

三、结果3.1 所用数据集的介绍3.2 训练细节3.3 One set of model parameters for all3.4 GLIPv2 as a strong few-shot learner3.5 Analysis

论文:GLIPv2: Unifying Localization and Vision-Language Understanding

代码:https://github.com/microsoft/GLIP,但当前仓库里边并没有 glipv2 的代码

HuggingFace 路径:https://huggingface.co/GLIPModel/GLIP/tree/main

出处:NIPS2022 | 华盛顿大学 | Meta | Microsoft | UCLA

时间:2022.10

一、背景

grounding 任务如何理解这个 “grounding”,个人理解来看,这个 grounding 就是将自然语言的单词和图像中特定区域对应起来的任务

视觉基础模型在近来引起了人们很大的兴趣,其能够同时解决多个视觉任务,如图像分类、目标检测、图文理解等

这些任务可以统一如下:

定位任务:目标检测、语义分割Vision-Language 理解任务:图文问答、图像检索等

现在比较流行的训练方法是先训练定位任务,再训练 VLP,也就是两阶段的预训练策略

但这样无法将两个任务联合训练,如何将这两个任务联合起来让其互利互惠很重要

定位任务:仅仅是视觉任务,需要很精细的输出VL 理解任务:更关注两个模态之间的融合,需要更高级的语义信息输出

这两种任务其实是不同的:

定位任务:需要更精细的输出(定位框或 mask)VL 任务:需要更高级的语义输出(回答问题或图像描述)

之前的方法是怎么进行两个任务统一的:

使用共享的 low-level visual encoder ,定位任务就只是 vision-only 的任务,无法从丰富语义信息的 VL 数据中获益后面接两个并行的高级分支分别进行定位和 VL 理解

GLIPv2 是什么:grounded VL understanding 模型,是 localization 和 VL understanding 任务的统一模型

1、 grounded VL understanding = Localization + VL understanding

Localization:目标检测(language input 就是所有类别合集)、实例分割、VL groundingVL understanding:VL grounding、视觉问答、图像描述生成可以看出 VL grounding 同时涉及到了定位任务和图像理解任务

2、A stronger VL grounding task:inter-image region-word 对比学习(跨 image 的对比学习)

GLIP 中提出了 phrase grounding 任务作为预训练任务,作者认为这个任务比较简单而且没有利用到全部信息。

如图 1 所示的 VL grounding 任务,phrase grounding 任务只需要模型能够将给定的图片区域匹配到 text 中的一个单词即可(如 green, pink striped, or plain white umbrella),也就是相当于 1-in-3 选择任务,是比较简单的。因为这个 sentence 中只涉及到了三个颜色,没有涉及到其他颜色(如绿色、黑色、黄色等),目标物体只涉及到了雨伞,没有其他类别。在对比学习层面,phrase grouding 任务只有两个 negative,其他的 negative 并没有输入到该对比学习中。

在 GLIPv2 中,作者引入了一个新的 inter-image region-word (inter 表示图像间)对比训练任务,能从同一 batch 的不同句子中拿到潜在的负样本,让 GLIPv2 能够学习更有区分力的 region-word 特征,并且能够提高下游任务的效果

3、GLIPv2 可以让定位任务和 VL 理解任务互惠互利

如表 2 所示,展示了单个 GLIPv2 模型能够达到接近 SOTA 的效果受益于语义信息丰富的 image-text 标注数据,GLIPv2 展示了很强的零样本和少样本迁移到开放世界的目标检测和语义分割任务的能力GLIPv2 具有 language-guided 的检测和分割能力,并且获得了很好的效果在 grounding model 内部,GLIPv2 能够让 VL 理解模型有很强的 grounding 能力。

4、GLIPv2 和 GLIP 的不同

GLIP 展示了 grounded pre-training 提升定位的能力,GLIPv2 进一步证明了 grounded pre-training 能够提升 VL 理解能力,并且能将两个任务进行统一GLIPv2 引入了 inter-image region-word 对比学习 loss,能够提供更强的 grounding 能力

二、方法

Unifying Localization and VL Understanding

2.1 A Unified VL Formulation and Architecture

GLIPv2 统一结构的中心思想:

classification-to-matching trick该 trick 的目标:将固定类别的分类问题重构为了一个开集(open-vocabulary)vision-language 匹配问题一个很好的例子就是 CLIP 将分类任务重构为了 image-text 匹配任务,可以让模型从大量的 image-text 数据中学习到很多,并且提升在开集分类任务上的零样本迁移能力GLIPv2 如何实现:将 vision model 中的语义分类的 linear layer 替换为 vision-language matching dot-product layer

如图 1 所示,GLIPv2 基于通用的框架将 VL 结构进行了统一:

dual encoder:

E

n

c

V

Enc_V

EncV​、

E

n

c

L

Enc_L

EncL​ fusion encoder:

E

n

c

V

L

Enc_{VL}

EncVL​ 模型输入:image-text pair (Img, Text) 抽取特征:

(

O

o

,

P

o

)

(O^o, P^o)

(Oo,Po) 表示 fusion 之前的特征,

(

O

,

P

)

(O, P)

(O,P) 表示 fusion 之后的特征

1、Vision-Language understanding task

Arch II 是常见的 VL understanding 任务的框架:

输入跨模态融合后的特征表达

(

O

,

P

)

(O, P)

(O,P),直接相加如 GLIPv2 在 text feature P 之前添加了一个 two-layer MLP ,作为 masked language modeling(MLM)head,来进行 MLM pre-training

2、(Language-guided) object detection and phrase grounding

GLIPv2 和 GLIP 使用的相同,使用 classification-to-matching 方法来对 detection 和 grounding 任务进行统一对于 detection:使用

S

g

r

o

u

n

d

=

O

P

T

S_{ground}=OP^T

Sground​=OPT 来代替 class logits

S

c

l

s

=

O

W

T

S_{cls}=OW^T

Scls​=OWT,text feature P 是经过 language encoder 编码后的文本特征。detection 任务的 text input 是 label 组成的句子phrase grounding:text input 是自然描述语言

3、(Language-guided) instance segmentation and referring image segmentation

得到检测结果后,添加了实例分割 head

2.2 GLIPv2 pre-training

GLIPv2 的训练包括三个 pre-training loss:

1、phrase grounding loss:

L

g

r

o

u

n

d

L_{ground}

Lground​,由两部分组成:

L

l

o

c

L_{loc}

Lloc​:定位 loss,这里的定位使用的是 anchor-based ATSS-Retinanet 的方法,即每个 gt 选择保留 9 个 anchor,iou > [均值+方差] 的 anchor 为正,如果一个 anchor 对应到了多个 gt 上,则将其分配给 iou 最大的 gt,定位 loss 使用的是 GIoU loss

L

i

n

t

r

a

L_{intra}

Lintra​: 单个图像内的 intra-image region-word alignment loss,也就是每个 region 的语义分类 loss,给定一个 image-text pair (Img, Text),使用的是融合后的特征来计算的,

L

i

n

t

r

a

L_{intra}

Lintra​ 如下:

其中

O

P

T

OP^T

OPT 是 image region 和 word token 的相似性得分,这里相似性得分在代码中是使用 torch.matmul 来实现的,该方法是矩阵乘法,维矩阵乘法就是把 batch 那个维度拿出来,每个 batch 内分别做矩阵乘法,表示的含义是图像的每个像素的特征256维(行方向)和语言的每个单词的特征256维(列方向)进行相乘然后相加,得到每个像素特征和每个单词特征的相关性

T

T

T 是 target affinity matrix,由 gt annotations 确定

O

P

T

OP^T

OPT 的维度为 [4, 18134, 256],T 的维度也为 [4, 18134, 256],这里 18134 表示 anchor 的个数,也就是每个 anchor 对应了一个特征编码,每个特征编码都是由 0 和 1 组成的,例如:[0,0,0,…,1],只有最后一位为 1 的特征表示负样本对儿。这里的

l

o

s

s

loss

loss 在两阶段检测器中一般是 cross-entropy loss,在单阶段检测器中一般是 focal loss图像间的 region-word 对比学习能力比较弱,因为可以捕捉的可用的 phrases 很有限GLIP 中通过添加一些 negative sentence 来让网络接收到更多 negative phrases,但由于 token 的长度限制为 256,也只能增加很少的 negative sentences

2、Inter-image region-word contrastive loss:

L

i

n

t

e

r

L_{inter}

Linter​,图像间的 region-word 对比学习,使用的是融合前的特征来计算的,之所以使用融合前的特征,是因为作者觉得在融合后的特征中,已经学习到了 paired 的信息,模型可以很快的从匹配错误的 image/text 对儿中找到 negative。而且,不能很简单的将没匹配的 paris 当做负样本对儿,而是在非对角线的位置使用预测的 label 作为真值 T,也就是说如果一个 region 被标注为 person,那么它应该和所有包含 person 的短语都是 positive pairs

在 GLIPv2 中,作者提出了从同一 batch 中的其他 image-text pairs 来提取 negative examples 的方法,这样能提高 negative examples 到 1000 倍,且不会带来很多额外的计算量

inter-image region-word contrastive loss 如下:

3、masked language modeling loss:

L

m

l

m

L_{mlm}

Lmlm​

mlm loss 是 BERT 中提出的 loss,也叫掩码语言建模,其目的是提供一个包含特殊标记 [MASK] 的序列,然后让模型去预测掩码位置本来的词语,如提供 “我[MASK]你”,预测 MASK 位置的词语,这个任务会让模型同时关注 MASK 左右的上下文信息,为下游任务如问答任务提供很好的基础。

预训练方式:同时使用 detection 和 paired-image-text data 进行 预训练

预训练数据:image-text-target triplet format (Img,Text,T)target affinity matrix T 包括 box-label localization 标注结果

分割头的两级预训练:

GLIPv2 支持两阶段的 language-guided 分割头的预训练

2.3 将 GLIPv2 迁移到 Localization 和 VL task

1、一个模型结构适用所有任务

GLIPv2 可以通过 fine-tuning 来迁移到很多下游任务:

检测和分割任务:不需要 task-specific head ,因为结构本来就可以实现检测和分割VL task:

对 VQA,需要增加一个分类头对 caption generation:使用 unidirectional language modeling loss 训练

2、一个权重参数适用所有任务

如表 2 所示

3、Grounded VL understanding

GLIPv2 如何实现 VL understanding 呢?

作者首先使用预训练好的 GLIP 模型来将下游的数据转换为 grounded VL data然后,同时训练下游任务 head 和 grounding head

对 VQA,模型被训练来预测 answer对 captioning,模型被训练预测给定 word 的下一个 word

clearer illustration:

三、结果

模型结构:

E

n

c

V

Enc_V

EncV​: image encoder( Swin Transformer)

E

n

c

L

Enc_L

EncL​:text transformer

E

n

c

V

L

Enc_{VL}

EncVL​:fusion encode,Dynamic Headinstance segmentation head:Hourglass network

模型尺寸:

GLIPv2-T:Swin-Tiny 和 BERT-Base 作为两个 encoder,数据:O365、GoldG 、Cap4M(4M image-text pairs collected from the web with boxes generated by GLIP-T [41])GLIPv2-B:Swin-Base 和 pre-layernorm text transformer [18] 作为两个 encoder,数据:

FiveODs (2.78M data)GoldG as in MDETR [30]CC15M+SBU, 16M public image-text data with generated boxes by GLIP-L [41]Segmentation head 的预训练:模型其他参数都冻结,只基于 COCO、 LVIS 、PhraseCu 训练 head GLIPv2-H:Swin-Huge 和 pre-layernorm text transformer [18] 作为两个 encoder,数据:

FiveODs (2.78M data)GoldG as in MDETR [30]CC15M+SBU, 16M public image-text data with generated boxes by GLIP-L [41]Segmentation head 的预训练:模型其他参数都冻结,只基于 COCO、 LVIS 、PhraseCu 训练 head

3.1 所用数据集的介绍

1、目标检测或 phrase grounding

COCO:目标检测常用数据集,有 80 个标注类别,每张图平均 7.3 个标注框 Flickr30k-entities:用于训练 phrase grounding,给定一个或多个 phrase,都是相关的, phrase grounding 任务是根据给定的 phrase,输出一系列检测框

Flickr30k 数据是一张图对应 5 个描述,标注示例如下,官网链接

image caption

0 1000092795.jpg#0 Two young guys with shaggy hair look at their ...

1 1000092795.jpg#1 Two young , White males are outside near many ...

2 1000092795.jpg#2 Two men in green shirts are standing in a yard .

3 1000092795.jpg#3 A man in a blue shirt standing in a garden .

4 1000092795.jpg#4 Two friends enjoy time spent together .

5 10002456.jpg#0 Several men in hard hats are operating a giant...

6 10002456.jpg#1 Workers look down from up above on a piece of ...

7 10002456.jpg#2 Two men working on a machine wearing hard hats .

8 10002456.jpg#3 Four men on top of a tall structure .

9 10002456.jpg#4 Three men on a large rig .

10 1000268201.jpg#0 A child in a pink dress is climbing up a set o...

11 1000268201.jpg#1 A little girl in a pink dress going into a woo...

12 1000268201.jpg#2 A little girl climbing the stairs to her playh...

13 1000268201.jpg#3 A little girl climbing into a wooden playhouse .

14 1000268201.jpg#4 A girl going into a wooden building .

15 1000344755.jpg#0 Someone in a blue shirt and hat is standing on...

16 1000344755.jpg#1 A man in a blue shirt is standing on a ladder ...

17 1000344755.jpg#2 A man on a ladder cleans the window of a tall ...

18 1000344755.jpg#3 man in blue shirt and jeans on ladder cleaning...

19 1000344755.jpg#4 a man on a ladder cleans a window

20 1000366164.jpg#0 Two men , one in a gray shirt , one in a black...

21 1000366164.jpg#1 Two guy cooking and joking around with the cam...

22 1000366164.jpg#2 Two men in a kitchen cooking food on a stove .

23 1000366164.jpg#3 Two men are at the stove preparing food .

24 1000366164.jpg#4 Two men are cooking a meal .

25 1000523639.jpg#0 Two people in the photo are playing the guitar...

26 1000523639.jpg#1 A man in green holds a guitar while the other ...

27 1000523639.jpg#2 A man is fixing the guitar players costume .

28 1000523639.jpg#3 a guy stitching up another man 's coat .

29 1000523639.jpg#4 the two boys playing guitar

... ... ...

158885 996962407.jpg#0 a man with a wheelbarrow is standing outside a...

158886 996962407.jpg#1 A man in a silver rain poncho standing next to...

158887 996962407.jpg#2 A man in a silver raincoat standing outside by...

158888 996962407.jpg#3 A man in a raincoat stands outside a house in ...

158889 996962407.jpg#4 A man in a raincoat is standing in the rain .

158890 997338199.jpg#0 Woman writing on a pad in room with gold , dec...

158891 997338199.jpg#1 A woman standing near a decorated wall writes .

158892 997338199.jpg#2 The walls are covered in gold and patterns .

158893 997338199.jpg#3 a woman behind a scrolled wall is writing

158894 997338199.jpg#4 A person stands near golden walls .

158895 997722733.jpg#0 A person in a red shirt climbing up a rock fac...

158896 997722733.jpg#1 A rock climber practices on a rock climbing wa...

158897 997722733.jpg#2 A man in a pink shirt climbs a rock face

158898 997722733.jpg#3 A man is rock climbing high in the air .

158899 997722733.jpg#4 A rock climber in a red shirt .

158900 997876722.jpg#0 Two male construction workers are working on a...

158901 997876722.jpg#1 Two workmen with a wheelbarrow for mixing ceme...

158902 997876722.jpg#2 Men in orange and yellow clothing lean over a ...

158903 997876722.jpg#3 Men are working on pouring concrete outside of...

158904 997876722.jpg#4 Fruits stationed by a dusty old window .

158905 99804383.jpg#0 An older busker in glasses plays an Eastern st...

158906 99804383.jpg#1 This is a man in front of a store performing w...

158907 99804383.jpg#2 A older Asian man is playing an instrument in ...

158908 99804383.jpg#3 An elderly man sits outside a storefront accom...

158909 99804383.jpg#4 An elderly gentleman playing a musical instrum...

158910 998845445.jpg#0 A man in shorts and a Hawaiian shirt leans ove...

158911 998845445.jpg#1 A young man hanging over the side of a boat , ...

158912 998845445.jpg#2 A man is leaning off of the side of a blue and...

158913 998845445.jpg#3 A man riding a small boat in a harbor , with f...

158914 998845445.jpg#4 A man on a moored blue and white boat with hil...

ODinW:

2、instance segmentation、referring image segmentation

LVIS: Large Vocabulary Instance Segmentation dataset,包括超过 1000 个类别,数据和 COCO 一样,多标注了一些类别PhraseCut:标注 referring expression 提及的 segmentation mask,这些 expression 包括很多的词汇、属性、目标相关性

3、VQA 和 image captioning

VQA:需要模型为给定的图像和问题生成回答,使用的是 VQA2.0 数据集,使用的图像是 COCO,作者将 VQA 当做一个分类问题,有 3129 个候选回答COCO image captioning:图文生成描述是为输入图像生成一个文本描述,作者使用的是 COCO captioning 数据集

3.2 训练细节

预训练使用的数据集有三种,如表 8 所示:

目标检测数据集:object365、openimages、coco、visual genome、ImageNetBoxesgrounding 数据集:GoldG(0.8M 大小的 MDETR 组织的数据,包括Flick30k、VG Caption、GQA)caption 数据集:Cap4M,是 4M 的 image-text pairs,从网络获取的,使用 GLIP-T 生成的 box;还有 CC (Conceptual Captions) + SBU (with 1M data) 数据集

3.3 One set of model parameters for all

3.4 GLIPv2 as a strong few-shot learner

3.5 Analysis

1、pre-training losses

2、pre-training data

3、Grounded VL understanding

速度:

好文阅读

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: