Text-based pedestrian image retrieval model establishment method, retrieval method and system

By generating cross-modal fusion features and using multiple loss functions for training, the matching errors caused by noisy and hard samples in existing technologies are solved, thus improving the accuracy of pedestrian image retrieval.

CN118797092BActive Publication Date: 2026-11-24SHANGHAI JIAOTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410946657.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2026-11-24
Estimated Expiration
2044-07-16

AI Technical Summary

Technical Problem

Existing text-based pedestrian image retrieval methods suffer from noisy and hard samples, leading to incorrect matching decisions.

Method used

By generating cross-modal fusion features and using a loss function for end-to-end training, hard matching labels, noise-corrected matching labels, masked labels, and word-image matching labels are generated, improving the model's ability to distinguish subtle differences, correcting noisy samples, and improving the judgment of hard samples through a masking scheme.

Benefits of technology

It improves the accuracy of text-based pedestrian image retrieval and solves the matching error problem caused by noisy and hard samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118797092B_ABST
    Figure CN118797092B_ABST
Patent Text Reader

Abstract

This invention provides a text-based pedestrian image retrieval model establishment method, retrieval method, and system, including: acquiring strong positive sample pairs and noisy sample pairs; acquiring image feature vectors and representations, and text feature vectors and representations of the image and text in a single modality from the strong positive sample pairs; acquiring image feature vectors and representations of the image in a single modality from the noisy sample pairs; acquiring masked text feature vectors of hard samples; generating cross-modal fusion features of image and text; generating hard-matching labels; generating noise-corrected matching labels; generating masked labels and word-image matching labels for hard samples; and training using a sum of losses L, where L includes feature comparison, hard matching, noise correction, mask modeling, and word-image matching losses. This invention corrects the error in judging whether image-text pairs match based on identity labels, improves the model's ability to perceive subtle differences between samples, and enhances cross-modal retrieval accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image retrieval technology, and in particular to a method for establishing a text-based pedestrian image retrieval model, a retrieval method, and a system. Background Technology

[0002] With the rapid development of deep learning technology, various human identification technologies have attracted widespread attention from researchers. Text-based cross-modal pedestrian image retrieval technology aims to find pedestrian images that best match a given textual description of a target person from a large-scale image database. Compared to traditional pedestrian retrieval methods that rely on known images or attributes of the target person, this method offers more flexible and convenient query conditions and can handle complex situations where known images of the person being searched are lacking. Text-based pedestrian image retrieval methods have significant practical application value, not only helping to improve the efficiency of crime detection but also meeting the needs of identity verification in various complex situations.

[0003] Current text-based pedestrian image retrieval methods commonly suffer from the problems of noisy and hard samples. In this task, noisy samples refer to cases where the image is incorrectly matched with the text. Hard samples refer to samples that are highly similar to positive samples but have inconsistent overall semantics.

[0004] Existing methods treat images and texts belonging to the same pedestrian identity label as positive sample pairs, and images and texts belonging to different identity labels as negative sample pairs. This method has certain limitations. Each text description in existing datasets is a specific description for a single pedestrian image, rather than a common description for all images of the same pedestrian. Due to differences in lighting conditions, angles, and occlusions between images, there may be semantic inconsistencies between the text description of a particular image and other images of the same pedestrian. In such cases, relying solely on identity label matching may result in false positive sample pairs. Furthermore, since text descriptions can only describe key information about an image, a single text description may match multiple images of different pedestrians. In this case, relying solely on identity label matching may result in false negative sample pairs (a type of noise sample). Summary of the Invention

[0005] This invention provides a text-based pedestrian image retrieval model establishment method, retrieval method, and system to solve the problems of noisy samples and difficult samples in the prior art.

[0006] To solve the above-mentioned technical problems, the present invention is achieved through the following technical solution:

[0007] According to a first aspect of the present invention, a method for establishing a text-based pedestrian image retrieval model is provided, comprising:

[0008] Obtain an image I containing the target pedestrian and a text T describing the target pedestrian to obtain a noise sample pair IT. For each text T describing the target pedestrian, find the corresponding image I in the dataset. 0 strong positive sample pairs I were obtained 0 -T;

[0009] Obtain image I from the strong positive sample pair 0 Image feature vector of text T within a single modality Text feature vector t embed And obtain the image feature representation v of the strong positive sample pair within a single modality. 0 and text feature representation t;

[0010] Obtain the image feature vector v of image I in a single modality from the noisy sample pair IT. embed And obtain the image feature representation v of the noisy image sample within a single modality;

[0011] Generating hard samples T using masking schemes for strong semantic words mask Obtain the masked text feature vector of the hard sample in a single modality.

[0012] Generate cross-modal fusion features for images and text, specifically including: v embed and t embed The cross-modal fusion features, and and Cross-modal fusion features;

[0013] Based on whether the identity labels of I and T of the noise sample pair are the same, a hard-matching label is generated;

[0014] According to image I 0 Based on the similarity to I, generate noise-corrected matching labels;

[0015] For the difficult samples, mask labels are generated based on the semantics of the real words at the mask locations; word-image matching labels are generated based on whether the semantics of each word in the difficult samples have changed.

[0016] End-to-end training is performed using the sum of losses L to obtain a model for extracting image and text feature representations and detecting image-text matching probabilities.

[0017] The sum of the losses L is: L = L CL +L ITM +L NC +L MLM +L WIM ;

