局部语义与全局语义融合的图文检索方法

王忠美 ,  彭深奥 ,  刘建华 ,  敖文秀 ,  李泉明

科学技术与工程 ›› 2026, Vol. 26 ›› Issue (13) :5574-5582

PDF (7722KB)
科学技术与工程 ›› 2026, Vol. 26 ›› Issue (13) :5574-5582 DOI: 10.12404/j.issn.1671-1815.2503447
自动化技术、计算机技术

局部语义与全局语义融合的图文检索方法

作者信息 +

Local and Global Semantic Fusion for Image-text Retrieval

Author information +
文章历史 +

摘要

图像-文本匹配作为连接视觉与语言的桥梁,是一项实现双模态间高质量语义对齐的关键任务。针对图像文跨模态检索任务中图像与文本模态的语义特征在细粒度区分能力弱的问题,提出了一种融合模态内样本细粒度局部语义信息及模态间全局语义的多模态对齐方法。首先,提取图像和文本特征,并使用图注意力网络进行区域关系推理,以获取关系增强的局部特征;然后,利用注意力机制对同一模态内不同样本进行语义交互,从而充分学习各模态内样本间关联关系,得到语义增强的图像文本嵌入;最后,采用三角约束改进的三元组损失函数来提升多模态对齐性能。实验结果表明,在MS-COCO数据集的1K测试集上,该方法通过Recall@1(正确匹配项出现在检索结果前1位的查询比例)指标评估,在图像检索任务中较现有方法实现了6.4%的性能提升,在文本检索任务中达到1.3%的性能提升,验证了所提方法的有效性。

Abstract

Image-text retrieval serves as a pivotal bridge between vision and language, playing a critical role in achieving high-quality semantic alignment across modalities. To enhance the fine-grained discriminative capacity of semantic features in cross-modal retrieval, a multi-modal alignment framework that integrates intra-modal fine-grained local semantics with inter-modal global semantic correlations was proposed. Original features of images and texts were first extracted, followed by region-level relational reasoning through graph attention networks (GAT) to obtain relation-enhanced local features. An intra-modal attention mechanism was then employed to facilitate semantic interactions among samples within the same modality, thereby capturing comprehensive intra-modal associations and producing semantically enriched embeddings for both images and texts. Finally, a triangular constraint-enhanced triplet loss function was designed to optimize the alignment process. Experimental results on the MS-COCO dataset (1K test set) demonstrate improvements of 6.4% and 1.3% in image retrieval and text retrieval tasks, respectively, in terms of Recall@1, confirming the effectiveness of the proposed method. Experimental results on the MS-COCO dataset (1K test set) indicate that the proposed method improves Recall@1 (the percentage of queries for which at least one ground-truth match is retrieved in the top-1 results) by 6.4% and 1.3% on image-to-text and text-to-image retrieval, respectively, demonstrating its effectiveness.

Graphical abstract

关键词

跨模态图文检索 / 关系推理 / 全局匹配 / 三元组损失

Key words

cross-modal image-text retrieval / relational reasoning / global matching / triplet loss

引用本文

引用格式 ▾
王忠美, 彭深奥, 刘建华, 敖文秀, 李泉明. 局部语义与全局语义融合的图文检索方法[J]. 科学技术与工程, 2026, 26(13): 5574-5582 DOI:10.12404/j.issn.1671-1815.2503447
WANG Zhong-mei, PENG Shen-ao, LIU Jian-hua, AO Wen-xiu, LI Quan-ming. Local and Global Semantic Fusion for Image-text Retrieval[J]. Science Technology and Engineering, 2026, 26(13): 5574-5582 DOI:10.12404/j.issn.1671-1815.2503447

登录浏览全文

4963

注册一个新账户 忘记密码

图像-文本检索旨在通过视觉和语言的理解,使用户基于文本查询找到对应图像,或基于图像查询得到合适的文本描述。其目标是实现图像与文本之间的跨模态语义对齐[1],对实现视觉与语言的深度融合具有重要意义。近年来,该领域取得了重大进展[2-5],然而,由于图像和文本之间存在巨大的语义差异,现有的方法对图像和文本中的语义信息利用仍不够充分,亟须进一步优化。
图像-文本检索方法通常由以下关键模块构成[6]:模态嵌入、模态交互和相似度计算。模态嵌入用于提取视觉和文本特征。模态交互用于对相似特征进行学习,建立图像和文本两种模态之间的关联和对齐,挖掘跨模态数据的语义关系,其可分为模态内交互[7-9]和跨模态交互[10-12]。相似度计算通过特定的准则来量化不同模态数据之间的语义相关性,实现模态间的有效对齐。相似度计算准则一般采用三元组损失[13]函数来判别语义相似性和不相似样本,但细粒度区分能力和难分样本的处理存在不足。对于语义模糊或差异细微的难分样本,模型可能难以准确判别其真实难分性,从而削弱模态对齐性能。
此外,三元组损失存在难以找到合适的边距参数以及对尺度变化敏感的问题,边距参数选择不当很容易导致嵌入学习效果不佳[14-15]。
针对这些问题,为了进一步挖掘细微差异样本中的信息,现提出一种利用模态内样本信息的网络(exploring intra-modal sample information network,EISIN),用于进一步区分难分样本并解决相似性度量对尺度变化敏感的问题。具体来说,通过挖掘同一模态中不同样本之间的关联关系和相似度关系,将其分别作为掩码和权重融入多头注意力中,充分利用同一模态样本之间的语义进行关系增强。为了深入挖掘难分样本信息,将三角损失与三元组排序损失相结合,通过加入内角约束来引导负样本在嵌入空间中远离正样本,以期为模型提供额外的优化方向,提升多模态对齐效果。

