Visual language model training method, device, medium and computer program product

Through the combination of scene graphs and learnable prompt words, the problem of low retrieval efficiency and local optimality in visual language model training is solved, and the model performance and applicability are improved.

CN118520933BActive Publication Date: 2024-09-17SHANDONG HAILIANG INFORMATION TECH RES INST
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411001895.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-09-17
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

Existing visual language models have low retrieval efficiency and poor retrieval quality during the training process, and local optimal problems caused by independent fine-tuning of some sub-modules lead to poor performance.

Method used

By obtaining the scene graph of the query image, the visual prompter in the visual language model is used to filter the most similar target image, and a learnable prompt word is generated based on the learnable parameters, which is integrated into the target image and label, and input into the visual language model for processing. training to avoid local optimal problems and improve retrieval efficiency and quality.

Benefits of technology

It achieves performance improvement of the visual language model, improves the efficiency and quality of image retrieval, fully taps the potential knowledge of the model, avoids local optimal problems, and enhances the applicability of the model in context learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118520933B
    Figure CN118520933B
Patent Text Reader

Abstract

The present invention discloses a visual language model training method, device, medium and computer program product, and relates to the field of artificial intelligence technology. The method comprises: obtaining a query image and a corresponding label, and generating a scene graph of the query image; using a visual prompter in a visual language model to screen a target image most similar to the query image in an image set based on the scene graph; generating a learnable prompt word based on the target image and a learnable parameter, and fusing the learnable prompt word into the target image and the corresponding label; inputting the fused target image and the corresponding fused label and the query image into the visual language model to obtain a prediction result of the query image; calculating a loss value according to the prediction result and the label corresponding to the query image, and training the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a trained visual language model. The present invention improves the performance of the visual language model in contextual learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and more specifically, to a visual language model training method, device, medium and computer program product. Background Art

[0002] The Visual Language Model (VLM) has demonstrated excellent performance on a variety of vision and language tasks, such as image classification, image generation, image retrieval, and natural language description of images, by learning the relationship between images and text.

[0003] In the related art, during the training process of the visual language model, the visual information of the query image and all the images in the data set are extracted respectively, and the similarity between the query image and all the images in the data set is calculated for screening, resulting in low retrieval efficiency and poor retrieval quality. At the same time, during the training process, the parameters of the visual feature model are fine-tuned using the downstream task data set to adapt to the downstream task, and the local optimal problem caused by the independent fine-tuning of some sub-modules leads to poor performance of the trained visual language model.

[0004] Therefore, how to improve the performance of the visual language model is a technical problem that technicians in this field need to solve. Summary of the invention

[0005] The purpose of the present invention is to provide a visual language model training method, device, medium and computer program product to improve the performance of the visual language model.

[0006] To achieve the above object, the present invention provides a visual language model training method, comprising:

[0007] Acquire a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image;

[0008] Using a visual cue in a visual language model to select a target image that is most similar to the query image in an image set based on the scene graph;

[0009] Generate a learnable prompt word based on the target image and the learnable parameter, and fuse the learnable prompt word into the target image and the corresponding label;

[0010] Inputting the fused target image, the corresponding fused label, and the query image into a visual language model to obtain a prediction result of the query image;

[0011] A loss value is calculated according to the prediction result and the label corresponding to the query image, and the parameters in the visual prompter and the learnable parameters are trained based on the loss value to obtain a trained visual language model.

[0012] The method of using a visual prompter in a visual language model to select a target image that is most similar to the query image from an image set based on the scene graph includes:

[0013] Using a visual cue in a visual language model to select a first target number of candidate images similar to the query image from an image set based on the scene graph;

[0014] Acquire text semantic information corresponding to the query image, and acquire text semantic information corresponding to the candidate image;

[0015] A target image most similar to the query image is determined from among the candidate images based on the similarity between text semantic information.

[0016] The method of using a visual prompter in a visual language model to select a first target number of candidate images similar to the query image from an image set based on the scene graph includes:

[0017] Using a visual prompter in a visual language model to select a second target number of candidate images similar to the query image in an image set based on objects in the scene graph, selecting a third target number of candidate images similar to the query image from the second target number of candidate images based on object relationships in the scene graph, and selecting a first target number of candidate images similar to the query image from the third target number of candidate images based on object attributes in the scene graph;

[0018] The second target quantity is greater than the third target quantity, and the third target quantity is greater than the first target quantity.

[0019] Wherein, selecting a second target number of candidate images similar to the query image from the image set based on the object in the scene graph includes:

[0020] Encoding the word segmentation results of the objects in the scene graph to obtain text codes, and encoding the images in the image set to obtain image codes;

[0021] The similarity between the text code and the image code is calculated, the images in the image set are sorted from large to small according to the similarity, and the first second target number of candidate images in the sorting result are determined.

[0022] The method of screening a third target number of candidate images similar to the query image from the second target number of candidate images based on the object relationship in the scene graph includes:

[0023] Encoding the word segmentation results of the object relationship in the scene graph to obtain a text code, and encoding the second target number of candidate images to obtain an image code;

[0024] The similarity between the text code and the image code is calculated, the second target number of candidate images are sorted from large to small according to the similarity, and the first third target number of candidate images in the sorting result are determined.

[0025] Wherein, screening a first target number of candidate images similar to the query image from the third target number of candidate images based on the object attributes in the scene graph includes:

[0026] Encoding the word segmentation results of the object attributes in the scene graph to obtain text codes, and encoding the third target number of candidate images to obtain image codes;

[0027] The similarity between the text code and the image code is calculated, the third target number of candidate images are sorted from large to small according to the similarity, and the first target number of candidate images in the sorting result are determined.

[0028] Wherein, obtaining text semantic information corresponding to the query image includes:

[0029] Encoding the query image using a visual encoder to obtain a visual encoding of the query image;

[0030] An attention mechanism is adopted to take objects, object relationships, and object attributes in the scene graph as queries and the visual encoding of the query image as keys and values ​​to obtain text semantic information corresponding to the query image.

[0031] Wherein, obtaining text semantic information corresponding to the candidate image includes:

[0032] Encoding the candidate image using a visual encoder to obtain a visual encoding of the candidate image;

[0033] An attention mechanism is adopted to obtain text semantic information corresponding to the candidate image by taking objects, object relationships, and object attributes in the scene graph as queries and visual encodings of the candidate images as keys and values.