[0018] Where L CL L represents the image-text feature contrast loss of the image-text pair. ITM L represents the hard-matching loss. NC L represents the noise-corrected matching loss. MLM L represents the mask modeling loss. WIM This represents the word-image matching loss.

[0019] Optionally, the image I obtained from the strong positive sample pair... 0 Image feature representation v within a single modality 0 The process of obtaining the image feature representation v of image I in a single modality from the noise sample pair specifically includes:

[0020] Input the image into the image feature encoder;

[0021] The image is converted from a two-dimensional mesh structure into a serialized feature matrix through a block embedding layer in the image feature encoder;

[0022] At the beginning of the feature matrix, a learnable [CLS] flag is added; a learnable positional code is then superimposed on this flag.

[0023] The feature matrix with the [CLS] flag and position encoding added is input into the Transformer block to obtain the image feature vector;

[0024] In the image feature vector, the [CLS] flag bit is the corresponding image feature representation;

[0025] Furthermore, obtaining the text feature representation t of text T in the strong positive sample pair within a single modality specifically includes:

[0026] Input the text into the text feature encoder;

[0027] Through the word embedding process, each word is converted into an embedding vector, resulting in an embedding vector representation;

[0028] Based on the embedded vector representation, a [CLS] flag and position encoding are added;

[0029] The embedded vector representation, with the addition of the [CLS] flag and position encoding, is input into BERT to obtain the text feature vector;

[0030] In the text feature vector, the [CLS] flag is the corresponding text feature representation.

[0031] Optionally, the masking scheme for strong semantic words generates hard samples T. mask Specifically, it includes:

[0032] Collect at least one category of high-frequency words that make a significant contribution to the semantics of the text, and form a list of strong semantic words;

[0033] The words in the text of the difficult sample are masked according to the masking rules;

[0034] The masking rule is as follows: each word has a probability of P% to be selected for masking, of which (100-M)% of the masked words are replaced with a specific marker, (M / 2)% remain unchanged, and (M / 2)% are randomly replaced.

[0035] The random replacement rule is as follows: if the word itself is in the strong semantic vocabulary list, then a word is randomly selected from the strong semantic vocabulary list to replace it; if the word itself is not in the strong semantic vocabulary list, then it is randomly replaced with any word from the entire vocabulary.

[0036] Optionally, generating hard-match tags specifically includes:

[0037] If image I and text T have the same identity label, they are considered a match; if image I and text T have different identity labels, they are considered a mismatch; and so on, one-hot hard match labels are generated between images and text.

[0038] Furthermore, the generation of noise-corrected matching labels specifically includes:

[0039] Image feature representation v 0 The cosine similarity between the image and the text is used as a noise-corrected matching label between the image and the text.

[0040] Optionally, generating the mask label specifically includes:

[0041] If the words in the text are not color words, the original words in the masked area will be treated as real labels; if they are color words, all color words belonging to the same color category as the original words will be treated as real labels.

[0042] Furthermore, the generation of word-image matching labels specifically includes:

[0043] For each word in the text, the matching label is determined based on whether the semantics of the word changes after masking. If the semantics change, the matching label is 0; if the semantics do not change, the matching label is 1.

[0044] The rule for determining whether the semantics have changed is as follows: if the word has not changed or the replaced word and the original word belong to the same color category, it is considered that the semantics have not changed; otherwise, it is considered that the semantics have changed.

[0045] Optionally, the image-text feature contrast loss for the image-text pair specifically includes:

[0046] Using feature queue Q v and Q t Multiple negative samples are stored; a momentum encoder is used to ensure the consistency of the feature queue in the feature space, and the momentum update formula is θ. k ←0.995θ k +0.005θ q The image text features obtained by the momentum encoder are v m and t m ;

[0047] The image-text feature contrast loss is:

[0048]

[0049] in, Indicates the intramodal contrast loss. This represents the contrast loss between modes.

[0050] Optionally, the hard-matching loss is specifically:

[0051]

[0052] Among them, y itm This indicates a hard match tag. This represents the probability distribution indicating whether an image matches text.

[0053] The noise correction matching loss is specifically as follows:

[0054]

[0055] Among them, y i Indicates noise correction matching label, The m represents the perceived matching probability of the noise sample; i The degree of matching between the image and the text.

[0056] Optionally, the mask modeling loss is specifically:

[0057]

[0058] Among them, y mask Indicates a mask label; The probability distribution of the mask labels represents the probability that the masked word belongs to each word in the word set;

[0059] Furthermore, the word-image matching loss is specifically as follows:

[0060]

[0061] Among them, y WIM This indicates the degree of matching between the word and the image, with 1 for a match and 0 for no match; This represents the probability of image-text matching predicted based on the image and the unmasked text context.

[0062] According to a second aspect of the present invention, a text-based pedestrian image retrieval method is provided, comprising:

[0063] The query text and candidate images are input into the detection model to obtain the image-text feature representations v and t, as well as the image-text matching probability. Wherein, the detection model is a detection model established according to the method described in any of the above-mentioned methods;

[0064] Based on the cosine similarity sim between v and t, the N images most similar to the query text are coarsely sorted to obtain the N images most similar to the query text.

[0065] Matching probability between sim and image / text The sum of the values ​​is used as the final similarity score. The N images are then finely sorted to obtain the image most similar to the query text.