1 相关工作

1.1 全局对齐方法

现有图像-文本检索往往通过学习一个公共嵌入空间,使得不同模态特征能在该空间进行相似性计算,全局对齐使用两个独立网络将图像和文本映射到同一个嵌入空间中。在早期的研究中[14-15],通常使用卷积神经网络(convolutional neural networks,CNN)来学习图像的全局特征,使用循环神经网络(recurrent neural network,RNN)或门控循环单元(gated recurrent unit,GRU)来提取文本特征,最后通过简单的距离度量来衡量两个模态特征之间的相似度。后续的研究改进了图像和文本特征的学习,如VSRN(visual semantic reasoning for image-text matching)[2]通过GRU构建全局特征并使用池化的方法来聚合全局特征[10]。随着注意力机制在自然语言处理领域的应用,现有的大多数方法使用双向Transformer的encoder(bidirectional encoder representation from Transformers,BERT)[16]提取文本特征来学习图像和文本特征的细粒度关系,进一步提升图像-文本检索效果。

在相似度度量方面,许多工作采用三元组排序损失(triplet ranking loss)和双向三元组排序损失来约束模型的学习,在此基础上,VSE++[11]采用批量难分样本挖掘(hard negative mining)来提升计算效率并简化过程。然而,这些方法需要预先人为设定边距信息[12],不恰当的边距会导致视觉-语义嵌入的学习效果欠佳。为此,自适应边距的三元组损失函数[17]通过引入三角约束,避免了对边距信息的依赖。

1.2 局部对齐方法

不同于全局对齐,局部对齐方法关注跨模态之间的细粒度匹配,通过对图像中的局部区域特征与文本中的词语或短语进行对齐,能够捕捉更为精细的语义关系,从而提升检索的准确性。

早期的局部对齐方法如SCAN(stacked cross attention network)[18],采用堆叠交叉注意力机制,计算单个片段与整体片段之间的相似度,逐一对齐图像中的局部区域与文本中的单词,实现细粒度的匹配。在此基础上,IMRAM(iterative matching with recurrent attention memory)[19]引入记忆蒸馏单元,并通过迭代方式提取跨模态信息,进一步提升了匹配的精度。随后,许多研究[20-21]将图卷积网络(graph convolutional networks,GCN)融入细粒度对齐中,利用GCN推断图像和文本的特征表示以优化模型。其中,NAAF(negative-aware attention framework)[21]通过挖掘不匹配的片段,增强了负样本的判别性和鲁棒性。随着注意力机制的发展,局部对齐方法得到了进一步的提升,DAN(dual attention network)[22]通过双向注意力机制,实现了图像区域与文本词语之间的双向对齐,增强了模型对细粒度语义关系的捕捉能力。局部对齐方法通过细粒度的特征匹配,弥补了全局对齐方法在捕捉复杂语义关系方面的不足。然而,现有方法对差异细微或语义模糊的难分样本,如图1所示,对于“冲浪”主题,不同的行为之间存在细微的差异,如“男人/女人”和“拿着冲浪板/蹲在冲浪板上/站在冲浪板上”),模型可能无法正确识别出真正的难分样本,进而影响模态对齐的效果。

2 局部语义与全局语义融合方法

首先,对图像和文本进行特征提取,并使用图注意力网络进行区域关系推理;然后,将同一模态内不同样本之间的联系加入关系图中,并利用注意力机制进行语义交互,从而充分学习各模态样本之间的信息,得到语义增强的图像文本嵌入;最后,将三元组排序损失与三角损失相结合,优化负样本点的梯度方向,达到了更好的对齐效果,增强模型在大幅度数据变化时的鲁棒性。

2.1 特征提取

使用以Resnet101[23]为主干的Faster-RCNN[24]模型提取图像区域特征,通过自底向上[25]的方法从一张图像的m个显著区域中提取特征,并运用全连接层将每个区域映射为一个d维的局部特征。具体来说,给定一张图像,其特征可以表示为$\mathit{V}=\{{\mathit{v}}_{1},{\mathit{v}}_{2},\dots,{\mathit{v}}_{\mathit{m}}\}$,${\mathit{v}}_{\mathit{i}}\in {\mathit{R}}^{\mathit{d}}$,其中vi编码该图像中的一个显著区域的特征。