[0034] Wherein, determining the target image most similar to the query image from among the candidate images based on the similarity between the text semantic information includes:

[0035] Mapping the text semantic information corresponding to the query image and the text semantic information corresponding to the candidate image to the same dimension;

[0036] Acquire, from the mapped text semantic information corresponding to the candidate image, a feature representation related to the mapped text semantic information corresponding to the query image;

[0037] The similarity between the candidate image and the query image is determined based on the feature representation, and the candidate image with the highest similarity is determined as the target image.

[0038] Wherein, obtaining the feature representation related to the mapped text semantic information corresponding to the query image from the mapped text semantic information corresponding to the candidate image includes:

[0039] An attention mechanism is adopted to obtain feature representation by taking the mapped text semantic information corresponding to the query image as a query and the mapped text semantic information corresponding to the candidate image as a key and a value.

[0040] The step of generating a learnable prompt word based on the target image and the learnable parameter includes:

[0041] Generate a learnable prompt word based on a learnable prompt word generation formula; wherein the learnable prompt word generation formula is: , is the generated learnable prompt word, is the learnable parameter, randn is a random number generation function, dim, h, and w are the dimension, height, and width of the target image, respectively.

[0042] Among them, the fused target image , the fused label , img is the target image before fusion, label is the label before fusion corresponding to the target image, is the preset coefficient.

[0043] To achieve the above object, the present invention provides a visual language model training method, comprising:

[0044] Acquire a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image;

[0045] Using a visual cue in a visual language model to select a target image that is most similar to the query image in an image set based on the scene graph;

[0046] Generate a learnable prompt word based on the target image and the learnable parameter, and fuse the learnable prompt word into the target image and the corresponding label;

[0047] Inputting the fused target image, the corresponding fused label, and the query image into a visual language model to obtain a prediction result of the query image;

[0048] Calculate a loss value according to the prediction result and the label corresponding to the query image, and train the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a pre-trained visual language pre-training model;

[0049] Determine a downstream task, retrain the visual language pre-training model according to the downstream training data corresponding to the downstream task to obtain a trained visual language model, and use the trained visual language model to execute the downstream task and output the execution result of the downstream task; wherein the downstream task includes any one or a combination of any one of an image classification task, an image generation task, an image retrieval task, and a natural language description image task.

[0050] To achieve the above object, the present invention provides a visual language model training device, comprising:

[0051] A first generation module is used to obtain a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image;

[0052] A screening module, configured to screen a target image most similar to the query image in an image set based on the scene graph using a visual cue in a visual language model;

[0053] A second generating module, configured to generate a learnable prompt word based on the target image and the learnable parameter, and fuse the learnable prompt word into the target image and the corresponding label;

[0054] An input module, used for inputting the fused target image, the corresponding fused label and the query image into the visual language model to obtain a prediction result of the query image;

[0055] A training module is used to calculate a loss value according to the prediction result and the label corresponding to the query image, and train the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a trained visual language model.

[0056] To achieve the above object, the present invention provides an electronic device, comprising:

[0057] Memory for storing computer programs;

[0058] A processor is used to implement the steps of the visual language model training method as described above when executing the computer program.

[0059] To achieve the above-mentioned purpose, the present invention provides a non-volatile storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the visual language model training method as described above are implemented.

[0060] To achieve the above objectives, the present invention provides a computer program product, including a computer program, which implements the steps of the above-mentioned visual language model training method when executed by a processor.

[0061] It can be seen from the above scheme that a visual language model training method provided by the present invention includes: obtaining a query image and a corresponding label, and generating a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image; using a visual prompter in a visual language model to screen a target image that is most similar to the query image in an image set based on the scene graph; generating learnable prompt words based on the target image and learnable parameters, and fusing the learnable prompt words into the target image and the corresponding label; inputting the fused target image and the corresponding fused label and the query image into the visual language model to obtain a prediction result of the query image; calculating a loss value based on the prediction result and the label corresponding to the query image, and training the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a trained visual language model.

[0062] The beneficial effects of the present invention are as follows: the visual language model training method provided by the present invention, without any need to fine-tune the existing visual language model and visual feature extraction model, selects the target image most similar to the query image by combining the scene graph of the query image, and enhances the target image and its corresponding label by learnable prompt words, and inputs the enhanced target image and its corresponding label and the query image into the visual language model together, and optimizes from the overall level based on the prediction results, which not only improves the retrieval efficiency and quality of the image, but also avoids the local optimal problem caused by not incorporating the visual language model into the learning process by fully mining the potential knowledge of the visual language model, thereby improving the performance of the visual language model in contextual learning and further improving the applicability of the visual language model. The present invention also discloses a visual language model training device, an electronic device, a non-volatile storage medium and a computer program product, which can also achieve the above technical effects.

[0063] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. The drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific implementation methods, they are used to explain the present disclosure, but do not constitute a limitation to the present disclosure. In the drawings:

[0065] Figure 1 is a flowchart of a visual language model training method according to an exemplary embodiment;

[0066] Figure 2 is a schematic diagram showing a prediction process of a visual language model for a query image according to an exemplary embodiment;

[0067] Figure 3 is a flow chart of a method for screening target images according to an exemplary embodiment;

[0068] Figure 4 A schematic diagram of a process of using a visual prompter to select a target image that is most similar to a query image according to an exemplary embodiment;

[0069] Figure 5 is a structural diagram of a visual language model training device according to an exemplary embodiment;

[0070] Figure 6 The figure is a structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0071] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, in the embodiments of the present invention, "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0072] Visual In-Context Learning based on the visual language model can achieve adaptation to new tasks without retraining the model or with minimal fine-tuning. The query image segmentation can be completed by only providing the query image and the in-context pair, where the in-context pair is an example provided by the user. These examples are retrieved from a limited dataset based on the query image and similarity. Due to the limitation of the number of retrieved sets, the similarity gap between the examples and the query image is large, and these are input into the visual language model, which further affects the final performance. The closer the in-context pair example is to the query image, the better the result. How to select better examples that are closer to the query image based on the knowledge of the visual language model and the limited amount of data for downstream tasks, without modifying the parameters of the visual language model, and improve its performance in specific tasks, has become an imminent issue.