[0066] According to a third aspect of the present invention, a text-based pedestrian image retrieval model building system is provided, comprising:

[0067] The sample pair acquisition module is used to acquire an image I containing the target pedestrian and a text T describing the target pedestrian, to obtain a noise sample pair IT, and to search for the corresponding image I in the dataset for the text T describing the target pedestrian. 0 strong positive sample pairs I were obtained 0 -T;

[0068] The image-text feature acquisition module for strong positive sample pairs is used to acquire the image feature vector of the strong positive sample within a single modality. Text feature vector t embed And obtain the image feature representation v of the strong positive sample within a single modality. 0 and text feature representation t;

[0069] The image feature acquisition module for noisy sample pairs is used to acquire the image feature vector v of image I in a single modality within the noisy sample pair IT. embed And obtain the image feature representation v of the noisy image sample within a single modality;

[0070] The module for obtaining masked text features of hard samples is used to generate hard sample T based on masking schemes for strong semantic words. mask Obtain the masked text feature vector of the hard sample in a single modality.

[0071] The cross-modal fusion feature generation module is used to generate cross-modal fusion features between images and text, specifically including: v embed and t embed The cross-modal fusion features, and and Cross-modal fusion features;

[0072] The matching label generation module is used to generate hard matching labels based on whether the identity labels of I and T of the noise sample are the same;

[0073] The noise correction matching label generation module is used to generate labels based on image I. 0 Based on the similarity with I, generate noise-corrected matching labels for the image-text pairs of the noise samples;

[0074] The mask label generation module is used to generate mask labels for the difficult samples based on the semantic meaning of the real words at the mask location;

[0075] The word-image matching label generation module is used to generate word-image matching labels based on whether the semantics of each word in the hard sample has changed.

[0076] The training module is used to perform end-to-end training using the sum of losses L to obtain a detection model for extracting image and text feature representations and detecting image-text matching probabilities.

[0077] The sum of the losses L is: L = L CL +L ITM +L NC +L MLM +L WIM ;

[0078] Where L CL L represents the image-text feature contrast loss of the image-text pair. ITM L represents the hard-matching loss. NC L represents the noise-corrected matching loss. MLM L represents the mask modeling loss. WIM This represents the word-image matching loss.

[0079] The present invention provides a text-based pedestrian image retrieval model establishment method, retrieval method, and system. By generating cross-modal fusion features and correcting noisy samples, it solves the problem of judgment errors caused by the judgment rule of determining whether image text pairs match based on identity tags, thus addressing the problem of noisy samples in the prior art. Furthermore, by combining a masking scheme with masked language modeling and word-image matching tasks, it improves the model's ability to distinguish subtle differences, thus solving the problem of hard samples in the prior art. In summary, the present invention improves the accuracy of text-based pedestrian image retrieval. Attached Figure Description

[0080] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0081] Figure 1 A flowchart illustrating a text-based pedestrian image retrieval model establishment method according to an embodiment of the present invention;

[0082] Figure 2 This is a flowchart illustrating the process of obtaining image feature representations of images in strong positive sample pairs and images in noisy sample pairs within a single modality, according to an embodiment of the present invention.

[0083] Figure 3 This is a flowchart illustrating the process of obtaining the text feature representation of a strongly positive sample within a single modality, according to an embodiment of the present invention.

[0084] Figure 4 This is a flowchart illustrating the process of obtaining masked text for hard samples according to an embodiment of the present invention;

[0085] Figure 5 This is a flowchart illustrating a text-based pedestrian retrieval method according to an embodiment of the present invention.

[0086] Figure 6 This is a schematic diagram of a text-based pedestrian image retrieval model establishment system according to an embodiment of the present invention;

[0087] Figure 7 This is a schematic diagram of an electronic device according to an embodiment of the present invention;

[0088] Explanation of reference numerals in the attached figures:

[0089] 101 - Sample Pair Acquisition Module;

[0090] 102 - Image and text feature acquisition module for strong positive sample pairs;

[0091] 103 - Image feature acquisition module for noisy sample pairs;

[0092] 104-Difficult Sample Masked Text Feature Acquisition Module;

[0093] 105 - Cross-modal fusion feature generation module;

[0094] 106 - Matching Tag Generation Module;

[0095] 107 - Noise Correction Matching Tag Generation Module;

[0096] 108 - Mask Label Generation Module;

[0097] 109-Word-Image Matching Tag Generation Module;

[0098] 110 - Training Module;

[0099] 201 - Processor;

[0100] 202 - Internal Bus;

[0101] 203 - Network Interface;

[0102] 204MB memory;

[0103] 205 - Memory. Detailed Implementation

[0104] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0105] In the description of this invention, it should be understood that the terms "upper part", "lower part", "upper end", "lower end", "lower surface", "upper surface", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention.

[0106] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.

[0107] In the description of this invention, "a plurality of" means multiple, such as two, three, four, etc., unless otherwise explicitly specified.

[0108] In the description of this invention, unless otherwise expressly specified and limited, the term "connection" and other such terms should be interpreted broadly. For example, it can refer to a fixed connection, a detachable connection, or an integral connection; it can refer to a mechanical connection, an electrical connection, or a connection that allows communication between the components; it can refer to a direct connection or an indirect connection through an intermediate medium; it can refer to the internal communication between two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0109] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0110] In one embodiment, a method for establishing a text-based pedestrian image retrieval model is provided; please refer to [reference needed]. Figure 1 It includes:

[0111] S11: Using pedestrian ID as the sampling basis, obtain image I containing the target pedestrian and text T describing the target pedestrian to obtain noise sample pair IT. For the text T describing the target pedestrian, find the corresponding image I in the dataset. 0 strong positive sample pairs I were obtained 0 -T;

[0112] S12: Obtain image I from strong positive sample pairs 0 Image feature vector of text T within a single modality Text feature vector t embed And obtain the image I from the strong positive sample pairs. 0 Image feature representation of text T within a single modality v 0 and text feature representation t;

[0113] S13: Existing methods that rely solely on the similarity or difference of identity tags to determine whether image-text pairs match have limitations, leading to noisy samples. For image I in the IT pair of this type of noisy sample in this task, we obtain its image feature vector v within a single modality. embed And obtain the image feature representation v of the noisy image sample within a single modality;

[0114] S14: Generating difficult samples T using masking schemes for strong semantic words mask Obtain the masked text feature vector of hard samples within a single modality

[0115] S15: Generate cross-modal fusion features for images and text, specifically including: v embed and t embed The cross-modal fusion features, and and Cross-modal fusion features;

[0116] S16: Generate hard-matching labels based on whether the identity labels of I and T of the noise samples are the same;

[0117] S17: According to image I 0 Based on the similarity to I, generate noise-corrected matching labels;

[0118] S18: For hard samples, generate mask labels based on the semantics of the real words at the mask; generate word-image matching labels based on whether the semantics of each word in the hard sample has changed.

[0119] S19: End-to-end training is performed using the sum of losses L to obtain a model for extracting image and text feature representations and detecting image-text matching probabilities.

[0120] The sum of losses, L, is: L = L CL +L ITM +L NC +L MLM +I WIM ;

[0121] Where L CL L represents the image-text feature contrast loss of the image-text pair. ITM L represents the hard-matching loss. NC L represents the noise-corrected matching loss. MLM L represents the mask modeling loss. WIM This represents the word-image matching loss.