文本特征提取主要采用来自自然语言处理(natural language processing,NLP)领域的BERT模型[16]来提取文本特征,同时还添加了一个全连接层来保证文本特征与图像拥有相同的尺寸。具体来说,一段由n个词组成的文本T,词特征可以表示为$\stackrel{\sim }{\mathit{C}}=\{{\stackrel{\sim }{\mathit{c}}}_{1},{\stackrel{\sim }{\mathit{c}}}_{2},\dots,{\stackrel{\sim }{\mathit{c}}}_{\mathit{n}}\}$,${\stackrel{\sim }{\mathit{c}}}_{\mathit{i}}\in {\mathit{R}}^{\mathit{d}}$。

2.2 区域关系推理

为了在图像和文本特征之间分别建立连接以获取其上下文信息,分别建立了视觉语义推理模型和文本语义推理模型,期望能够更好地捕捉图像与文本之间的深层语义关联,从而提升跨模态匹配的准确性与鲁棒性。

考虑到图像区域之间的语义相关性,首先建立了图像区域关系图,然后通过语义交互模型来学习上下文信息。具体而言,首先用式(1)来测量图像区域之间的成对相似度以构建关系矩阵。

$\boldsymbol{R}\left(\tilde{\boldsymbol{v}}_{i}, \tilde{\boldsymbol{v}}_{j}\right)=\boldsymbol{\omega}\left(\tilde{\boldsymbol{v}}_{i}\right)^{\mathrm{T}} \boldsymbol{\mu}\left(\tilde{\boldsymbol{v}}_{j}\right)$

式(1)中:$\mathit{\omega }\left({\stackrel{\sim }{\mathit{v}}}_{\mathit{i}}\right)={\mathit{W}}_{\mathit{\omega }}{\stackrel{\sim }{\mathit{v}}}_{\mathit{i}}$和$\mathit{\mu }\left({\stackrel{\sim }{\mathit{v}}}_{\mathit{j}}\right)={\mathit{W}}_{\mathit{\mu }}{\stackrel{\sim }{\mathit{v}}}_{\mathit{j}}$是两个嵌入特征,权重参数Wω和Wμ通过反向传播学习。随后使用区域特征$\stackrel{\sim }{\mathit{V}}=\{{\stackrel{\sim }{\mathit{v}}}_{1},{\stackrel{\sim }{\mathit{v}}}_{2},\dots,{\stackrel{\sim }{\mathit{v}}}_{\mathit{m}}\}$当作图的节点V,关系矩阵R作为图的边E来构建关系图GI=(V,E)。最后使用图注意力网络(GAT)[8],即自注意层[11]对这个全连通图进行推理来捕获语义关系并学习关系增强的局部特征${\mathit{V}}^{\mathit{*}}=\{{\mathit{v}}_{1}^{\mathit{*}},{\mathit{v}}_{2}^{\mathit{*}},\dots,{\mathit{v}}_{\mathit{m}}^{\mathit{*}}\}$,${\mathit{v}}_{\mathit{i}}^{\mathit{*}}\in {\mathit{R}}^{\mathit{d}}$。最后,通过最大池化和平均

池化相结合的方式对原始区域特征和增强后的特征进行聚合,以得到全局视觉嵌入$\mathit{v}\in {\mathit{R}}^{\mathit{d}}$,如式(2)所示。

$\mathit{v}=\mathit{\eta }\mathit{M}\mathit{a}\mathit{x}\mathit{P}\mathit{o}\mathit{o}\mathit{l}\left(\mathit{V}\right)+(1-\mathit{\eta })\mathit{A}\mathit{v}\mathit{g}\mathit{P}\mathit{o}\mathit{o}\mathit{l}\left({\mathit{V}}^{\mathit{*}}\right)$

式(2)中:参数η用于控制两种表示的比例,MaxPool(V)为对特征集合V进行最大池化(max pooling),以获得全局表示向量;AvgPool(V*)为对增强后的特征集合V*进行平均池化(global average pooling)。

与视觉语义推理类似,在文本的单词之间构建语义关系图。全连通图GT=(V,E)中的节点V表示词特征$\stackrel{\sim }{\mathit{C}}=\{{\stackrel{\sim }{\mathit{c}}}_{1},{\stackrel{\sim }{\mathit{c}}}_{2},\dots,{\stackrel{\sim }{\mathit{c}}}_{\mathit{n}}\}$,边表示词与词之间的语义关系。同样用自注意层来获取关系增强的词特征${\mathit{C}}^{\mathit{*}}=\{{\mathit{c}}_{1}^{\mathit{*}},{\mathit{c}}_{2}^{\mathit{*}},\dots,{\mathit{c}}_{\mathit{n}}^{\mathit{*}}\}$。最后,利用最大池化和平均池化对这些词特征进行聚合,得到全局文本嵌入$\mathit{u}\in {\mathit{R}}^{\mathit{d}}$,如式(3)所示。

$\mathit{u}=\mathit{\eta }\mathit{M}\mathit{a}\mathit{x}\mathit{P}\mathit{o}\mathit{o}\mathit{l}\left(\mathit{C}\right)+(1-\mathit{\eta })\mathit{A}\mathit{v}\mathit{g}\mathit{P}\mathit{o}\mathit{o}\mathit{l}\left({\mathit{C}}^{\mathit{*}}\right)$

