|
发布时间: 2022-09-16 |
多媒体分析与理解 |
|
|
收稿日期: 2022-01-20; 修回日期: 2022-05-05; 预印本日期: 2022-05-12
基金项目: 科技创新2030-“新一代人工智能”重大项目(2020AAA0109301);国家自然科学基金项目(62161013,62162029);江西省重点研发计划项目(20203BBE53033)
作者简介:
姜文晖,1989年生,男,讲师,主要研究方向为计算机视觉、跨媒体分析、深度学习。E-mail: jiang1st@bupt.cn
占锟,男,硕士研究生,主要研究方向为计算机视觉与深度学习。E-mail: zhankun1008@gmail.com 程一波,男,硕士研究生,主要研究方向为跨媒体分析。E-mail: 592891032@qq.com 夏雪,女,讲师,主要研究方向为图像处理和语义分割。E-mail: yeziandkuma@qq.com 方玉明,通信作者,男,教授,主要研究方向为计算机视觉、多媒体信号处理、视觉质量评估。E-mail: fa0001ng@e.ntu.edu.sg *通信作者: 方玉明 fa0001ng@e.ntu.edu.sg
中图法分类号: TP391
文献标识码: A
文章编号: 1006-8961(2022)09-2775-13
|
摘要
目的 注意力机制是图像描述模型的常用方法,特点是自动关注图像的不同区域以动态生成描述图像的文本序列,但普遍存在不聚焦问题,即生成描述单词时,有时关注物体不重要区域,有时关注物体上下文,有时忽略图像重要目标,导致描述文本不够准确。针对上述问题,提出一种结合多层级解码器和动态融合机制的图像描述模型,以提高图像描述的准确性。方法 对Transformer的结构进行扩展,整体模型由图像特征编码、多层级文本解码和自适应融合等3个模块构成。通过设计多层级文本解码结构,不断精化预测的文本信息,为注意力机制的聚焦提供可靠反馈,从而不断修正注意力机制以生成更加准确的图像描述。同时,设计文本融合模块,自适应地融合由粗到精的图像描述,使低层级解码器的输出直接参与文本预测,不仅可以缓解训练过程产生的梯度消失现象,同时保证输出的文本描述细节信息丰富且语法多样。结果 在MS COCO(Microsoft common objects in context)和Flickr30K两个数据集上使用不同评估方法对模型进行验证,并与具有代表性的12种方法进行对比实验。结果表明,本文模型性能优于其他对比方法。其中,在MS COCO数据集中,相比于对比方法中性能最好的模型,BLEU-1(bilingual evaluation understudy)值提高了0.5,CIDEr(consensus-based image description evaluation)指标提高了1.0;在Flickr30K数据集中,相比于对比方法中性能最好的模型,BLEU-1值提高了0.1,CIDEr指标提高了0.6;同时,消融实验分别验证了级联结构和自适应模型的有效性。定性分析也表明本文方法能够生成更加准确的图像描述。结论 本文方法在多种数据集的多项评价指标上取得最优性能,能够有效提高文本序列生成的准确性,最终形成对图像内容的准确描述。
关键词
图像描述; 注意力机制; Transformer; 多层级解码; 动态融合; 门机制
Abstract
Objective Image captioning aims at automatically generating lingual descriptions of images. It has a wide variety of applications scenarios like image indexing, medical imaging reports generation and human-machine interaction. To generate fluent sentences of the gathered information all, an algorithm of image captioning is called to recognize the scenes, entities and their relationships of the image. A deep encoder-decoder framework has been developed to resolve the issue past decades. The convolutional neural networks based (CNNs-based) encoder extracts feature vectors of the image and the recurrent neural networks based (RNNs-based) decoder generates image descriptions. Recent image captioning is driven by the development of attention mechanism. It improves the performance of image captioners via attending to informative image regions. Most attention models are based on the previously generated words as inputs when the next attending phases are predicted. Due to the lack of relevant textual guidance, most existing works are challenged of "attention defocus", i.e., they fail to concentrate on correct image regions when generating the target words. As a result, contemporary models are prone to "hallucinating" objects, or missing informative visual clues, and make attention model be less interpretable. So, we facilitate an integrated hierarchical architecture and dynamic fusion strategy. Method The estimated word provides useful knowledge for predicting more grounded regions, although it is hard to localize the correct regions from the previously generated words at once. To refine the attention mechanism and improve the predicted words, we design a hierarchical architecture based on a series of captioning decoders. Our architecture is a hierarchical variant extended from the conventional encoder-decoder framework. Specifically, the first step is focused on the standard image captioning models, which generates a coarse description as a draft. To ground correct image regions with proper generated words, the latter one takes the outputs from the early decoder. Since the former decoder provides more predictable information to the target word, the attention accuracy is improved in latter decoders. To ground the final predicted words properly in this hierarchical architecture, attended regions from the early decoder can be well validated by the later decoders in a coarse-to-fine manner. Furthermore, we carry out a dynamic fusion strategy to aggregate the coarse-to-fine predictions from different decoders. Noteworthy, our manipulated gating mechanism is focused on the contributions from different decoders to the final word prediction. Differentiated from the previous gating mechanism managing the weight from each pathway, the contributions are jointed with a softmax schema from each decoder, which incorporates contextual information from all decoders to estimate the overall weight distribution. The dynamic fusion strategy provides rich fine-grained image descriptions and alleviates the problem of "vanishing gradients", which makes the learning of the hierarchical architecture easier. Result Our method is evaluated on Microsoft common objects in context (MS COCO) and Flickr30K, which are the common benchmark for image captioning. The MS COCO dataset is composed of 120 k images, and the Flickr30K includes 31 k examples. Each image of both datasets is provided with five descriptions. The model is trained and tested using the Karpathy splits. The quantitative evaluation metrics are related to bilingual evaluation understudy (BLEU), metric for evaluation of translation with explicit ordering (MEREOR), and consensus-based image description evaluation (CIDEr). We compare the performance of our model with 12 current methods. On MS COCO, our analysis is optimized by 0.5 and 1.0 of each beyond BLEU-1 and CIDEr. Our result achieves a CIDEr of 69.94 on Flickr30K. Compared to the baseline method (Transformer), our performance is optimized 4.6 of CIDEr on MS COCO and 3.8 on Flickr30K, which verifies that our method improves the accuracy of the predicted sentences effectively. In addition, our qualitative results demonstrate that the proposed method provides rich fine-grained image descriptions in comparison with other methods. Our method describes the number of appeared objects precisely when they belong to the same category. Our method could also describe small objects accurately. To further verify the effectiveness of the proposed hierarchical architecture, we visualize the attention mechanism and it shows that our method attends to discriminative parts of the target objects. In contrast, the baseline method may focus on irrelevant backgrounds, which leads to false predictions straightforward. Conclusion Our research is focused on a hierarchical architecture with dynamic fusion strategy for image captioning. The hierarchical architecture consists of a sequence of captioning decoders that refine the attention mechanism. To generate final sentence with rich fine-grained information, the dynamic fusion strategy aggregates different decoders. The ablation study demonstrates the effectiveness of each module in our proposed network. Our optimized results are demonstrated through the comparative experiments on MS COCO and Flickr30K datasets.
Key words
image captioning; attention mechanism; Transformer; hierarchical decoders; dynamic fusion; gating mechanism
0 引言
图像描述任务(image captioning)旨在对一幅输入图像自动生成完整的自然语言描述。图像描述任务可以应用于人机对话、盲人导航以及医疗影像报告生成等场景,具有巨大的应用前景和研究价值。为生成完整的句子描述,该任务需要全面建模图像中物体的类别、属性以及与场景的交互关系等丰富信息,并将这些内容通过组织语言的方式流畅地进行描述。图像描述任务是计算机视觉和自然语言处理交叉领域的挑战性问题。
早期研究首先分析图像视觉内容,即检测图像中的物体及其属性,分析物体间的相对关系,并将这些内容映射为单词或短语等描述信息(Farhadi等,2010)。然后通过自然语言技术,例如句子模板或语法规则,将这些基本描述单元转化为完整句子进行图像描述(Kuznetsova等,2014)。然而模板和语法规则较大地限制了图像描述的多样性和独特性,且对数据集和人工设计的依赖性较强。
得益于深度学习(deep learning)的发展,大量研究工作将深度学习应用于自动图像描述领域(Wan等,2022)。基于深度学习的主要框架是“编码器—解码器”模型。其中,编码器分析图像的语义内容,形成一组图像特征向量;解码器输入这些特征向量,通过语言生成模型输出完整的图像描述。相比于传统的方式,基于深度学习的模型脱离了具体的本文规则,能够生成变长、多样化的图像描述,并在描述准确性方面具有压倒性优势。因此,基于深度学习的方法是当前自动图像描述领域的主流模型。
注意力机制(attention mechanism)广泛融入编码器—解码器框架(Xu等,2015),其主要优势在于生成描述语句的每个字符时,可以动态地改变输入特征的权重以指导文本生成,极大提高了图像描述模型的准确性。然而,通过可视化分析和量化分析,发现注意力机制普遍存在不聚焦问题(Liu等,2017)。具体地,在生成描述单词时,注意力机制有时关注在物体不重要区域,例如人的身体,从而错误预测人的性别(Hendricks等,2018);有时关注物体背景,导致幻想出与目标相关但未实际出现的物体(Rohrbach等,2018);有时忽略图像中重要目标,导致描述中缺少重要信息。注意力机制的不聚焦问题严重影响了模型的可解释性。导致该问题的原因为:1)预测
为解决以上问题,本文提出一种结合多层级解码器和动态融合机制的图像描述模型。该模型是对标准的编码器—解码器结构的扩展,出发点是虽然通过
为验证模型的有效性,在MS COCO(Microsoft common objects in context)(Lin等,2014)和Flickr30K(Plummer等,2015)数据集上进行实验。结果表明,本文设计的模型效果显著,在BLEU(bilingual evaluation understudy)、METEOR(metric for evaluation of translation with explicit ordering)和CIDEr(consensus-based image description evaluation)等多项评价指标上优于其他对比方法。定性分析结果也验证了本文模型能够生成更加准确的图像描述。
1 相关工作
自动图像描述任务主要以编码器—解码器为主要架构。编码器提取输入图像的语义特征,解码器对编码器的输出结果进行处理,形成完整的文本描述。鉴于深度神经网络的灵活性和较强的建模能力,当前的主要工作是基于深度神经网络分别对编码器和解码器的结构进行建模(谭云兰等,2021)。编码器广泛采用卷积神经网络(convolutional neural network,CNN),例如使用ResNet(residual network)和VGG(Visual Geometry Group network)等深层网络进行图像的特征表示(汤鹏杰等,2017)。解码器广泛采用循环神经网络(recurrent neural network,RNN)和长短时记忆网络(long short-term memory,LSTM)对较长的文本序列进行关联建模(罗会兰和岳亮亮,2020)。基于深度神经网络的结构不依赖文本规则,生成的图像描述语法灵活。
1.1 注意力机制
随着注意力机制在机器翻译领域的广泛应用,越来越多的研究将其引入编码器—解码器结构。Xu等人(2015)将注意力机制引入自动图像描述任务,提出软注意力机制(soft attention),通过隐状态估算图像中不同空间特征的权重,使每一时刻的文本预测都能自适应地关注图像中的不同区域,从而提高下一时刻文本预测的准确性。然而,注意力机制学习的权重在模型中是隐变量,缺少显式的监督信息指导,导致注意力机制普遍存在离焦问题(Liu等,2017)。为解决该问题,Lu等人(2017)提出并不是每个本文都对应具体的图像区域,对于部分虚词和注意力机制不置信的情况,引入视觉信息将误导文本预测的结果。因此提出一种“哨兵”模型,当注意力机制的输出结果不足以对预测的单词提供有效的指导信息时,依赖语言模型进行文本预测。Huang等人(2019a)通过分析注意力机制预测的结果与输入单词的相关性,提取可靠信息对图像编码特征和输入词向量进行加权,以修正注意力机制的输出结果。除此之外,Zhou等人(2019)额外引入名词在图像中的位置信息,显式地监督注意力机制的学习。然而,收集描述中的名词在图像对应位置的标注信息引入了额外的标注成本。Zhou等人(2020)提出基于图像和文本的匹配模型进行知识蒸馏,以提高注意力机制的定位能力,降低了监督信息的标注成本。Ma等人(2020)提出对预测的单词重建作为对注意力机制的规则化,以避免注意力机制关注不相关的图像区域。Zhang等人(2021)通过视觉图模型和语言图模型的对齐操作提高注意力机制的准确性。这些方法都一定程度地改善了注意力机制,但准确性远低于预期效果。
1.2 语言生成模型
语言生成模型旨在预测句子中文本生成的概率。当前,图像描述任务中的语言模型可以分为两类,一类是基于LSTM的模型(Vinyals等,2015),主要结构基于单层LSTM或多层LSTM进行序列预测;另一类是基于Transformer的模型(Vaswani等,2017)。
LSTM可以对时间序列进行关联建模,为生成复杂的文本序列奠定了基础。在该方案中,图像的特征编码作为LSTM的第1个词向量输入,其后每一时刻以前一时刻预测的文本作为词向量的输入,预测下一时刻的输出单词(Vinyals等,2015)。然而,该过程较大程度地依赖语言模型,忽视了图像的视觉信息。Gu等人(2018)设计了一种双层LSTM序列生成器,第1层LSTM生成粗略的图像描述,第2层LSTM以第1层LSTM的输出作为输入,生成更加准确的图像描述。Huang等人(2019b)进一步改进多层LSTM结构,针对LSTM预测不够准确的问题,提出基于每层输出结果的置信度,动态决定是否需要引入更深的LSTM修正预测结果。Guo等人(2020)提出先通过标准的LSTM模型输出完整的图像描述,随后结合完整描述的上下文对每个单词进行修正。然而,LSTM对较长的序列建模能力不足。同时,LSTM的训练过程是串行的,导致模型训练较为耗时。
Transformer的模型结构广泛用于自然语言处理领域(Vaswani等,2017),并逐渐应用于自动图像描述任务。标准的Transformer编码器采用多层的自注意力操作(self-attention)实现图像的上下文关联。解码器对生成的单词采用掩膜化的自注意力操作(masked self-attention),建模文本序列的上下文信息,同时采用跨模态注意力模块(cross attention)动态地更新图像的特征编码,以输出正确文本。同时,解码器通过自堆叠形成更加鲁棒的词汇预测。然而,堆叠增加了模型的深度,伴随而来的梯度消失使模型训练困难。
本文对Transformer的结构进行扩展,提出一种新颖的多层级解码器动态融合的图像描述模型。该模型通过解码器级联实现注意力机制的渐进式精化,并设计动态融合策略,自适应地融合由粗到精的文本信息,提高文本描述的准确性。同时,缓解了梯度消失现象,使模型训练更加稳定。
2 模型设计
本文模型的整体结构如图 1所示。模型采取编码器—解码器架构。对于输入图像I,其对应的语言描述为
2.1 标准解码器结构
本文提出的解码器基本结构是标准Transformer解码器(Vaswani等,2017),包含1个跨模态注意力模块和1个文本生成模块。跨模态注意力模块通过基于点乘的注意力机制(dot-product attention)建模文本与图像之间的跨模态关联。具体地,该机制以查询矩阵
$ \boldsymbol{\alpha}=A(\boldsymbol{Q}, \boldsymbol{K})=f_{\text {softmax }}\left(\frac{\boldsymbol{Q} \boldsymbol{K}^{\mathrm{T}}}{\sqrt{d}}\right) $ | (1) |
式中,
$ \boldsymbol{Z}=f_{\text {Attention }}(\boldsymbol{Q}, \boldsymbol{K}, \boldsymbol{V})=A(\boldsymbol{Q}, \boldsymbol{K}) \boldsymbol{V} $ | (2) |
式中,
$ \begin{gathered} \boldsymbol{Z}=f_{\text {Attention }}\left(\boldsymbol{W}_q \boldsymbol{Y}, \boldsymbol{W}_k \boldsymbol{X}, \boldsymbol{W}_v \boldsymbol{X}\right) \\ \boldsymbol{F}=F F N(\boldsymbol{Z}) \end{gathered} $ | (3) |
式中,
$ \boldsymbol{Y}=S A_{\text {mask }}\left(\tilde{y}_{1: t-1}\right) $ | (4) |
式中,
最后,基于生成的加权图像特征编码,预测输出单词的概率分布,以预测该时刻的目标单词。具体为
$ \tilde{y}_t \sim f_{\text {softmax }}\left(\boldsymbol{W}_e \boldsymbol{F}\right) $ | (5) |
式中,
由于
2.2 级联解码器结构
本文提出的解码器级联结构如图 2所示。首先,通过标准的解码器,基于
$ \boldsymbol{Y}^s=S A_{\text {mask }}\left(\left[\tilde{y}_{1: t-1}, \tilde{y}_t^{s-1}\right]\right) $ | (6) |
式中,[·, ·] 是拼接操作。对于第
$ \begin{gathered} \bf{Z}^s=f_{\text {Attention }}\left(W_q \boldsymbol{Y}^s, W_k \boldsymbol{X}, W_v \boldsymbol{X}\right) \\ \boldsymbol{F}^s=F F N\left(\boldsymbol{Z}^s\right) \\ \tilde{y}_t^s \sim f_{\text {softmax }}\left(\boldsymbol{W}_e^s \boldsymbol{F}^s\right) \end{gathered} $ | (7) |
高层解码器相比于标准的单层解码器,引入了额外的文本信息
2.3 多层级解码器自适应融合
解码器级联结构包含了文本由粗到精的预测结果,蕴含了描述图像内容的丰富细节。为进一步提高模型预测的准确性,本文提出一种自适应融合结构,以最大化利用不同层级解码器的输出结果。具体地,基于门机制(gating mechanism),动态地预测权重
$ \begin{array}{c} {c^s} = {\mathit{\boldsymbol{W}}_s}\left[ {{\mathit{\boldsymbol{Y}}^s}, {\mathit{\boldsymbol{F}}^s}} \right]\\ \mathit{\boldsymbol{\beta }} = {f_{{\rm{softmax }}}}\left({\left[ {{c^1}, {c^2}, \cdots, {c^S}} \right]} \right) \end{array} $ | (8) |
式中,[·, ·] 是拼接操作,
随后,自适应融合模块基于已学习的权重对不同层的注意力特征进行集成。即
$ \boldsymbol{F}_e=\sum\limits_{s=1}^S \beta^s \boldsymbol{F}^s $ | (9) |
最后,基于集成后的特征预测最终的输出单词。具体为
$ \tilde{y}_t \sim \boldsymbol{p}=f_{\text {softmax }}\left(\boldsymbol{W}_e \boldsymbol{F}_e\right) $ | (10) |
动态融合结构能为多层级解码器更好地引入监督信息并缓解梯度消失。以最容易形成梯度消失现象的第1级解码器为例,设模型学习的损失函数为
$ \frac{\partial L}{\partial \theta^1}=\frac{\partial L}{\partial \boldsymbol{F}_e}\left[\sum\limits_{s=1}^S\left(\frac{\partial \beta^s}{\partial \theta_1} \boldsymbol{F}^s+\frac{\partial \boldsymbol{F}^s}{\partial \theta_1} \beta^s\right)\right] $ | (11) |
由式(11)可见,梯度包含
以3层解码器为例,本文提出的级联解码器与其他多层解码器结构相比,主要区别如图 4所示。图中,E代表标准编码器,D代表标准解码器,
2.4 学习策略
本文采用图像自动描述的标准训练方法(Rennie等,2017),将训练过程分为两个阶段。第1阶段对每个时刻生成的单词采用交叉熵损失函数(cross-entropy loss)进行训练,第2阶段采用强化学习对描述生成的模型进行调优。
在以交叉熵损失函数为目标的训练阶段,通过输入真实文本
$ L_{\mathrm{XE}}(\theta)=-\sum\limits_{t=1}^T \log \left(p_\theta\left(y_t \mid y_{1: t-1}\right)\right) $ | (12) |
式中,
为解决该问题,本文以交叉熵损失函数训练得到的
$ L_{\mathrm{RL}}(\theta)=-E_{\tilde{y}_{1: T \sim p_\theta}}\left[r\left(\tilde{y}_{1: T}\right)\right] $ | (13) |
式中,
$ \nabla_\theta L_{\mathrm{RL}}(\theta)=-\frac{1}{N} \sum\limits_{t=1}^T\left(r\left(\tilde{y}_{1: T}\right)-b\right) \nabla_\theta \log \left(p\left(y_t\right)\right) $ | (14) |
式中,
在序列的预测过程中,本文采用集束搜索策略(beam search),即每个时刻从解码器的概率分布中采样概率最大的前k个单词,并在解码过程中始终保留置信度最高的前k个文本序列。最后,将置信度最高的序列作为预测的文本描述。
3 实验结果与分析
3.1 数据集和评估指标
实验在MS COCO(Lin等,2014)和Flickr30K(Plummer等,2015)公开数据集上进行,对图像描述模型进行评价。MS COCO数据集包含123 287幅图像,Flickr30K数据集包含31 783幅图像。两组数据集均涵盖广泛的自然场景,每幅图像均提供5条参考描述。实验采用Karpathy和Li(2015)提出的训练集和测试集划分方法对模型进行训练和评估。对MS COCO数据集,分别取82 783、5 000和5 000幅图像及其描述作为训练集、验证集和测试集。对Flickr30K数据集,分别取29 000、1 000和1 000幅图像及其描述作为训练集、验证集和测试集。
为评估模型生成图像描述的质量,采用BLEU-1、BLEU-4(Papineni等,2002)、METEOR(Banerjee和Lavie,2005)和CIDEr(Vedantam等,2015)等标准的图像描述评估标准验证模型的效果。以上指标分别记为B-1、B-4、M和C。B-1和B-4评价预测语句与参考语句之间1元组和4元组共同出现的程度,衡量预测语句的准确性;METEOR描述句子中连续且顺序相同的文本数量,反映语句的流畅度;CIDEr使用语法匹配测量生成句子与参考语句之间的语义相似性,与人类的主观评价一致。
3.2 实施细节
本文基于深度学习框架Pytorch实现所述模型,模型的训练和测试均使用2080TI GPU。在图像的编码器部分,采用Jiang等人(2020)的方法抽取图像的网格特征,其中网格大小为7 × 7,每个特征表示为2 048维的向量。文本的编码采用标准的词嵌入模型(Cornia等,2020)。模型的实现细节中,本文参照Transformer的一般设置,将维度
3.3 消融实验与分析
为验证多层级解码器动态融合的有效性,设计4种不同结构与本文提出的模型进行对比。第1种结构(图 4(b))为级联结构中每层解码器独立地设计损失函数,预测过程依靠最终解码器输出的结果,该结构记为堆叠;第2种结构(图 4(c))对不同解码器的输出拼接后预测文本序列,该结构记为拼接;第3种结构将式(8)采用的softmax门函数替换为sigmoid门函数,以独立计算不同解码器的权重;第4种结构将式(8)中的
表 1
不同的解码器结构对图像描述性能的影响
Table 1
Ablation study on different decoder architectures
结构 | 融合模式 | 门函数 | 标量权重 | MS COCO | Flickr30K | |||||||
B-1 | B-4 | M | C | B-1 | B-4 | M | C | |||||
基准 | 基准 | - | - | 80.1 | 38.8 | 28.7 | 127.2 | 71 | 28 | 21.6 | 66.1 | |
对比1 | 堆叠 | - | - | 80.9 | 39.1 | 29.2 | 130.4 | 71.4 | 29.4 | 22 | 65.6 | |
对比2 | 拼接 | - | - | 81 | 39.7 | 29.1 | 130.2 | 72.1 | 29.5 | 21.9 | 65.9 | |
对比3 | 级联 | sigmoid | √ | 80.1 | 38.9 | 29.3 | 130.1 | 73.1 | 31.1 | 22.4 | 69.8 | |
对比4 | 级联 | softmax | - | 81.1 | 39.7 | 29.3 | 130.8 | 70.4 | 28.5 | 21.7 | 62 | |
本文 | 级联 | softmax | √ | 81 | 38.9 | 29.3 | 131.8 | 73.5 | 31 | 22.7 | 69.9 | |
注:加粗字体表示各列最优结果。“-”表示不添加函数,“√”表示添加对应函数。 |
从表 1可以看出,相比于堆叠和拼接,自适应加权融合方法在MS COCO和Flickr30K数据集都具有明显优势。具体地,堆叠结构的CIDEr在MS COCO数据集上下降了1.4,在Flickr30K数据集上下降显著,比本文方法低4.3。拼接结构结果相似。在门函数设计方面,采用sigmoid门函数预测不同层解码器的权重使CIDEr在MS COCO数据集上下降了1.3,在Flickr30K数据集上下降了0.06。这意味着通过softmax操作引入不同层解码器的上下文关联对于解码器的权重控制十分重要。最后,对比基于矢量权重的融合方法,标量权重能够显著提高图像描述的准确性。特别地,基于矢量权重的融合方法在Flickr30K数据集上的CIDEr仅为62.0,显著低于基于标量权重的融合方法。原因是矢量权重增加了模型参数量,使预测结果对噪声干扰更加敏感,因此在较小的Flickr30K数据集上性能下降更加明显。
为进一步分析级联结构的有效性,实验对
3.4 对比实验与分析
实验挑选12种代表性方法与本文提出的模型开展定量比较。包括Up-Down(Anderson等,2018)、Transformer(Vaswani等,2017)、M2(meshed-memory Transformer)(Cornia等,2020)、POS-SCAN(part-of-speech enhanced stacked cross attention)(Zhou等,2020)、GVD(grounded video description)(Zhou等,2019)、Stack-Cap(Gu等,2018)、AAT(adaptive attention time)(Huang等,2019b)、RD(ruminant decoding)(Guo等,2020)、CGRL(consensus graph representation learning)(Zhang等,2021)、Cyclical(Ma等,2020)、SOCPK(scene and object category prior knowledge)(汤鹏杰等,2017)和CMFF/CD(cross-layer multi-model feature fusion and causal convolutional decoding)(罗会兰和岳亮亮,2020)。其中,Up-Down和Transformer是基准模型;M2是目前性能最好的图像描述模型;SCAN、CGRL和GVD通过修正注意力机制提高图像描述的准确性;Stack-Cap、RD和Cyclical通过引入解码器级联结构提高图像描述的性能;SOCPK和CMFF/CD通过改善图像的特征表示提高图像描述的准确性。
表 2展示了不同方法在MS COCO和Flickr30K数据集上的对比结果。
表 2
不同方法在MS COCO和Flickr30K测试集的性能比较
Table 2
Comparison of performance among different methods on the MS COCO and Flickr30K test set
模型 | MS COCO | Flickr30K | |||||||
B-1 | B-4 | M | C | B-1 | B-4 | M | C | ||
Up-Down | 79.8 | 36.3 | 27.7 | 120.1 | - | 26.4 | 21.5 | 57.0 | |
Transformer | 80.1 | 38.8 | 28.7 | 127.2 | 71.0 | 28 | 21.6 | 66.1 | |
M2 | 80.5 | 38.9 | 29.2 | 130.8 | 73.0 | 30.9 | 22.4 | 67.7 | |
SOCPK | 71.0 | 28.1 | 23.9 | 88.2 | 62.7 | 21.7 | 19.7 | 43.9 | |
CMFF/CD | 72.1 | 31.0 | 24.6 | 94.6 | 64.6 | 19.7 | 19.1 | 39.5 | |
Cyclical | - | - | - | - | 69.9 | 27.4 | 22.3 | 61.4 | |
GVD | - | - | - | - | 69.9 | 27.3 | 22.5 | 62.3 | |
POS-SCAN | 80.2 | 38 | 28.5 | 126.1 | 73.4 | 30.1 | 22.6 | 69.3 | |
Stack-Cap | 78.6 | 36.1 | 27.4 | 120.4 | - | - | - | - | |
AAT | - | 38.7 | 28.6 | 128.6 | - | - | - | - | |
RD | - | 38.6 | 28.7 | 128.3 | - | 26.8 | 20.5 | 57.0 | |
CGRL | - | - | - | - | 72.5 | 27.8 | 22.4 | 65.2 | |
本文 | 81.0 | 38.9 | 29.3 | 131.8 | 73.5 | 31.0 | 22.7 | 69.9 | |
注:加粗字体表示各列最优结果,“-”表示该方法原文未提供数据。 |
在MS COCO数据集的实验结果表明,本文方法显著改善了基于Transformer的基准模型,同时高于其他对比方法。具体地,对于描述短语重叠率的评估指标,B-1指标比M2提高了0.5,说明本文提出的模型能精确地输出描述图像的单词;对于描述句子流畅程度的指标,M指标相比对比方法中的最好结果也略有改善。对于描述语义相似性的指标,CIDEr提升更显著,相比当前最好的模型M2提高1.0,说明模型能更好地输出与人类主观描述一致的文本序列。对比Transformer、M2、Stack-Cap、AAT和RD在各项指标上的性能,本文方法性能均高于对比方法。值得注意的是,在Transformer和M2结构中,堆叠的参数
在Flickr30K数据集上的实验结果表明,本文模型在较小数据集上能够保持良好描述效果。具体地,相比M2模型,本文方法在CIDEr上提高了2.2。B-1、B-4和M指标也均高于M2。相比引入额外监督信息的SCAN和GVD方法,本文提出的模型在CIDEr指标上分别高出0.6和7.6。以上结果表明,本文提出模型同时关注了图像描述的准确性、流畅性和语义的正确性。
3.5 可视化分析
图 7展示了本文模型与Transformer基准模型在MS COCO测试集上对部分图像的描述对比。整体来看,本文方法能够输出更加准确和丰富的图像描述。例如,图 7第1行,本文模型能够准确预测出猫旁边小物体是a box of donuts,而不是toy;图 7第2行,本文模型能够在同类物体密集出现条件下正确预测量词。为了进一步验证多层次解码器的有效性,本文对跨模态注意力机制进行可视化分析。由图 7(b)可见,Transformer基准模型关注的视觉区域更分散,受背景干扰较大。例如,图 7第1行,注意力机制部分关注于“猫”后方的背景区域,从而对描述“猫”周围环境时造成干扰。对比图 7(c)可见,本文提出的级联解码结构能够准确定位至图像的相关区域,从而生成更加准确的文字描述。以上可视化分析结果从另一角度验证了本文方法的有效性。
4 结论
本文提出了一种结合多层级解码器和动态融合机制的图像描述模型。通过设计解码器级联结构实现注意力机制的渐进式精化。其中,高层级的解码器以低层级解码器的预测结果为输入。由于该输入与预测的目标单词更相关,注意力机制能够更有效地聚焦到图像的关键区域,从而生成更准确的文本序列。此外,设计了一种解码器动态融合策略,根据每级解码器的输出动态地调整输出权重,自适应地融合由粗到精的文本信息,提高图像描述的鲁棒性。同时,动态融合为不同层次解码器引入监督信息,进一步解决了级联结构容易产生的梯度消失现象,使模型训练更加稳定。但是自动图像描述的准确率还有进一步提升空间。下一步工作将尝试改进图像的特征表达以提高图像描述的丰富性,优化图像的视觉特征和语言模型的关联以提高自动图像描述模型的鲁棒性。
参考文献
-
Anderson P, He X D, Buehler C, Teney D, Johnson M, Gould S and Zhang L. 2018. Bottom-up and top-down attention for image captioning and visual question answering//Proceedings of 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City, USA: IEEE: 6077-6086 [DOI: 10.1109/CVPR.2018.00636]
-
Banerjee S and Lavie A. 2005. METEOR: an automatic metric for MT evaluation with improved correlation with human judgments//Proceedings of 2005 ACL Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation and/or Summarization. Ann Arbor, USA: Association for Computational Linguistics: 65-72
-
Cornia M, Stefanini M, Baraldi L and Cucchiara R. 2020. Meshed-memory transformer for image captioning//Proceedings of 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle, USA: IEEE: 10575-10584 [DOI: 10.1109/CVPR42600.2020.01059]
-
Farhadi A, Hejrati M, Sadeghi M A, Young P, Rashtchian C, Hockenmaier J and Forsyth D. 2010. Every picture tells a story: generating sentences from images//Proceedings of the 11th European Conference on Computer Vision. Heraklion, Greece: Springer: 15-29 [DOI: 10.1007/978-3-642-15561-1_2]
-
Gu J X, Cai J F, Wang G and Chen T. 2018. Stack-captioning: coarse-to-fine learning for image captioning//Proceedings of the 32nd AAAI Conference on Artificial Intelligence. New Orleans, USA: AAAI: 6837-6844
-
Guo L T, Liu J, Lu S C, Lu H Q. 2020. Show, tell, and polish: ruminant decoding for image captioning. IEEE Transactions on Multimedia, 22(8): 2149-2162 [DOI:10.1109/TMM.2019.2951226]
-
Hendricks L A, Burns K, Saenko K, Darrell T and Rohrbach A. 2018. Women also snowboard: overcoming bias in captioning models//Proceedings of the 15th European Conference on Computer Vision. Munich, Germany: Springer: 793-811 [DOI: 10.1007/978-3-030-01219-9_47]
-
Huang L, Wang W M, Chen J and Wei X Y. 2019a. Attention on attention for image captioning//Proceedings of 2019 IEEE/CVF International Conference on Computer Vision. Seoul, Korea (South): IEEE: 4633-4642 [DOI: 10.1109/ICCV.2019.00473]
-
Huang L, Wang W M, Xia Y X and Chen J. 2019b. Adaptively aligned image captioning via adaptive attention time//Proceedings of the 33rd International Conference on Neural Information Processing Systems. Vancouver, Canada: Curran Associates, Inc. : 8942-8951
-
Jiang H Z, Misra I, Rohrbach M, Learned-Miller E and Chen X L. 2020. In defense of grid features for visual question answering//Proceedings of 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle, USA: IEEE: 10264-10273 [DOI: 10.1109/CVPR42600.2020.01028]
-
Karpathy A and Li F F. 2015. Deep visual-semantic alignments for generating image descriptions//Proceedings of 2015 IEEE Conference on Computer Vision and Pattern Recognition. Boston, USA: IEEE: 3128-3137 [DOI: 10.1109/CVPR.2015.7298932]
-
Kuznetsova P, Ordonez V, Berg T L, Choi Y. 2014. TreeTalk: composition and compression of trees for image descriptions. Transactions of the Association for Computational Linguistics, 2: 351-362 [DOI:10.1162/tacl_a_00188]
-
Lin T Y, Maire M, Belongie S, Hays J, Perona P, Ramanan D, Dollár P and Zitnick C L. 2014. Microsoft COCO: common objects in context//Proceedings of the 13th European Conference on Computer Vision. Zurich, Switzerland: Springer: 740-755 [DOI: 10.1007/978-3-319-10602-1_48]
-
Liu C X, Mao J H, Sha F and Yuille A. 2017. Attention correctness in neural image captioning//Proceedings of the 31st AAAI Conference on Artificial Intelligence. San Francisco, USA: AAAI: 4176-4182
-
Lu J S, Xiong C M, Parikh D and Socher R. 2017. Knowing when to look: adaptive attention via a visual sentinel for image captioning//Proceedings of 2017 IEEE Conference on Computer Vision and Pattern Recognition. Honolulu, USA: IEEE: 3242-3250 [DOI: 10.1109/CVPR.2017.345]
-
Luo H L, Yue L L. 2020. Image caption based on causal convolutional decoding with cross-layer multi-model feature fusion. Journal of Image and Graphics, 25(8): 1604-1617 (罗会兰, 岳亮亮. 2020. 跨层多模型特征融合与因果卷积解码的图像描述. 中国图象图形学报, 25(8): 1604-1617) [DOI:10.11834/jig.190543]
-
Ma C Y, Kalantidis Y, AlRegib G, Vajda P, Rohrbach M and Kira Z. 2020. Learning to generate grounded visual captions without localization supervision//Proceedings of the 16th European Conference on Computer Vision. Glasgow, UK: Springer: 353-370 [DOI: 10.1007/978-3-030-58523-5_21]
-
Papineni K, Roukos S, Ward T and Zhu W J. 2002. BLEU: a method for automatic evaluation of machine translation//Proceedings of the 40th Annual Meeting on Association for Computational Linguistics. Philadelphia, USA: ACL: 311-318 [DOI: 10.3115/1073083.1073135]
-
Plummer B A, Wang L W, Cervantes C M, Caicedo J C, Hockenmaier J and Lazebnik S. 2015. Flickr30k entities: collecting region-to-phrase correspondences for richer image-to-sentence models//Proceedings of 2015 IEEE International Conference on Computer Vision. Santiago, Chile: IEEE: 2641-2649 [DOI: 10.1109/ICCV.2015.303]
-
Rennie S J, Marcheret E, Mroueh Y, Ross J and Goel V. 2017. Self-critical sequence training for image captioning//Proceedings of 2017 IEEE Conference on Computer Vision and Pattern Recognition. Honolulu, USA: IEEE: 1179-1195 [DOI: 10.1109/CVPR.2017.131]
-
Rohrbach A, Hendricks L A, Burns K, Darrell T and Saenko K. 2018. Object hallucination in image captioning//Proceedings of 2018 Conference on Empirical Methods in Natural Language Processing. Brussels, Belgium: ACL: 4035-4045 [DOI: 10.18653/v1/d18-1437]
-
Tan Y L, Tang P J, Zhang L, Luo Y P. 2021. From image to language: image captioning and description. Journal of Image and Graphics, 26(4): 727-750 (谭云兰, 汤鹏杰, 张丽, 罗玉盘. 2021. 从图像到语言: 图像标题生成与描述. 中国图象图形学报, 26(4): 727-750) [DOI:10.11834/jig.200177]
-
Tang P J, Tan Y L, Li J Z. 2017. Image description based on the fusion of scene and object category prior knowledge. Journal of Image and Graphics, 22(9): 1251-1260 (汤鹏杰, 谭云兰, 李金忠. 2017. 融合图像场景及物体先验知识的图像描述生成模型. 中国图象图形学报, 22(9): 1251-1260) [DOI:10.11834/jig.170052]
-
Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez A N, Kaiser Ł and Polosukhin I. 2017. Attention is all you need//Proceedings of the 31st International Conference on Neural Information Processing Systems. Long Beach, USA: Curran Associates Inc. : 6000-6010
-
Vedantam R, Zitnick C L and Parikh D. 2015. CIDEr: consensus-based image description evaluation//Proceedings of 2015 IEEE Conference on Computer Vision and Pattern Recognition. Boston, USA: IEEE: 4566-4575 [DOI: 10.1109/CVPR.2015.7299087]
-
Vinyals O, Toshev A, Bengio S and Erhan D. 2015. Show and tell: a neural image caption generator//Proceedings of 2015 IEEE Conference on Computer Vision and Pattern Recognition. Boston, USA: IEEE: 3156-3164 [DOI: 10.1109/CVPR.2015.7298935]
-
Wan B Y, Jiang W H, Fang Y M, Zhu M W, Li Q, Liu Y. 2022. Revisiting image captioning via maximum discrepancy competition. Pattern Recognition, 122: #108358 [DOI:10.1016/j.patcog.2021.108358]
-
Xu K, Ba J L, Kiros R, Cho K, Courville A, Salakhutdinov R, Zemel R S and Bengio Y. 2015. Show, attend and tell: neural image caption generation with visual attention//Proceedings of the 32nd International Conference on International Conference on Machine Learning. Lille, France: PMLR: 2048-2057
-
Zhang W Q, Shi H C, Tang S L, Xiao J, Yu Q and Zhuang Y T. 2021. Consensus graph representation learning for better grounded image captioning//Proceedings of the 35th AAAI Conference on Artificial Intelligence. Virtual: AAAI: 3394-3402
-
Zhou L W, Kalantidis Y, Chen X L, Corso J J and Rohrbach M. 2019. Grounded video description//Proceedings of 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Long Beach, USA: IEEE: 6571-6580 [DOI: 10.1109/CVPR.2019.00674]
-
Zhou Y E, Wang M, Liu D Q, Hu Z Z and Zhang H W. 2020. More grounded image captioning by distilling image-text matching model//Proceedings of 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Seattle, USA: IEEE: 4776-4785 [DOI: 10.1109/CVPR42600.2020.00483]