[0122] Understandably, strong positive sample pairs refer to strictly matched sample pairs, as opposed to weak positive sample pairs. Strong positive sample pairs (I... 0 In (T), T is strictly for I. 0 The text annotation for this image is therefore a strong match. However, in the weak positive sample pair (I,T), T is not the text annotation for I, but rather for the image I belonging to the same pedestrian ID as I. 0 The text annotation, due to I and I 0 There may be differences in lighting conditions, occlusion, and angles between them, so (I,T) is not a strict match.

[0123] In one embodiment, please refer to Figure 2 Obtain image I from strong positive sample pairs 0 Image feature representation v within a single modality 0 To obtain the image feature representation v of image I in a single modality from a pair of noisy samples, specifically including:

[0124] S21: Input the image into the image feature encoder F visual ;

[0125] In practice, an ALBEF pre-trained model can be used as the image feature encoder F. visual Preferably, the image feature encoder uses a 12-layer ViT-B / 16 with initialized weights in ALBEF.

[0126] S22: The image is converted from a two-dimensional mesh structure into a serialized feature matrix through the block embedding layer in the image feature encoder;

[0127] In one example, an image I with a size of 3×384×384... 0 Input image encoder F visual via image encoder F visual The block embedding layer in the image transforms the image from a two-dimensional mesh structure into a serialized feature matrix. Here, 576 represents 576 image patches, each with a 768-dimensional feature representation. This serialization step facilitates better utilization of subsequent self-attention mechanisms to learn the contextual relationships between image patches and to perform global image modeling and feature extraction.

[0128] S23: At the beginning of the feature matrix, a learnable [CLS] flag is added. This position represents the feature of the entire image in the final output. A learnable positional code is then superimposed on this to capture positional information within the image. The serialized feature representation combining the [CLS] flag and positional information can be denoted as...

[0129] S24: Will Input a Transformer block to obtain the image feature vector;

[0130] In practice, a Transformer block can consist of 12 cascaded Transformer blocks; each Transformer block comprises a self-attention module and a multilayer perceptron. In the self-attention module, the input features first pass through a linear transformation layer to generate query (q), key (k), and value (v) feature vectors. A softmax transformation is then applied to the dot product between q and k to obtain the attention weights between blocks. This weight matrix is ​​used to perform a weighted summation of the value vectors to update the feature representation of each image block. This feature representation is then fed into a multilayer perceptron consisting of two linear transformation layers and a nonlinear activation function to achieve a nonlinear transformation of the feature vectors. The image feature vector obtained from the above process is:

[0131] S25: The first bit, [CLS], in the image feature vector represents the image feature representation of the entire image.

[0132] Implementable, for Take its [CLS] flag bit Through the feature mapping layer FC v Will Mapping to a 256-dimensional feature space yields the image feature representation v. 0 ∈R 256 .

[0133] In one embodiment, please refer to Figure 3 To obtain the text feature representation t of text T in a single modality from a strong positive sample pair, specifically including:

[0134] S31: Input text of length L into the text feature encoder;

[0135] In practice, an ALBEF pre-trained model can be used as the text feature encoder F. textual Preferably, the text encoding F textual The device is implemented using the first 6 layers of BERT pre-trained by ALBEF.

[0136] S32: Through the word embedding process, each word is converted into an embedding vector, resulting in the embedding vector representation T. s ∈R L×768 ;

[0137] S33: Based on the embedded vector representation, add the [CLS] flag and position encoding to obtain T. s1 ∈R (1 +L)×768 ;

[0138] S34: Input the embedding vector representation with added [CLS] flag and position encoding into BERT to obtain the text feature vector;

[0139] Implementably, T s1 The input consists of 6 layers in BERT. Each layer contains a multi-head self-attention module and a fully connected feedforward network. In the multi-head self-attention module, the input embedding vector is mapped to multiple subspaces, each corresponding to an "attention head". The text feature vector obtained from the above process is t. embed ∈R (1+L)×768 .

[0140] S35: The first [CLS] flag in the text feature vector represents the text feature representation t of the entire text. cls ∈R 768 ;

[0141] Implementable, for t embed ∈R 577×768 Take its [CLS] flag bit t cls ∈R 768 Through the feature mapping layer FC t t cls Mapping to a 256-dimensional feature space yields the text feature representation t∈R. 256 .

[0142] In one embodiment, please refer to Figure 4 Generating difficult samples T using masking schemes for strong semantic words. mask Specifically, it includes:

[0143] S41: Collect at least one class of high-frequency words that make a significant contribution to the semantics of the text, and form a list of strong semantic words.

[0144] In practice, two types of high-frequency words can be collected, such as color adjectives and nouns, to form a strong semantic vocabulary list, and color adjectives can be divided into ten main categories: gray, white, black, red, orange, yellow, green, brown, blue and purple.

[0145] S42: Mask the words in the text of the hard sample according to the masking rules;

[0146] The masking rules are as follows: each word has a probability of P% to be selected for masking, of which (100-M)% of the masked words are replaced with a specific marker, (M / 2)% remain unchanged, and (M / 2)% are randomly replaced.

[0147] The random replacement rule is as follows: if the word itself is in the strong semantic vocabulary list, then a word is randomly selected from the strong semantic vocabulary list to replace it; if the word itself is not in the strong semantic vocabulary list, then it is randomly replaced with any word from the entire vocabulary.

[0148] In practice, P can be 20, and M can be 20, meaning each word has a 20% probability of being selected for masking. Of the words selected for masking, 80% are replaced with special symbols, 10% remain unchanged, and 10% are randomly replaced. In different embodiments, the percentages can also be set in other proportions.

[0149] In one embodiment, S15 generates cross-modal fusion features of images and text, specifically including:

[0150] S51: Composed of a cross-modal encoder F fusionThis function performs feature fusion between images and text. The cross-modal encoder consists of six Transformer layers, each containing a self-attention module, a cross-attention module, and a fully connected feedforward module. The input to the self-attention module of the first Transformer block is the output of the text encoder, while the inputs to the self-attention modules of the subsequent five Transformer blocks are the outputs of the previous Transformer block in the cross-modal encoder. The inputs to the cross-attention modules are the output of the image encoder and the outputs of the self-attention modules within the same Transformer block. The fully connected feedforward network contains two linear transformation layers and a non-linear activation function to implement the non-linear transformation. embed With t embed The fused feature vector is f embed ∈R (1+L)×768 The first bit, [CLS], represents the feature representation f of the fused feature. cls ∈R 768 ;

[0151] S52: and The fusion feature vector is The first bit, [CLS], represents the feature representation of the fused feature.

[0152] In one embodiment, S16 generates hard-match tags, specifically including:

[0153] If image I and text T have the same identity label, they are considered a match; if image I and text T have different identity labels, they are considered a mismatch. This process is repeated to generate a one-hot hard match label y between the image and the text. itm ;

[0154] Furthermore, S17 generates noise-corrected matching labels, specifically including:

[0155] Image feature representation v 0 The cosine similarity between y and v serves as a noise-corrected matching label between the image and text. NC .

[0156] In one embodiment, S18 generates mask labels for hard samples, specifically including:

[0157] If the words in the text are not color words, the original words in the masked area will be treated as real labels; if they are color words, all color words belonging to the same color category as the original words will be treated as real labels.

[0158] Furthermore, S18 generates word-image matching labels for hard samples, specifically including:

[0159] For each word in the text, the matching label is determined based on whether the semantics of the word changes after masking. If the semantics change, the matching label is 0; if the semantics do not change, the matching label is 1.

[0160] The rule for determining whether the semantics have changed is as follows: if the word has not changed or the replaced word and the original word belong to the same color category, it is considered that the semantics have not changed; otherwise, it is considered that the semantics have changed.

[0161] In one embodiment, the image-text feature contrast loss of the image-text pair in S19 specifically includes:

[0162] Before feeding the features into the multimodal encoder, intramodal and intermodal contrastive learning is performed first;

[0163] Using feature queue Q v and Q t Storing a sufficient number of negative samples enhances the performance of contrastive learning; a momentum encoder ensures the consistency of the feature queue in the feature space, and the momentum update formula is θ. k ←0.995θ k +0.005θ q The image text features obtained by the momentum encoder are v m and t m ;

[0164] The image-text feature contrast loss is:

[0165]

[0166] in, Indicates the intramodal contrast loss. This represents the contrast loss between modes.

[0167] In one embodiment, the hard-matching loss in S19 is specifically as follows:

[0168]

[0169] Among them, y itm This indicates a hard match tag. The probability distribution representing whether an image matches text can be expressed by f. cls It is obtained by sequentially passing through a binary classification head and a Softmax function.

[0170] In one embodiment, the noise correction matching loss in S19 is specifically as follows:

[0171]

[0172] Among them, y i Corresponding noise correction matching label yNC , The m represents the perceived matching probability of the noise sample; i The matching degree between the image and the text can be determined by f. cls Through a fully connected layer FC NC get; The sigmoid function can be used to convert m i Obtained through conversion.

[0173] In one embodiment, the mask modeling loss in S19 is specifically as follows:

[0174]

[0175] Among them, y mask Indicates a mask label; Let be the probability distribution of the mask labels, representing the probability that the masked word belongs to each word in the word set. This can be achieved by... sequentially through a multi-class head FC MLM It is obtained using a Softmax function.

[0176] In one embodiment, the word-image matching loss in S19 is specifically as follows:

[0177]

[0178] Among them, y WIM This represents the degree of match between the word at each position and the image, with 1 for a match and 0 for a non-match; This represents the image-text matching probability predicted based on the image and the unmasked text context, which can be obtained by... Passing through a binary sorting head FC in sequence WIM It is obtained using a Softmax function.

[0179] In one embodiment, a text-based pedestrian image retrieval method is also provided; please refer to [reference needed]. Figure 5 It includes:

[0180] S61: Load the model;

[0181] Specifically, the query text and candidate images are input into the detection model to obtain the image-text feature representations v and t, as well as the image-text matching probability. Wherein, the detection model is the detection model established by the method according to any one of claims 1 to 8;

[0182] S62: Coarse sorting;

[0183] Specifically, the N images most similar to the query text are obtained by coarsely sorting them according to the cosine similarity sim between v and t.

[0184] S63: Fine sorting;

[0185] Specifically, the probability of matching sim and image / text. The sum of the values ​​is used as the final similarity score. The N images are then finely sorted to obtain the image most similar to the query text.

[0186] In one embodiment, a text-based pedestrian image retrieval model building system is also provided; please refer to [reference needed]. Figure 6 It includes:

[0187] The sample pair acquisition module 101 is used to acquire an image I containing the target pedestrian and a text T describing the target pedestrian, to obtain a noise sample pair IT, and to search for the corresponding image I in the dataset for the text T describing the target pedestrian. 0 strong positive sample pairs I were obtained 0 -T;

[0188] The image-text feature acquisition module 102 for strong positive sample pairs is used to acquire image I from the strong positive sample pairs. 0 Image feature vector of text T within a single modality Text feature vector t embed And obtain the image I from the strong positive sample pairs. 0 Image feature representation of text T within a single modality v 0 and text feature representation t;

[0189] The image feature acquisition module 103 for noise sample pairs is used to acquire the image feature vector v of image I in a single modality within the noise sample pair IT. embed And obtain the image feature representation v of the noisy image sample within a single modality;

[0190] The hard sample masked text feature acquisition module 104 is used to generate hard sample T for masking schemes targeting strong semantic words. mask Obtain the masked text feature vector of hard samples within a single modality

[0191] The cross-modal fusion feature generation module 105 is used to generate cross-modal fusion features of images and text, specifically including: v embed and t embed The cross-modal fusion features, and and Cross-modal fusion features;

[0192] The matching label generation module 106 is used to generate hard matching labels based on whether the identity labels of I and T of the noise sample pair are the same.

[0193] Noise correction matching label generation module 107, used to generate labels based on image I 0 Similarity with I, generating noise-corrected matching labels for image-text pairs of noisy samples;

[0194] The mask label generation module 108 is used to generate mask labels for difficult samples based on the semantics of the real words at the mask location.

[0195] The word-image matching label generation module 109 is used to generate word-image matching labels based on whether the semantics of each word in the hard sample has changed.

[0196] Training module 110 is used to perform end-to-end training using the sum of losses L to obtain a detection model for image and text feature representation extraction and image-text matching probability.

[0197] The sum of losses, L, is: L = L CL +L ITM +L NC +L MLM +L WIM ;

[0198] Where L CL L represents the image-text feature contrast loss of the image-text pair. ITM L represents the hard-matching loss. NC L represents the noise-corrected matching loss. MLM L represents the mask modeling loss. WIM This represents the word-image matching loss.

[0199] After the end-to-end training described above, we obtain the extraction of image and text feature representations and the image-text matching probability. The prediction model is as follows. During actual retrieval, the query text and candidate images are input into the network to obtain the image-text feature representations v and t, as well as the image-text matching probability. Then, based on the cosine similarity (sim) between v and t, a coarse sort is performed to obtain the N images most similar to the query text. In a specific embodiment, N can be set to 256. Then, sim and the image-text matching probability are... The sum of the similarities is used as the final similarity score. The N images are then finely ranked to obtain the image most similar to the query text, thus completing the retrieval.

[0200] The following experiments demonstrate that the method / system provided in this invention can effectively correct the judgment rule of determining whether image-text pairs match based on identity tags by using the similarity between the actual matched image features. The masking scheme for strong semantic vocabulary, combined with masked language modeling and word-image matching tasks, enhances the model's ability to perceive subtle differences between samples. Overall, the accuracy of cross-modal retrieval is significantly improved. Table 1 shows the performance of this embodiment on different datasets, and Table 2 compares the performance of this embodiment on the CUHK-PEDES dataset with different combinations of loss functions.

[0201] Table 1

[0202]

[0203] Table 2

[0204]

[0205] The two tables above demonstrate that the results obtained from the embodiments of the present invention significantly improve the performance of cross-modal pedestrian retrieval. Specifically, in the prior art, only the contrast loss and image-text matching loss are constrained, resulting in an R@1 accuracy of 73.39% and a mAP of 67.16%, respectively. However, by adding the noise sample perception loss L of the present invention… NC Afterwards, R@1 and mAP improved by 0.73% and 0.96%, respectively. Furthermore, for hard samples, the masked language modeling loss L was increased... MLM Word image matching loss L WIM Subsequently, R@1 and mAP improved by 2.83% and 2.53%, respectively. Therefore, this embodiment of the invention significantly improves the performance of cross-modal pedestrian retrieval by correcting the traditional method of determining whether image text pairs match solely based on whether the image text IDs are the same and enhancing the understanding of strong semantic terms.

[0206] In one embodiment, an electronic device is also provided, please refer to Figure 7 At the hardware level, the device includes a processor 201, an internal bus 202, a network interface 203, memory 204, and a storage device 205, and may also include other hardware required for business operations. One or more embodiments of the present invention can be implemented in software, for example, the processor 201 reads the corresponding computer program from the storage device 205 into the memory device 204 and then runs it. Of course, in addition to software implementation, one or more embodiments of the present invention do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0207] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which can take the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending and receiving device, game console, tablet computer, wearable device, or any combination of these devices.