[0073] In related technologies, the visual feature extraction model is fine-tuned based on the contextual learning of the visual language model, that is, the parameters of the visual feature model are fine-tuned using the downstream task dataset to adapt to the downstream task. The visual information of the query image and all images in the dataset are extracted separately, and the similarity between the query image and all images in the dataset is calculated for screening, resulting in low retrieval efficiency and poor retrieval quality. In the entire process, the visual language model is not combined for global optimization, but some sub-modules are fine-tuned independently, resulting in sub-optimization problems.

[0074] Therefore, in the present invention, without any need to fine-tune the existing visual language model and visual feature extraction model, the target image most similar to the query image is screened by combining the scene graph of the query image, and the target image and its corresponding label are enhanced by learnable prompt words. The enhanced target image and its corresponding label and the query image are input into the visual language model together, and the prediction result is optimized at the overall level, which not only improves the retrieval efficiency and quality of the image, but also avoids the local optimal problem caused by not incorporating the visual language model into the learning process by fully mining the potential knowledge of the visual language model, thereby improving the performance of the visual language model in contextual learning and further improving the applicability of the visual language model.

[0075] The embodiment of the present invention discloses a visual language model training method, which improves the performance of the visual language model.

[0076] See also Figure 1 , according to a flowchart of a visual language model training method shown in an exemplary embodiment, as shown in Figure 1 As shown, including:

[0077] S11: Acquire a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image;

[0078] The purpose of this embodiment is to train a visual language model, which is an artificial intelligence model that combines computer vision (Computer Vision) and natural language processing (NLP). The training of the visual language model includes two stages, namely the pre-training stage and the fine-tuning stage. In the pre-training stage, it is generally based on an image library, and for a specific model training task, a large-scale neural network algorithm structure is trained to learn and implement it. The final large-scale neural network algorithm structure and parameters are the visual language pre-training model. In the fine-tuning stage, small-scale training is performed for specific task objectives (downstream tasks) and task data (downstream data) to achieve minor adjustments to the pre-training model parameters, and finally obtain a model adapted to specific tasks and data. The neural network algorithm structure for visual language model training can be CNN (Convolutional Neural Network), RNN (Recurrent Neural Network), LSTM (Long Short-Term Memory), etc., or it can be a model built with attention network, such as transformer, BERT (Bidirectional Encoder Representations from Transformers), etc., which is not limited in the present invention. Attention network refers to a network model that uses attention mechanism for training. The model extracts more important feature information from the input sequence by assigning different weights to each part of the input sequence, so that the model finally obtains more accurate output.

[0079] In this step, the query image and the corresponding label are obtained to generate a scene graph of the query image, which includes the objects (O), object relationships (E), and object attributes (A) in the query image. The scene graph can be represented in the form of a graph, where nodes represent objects and edges represent relationships between objects.

[0080] As an optional implementation, image parsing technology can be used, such as using a semantic segmentation network in deep learning to more accurately identify objects and their attributes in the query image. At the same time, a graph neural network (GNN) can be used to better capture and represent the relationship between objects, thereby improving the accuracy of the generated scene graph and improving the performance of the trained visual language model.

[0081] S12: using a visual cue in a visual language model to select a target image that is most similar to the query image in an image set based on the scene graph;

[0082] In this step, the visual prompter selects the target image in the image set that is most similar to the query image based on the objects, object relationships, and object properties contained in the scene graph. The scene graph provides a detailed description of the objects, object relationships, and object properties in the query image. This information greatly enriches the visual language model's semantic understanding of the image. Using this detailed information, the visual language model can match the query image with the images in the image set at a deeper level.

[0083] S13: generating a learnable prompt word based on the target image and the learnable parameter, and fusing the learnable prompt word into the target image and the corresponding label;

[0084] In this step, pixel-level prompts are learned in the target image. The learned prompts directly guide the visual language model to focus on the key information in the input data, reducing the possibility of learning irrelevant features, thereby improving the learning efficiency and efficient information retrieval. Learnable prompts can fully tap the potential visual knowledge of the visual language model, enhance the visual understanding ability of the visual language model, avoid the problem of deviation caused by the deviation between the original domain data and the target domain when the trained visual language model is adapted to downstream tasks, and improve the performance of tasks in contextual learning.

[0085] In a specific implementation, a learnable prompt word is generated based on a target image and a learnable parameter. As a feasible implementation, a learnable prompt word is generated based on a learnable prompt word generation formula; wherein the learnable prompt word generation formula is: , is the generated learnable prompt word, is the learnable parameter, randn is a random number generation function, dim, h, and w are the dimension, height, and width of the target image, respectively.

[0086] Furthermore, the learnable prompt words are fused into the target image and the corresponding labels. The fused target image , the fused label , img is the target image before fusion, label is the label before fusion corresponding to the target image, is the preset coefficient.

[0087] S14: inputting the fused target image, the corresponding fused label, and the query image into a visual language model to obtain a prediction result of the query image;

[0088] In the specific implementation, the target image fused with the learnable prompt word and its corresponding label and the query image are input into the visual language model to obtain the prediction result for the query image, that is, , , , For the query image, is an empty set, and LVM is a visual language model.

[0089] The prediction process of the visual language model for the query image in this embodiment is as follows: Figure 2 As shown, a visual prompter is used to filter the target image most similar to the query image in the image set based on the scene graph, a learnable prompt word is generated based on the target image and the learnable parameters, and the learnable prompt word is fused into the target image and the label of the target image to obtain the target image fused with the learnable prompt word and the label of the target image fused with the learnable prompt word. The query image, the target image fused with the learnable prompt word, and the label of the target image fused with the learnable prompt word are input into the visual language model to obtain the prediction result of the query image.

[0090] S15: Calculate a loss value according to the prediction result and the label corresponding to the query image, and train the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a trained visual language model.

[0091] In the specific implementation, a loss function is constructed according to the prediction result of the query image and the actual label. The loss function here is related to the task. The parameters and learnable parameters in the visual prompter are trained based on the calculated loss value to obtain a trained visual language model.

[0092] It should be noted that this embodiment pre-trains the visual language model. Through the scheme of this embodiment, a pre-trained visual language pre-trained model can be obtained, and then the downstream task is determined. The visual language pre-trained model is re-trained according to the downstream training data corresponding to the downstream task to obtain a trained visual language model. The trained visual language model is used to execute downstream tasks and output the execution results of the downstream tasks; wherein the downstream tasks include any one or a combination of image classification tasks, image generation tasks, image retrieval tasks, and natural language description image tasks.