2.3 语义关系增强

为了融入同一模态内样本的语义信息,首先建立各样本之间的关系矩阵和权值矩阵,然后将两个矩阵与关系交互机制结合捕捉细微的语义信息,最终得到语义增强的图像文本嵌入。

在学习同一模态语义信息时,全连通图在神经网络的多层传播过程中会使得来自同类图像的嵌入变得越来越相似,而来自不同类图像的嵌入变得越来越不相似,从而导致过度平滑和噪声[26]。因此需要构建新的关系矩阵来帮助进行模态内的语义信息学习。当两个嵌入节点距离较近时,它们的语义信息通常是重叠的,可能存在语义连接[27],因此给定N组图像文本全局嵌入$\{{\mathit{v}}_{\mathit{i}},{\mathit{c}}_{\mathit{i}}{\}}_{\mathit{i}=1}^{\mathit{N}}$,计算同一模态样本之间的相似度,并取前θ的特征向量认为他们存在语义连接,表达式为

$\left\{\begin{array}{l}({\mathit{A}}_{\mathit{I}\to \mathit{I}}{)}_{\mathit{i}\mathit{j}}=\left\{\begin{array}{l}1,\mathit{ }\mathit{S}\left({\mathit{v}}_{\mathit{i}}{\mathit{v}}_{\mathit{j}}\right)\mathit{ }\ge \mathit{ }\mathit{q}\mathit{u}\mathit{a}\mathit{n}\mathit{t}\mathit{i}\mathit{l}\mathit{e}(\mathit{S},\mathit{\theta })\\ 0,\mathit{ }\mathit{S}\left({\mathit{v}}_{\mathit{i}}{\mathit{v}}_{\mathit{j}}\right)\mathit{ }\mathit{ }\mathit{q}\mathit{u}\mathit{a}\mathit{n}\mathit{t}\mathit{i}\mathit{l}\mathit{e}(\mathit{S},\mathit{\theta })\end{array}\right.\\ ({\mathit{A}}_{\mathit{T}\to \mathit{T}}{)}_{\mathit{i}\mathit{j}}=\left\{\begin{array}{l}1,\mathit{ }\mathit{S}\left({\mathit{c}}_{\mathit{i}}{\mathit{c}}_{\mathit{j}}\right)\mathit{ }\ge \mathit{ }\mathit{q}\mathit{u}\mathit{a}\mathit{n}\mathit{t}\mathit{i}\mathit{l}\mathit{e}(\mathit{S},\mathit{\theta })\\ 0,\mathit{ }\mathit{S}\left({\mathit{c}}_{\mathit{i}}{\mathit{c}}_{\mathit{j}}\right)\mathit{ }\mathit{ }\mathit{q}\mathit{u}\mathit{a}\mathit{n}\mathit{t}\mathit{i}\mathit{l}\mathit{e}(\mathit{S},\mathit{\theta })\end{array}\right.\end{array}\right.$

式(4)中:S(·)为在联合嵌入空间中的相似度函数,在实验中使用常规的内积;quantile(S,θ)为相似度前θ分位数;I与T分别表示图像与文本模态;下标I→I与T→T表示在图像模态内、文本模态内构建样本间关系。

给定N组图像文本对$\{{\mathit{u}}_{\mathit{i}},{\mathit{v}}_{\mathit{i}}{\}}_{\mathit{i}=1}^{\mathit{N}}$,对于同一模态内样本,使用全局嵌入来计算相关性权值矩阵,即

$\left\{\begin{array}{l}({\mathit{X}}_{\mathit{I}\to \mathit{I}}{)}_{\mathit{i}\mathit{j}}=\mathit{e}\mathit{x}\mathit{p}\left(-\frac{{‖\frac{\mathit{ }}{\mathit{ }}{\mathit{u}}_{\mathit{i}}-{\mathit{u}}_{\mathit{j}}‖}_{2}^{2}}{\mathit{\sigma }}\right)\\ ({\mathit{X}}_{\mathit{T}\to \mathit{T}}{)}_{\mathit{i}\mathit{j}}=\mathit{e}\mathit{x}\mathit{p}\left(-\frac{{‖\frac{\mathit{ }}{\mathit{ }}{\mathit{v}}_{\mathit{i}}-{\mathit{v}}_{\mathit{j}}‖}_{2}^{2}}{\mathit{\sigma }}\right)\end{array}\right.$

式(5)中:σ为控制相关值的正标量,为简单起见,σ=1。

在获取了嵌入关系矩阵和权值矩阵之后,使用关系交互机制来捕获语义关系。将视觉嵌入和文本嵌入分别输入多头注意力模块中实现多模态关系交互,其中查询(Q)和键值对(KV)来自两个不同的模态。连接矩阵A作为注意模块的注意遮罩矩阵,关联矩阵X则作为额外的注意权值矩阵,用于显式关系建模[9],使用λ来平衡X与原始注意权矩阵。因此,将基本注意力公式修改为

$\mathit{A}\mathit{t}\mathit{t}(\mathit{Q},\mathit{K},\mathit{V};\mathit{A},\mathit{X})=\underset{\mathit{M}\mathit{a}\mathit{s}\mathit{k}\left(\mathit{A}\right)}{\mathit{s}\mathit{o}\mathit{f}\mathit{t}\mathit{m}\mathit{a}\mathit{x}}\left(\frac{\mathit{Q}{\mathit{K}}^{\mathit{T}}}{\sqrt{{\mathit{d}}_{\mathit{k}}}}+\mathit{\lambda }\mathit{X}\right)\mathit{V}$

式(6)中:$\sqrt{{\mathit{d}}_{\mathit{k}}}$为缩放因子,用于对QKT进行归一化以稳定训练。

进行关系交互之后,得到了两个模态关系增强后的特征$\{{\stackrel{-}{\mathit{v}}}_{1},{\stackrel{-}{\mathit{v}}}_{2},\dots,{\stackrel{-}{\mathit{v}}}_{\mathit{N}}\}$和$\{{\stackrel{-}{\mathit{c}}}_{1},{\stackrel{-}{\mathit{c}}}_{2},\dots,{\stackrel{-}{\mathit{c}}}_{\mathit{N}}\}$。

2.4 损失函数

结合了三角损失与三元组排序损失以解决同一模态中不同类特征在嵌入空间中分布差异较大且对尺度变化敏感的问题。角损失测量的是样本之间的角度关系,具有旋转不变性和尺度不变性的优点,从而减少了选择合适边距参数的困难,并降低了对尺度变化的敏感性。

对于关系增强后的图像和文本特征$\{{\stackrel{-}{\mathit{v}}}_{1},{\stackrel{-}{\mathit{v}}}_{2},\dots,{\stackrel{-}{\mathit{v}}}_{\mathit{N}}\}$和$\{{\stackrel{-}{\mathit{c}}}_{1},{\stackrel{-}{\mathit{c}}}_{2},\dots,{\stackrel{-}{\mathit{c}}}_{\mathit{N}}\}$,使用基于难分样本的三元组排序损失[11]来进行匹配,将损失定义为

$\begin{array}{l}{\mathit{L}}_{\mathit{t}\mathit{r}\mathit{i}\mathit{p}\mathit{l}\mathit{e}\mathit{t}}(\mathit{v},\mathit{c})=[\mathit{\alpha }-\mathit{S}(\mathit{v},\mathit{c})+\mathit{S}{(\mathit{v},\stackrel{\wedge }{\mathit{c}})]}_{+}+\\ [\mathit{\alpha }-\mathit{S}(\mathit{v},\mathit{c})+\mathit{S}{(\stackrel{\wedge }{\mathit{v}},\mathit{c})]}_{+}\end{array}$

式(7)中:α为边距参数;[x]+=max(x,0);S(·)为在联合嵌入空间中的相似度函数;(v,c)为一对正样本对;$(\mathit{v},\stackrel{\wedge }{\mathit{c}})$和$(\stackrel{\wedge }{\mathit{v}},\mathit{c})$为一组负样本对,难分样本由$\stackrel{\wedge }{\mathit{v}}=\underset{\mathit{j}\ne \mathit{v}}{\mathit{a}\mathit{r}\mathit{g}\mathit{m}\mathit{a}\mathit{x}}\mathit{S}(\mathit{j},\mathit{c})$和$\stackrel{\wedge }{\mathit{c}}=\underset{\mathit{i}\ne \mathit{c}}{\mathit{a}\mathit{r}\mathit{g}\mathit{m}\mathit{a}\mathit{x}}\mathit{S}(\mathit{v},\mathit{i})$给出。

由图3(a)所示的梯度方向可知,三元组排序损失中负样本和正样本的梯度方向可能会导致它们之间的距离变得更近,因此引入了三角损失[6,13],如图3(b)所示,构造以锚点与正负样本距离为边的三角形的内角约束,提供额外约束源的同时使负样本点的梯度方向远离正样本点和锚点,避免了三元排序组损失中将负样本点推离锚点时反而接近正样本点的情况,实现了更好的对齐效果,表达式为

$\begin{array}{l}{\mathit{L}}_{\mathit{a}\mathit{n}\mathit{g}\mathit{u}\mathit{l}\mathit{a}\mathit{r}}(\mathit{v},\mathit{c})=\mathit{l}\mathit{n}\{1+\mathit{e}\mathit{x}\mathit{p}[\mathit{f}({\mathit{e}}^{\mathit{v}},{\mathit{e}}^{\mathit{c}},\stackrel{\mathit{⌒}}{{\mathit{e}}^{\mathit{c}}})\left]\right\}+\\ \mathit{ }\mathit{l}\mathit{n}\{1+\mathit{e}\mathit{x}\mathit{p}[\mathit{f}({\mathit{e}}^{\mathit{c}},{\mathit{e}}^{\mathit{v}},\stackrel{\mathit{⌒}}{{\mathit{e}}^{\mathit{v}}})\left]\right\}\end{array}$

式(8)中:α为约束三角损失角度的参数;$\mathit{f}(\mathit{a},\mathit{p},\mathit{n})=4\mathit{t}\mathit{a}{\mathit{n}}^{2}\mathit{\alpha }(\mathit{a}+\mathit{p}){\mathit{n}}^{\mathit{T}}-2(1+\mathit{t}\mathit{a}{\mathit{n}}^{2}\mathit{\alpha })\mathit{a}{\mathit{p}}^{\mathit{T}}$,a、p和n分别为图像或文本嵌入;$\stackrel{\mathit{⌒}}{\mathit{v}}=\underset{\mathit{\tau }\ne \mathit{v}}{\mathit{a}\mathit{r}\mathit{g}\mathit{m}\mathit{a}\mathit{x}}\mathit{f}({\mathit{e}}^{\mathit{c}},{\mathit{e}}^{\mathit{v}},{\mathit{e}}^{\mathit{\tau }})$和$\stackrel{\mathit{⌒}}{\mathit{c}}=\underset{\mathit{\psi }\ne \mathit{c}}{\mathit{a}\mathit{r}\mathit{g}\mathit{m}\mathit{a}\mathit{x}}\mathit{f}({\mathit{e}}^{\mathit{v}},{\mathit{e}}^{\mathit{c}},{\mathit{e}}^{\mathit{\psi }})$为三角损失中的难分样本。

最后将三元组排序损失和三角损失结合得到最终的损失函数为

$\mathit{L}(\mathit{v},\mathit{c})={\mathit{L}}_{\mathit{t}\mathit{r}\mathit{i}\mathit{p}\mathit{l}\mathit{e}\mathit{t}}(\mathit{v},\mathit{c})+\mathit{\omega }{\mathit{L}}_{\mathit{a}\mathit{n}\mathit{g}\mathit{u}\mathit{l}\mathit{a}\mathit{r}}(\mathit{v},\mathit{c})$

式(9)中:权重ω用于控制三角损失重要度。

3 实验结果与分析

3.1 数据集和评价指标

为了验证所提出方法的有效性,使用两个公开数据集评估模型:MS-COCO[28]和Flickr30K[29]。MS-COCO包含123 287张图像,每张图像有5个对应的文本描述。根据文献[11,30],使用113 287张图像进行训练,5 000张图像进行验证,其余5 000张图像用于测试。MS-COCO的测试结果由1 000个测试样本的五折交叉验证的平均结果(COCO 5-fold 1K Test)和完整的5 000个测试样本(COCO 5K Test)组成。Flickr30K包含31 783张图像,每张图像有5个文本描述。根据文献[11]的划分,使用1 014张图像进行验证,1 000张图像进行测试,29 000张图像进行训练。

图像-文本检索通常使用Recall@K(K=1, 5, 10)指标进行评估,记作R@1、R@5和R@10。Recall@K表示在前K个检索到的项目中找到的真实情况的百分比,较高的值表示较高的检索准确性。计算3种图像检索指标的总和以及3种文本检索指标的总和,并将它们合并为图像-文本检索的总评估指标,称为rSum,表达式为

$\begin{array}{l}\mathit{r}\mathit{S}\mathit{u}\mathit{m}={(\mathit{R}@1+\mathit{R}@5+\mathit{R}@\left.10\right)}_{\mathit{i}\mathit{m}\mathit{a}\mathit{g}\mathit{e}}+\\ {(\mathit{R}@1+\mathit{R}@5+\mathit{R}@\left.10\right)}_{\mathit{t}\mathit{e}\mathit{x}\mathit{t}}\end{array}$

在实验设置方面,所有实验都使用PyTorch框架在NVIDIA Tesla T4上实现。在训练过程中,使用Adam优化器,初始学习率为1×10-5,每10次迭代衰减0.1倍。将Flickr30k和MS-COCO的批量大小分别设置为128和256。在图像方面使用预提取的图像区域特征[24],将图像和文本特征维度转换为d维,d=1 024,控制两种池化比例的超参数η=0.8。在语义关系增强学习中,将分位数θ设置为50%并令λ=1.5。损失函数中的超参数为α=0.2、β=0.5,ω=0.65。

3.2 对比实验

为了验证所提出方法的先进性,表1和表2中展示了本文模型与近年来先进模型的性能比较。由于实验环境的限制,比较中不包括大型预训练模型。

表1中展示了所提出的方法和近年来先进方法在MS-COCO数据集上的比较结果。在COCO 5K测试集中,EISIN模型有3个指标取得了R@K的最高性能。在rSum方面比HREM[3]和VSRN++[32]高出1%、1.5%。虽然EISIN模型在图像检索方面的性能和之前的方法相差不大,但在文本检索方面有明显的改进,分别比HREM[3]和VSRN++[32]高出约2.3%和2.7%。在COCO 5-fold 1K测试集中,EISIN模型也有可观的性能提升。表2中展示了所提出的方法和近年来先进方法在Flickr30K数据集上的比较结果。在Flickr30K测试集中,EISIN模型有4个指标取得了R@K的最高性能,rSum与VSRN++[32]相比也提升了约2.3。

此外,为了更直观地展现EISIN框架的优越性,图4对比了两种图文检索方法EISIN和VSRN[2]的实例。可以看出,EISIN比VSRN[2]有更好的图文检索能力。

3.3 消融实验

选取方法的主要组成部分在MS-COCO 5K数据集上进行了消融实验,并研究了这些组成部分对模型性能的影响。在表3中列出了几种不同配置的实验结果。

(1)三角损失的有效性:去除三角损失Angular Loss(AL)后研究模型的性能,结果如表3所示,去除Angular loss后导致文本检索总体下降约2.2%,rSum下降约1.0%,由此可见三角损失的确优化了梯度方向,使得负样本点的梯度方向远离正样本点和锚点,从而达到了更好的检索效果。相比于文本检索,Angular Loss对图像检索的影响不太明显,这可能是因为图像的不同类特征在嵌入空间中分布差异较大,因此对检索的影响更大。

(2)语义关系增强学习的有效性:去除语义关系增强学习(social and emotional learning,SEL)模块,研究不学习同一模态内不同信息的模型效果。结果如表3所示,所有6个评价指标以及rSum都有明显的下降,这证明EISIN使得模型准确地学习了图像之间和文本之间的语义信息,利用更充足的语义信息达成了更好的检索效果,使得各个指标都有所提升,证明了方法的有效性。

4 结论

提出了一种优化全局匹配的图像文本检索方法,该方法不仅融合了全局匹配的优势,而且充分利用了同模态内样本间的细微语义关联,来区分语义模糊性的难分样本。通过建立同一模态内不同样本之间的权值关系,并将其融入注意力机制中,以捕获样本之间的语义信息。此外,引入了三角损失,提供额外的约束源,从而实现了更好的对齐效果。在Flickr30K和MS-COCO两个通用数据集上进行的大量实验表明该方法可以有效提升图像文本检索的准确度。但模型依赖于目标检测器提取的区域特征,从而带来了训练过程中误差传播的问题,未来的研究计划将致力于探索新的特征提取策略,直接从原始图像数据中学习特征表示,旨在减少误差传播并优化模型性能。

参考文献

[1]

Pan Z, Wu F, Zhang B. Fine-grained image-text matching by cross-modal hard aligning network[C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Vancouver: IEEE, 2023: 19275-19284.

[2]

Li K, Zhang Y, Li K, et al. Visual semantic reasoning for image-text matching[C]// Proceedings of the IEEE/CVF International Conference on Computer Vision. Seoul: IEEE, 2019: 4654-4662.

[3]

Fu Z, Mao Z, Song Y, et al. Learning semantic relationship among instances for image-text match-ing[C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. Vancouver: IEEE, 2023: 15159-15168.

[4]

李俊屿, 卜凡亮, 谭林, 等. 基于多模态共享网络的自监督语音-人脸跨模态关联学习方法[J]. 科学技术与工程, 2024, 24(7): 2804-2812.

[5]

Li Junyu, Bu Fanliang, Tan Lin, et al. Self-supervised voice-face cross-modal association learning method via multi-modal shared network[J]. Science Technology and Engineering, 2024, 24(7): 2804-2812.

[6]

贺锋, 王天赐, 杨玉燕, 等. 改进的文本语义先验引导的场景文本图像超分辨率[J]. 科学技术与工程, 2025, 25(25): 10821-10828.

[7]

He Feng, Wang Tianci, Yang Yuyan, et al. Enhanced text prior guided text image super-resolution[J]. Science Technology and Engineering, 2025, 25(25): 10821-10828.

[8]

Rao J, Wang F, Ding L, et al. Where does the perfor-mance improvement come from? -a reproducibility concern about image-text retrieval[C]// Proceedings of the 45th International ACM SIGIR Conference on Research and Development in Information Retrieval. Madrid: IEEE, 2022: 2727-2737.

[9]

邓亚萍, 王新, 尹甜甜. 基于多层交叉注意力融合网络模型的人脸图像情感分析[J]. 科学技术与工程, 2023, 23(3): 1152-1159.

[10]

Deng Yaping, Wang Xin, Yin Tiantian. Emotion analysis of face image based on multi-layer cross attention fusion network model[J]. Science Technology and Engineering, 2023, 23(3): 1152-1159.

[11]

Wu Y, Wang S, Song G, et al. Learning fragment self-attention embeddings for image-text matching[C]// Proceedings of the 27th ACM International Conference on Multimedia. Nice: IEEE, 2019: 2088-2096.

[12]

袁陆, 陶庆, 刘景轩, 等. 改进的双流多模态信息融合坐姿识别方法[J]. 科学技术与工程, 2024, 24(5): 1980-1988.

[13]

Yuan Lu, Tao Qing, Liu Jingxuan, et al. Improved dual-stream multi-modal information fusion method for sitting posture recognition[J]. Science Technology and Engineering, 2024, 24(5): 1980-1988.

[14]

Velickovic P, Cucurull G, Casanova A, et al. Graph attention networks[J]. Statistics and Computing, 2017(20): 3292002.

[15]

Vaswani A. Attention is all you need[C]// Proceedings of the 31st International Conference on Neural Information Processing Systems. Long Beach: IEEE, 2017: 6000-6010.

[16]

Chen J, Hu H, Wu H, et al. Learning the best pooling strategy for visual semantic embedding[C]// Proceedings of the IEEE/CVF Conference On Computer Vision and Pattern Recognition. Online: IEEE, 2021: 15789-15798.

[17]

Faghri F, Fleet D J, Kiros J R, et al. VSE++: Improving visual-semantic embeddings with hard negatives[C]// Proceedings of the 2018 British Machine Vision Conference(BMVC). Durham: BMVC, 2018: 344.

[18]

刘萌, 齐孟津, 詹圳宇, 等. 基于深度学习的图像-文本匹配研究综述[J]. 计算机学报, 2023, 46(11): 2370-2399.

[19]

Liu Meng, Qi Mengjin, Zhan Zhenyu, et al. A survey on deep learning based image-text matching[J]. Chinese Journal of Computers, 2023, 46(11): 2370-2399.

[20]

Wang J, Zhou F, Wen S, et al. Deep metric learning with angular loss[C]// Proceedings of the IEEE International Conference on Computer Vision. Venice: IEEE, 2017: 2593-2601.

[21]

Wang L, Li Y, Lazebnik S. Learning deep structure-preserving image-text embeddings[C]// Proceedings of the IEEE Conference On Computer Vision And Pattern Recognition. Las Vegas: IEEE, 2016: 5005-5013.

[22]

Wang L, Li Y, Huang J, et al. Learning two-branch neural networks for image-text matching tasks[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018, 41(2): 394-407.

[23]

Devlin J, Chang M W, Lee K, et al. BERT: Pretraining of deep bidirectional transformers for language understanding[C]// Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers). Minneapolis: Association for Computational Linguistics, 2019: 4171-4186.

[24]

Biten A F, Mafla A, Gómez L, et al. Is an image worth five sentences? a new look into semantics for image-text matching[C]// Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision. Waikoloa: IEEE, 2022: 1391-1400.

[25]

Lee K H, Chen X, Hua G, et al. Stacked cross attention for image-text matching[C]//Proceedings of the European conference on computer vision (ECCV). Berlin: Springer, 2018: 201-216.

[26]

Chen H, Ding G, Liu X, et al. IMRAM: Iterative matching with recurrent attention memory for cross-modal image-text retrieval[C]// Proceedings of the IEEE/CVF Conference On Computer Vision and Pattern Recognition. Seattle: IEEE, 2020: 12655-12663.

[27]

Cheng Y, Zhu X, Qian J, et al. Cross-modal graph matching network for image-text retrieval[J]. ACM Transactions on Multimedia Computing, Communications, and Applications, 2022, 18(4): 1-23.

[28]

Zhang K, Mao Z, Wang Q, et al. Negative-aware attention framework for image-text matching[C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 15661-15670.

[29]

Nam H, Ha J W, Kim J. Dual attention networks for multimodal reasoning and matching[C]// Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. Honolulu: IEEE, 2017: 299-307.

[30]

He K, Zhang X, Ren S, et al. Deep residual learning for image recognition[C]// Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. Las Vegas: IEEE, 2016: 770-778.

[31]

Ren S, He K, Girshick R, et al. Faster R-CNN: towards real-time object detection with region proposal net-works[J]. IEEE Transactions On Pattern Analysis and Machine Intelligence, 2016, 39(6): 1137-1149.

[32]

Anderson P, He X, Buehler C, et al. Bottom-up and top-down attention for image captioning and visual question answering[C]// Proceedings of the IEEE Con-ference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 6077-6086.

[33]

Seidenschwarz J D, Elezi I, Leal-Taixé L. Learning intra-batch connections for deep metric learning[C]// International Conference on Machine Learning. Online: PMLR, 2021: 9410-9421.

[34]

Kaya M, Bilge H Ş. Deep metric learning: a survey[J]. Symmetry, 2019, 11(9): 1066.

[35]

Lin T Y, Maire M, Belongie S, et al. Microsoft COCO: common objects in context[C]// Computer Vision-ECCV 2014: 13th European Conference. Zurich: Springer International Publishing, 2014: 740-755.

[36]

Plummer B A, Wang L, Cervantes C M, et al. Flickr30k entities: Collecting region-to-phrase correspondences for richer image-to-sentence models[C]// Proceedings of the IEEE International Conference on Computer vision. Chile: IEEE, 2015: 2641-2649.

[37]

Messina N, Amato G, Esuli A, et al. Fine-grained visual textual alignment for cross-modal retrieval using Transformer encoders[J]. ACM Transactions on Multimedia Computing, Communications, and Applications, 2021, 17(4): 1-23.

基金资助

国家重点研发计划(2021YFF0501101)

国家自然科学基金青年科学基金(62106074)

国家自然科学基金(52272347)

湖南省自然科学基金(2024JJ7132)

湖南工业大学研究生科研创新项目(LXBZZ2422)

PDF (7722KB)

42

访问

0

被引

详细

导航
相关文章

/

〈 〉