[0208] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0209] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0210] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0211] In the description of this specification, the references to terms such as "an embodiment," "an example," "a specific implementation process," and "an example" indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0212] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for establishing a text-based pedestrian image retrieval model, characterized in that, include: Acquiring an image containing a target pedestrian , and text describing the target pedestrian , obtaining a noise sample pair , for the text describing the target pedestrian , searching for a corresponding image in a data set , obtaining a strong positive sample pair ; Obtain the image from the strong positive sample pair. Image feature vector of text T within a single modality Text feature vectors ; and by and Furthermore, the image feature representation of the strong positive sample pair within a single modality is obtained. and text feature representation ; Obtain noise sample pairs Images in Image feature vector within a single modality ; And obtain the image feature representation of the noisy image sample within a single modality. ; Generating hard samples using masking schemes for strong semantic words Obtain the masked text feature vector of the hard sample in a single modality. ; The cross-modal fusion features for generating images and text specifically include: and The cross-modal fusion features, and and Cross-modal fusion features; Based on the noise sample pairs If the identity label is the same as T's, generate a hard match label; According to the image and Based on the similarity, noise-corrected matching labels for the image-text pairs of the noise samples are generated; For the difficult samples, mask labels are generated based on the semantics of the real words at the mask locations; word-image matching labels are generated based on whether the semantics of each word in the difficult samples have changed. End-to-end training is performed using the sum of losses L to obtain a model for extracting image and text feature representations and detecting image-text matching probabilities. The sum of the losses L is: ; in This represents the image-text feature contrast loss of the image-text pair. This represents the hard-matching loss. This indicates noise-corrected matching loss. This represents the mask modeling loss. This represents the word-image matching loss; The masking scheme for strong semantic words generates hard samples. Specifically, it includes: Collect high-frequency words that contribute significantly to the semantics of the text to form a list of words with strong semantic meaning; The words in the text of the difficult sample are masked according to the masking rules; The masking rule is as follows: each word has a probability of P% to be selected for masking, of which (100-M)% of the masked words are replaced with a specific marker, (M / 2)% remain unchanged, and (M / 2)% are randomly replaced. The random replacement rule is as follows: if the word itself is in the strong semantic vocabulary list, then a word is randomly selected from the strong semantic vocabulary list to replace it; if the word itself is not in the strong semantic vocabulary list, then it is randomly replaced with any word from the entire vocabulary.