[0093] The visual language model training method provided by the embodiment of the present invention does not require any fine-tuning of the existing visual language model and visual feature extraction model. It selects the target image most similar to the query image by combining the scene graph of the query image, enhances the target image and its corresponding label by learnable prompt words, and inputs the enhanced target image and its corresponding label and the query image into the visual language model. It optimizes at the overall level based on the prediction results, which not only improves the retrieval efficiency and quality of the image, but also avoids the local optimal problem caused by not incorporating the visual language model into the learning process by fully mining the potential knowledge of the visual language model, thereby improving the performance of the visual language model in contextual learning and further improving the applicability of the visual language model.

[0094] The embodiment of the present invention discloses a method for screening target images, which is to further illustrate and optimize step S12 in the previous embodiment. Specifically:

[0095] See also Figure 3 , according to an exemplary embodiment, a flowchart of a method for screening a target image is shown, such as Figure 3 As shown, including:

[0096] S121: using a visual prompter in a visual language model to select a first target number of candidate images similar to the query image from an image set based on the scene graph;

[0097] In the specific implementation, the visual prompter conducts comparative learning through a large number of image and text pairs, so that it can understand and associate the image content and text description, use the content contained in the scene graph as the query statement, and screen candidate images with a high degree of match with the query image in the image set.

[0098] As a feasible implementation manner, using visual cues in a visual language model to screen a first target number of candidate images similar to the query image in an image set based on the scene graph includes: using visual cues in a visual language model to screen a second target number of candidate images similar to the query image in an image set based on objects in the scene graph, screening a third target number of candidate images similar to the query image from the second target number of candidate images based on object relationships in the scene graph, and screening a first target number of candidate images similar to the query image from the third target number of candidate images based on object attributes in the scene graph; wherein the second target number is greater than the third target number, and the third target number is greater than the first target number.

[0099] In a specific implementation, first, a second target number (e.g., 100) of candidate images with a high degree of matching with the query image are screened from the image set using the object as a query statement, and then a third target number (e.g., 50) of candidate images with a higher degree of matching with the query image are screened from the second target number of candidate images using the object relationship as a query statement, and then a first target number (e.g., 20) of candidate images with a higher degree of matching with the query image are screened from the third target number of candidate images using the object attribute as a query statement.

[0100] As a feasible implementation method, a second target number of candidate images similar to the query image are screened in an image set based on the objects in the scene graph, including: encoding the word segmentation results of the objects in the scene graph to obtain text codes, and encoding the images in the image set to obtain image codes; calculating the similarity between the text codes and the image codes, sorting the images in the image set from large to small according to the similarities, and determining the top second target number of candidate images in the sorting results.

[0101] As a feasible implementation method, a third target number of candidate images similar to the query image are screened from the second target number of candidate images based on the object relationship in the scene graph, including: encoding the word segmentation results of the object relationship in the scene graph to obtain a text code, and encoding the second target number of candidate images to obtain an image code; calculating the similarity between the text code and the image code, sorting the second target number of candidate images from large to small according to the similarity, and determining the top third target number of candidate images in the sorting result.

[0102] As a feasible implementation method, a first target number of candidate images similar to the query image are screened from the third target number of candidate images based on the object attributes in the scene graph, including: encoding the word segmentation results of the object attributes in the scene graph to obtain text codes, and encoding the third target number of candidate images to obtain image codes; calculating the similarity between the text codes and the image codes, sorting the third target number of candidate images from large to small according to the similarity, and determining the first first target number of candidate images in the sorting results.

[0103] In a specific implementation, the image set , read all images in the image set, record the result as imgs_data, and tokenize the object O in the scene graph. Use the image encoder to encode imgs_data to get the image encoding , using the text encoder Encode to get text encoding ,calculate and The similarity between them can be measured by cosine similarity, similarity score , norm is the normalization operation, cosine is the cosine similarity calculation operation, and the second target number of candidate images with the highest score are selected as the screening result D0.

[0104] Furthermore, the object relationship E in the scene graph is segmented, and the segmentation result is encoded using a text encoder to obtain a text encoding of the object relationship. The similarity score between the text encoding of the object relationship and the image encoding of the image in the screening result D0 is calculated, and the third target number of candidate images with the highest similarity scores are selected as the screening result D1.

[0105] Furthermore, the object attribute A in the scene graph is segmented, and the segmentation result is encoded using a text encoder to obtain a text encoding of the object attribute, and the similarity score between the text encoding of the object attribute and the image encoding of the image in the screening result D1 is calculated, and the first target number of candidate images with the highest similarity score are selected as the screening result D2.

[0106] S122: Acquire text semantic information corresponding to the query image, and acquire text semantic information corresponding to the candidate image;

[0107] In this step, the text semantic information of the query image related to the object, object relationship, and object attribute, as well as the text semantic information of the candidate images in the screening result D2 related to the object, object relationship, and object attribute are obtained.

[0108] As a feasible implementation method, obtaining text semantic information corresponding to the query image includes: using a visual encoder to encode the query image to obtain a visual encoding of the query image; using an attention mechanism to use objects, object relationships, and object attributes in the scene graph as queries and the visual encoding of the query image as keys and values ​​to obtain the text semantic information corresponding to the query image.

[0109] In the specific implementation, a visual encoder is used to encode the query image, that is, , visual_encoder is a visual encoder, such as ViT (VisionTransformer, visual transformer), etc., The visual encoding of the query image is obtained by using the multi-head cross attention mechanism to establish the association between the object + object relationship + object attribute and the visual encoding, that is, the object + object relationship + object attribute is used as the query. As key and value, a semantic association is established between the two in different subspaces to obtain relevant text semantic information in visual encoding. , , MultiHeaderAttention is a multi-head cross attention mechanism.

[0110] As a feasible implementation method, obtaining the text semantic information corresponding to the candidate image includes: using a visual encoder to encode the candidate image to obtain the visual encoding of the candidate image; using an attention mechanism to use the objects, object relationships, and object attributes in the scene graph as queries and the visual encoding of the candidate image as keys and values ​​to obtain the text semantic information corresponding to the candidate image.