2. The method for establishing a text-based pedestrian image retrieval model according to claim 1, characterized in that, The image obtained from the strong positive sample pair Image feature representation within a single modality The image obtained from the noise sample pair Image feature representation within a single modality Specifically, it includes: Input the image into the image feature encoder; The image is converted from a two-dimensional mesh structure into a serialized feature matrix through a block embedding layer in the image feature encoder; At the beginning of the feature matrix, add a learnable... Flag bit; on top of this, a learnable position code is superimposed; Added The feature matrix containing the flag bits and position encoding is input into the Transformer block to obtain the image feature vector; Among them, the image feature vector The flag bit represents the corresponding image feature; Furthermore, the text obtained from the strong positive sample pair Text feature representation within a single modality Specifically, it includes: Input the text into the text feature encoder; Through the word embedding process, each word is converted into an embedding vector, resulting in an embedding vector representation; Based on the aforementioned embedded vector representation, add Flag bits and position codes; Will be added The embedding vector, represented by the flag bits and positional encoding, is input to BERT to obtain the text feature vector; Among them, the text feature vector The flag bit represents the corresponding text feature.

3. The method for establishing a text-based pedestrian image retrieval model according to claim 1, characterized in that, The generation of hard-match tags specifically includes: If the image With text If the identity tags are the same, it is considered a match; if the images are... With text If the identity tags are different, they are considered a mismatch; accordingly, one-hot hard matching tags are generated between the image and the text. Furthermore, the generation of noise-corrected matching labels specifically includes: Representing image features and The cosine similarity between the images and text is used as a noise-corrected matching label between the images and text.