[0111] In the specific implementation, a visual encoder is used to encode the candidate images in the screening result D2, and a multi-head cross attention mechanism is used to establish the association between the object + object relationship + object attribute and the visual encoding of the candidate image. The object + object relationship + object attribute is used as the query, and the visual encoding of the candidate image is used as the key and value to obtain the text semantic information corresponding to the candidate image. .

[0112] S123: Determine a target image that is most similar to the query image from among the candidate images based on the similarity between text semantic information.

[0113] In a specific implementation, the similarity between the text semantic information corresponding to the query image and the text semantic information corresponding to each candidate image is calculated to determine the target image most similar to the query image among the candidate images.

[0114] As a feasible implementation manner, a target image that is most similar to the query image is determined in the candidate images based on the similarity between text semantic information, including: mapping the text semantic information corresponding to the query image and the text semantic information corresponding to the candidate image to the same dimension; obtaining a feature representation related to the mapped text semantic information corresponding to the query image in the mapped text semantic information corresponding to the candidate image; determining the similarity between the candidate image and the query image based on the feature representation, and determining the candidate image with the highest similarity as the target image.

[0115] In the specific implementation, and Mapped to the same latitude, that is , , To query the mapped text semantic information corresponding to the image, is the mapped text semantic information corresponding to the candidate image, and FC is fully connected. Furthermore, the attention mechanism is used to obtain feature representation with the mapped text semantic information corresponding to the query image as the query and the mapped text semantic information corresponding to the candidate image as the key and value, that is, , attn_out is the feature representation. Furthermore, the similarity score between the candidate image and the query image is calculated: scores=softmax(FC(attn_out)), FC is a linear mapping, softmax is an activation function, and the candidate image with the highest similarity score is selected as the target image.

[0116] The process of using the visual prompter to select the target image that is most similar to the query image in this embodiment is as follows: Figure 4 As shown, a scene graph generator is used to generate a scene graph containing objects, object relationships, and object attributes. The second target number of candidate images with a high degree of matching with the query image are selected from the image set using the object as a query statement as the screening result D0. Then, the third target number of candidate images with a higher degree of matching with the query image are selected from the second target number of candidate images using the object relationship as a query statement as the screening result D1. Then, the first target number of candidate images with a higher degree of matching with the query image are selected from the third target number of candidate images using the object attribute as a query statement as the screening result D2. The query image is encoded using a visual encoder to obtain a visual encoding of the query image; an attention mechanism is used to use the objects, object relationships, and object attributes in the scene graph as queries, and the visual encoding of the query image as keys and values ​​to obtain text semantic information corresponding to the query image. The candidate image is encoded using a visual encoder to obtain a visual encoding of the candidate image; an attention mechanism is used to use the objects, object relationships, and object attributes in the scene graph as queries, and the visual encoding of the candidate image as keys and values ​​to obtain text semantic information corresponding to the candidate image. The similarity between the text semantic information corresponding to the query image and the text semantic information corresponding to each candidate image is calculated to determine the target image most similar to the query image among the candidate images.

[0117] It can be seen that the multi-head cross-attention mechanism generates a unique similarity score for each head by calculating the correlation on different dimensions. Integrating these similarity scores can provide a more comprehensive similarity evaluation, which reflects the similarity between the query image and the images in the image set, and improves the retrieval accuracy and reliability. By optimizing semantic matching and multi-dimensional analysis, the most relevant target images can be quickly and effectively screened out from large-scale image sets. The visual language model can automatically adjust its attention focus according to different query images and optimize the screening strategy to match specific search needs or cope with different visual tasks.

[0118] The following is an application embodiment provided by the present invention, which constructs a visual prompter based on a scene graph. The scene graph model can output the object corresponding to the image, the relationship between objects, and the attributes of the object. Based on this, a set of screening mechanisms from objects, objects + relationships, and objects + relationships + attributes are designed, that is, with the query image as the target, similar examples are screened out from the data set; then, with the object + relationship + attribute as the query, relevant semantic information is obtained from the query image and the screened examples; finally, the most similar example is found from the semantic information of the screened examples based on the semantic information of the query image. This method not only improves the efficiency and quality of image retrieval by coordinating the scene graph with the multi-head cross-attention mechanism, but also further improves the model's ability to understand images. The specific steps are as follows:

[0119] Step 1: Generate a scene graph of the query image. A scene graph is used to describe the scene in an image, usually including objects in the image, the relationships between objects, and the attributes of the objects, represented by letters O, E, and A, respectively. A scene graph is usually represented in the form of a graph, where nodes represent objects and edges represent the relationships between objects.

[0120] Step 2: Filter from the dataset with the object O in the scene graph as the target. Through comparative learning of a large number of image and text pairs, it is possible to understand and associate the image content and text description, and use the object in the scene graph as the query statement to filter images with high matching degree. The specific steps are as follows:

[0121] 2.1. Prepare and read images. Let the image set be D, ,img i is the i-th image in the image set D, 1≤i≤n, read all images in the image set, and the result is recorded as imgs_data;

[0122] 2.2. Tokenize the object O in the scene graph, that is , is the tokenization result of object O;

[0123] 2.3. Use the image encoder to encode all images imgs_data, that is , It is the encoding result of the image data imgs_data;

[0124] 2.4. Using text encoder Encode, that is , for The encoding result of

[0125] 2.5 Calculation and The similarity between them is calculated and the top-k results are output. Cosine similarity is used to measure text and image, that is, , norm is the normalization operation, cosine is the cosine similarity calculation operation, score is and The similarity scores between them are finally selected, and the top-k results in the score are finally selected as the output. Here, k is selected as 100, and the screening result is recorded as D0.

[0126] Step 3: Further filter the objects + relationships in the scene graph. That is, further filter the result D0 of the scene graph object filtering, and record the result as D1. This step is similar to the previous step. Here, k in top-k is 50, D1=Ψ(D0,O,E), and Ψ is the operation in the previous step.

[0127] Step 4: Further filter the objects + relationships + attributes in the scene graph. D1 is further filtered and the result is recorded as D2. Here, k in the top-k is 20, and D2 = Ψ(D1, O, E, A).

[0128] Step 5: Use the cross attention mechanism to obtain the semantic information related to the query image and the screening result D2 with object + relationship + attribute as the query. Here, object + relationship + attribute is used as the query, and the visual information of the query image img_query and the image in the screening result D2 is used as the value and key. The cross attention mechanism uses text information to guide the attention allocation of the image visual information to obtain the information related to the text semantics in the image. The specific steps are as follows:

[0129] 5.1. Obtain semantic information related to objects, relations and attributes in the query image. The operation is as follows:

[0130] 5.11. Encode the image using a visual encoder. , visual_encoder is the visual encoder, For the query image Visual encoding of

[0131] 5.12. Using multi-head attention mechanism to establish object + relationship + attribute and visual information Association, that is, object + relationship + attribute as query, As key and value, the semantic association between the two is established in different subspaces, so as to obtain the relevant text semantic information in the visual information. .

[0132] 5.2. Obtain semantic information related to objects, relations, and attributes in the screening result D2. For all images in the screening result 2, the same processing method as the query image is used to obtain semantic information related to objects, relations, and attributes for all images in D2. The result is recorded as .

[0133] Step 6: Filter out Zhongyu The most similar examples. For query, For keys and values, the cross-attention mechanism is dynamically established and The most relevant features in terms of visual content, thus obtaining examples that are more visually similar to the query image. The specific operation is as follows:

[0134] 6.1、Respectively and Mapped to the same latitude, that is , , FC is fully connected, , for and The linear mapping result of ;

[0135] 6.2. Using multi-head cross attention mechanism to obtain Visual content and The relevant features, namely For query, For key and value, , attn_out is the input data and The weighted and comprehensive feature representation of

[0136] 6.3. Output D2 and the query image Similarity, scores=softmax(FC(attn_out)), FC is a linear mapping, softmax is an activation function, scores are the sum of all images in D2 and the query image Similarity, select the one with the largest score as the final screening result.

[0137] It can be seen that the visual prompter based on the full scene graph can perform accurate semantic matching: the scene graph provides a detailed description of the objects, relationships, and attributes in the image. This information greatly enriches the model's semantic understanding of the image. Using this detailed information, the model can match the query image with the examples in the dataset at a deeper level. The visual prompter based on the full scene graph can optimize the similarity evaluation: the multi-head cross-attention mechanism generates a unique similarity score for each head by calculating the correlation on different dimensions. The integration of these scores can provide a more comprehensive similarity evaluation, thereby reflecting the similarity between the query image and the images in the dataset, improving the retrieval accuracy and reliability. The visual prompter based on the full scene graph can be dynamically adaptable and flexible: the model can automatically adjust its attention focus according to different query images and optimize the screening strategy to match specific search needs or cope with different visual tasks. The visual prompter based on the full scene graph can improve the retrieval efficiency: by optimizing semantic matching and multi-dimensional analysis, the most relevant examples can be quickly and effectively screened from large-scale datasets.

[0138] The model training process is as follows:

[0139] Step 1: Based on the input query image , based on the scene graph visual cue, select the sample S={img,label} that is most similar to the query image from the dataset D, where img is the filtered image and label is the label corresponding to img.

[0140] Step 2: Learn pixel-level prompts in example images. In NLP, when a trained model is adapted to downstream tasks, there will be an offset problem due to the deviation between the original domain data and the target domain. Learnable prompts can be used to fully tap the model's potential knowledge to solve this problem without making any changes to the model. Therefore, in the visual field, pixel-level prompts are learned to enhance the visual understanding ability of the visual model. The details are as follows:

[0141] Let the learnable pixel-level prompt be , the width, height and dimensions of the example image are w, h and dim respectively. , randn is the random number generation function, Representation model training Learnable parameters in the process;

[0142] Step 3: Add the learned prompt to the example S, that is ,in, , , For learnable prompt words The coefficient of .

[0143] Step 4: Result prediction. Combine the enhanced examples and query image and input them into the visual model to obtain the prediction result for the query image, that is, , LVM is the visual language model, , Is an empty set.

[0144] Step 5: Build a loss function based on the task, train and learn related parameters. Build a loss function based on the query image prediction result and the actual label. The loss function here is related to the task. Based on the built loss function, learn the scene graph visual prompt module parameters and pixel-level learnable prompt words. .

[0145] Pixel-level learnable prompts can improve learning efficiency: prompts directly guide the model to focus on key information in the input data, reducing the possibility of learning irrelevant features, thereby improving learning efficiency and efficient information retrieval. Pixel-level learnable prompts can b) fully tap the potential knowledge of large visual models: large visual models are usually pre-trained on large-scale datasets and have accumulated a large amount of visual knowledge. Through learnable prompts, these visual knowledge can be activated to improve the performance of tasks in contextual learning. Contextual learning of visual language models based on scene graphs, through scene graphs, cross-attention mechanisms, and pixel-level learnable prompts, the performance of visual language models in contextual learning is improved.

[0146] A visual language model training device provided by an embodiment of the present invention is introduced below. The visual language model training device described below and the visual language model training method described above can be referenced to each other.

[0147] See also Figure 5 , according to a structural diagram of a visual language model training device shown in an exemplary embodiment, such as Figure 5 As shown, including:

[0148] The first generation module 501 is used to obtain a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image;

[0149] A screening module 502 is used to screen a target image that is most similar to the query image in the image set based on the scene graph using a visual cue in a visual language model;

[0150] A second generating module 503 is used to generate a learnable prompt word based on the target image and the learnable parameter, and merge the learnable prompt word into the target image and the corresponding label;

[0151] An input module 504 is used to input the fused target image, the corresponding fused label, and the query image into a visual language model to obtain a prediction result of the query image;

[0152] The training module 505 is used to calculate the loss value according to the prediction result and the label corresponding to the query image, and train the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a trained visual language model.

[0153] The visual language model training device provided by the embodiment of the present invention does not require any fine-tuning of the existing visual language model and visual feature extraction model. It selects the target image most similar to the query image by combining the scene graph of the query image, enhances the target image and its corresponding label by learnable prompt words, and inputs the enhanced target image and its corresponding label and the query image into the visual language model. It optimizes at the overall level based on the prediction result, which not only improves the retrieval efficiency and quality of the image, but also avoids the local optimal problem caused by not incorporating the visual language model into the learning process by fully mining the potential knowledge of the visual language model, thereby improving the performance of the visual language model in contextual learning and further improving the applicability of the visual language model.

[0154] On the basis of the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: use the visual prompt in the visual language model to screen a first target number of candidate images similar to the query image in the image set based on the scene graph; obtain the text semantic information corresponding to the query image, obtain the text semantic information corresponding to the candidate images; determine the target image most similar to the query image in the candidate images based on the similarity between the text semantic information.

[0155] On the basis of the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: use the visual prompt in the visual language model to screen a second target number of candidate images similar to the query image in the image set based on the objects in the scene graph, screen a third target number of candidate images similar to the query image from the second target number of candidate images based on the object relationship in the scene graph, and screen a first target number of candidate images similar to the query image from the third target number of candidate images based on the object attributes in the scene graph; wherein the second target number is greater than the third target number, and the third target number is greater than the first target number.

[0156] On the basis of the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: encode the word segmentation results of the objects in the scene graph to obtain text codes, and encode the images in the image set to obtain image codes; calculate the similarity between the text codes and the image codes, sort the images in the image set from large to small according to the similarity, and determine the top second target number of candidate images in the sorting results.

[0157] On the basis of the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: encode the word segmentation results of the object relationship in the scene graph to obtain a text code, and encode the second target number of candidate images to obtain an image code; calculate the similarity between the text code and the image code, sort the second target number of candidate images from large to small according to the similarity, and determine the top third target number of candidate images in the sorting result.

[0158] On the basis of the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: encode the word segmentation results of the object attributes in the scene graph to obtain text codes, and encode the third target number of candidate images to obtain image codes; calculate the similarity between the text code and the image code, sort the third target number of candidate images from large to small according to the similarity, and determine the first first target number of candidate images in the sorting result.

[0159] Based on the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: use a visual encoder to encode the query image to obtain a visual encoding of the query image; use an attention mechanism to use objects, object relationships, and object attributes in the scene graph as queries and the visual encoding of the query image as keys and values ​​to obtain text semantic information corresponding to the query image.

[0160] Based on the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: use a visual encoder to encode the candidate image to obtain a visual encoding of the candidate image; use an attention mechanism to use objects, object relationships, and object attributes in the scene graph as queries and the visual encoding of the candidate image as keys and values ​​to obtain text semantic information corresponding to the candidate image.

[0161] On the basis of the above embodiments, as a preferred implementation mode, the screening module 502 is specifically used to: map the text semantic information corresponding to the query image and the text semantic information corresponding to the candidate image to the same dimension; obtain the feature representation related to the mapped text semantic information corresponding to the query image in the mapped text semantic information corresponding to the candidate image; determine the similarity between the candidate image and the query image based on the feature representation, and determine the candidate image with the highest similarity as the target image.

[0162] Based on the above embodiments, as a preferred implementation, the screening module 502 is specifically used to: adopt an attention mechanism to take the mapped text semantic information corresponding to the query image as the query, and take the mapped text semantic information corresponding to the candidate image as the key and value to obtain feature representation.

[0163] Based on the above embodiment, as a preferred implementation, the second generation module 503 is specifically used to: generate a learnable prompt word based on a learnable prompt word generation formula; wherein the learnable prompt word generation formula is: , is the generated learnable prompt word, is the learnable parameter, randn is a random number generation function, dim, h, and w are the dimension, height, and width of the target image, respectively.

[0164] Based on the above embodiment, as a preferred implementation, the fused target image , the fused label , img is the target image before fusion, label is the label before fusion corresponding to the target image, is the preset coefficient.

[0165] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0166] Based on the hardware implementation of the above program modules and in order to implement the method of the embodiment of the present invention, the embodiment of the present invention further provides an electronic device, Figure 6 FIG. 1 is a structural diagram of an electronic device according to an exemplary embodiment. Figure 6 As shown, the electronic equipment includes:

[0167] Communication interface 1, capable of exchanging information with other devices such as network devices;

[0168] The processor 2 is connected to the communication interface 1 to realize information interaction with other devices, and is used to execute the visual language model training method provided by one or more technical solutions when running a computer program. The computer program is stored in the memory 3.

[0169] Of course, in actual application, the various components in the electronic device are coupled together through the bus system 4. It can be understood that the bus system 4 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 4 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, Figure 6 Various buses are labeled as bus system 4.

[0170] The memory 3 in the embodiment of the present invention is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program used to operate on the electronic device.

[0171] It can be understood that the memory 3 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory 3 described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable types of memories.

[0172] The method disclosed in the above embodiment of the present invention can be applied to the processor 2, or implemented by the processor 2. The processor 2 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 2 or the instruction in the form of software. The above processor 2 can be a general-purpose processor, a DSP, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 2 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general-purpose processor can be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 3. The processor 2 reads the program in the memory 3 and completes the steps of the above method in combination with its hardware.

[0173] When the processor 2 executes the program, the corresponding processes in the various methods of the embodiments of the present invention are implemented, which will not be described here for the sake of brevity.

[0174] In an exemplary embodiment, the embodiment of the present invention further provides a non-volatile storage medium storing a computer program, which can be executed by the processor 2 to complete the steps of the aforementioned method.

[0175] In an exemplary embodiment, the present invention further provides a computer program product, including a computer program, which is executed by the processor 2 to complete the steps of the aforementioned method.

[0176] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to computer program instructions, and the aforementioned computer program can be stored in a non-volatile storage medium. When the computer program is executed, it executes the steps of the above method embodiments. Alternatively, if the above-mentioned integrated unit of the present invention is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the embodiment of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a non-volatile storage medium and includes a number of instructions for an electronic device (which can be a personal computer, a server, a network device, etc.) to execute all or part of the methods described in each embodiment of the present invention.

[0177] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.

Claims

1. A visual language model training method, It is characterized in that include: Acquire a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image; Using a visual cue in a visual language model to select a target image that is most similar to the query image in an image set based on the scene graph; Generate a learnable prompt word based on the target image and the learnable parameter, and fuse the learnable prompt word into the target image and the corresponding label; Inputting the fused target image, the corresponding fused label, and the query image into a visual language model to obtain a prediction result of the query image; A loss value is calculated according to the prediction result and the label corresponding to the query image, and the parameters in the visual prompter and the learnable parameters are trained based on the loss value to obtain a trained visual language model.

2. According to the visual language model training method of claim 1, It is characterized in that Using a visual prompter in a visual language model to select a target image that is most similar to the query image from an image set based on the scene graph, comprising: Using a visual cue in a visual language model to select a first target number of candidate images similar to the query image from an image set based on the scene graph; Acquire text semantic information corresponding to the query image, and acquire text semantic information corresponding to the candidate image; A target image most similar to the query image is determined from among the candidate images based on the similarity between text semantic information.