4. The method for establishing a text-based pedestrian image retrieval model according to claim 1, characterized in that, The generation of the mask label specifically includes: If the words in the text are not color words, the original words in the masked area will be treated as real labels; if they are color words, all color words belonging to the same color category as the original words will be treated as real labels. Furthermore, the generation of word-image matching labels specifically includes: For each word in the text, the matching label is determined based on whether the semantics of the word changes after masking. If the semantics change, the matching label is 0; if the semantics do not change, the matching label is 1. The rule for determining whether the semantics have changed is as follows: if the word has not changed or the replaced word and the original word belong to the same color category, it is considered that the semantics have not changed; otherwise, it is considered that the semantics have changed.

5. The method for establishing a text-based pedestrian image retrieval model according to claim 1, characterized in that, The image-text feature comparison loss for the image-text pair specifically includes: Using feature queues and Multiple negative samples are stored; a momentum encoder is used to ensure the consistency of the feature queue in the feature space, and the momentum update formula is as follows: The image text features obtained by the momentum encoder are: and ; The image-text feature contrast loss is: ; in, , Indicates the intramodal contrast loss. This represents the contrast loss between modes.

6. The method for establishing a text-based pedestrian image retrieval model according to claim 1, characterized in that, The hard-matching loss is specifically as follows: ; in, This indicates a hard match tag. This represents the probability distribution indicating whether an image matches text. The noise correction matching loss is specifically as follows: ; in, Indicates noise correction matching label, , representing the perceived matching probability of the noise sample; The degree of matching between the image and the text.

7. The method for establishing a text-based pedestrian image retrieval model according to claim 1, characterized in that, The mask modeling loss is specifically as follows: ; in, Indicates a mask label; The probability distribution of the mask labels represents the probability that the masked word belongs to each word in the word set; Furthermore, the word-image matching loss is specifically as follows: ; in, This indicates the degree of matching between the word and the image, with 1 for a match and 0 for no match; This represents the probability of image-text matching predicted based on the image and the unmasked text context.

8. A text-based pedestrian image retrieval method, characterized in that, include: The query text and candidate images are input into the detection model to obtain image-text feature representations. , and the probability of image-text matching The detection model is a detection model established according to any one of claims 1 to 7. according to and Cosine similarity between Perform a coarse sort to obtain the N images that are most similar to the query text; Will Probability of matching images and text The sum of the values ​​is used as the final similarity score. The N images are then finely sorted to obtain the image most similar to the query text.

9. A text-based pedestrian image retrieval model establishment system, characterized in that, include: The sample pair acquisition module is used to acquire images containing the target pedestrian. and text describing the target pedestrian Obtain noise sample pairs Regarding the text describing the target pedestrian Find the corresponding image in the dataset. strong positive sample pairs were obtained. ; The image-text feature acquisition module for strong positive sample pairs is used to acquire the image feature vector of the strong positive sample within a single modality. Text feature vectors And obtain the image feature representation of the strong positive sample within a single modality. and text feature representation ; The image feature acquisition module for noise sample pairs is used to acquire noise sample pairs. Images in Image feature vector within a single modality And obtain the image feature representation of the noisy image sample within a single modality. ; The hard sample masked text feature acquisition module is used to generate hard samples based on masking schemes for strong semantic words. Obtain the masked text feature vector of the hard sample in a single modality. ; The cross-modal fusion feature generation module is used to generate cross-modal fusion features of images and text, specifically including: and The cross-modal fusion features, and and Cross-modal fusion features; The matching label generation module is used to match the noise samples. If the identity label is the same as T's, generate a hard match label; The noise correction matching label generation module is used to generate labels based on images. and Based on the similarity, noise-corrected matching labels for the image-text pairs of the noise samples are generated; The mask label generation module is used to generate mask labels for the difficult samples based on the semantic meaning of the real words at the mask location; The word-image matching label generation module is used to generate word-image matching labels based on whether the semantics of each word in the hard sample has changed. The training module is used to perform end-to-end training using the sum of losses L to obtain a detection model for extracting image and text feature representations and detecting image-text matching probabilities. The sum of the losses L is: ; in This represents the image-text feature contrast loss of the image-text pair. This represents the hard-matching loss. This indicates noise-corrected matching loss. This represents the mask modeling loss. This represents the word-image matching loss; The hard sample masked text feature acquisition module generates hard samples based on masking schemes for strong semantic words. Specifically, it includes: Collect high-frequency words that contribute significantly to the semantics of the text to form a list of words with strong semantic meaning; The words in the text of the difficult sample are masked according to the masking rules; The masking rule is as follows: each word has a probability of P% to be selected for masking, of which (100-M)% of the masked words are replaced with a specific marker, (M / 2)% remain unchanged, and (M / 2)% are randomly replaced. The random replacement rule is as follows: if the word itself is in the strong semantic vocabulary list, then a word is randomly selected from the strong semantic vocabulary list to replace it; if the word itself is not in the strong semantic vocabulary list, then it is randomly replaced with any word from the entire vocabulary.

Citation Information

Patent Citations

  • Text image cross-modal pedestrian retrieval method and system based on implicit relation reasoning alignment

    CN116383671A

  • Pedestrian Retrieval Method and Apparatus

    US20200012849A1