3. According to the visual language model training method of claim 2, It is characterized in that Using a visual prompter in a visual language model to select a first target number of candidate images similar to the query image from an image set based on the scene graph, comprising: Using a visual prompter in a visual language model to select a second target number of candidate images similar to the query image in an image set based on objects in the scene graph, selecting a third target number of candidate images similar to the query image from the second target number of candidate images based on object relationships in the scene graph, and selecting a first target number of candidate images similar to the query image from the third target number of candidate images based on object attributes in the scene graph; The second target quantity is greater than the third target quantity, and the third target quantity is greater than the first target quantity.

4. According to the visual language model training method of claim 3, It is characterized in that Screening a second target number of candidate images similar to the query image from an image set based on the object in the scene graph includes: Encoding the word segmentation results of the objects in the scene graph to obtain text codes, and encoding the images in the image set to obtain image codes; The similarity between the text code and the image code is calculated, the images in the image set are sorted from large to small according to the similarity, and the first second target number of candidate images in the sorting result are determined.

5. According to the visual language model training method of claim 3, It is characterized in that Screening a third target number of candidate images similar to the query image from the second target number of candidate images based on the object relationship in the scene graph includes: Encoding the word segmentation results of the object relationship in the scene graph to obtain a text code, and encoding the second target number of candidate images to obtain an image code; The similarity between the text code and the image code is calculated, the second target number of candidate images are sorted from large to small according to the similarity, and the first third target number of candidate images in the sorting result are determined.

6. According to the visual language model training method of claim 3, It is characterized in that Screening a first target number of candidate images similar to the query image from the third target number of candidate images based on the object attributes in the scene graph includes: Encoding the word segmentation results of the object attributes in the scene graph to obtain text codes, and encoding the third target number of candidate images to obtain image codes; The similarity between the text code and the image code is calculated, the third target number of candidate images are sorted from large to small according to the similarity, and the first target number of candidate images in the sorting result are determined.

7. The visual language model training method according to claim 2, It is characterized in that Acquiring text semantic information corresponding to the query image, including: Encoding the query image using a visual encoder to obtain a visual encoding of the query image; An attention mechanism is adopted to take objects, object relationships, and object attributes in the scene graph as queries and the visual encoding of the query image as keys and values ​​to obtain text semantic information corresponding to the query image.

8. According to the visual language model training method of claim 2, It is characterized in that Obtaining text semantic information corresponding to the candidate image includes: Encoding the candidate image using a visual encoder to obtain a visual encoding of the candidate image; An attention mechanism is adopted to obtain text semantic information corresponding to the candidate image by taking objects, object relationships, and object attributes in the scene graph as queries and visual encodings of the candidate images as keys and values.

9. The visual language model training method according to claim 2, It is characterized in that Determining a target image that is most similar to the query image from among the candidate images based on the similarity between text semantic information includes: Mapping the text semantic information corresponding to the query image and the text semantic information corresponding to the candidate image to the same dimension; Acquire, from the mapped text semantic information corresponding to the candidate image, a feature representation related to the mapped text semantic information corresponding to the query image; The similarity between the candidate image and the query image is determined based on the feature representation, and the candidate image with the highest similarity is determined as the target image.

10. The visual language model training method according to claim 9, It is characterized in that Acquiring feature representation related to the mapped text semantic information corresponding to the query image from the mapped text semantic information corresponding to the candidate image, including: An attention mechanism is adopted to obtain feature representation by taking the mapped text semantic information corresponding to the query image as a query and the mapped text semantic information corresponding to the candidate image as a key and a value.

11. The visual language model training method according to claim 1, It is characterized in that Generating a learnable prompt word based on the target image and the learnable parameter includes: Generate a learnable prompt word based on a learnable prompt word generation formula; wherein the learnable prompt word generation formula is: , is the generated learnable prompt word, is the learnable parameter, randn is a random number generation function, dim, h, and w are the dimension, height, and width of the target image, respectively.

12. The visual language model training method according to claim 11, It is characterized in that The fused target image , the fused label , img is the target image before fusion, label is the label before fusion corresponding to the target image, is the preset coefficient.

13. A visual language model training method, It is characterized in that include: Acquire a query image and a corresponding label, and generate a scene graph of the query image; wherein the scene graph is used to describe objects, object relationships, and object attributes in the query image; Using a visual cue in a visual language model to select a target image that is most similar to the query image in an image set based on the scene graph; Generate a learnable prompt word based on the target image and the learnable parameter, and fuse the learnable prompt word into the target image and the corresponding label; Inputting the fused target image, the corresponding fused label, and the query image into a visual language model to obtain a prediction result of the query image; Calculate a loss value according to the prediction result and the label corresponding to the query image, and train the parameters in the visual prompter and the learnable parameters based on the loss value to obtain a pre-trained visual language pre-training model; Determine a downstream task, retrain the visual language pre-training model according to the downstream training data corresponding to the downstream task to obtain a trained visual language model, and use the trained visual language model to execute the downstream task and output the execution result of the downstream task; wherein the downstream task includes any one or a combination of any one of an image classification task, an image generation task, an image retrieval task, and a natural language description image task.

14. An electronic device, It is characterized in that include: Memory for storing computer programs; A processor, configured to implement the steps of the visual language model training method as claimed in any one of claims 1 to 13 when executing the computer program.

15. A non-volatile storage medium, It is characterized in that The non-volatile storage medium stores a computer program, and when the computer program is executed, the steps of the visual language model training method according to any one of claims 1 to 13 are implemented.

16. A computer program product, It is characterized in that It comprises a computer program, which, when executed, implements the steps of the visual language model training method as claimed in any one of claims 1 to 13.

Citation Information

Patent Citations

  • Video language task execution method and device, video language task model training method and device, equipment and medium

    CN117876940A

  • Visual question-answering method, device and equipment based on relation alignment, medium and product

    CN118211657A

  • Visual language model field adaptive method based on adversarial double-prompt learning, terminal and readable storage medium

    CN118334489A

  • Model training method and device, equipment, storage medium and program product

    CN118378633A

  • Processing method and apparatus for visual question answering task, and device and non-volatile readable storage medium

    WO2024045444A1