Image matching method, device, electronic device and storage medium
By extracting feature information from news texts and pictures through a pre-trained feature extraction model, it solves the problems in the existing technology of low matching efficiency caused by redundant information and results that do not conform to the topic, achieves efficient and accurate picture matching, and improves the quality of news The perceived quality of coverage and reader interest.
Patent Information
- Application Number
- CN202011561238.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2040-12-25
AI Technical Summary
When matching pictures in news reports with the existing technology, redundant information can easily lead to low matching efficiency and results that do not conform to the news theme, and lack flexibility.
The pre-trained feature extraction model is used to extract feature information from the target text and pictures, and the pictures that best match the target text are selected by calculating the distance of the feature information to realize automatic text matching.
It improves the accuracy and efficiency of image matching, improves the look and feel quality of text, stimulates readers' interest in reading, and enhances the attractiveness of news reports.
Smart Images

Figure CN112650867B
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the fields of computer vision and natural language technology, and in particular to a picture matching method, device, electronic device, and storage medium. Background Art
[0002] Pictures in news can not only let readers understand the main content of the news intuitively and clearly, but also stimulate readers' interest to a great extent, improve readers' reading experience, and thus attract more readers. Therefore, pictures play an irreplaceable role in news reports, and it is extremely important to match each news article with appropriate pictures.
[0003] Most existing technical methods directly use long text content for image-text matching, and the matching results are likely to be inconsistent with the news topic. In addition, existing methods mainly use pictures in news with pictures to construct a supplementary picture library, and use multiple topic tags in the news as the label of the picture, which makes the image matching efficiency low. Summary of the invention
[0004] The present invention provides a picture matching method, device, electronic device and storage medium, which realize automatic picture matching of text, thereby improving the visual quality of the text, stimulating the reading interest of the reader, and improving the reading experience of the reader.
[0005] In a first aspect, an embodiment of the present invention provides a picture matching method, the method comprising:
[0006] Acquire a target text, and extract text feature information of the target text based on a pre-trained feature extraction model;
[0007] Matching the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model;
[0008] The picture matching the text feature information is determined as the matching picture of the target text.
[0009] In a second aspect, an embodiment of the present invention further provides a picture matching device, the device comprising:
[0010] A text feature information acquisition module, used to acquire a target text and extract text feature information of the target text based on a pre-trained feature extraction model;
[0011] A text feature information matching module, used for matching the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model;
[0012] The matching picture determination module is used to determine the picture that matches the text feature information as the matching picture of the target text.
[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0014] one or more processors;
[0015] a storage device for storing one or more programs,
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the image matching method provided by any embodiment of the present invention.
[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image matching method provided by any embodiment of the present invention.
[0018] The technical solution of the embodiment of the present invention uses a pre-trained feature extraction model to extract text feature information from the acquired target text, thereby removing a large amount of redundant information in the target text and reducing the amount of calculation on the text information. The distance information of the acquired text feature information and the image feature information of each image in the preset gallery are then checked, and the image in the preset gallery that best matches the target text is screened out through the calculated distance, thereby realizing automatic image matching for the text, thereby improving the visual quality of the text, stimulating the reader's interest in reading, and enhancing the reader's reading experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required to describe the embodiments. Obviously, the drawings introduced are only drawings of a part of the embodiments to be described in the present invention, rather than all the drawings. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 is a flowchart of the image matching method provided in the first embodiment of the present invention;
[0021] Figure 2 is a flowchart of a picture matching method provided in Embodiment 2 of the present invention;
[0022] Figure 3 is a flow chart of a feature extraction model training method provided in Embodiment 3 of the present invention;
[0023] Figure 4 is a structural diagram of a feature extraction model provided in Embodiment 4 of the present invention;
[0024] Figure 5 is a structural diagram of a picture matching device provided in Embodiment 5 of the present invention;
[0025] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention. DETAILED DESCRIPTION
[0026] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0027] Embodiment 1
[0028] Figure 1 This is a flowchart of a picture matching method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where a picture matching the target text is selected from a preset picture library. The method can be executed by a picture matching device, which can be implemented by software and / or hardware.
[0029] Before introducing the technical solution of the embodiment of the present invention, the application scenario of the embodiment of the present invention is first introduced as an example: when reading a piece of news, the pictures in the news can not only allow readers to understand the main content of the news intuitively and clearly, but also can greatly stimulate the interest of readers and improve the reading experience of readers, thereby attracting more readers. Therefore, pictures play an irreplaceable role in news reports, and it is extremely important to match each news article with appropriate pictures.
[0030] When illustrating news without pictures, long text information is directly used to extract feature information and compared with the extracted picture feature information. In the process of implementing text illustration, the large amount of redundant information in the news content is not taken into account. Instead, text features are directly extracted from the redundant news content, which easily leads to a large amount of noise information contained in the extracted text features, making it difficult to accurately match pictures related to the news content. The results of matching pictures are very likely to be inconsistent with the news topic.
[0031] There are also technical solutions that directly use the labels of pictures and texts in news with pictures and the labels of news without pictures for matching. However, pictures in the existing Internet usually do not contain labels, resulting in a small number of pictures that can be matched, reducing the flexibility of picture matching.
[0032] In order to solve the above technical problems, the technical solution of the embodiment of the present invention uses the Internet to build a preset gallery, and uses the feature information of the picture with text and the corresponding text to obtain a trained feature extraction model, and uses the feature extraction model to respectively obtain the target text feature information of the text to be matched and the picture feature information of each picture in the preset gallery, calculates the distance information of the text feature information and the picture feature information, and uses the picture with the smallest distance as the matching picture of the target picture. The technical solution of this embodiment removes the redundant information of the target text and each picture, and directly uses the text feature information and the picture feature information of each picture in the preset gallery constructed by pictures on the Internet for matching, which reduces the amount of information calculation and improves the accuracy of picture matching.
[0033] like Figure 1 As shown, the method specifically comprises the following steps:
[0034] S110: Acquire a target text, and extract text feature information of the target text based on a pre-trained feature extraction model.
[0035] In an embodiment of the present invention, the target text may be news, stories, introductions, and other text content without accompanying pictures, and this embodiment does not limit the type of the target text. The feature extraction model may respectively extract text feature information in the target text and image feature information of each image in the preset gallery. Specifically, the feature extraction model may include a text feature extraction sub-model, an image feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the image feature extraction sub-model. Among them, the joint feature extraction sub-model may respectively map the text feature information and the image feature information to a higher dimensional space to achieve more accurate extraction of the text feature information and the image feature information.
[0036] Specifically, the target text is first input into the text feature extraction sub-model in the feature extraction model to obtain text feature information of a preset dimension to remove redundant information in the target text that is not related to the text feature extraction. Then, the text feature information of the preset dimension is input into the joint feature extraction sub-model to obtain text feature information of a higher dimension to achieve more accurate extraction of the text feature information of the target text.
[0037] S120: Match the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on a pre-trained feature extraction model.
[0038] The preset gallery may be a file database that stores each image and the image feature information of each image. Specifically, each image may be a picture of various types downloaded from the Internet and saved to a preset location of the preset gallery. For example, the types of images may include but are not limited to entertainment, current affairs, military, education, science and technology, economy, sports, tourism, culture and society. Optionally, a unique identifier for each image may be pre-set, and the identifier may be but is not limited to the name, number or a string formed by at least one of numbers, letters and characters of each image. The identifiers of the images of the same category are set as associated identifiers to facilitate the associated storage of the images of the same category. The identifiers of the image feature information of each image may also be set as identifiers corresponding to each image, and stored in the preset gallery accordingly, so as to facilitate the rapid determination of the path of the image corresponding to any image feature information, and to achieve rapid acquisition of matching images of the target text.
[0039] Specifically, in order to clearly introduce the method of extracting image feature information of each picture in the preset gallery, one of the pictures is used as an example for introduction: first, any picture in the preset gallery is input into the picture feature extraction sub-model in the feature extraction model to obtain image feature information of a preset dimension, and then the picture feature information of the preset dimension is input into the joint feature extraction sub-model to obtain picture feature information of a higher dimension, so as to achieve more accurate extraction of the picture feature information of the picture, and then based on this method, the picture feature information of each picture in the preset gallery is extracted.
[0040] In order to realize convenient and fast updating of pictures and picture feature information in a preset gallery, the technical solution of an embodiment of the present invention is based on the above technical solution, and matches the identifiers of each picture in the preset gallery and the identifiers of each picture feature information in pairs at a preset interval. When it is determined that there are unpaired pictures, the method of the above embodiment is used to extract the picture feature information of the picture, and store it accordingly, so as to realize updating the picture feature information of each picture in the preset gallery and increase the flexibility of picture matching. When it is determined that there is unpaired picture feature information, it means that the picture corresponding to the picture feature information no longer exists in the preset gallery, and the picture feature information is deleted accordingly to save the storage space of the database and reduce the amount of calculation when calculating the distance information.
[0041] Optionally, before matching the text feature information with the image feature information of each image in the preset gallery, the distance information between the image feature information of each image and the text feature information is determined. Specifically, the following calculation formula may be used to calculate the Euclidean distance between the text feature information of the target text and the image feature information of each image to determine the distance information between the image feature information of each image and the text feature information.
[0042]
[0043] Among them, F text Represents the text feature information of the target text, F img_i represents the picture feature information of the i-th picture; m represents the m-th digit of the picture feature information.
[0044] S130: Determine the picture that matches the text feature information as the matching picture of the target text.
[0045] Optionally, the distance information between the image feature information and the text feature information of each image is determined respectively, and the image corresponding to the image feature information that meets the preset conditions is used as the matching image of the target text of the current text feature information. The preset condition may be to determine the minimum distance information between the image feature information and the text feature information of each image. Specifically, the minimum distance information between each image feature information and the text feature information is determined, and the image corresponding to the minimum distance information is determined as the matching image of the target text.
[0046] The technical solution of the embodiment of the present invention uses a pre-trained feature extraction model to extract text feature information from the acquired target text, thereby removing a large amount of redundant information in the target text and reducing the amount of calculation on the text information. The distance information of the acquired text feature information and the image feature information of each image in the preset gallery are then checked, and the image in the preset gallery that best matches the target text is screened out through the calculated distance, thereby realizing automatic image matching for the text, thereby improving the visual quality of the text, stimulating the reader's interest in reading, and enhancing the reader's reading experience.
[0047] Embodiment 2
[0048] Figure 2 A flow chart of a picture matching method provided for the second embodiment of the present invention, based on the above embodiments, this embodiment further refines the step of "extracting text feature information of the target text based on a pre-trained feature extraction model". Optionally, extracting text feature information of the target text based on a pre-trained feature extraction model includes: determining text event information in the target text, inputting the text event information into a text feature extraction sub-model of a pre-trained feature extraction model, and obtaining text feature information output by a joint feature extraction sub-model, thereby realizing the extraction of text features in the target content, removing a large amount of redundant information in the target text, reducing the amount of calculation for text information, further determining pictures that better match the target content, and improving matching efficiency. The explanations of terms that are the same or corresponding to the above embodiments are not repeated here.
[0049] See also Figure 2 , the image matching method provided in this embodiment includes:
[0050] S210: Acquire a target text, and determine text event information in the target text.
[0051] In the embodiment of the present invention, the text event information of the target text may be the subject information, predicate information and object information of each sentence in the text summary information of the target text. The text summary information of the target text may be the text content without redundant information in the target text.
[0052] Specifically, a summary extraction algorithm is used to extract text summary information from the target text to remove text information in the target text that is irrelevant to the feature information. Exemplarily, the summary extraction algorithm may be a TextRank algorithm, which uses the following expression to extract the text summary information of the target text New N Extract the summary and get the text summary information text abs .
[0053] text abs =TextRank(text)
[0054] There is still some redundant information in the extracted text summary information, including modal particles, conjunctions, etc. In order to further remove the redundant information in the summary information, the event extraction algorithm is used to extract the text event information in the text summary information, which is more conducive to extracting the text feature information of the target text. Specifically, the event extraction algorithm can be the DMCNN algorithm, which uses the following expression to extract the text summary information text abs Extract event information and obtain text event information in the target text event .
[0055] text event =DMCNN(text abs )
[0056] Among them, the expression of the extracted text event information is:
[0057] text event =<<text sub1 ,text pred1 ,texto bj1 >,<…>,<text subN ,text predN ,texto bjN >>
[0058] Specifically, an event information is extracted for each sentence in the extracted text summary information, and the text event information extracted for each sentence includes the subject, predicate and object of the sentence. eventIn the above example, N is the number of sentences in the extracted text summary information, text sub Indicates extracting subject information from a sentence. pred To extract the predicate information in the sentence content, text obj It means to extract the object information in the sentence content.
[0059] S220, inputting the text event information into the text feature extraction sub-model of the pre-trained feature extraction model to obtain the text feature information output by the joint feature extraction sub-model.
[0060] Optionally, the text feature extraction submodel includes a text feature extraction module and at least one first fully connected module, the text feature extraction module is used to extract first feature information of a first dimension of the target text, and the at least one first fully connected module is used to extract second feature information of a second dimension based on the first feature information.
[0061] Among them, the first feature information may be the text feature information after passing through the text feature extraction module, the first dimension may be the dimension of the text feature information after passing through the text feature extraction module, the second feature information may be the text feature information after passing through the first fully-connected module, the second dimension may be the dimension of the text feature information after passing through the first fully-connected module, and the first fully-connected module may be a text fully-connected module, which is used to convert the text feature information into a preset dimension.
[0062] The first feature information of the first dimension of the text event information of the target text is extracted by using a text feature extraction module. Specifically, the text feature extraction module can use a TextCNN model for extraction. Exemplarily, the following formula is used to extract the text event information text event The text features in the text feature information f of the preset dimension (for example, 300 dimensions) are obtained. text .
[0063] f text =TextCNN(text event )
[0064] In order to match the text feature information with the image feature information, the dimensions of the text feature information and the image feature information need to be kept equal. The text fully connected module M can be used FCtext The text feature information extracted in the above embodiment is converted into a dimension. There is at least one text fully connected module, which can be one or more. At least one fully connected module can more accurately obtain a preset dimension for the text feature information.
[0065] Specifically, the following formula can be used to convert the 300-dimensional text feature information f textConverted to 2048-dimensional text feature information f FCtext , so that the dimensions of text feature information and image feature information remain equal.
[0066] f FCtext =M FCtext (f text )
[0067] S230, inputting the image into the image feature extraction sub-model of the pre-trained feature extraction model to obtain the image feature information output by the joint feature extraction sub-model.
[0068] Specifically, the image feature extraction sub-model includes an image feature extraction module and at least one second fully connected module, wherein the image feature extraction module is used to extract third feature information of a third dimension of the image, and at least one second fully connected module is used to extract fourth feature information of a fourth dimension based on the third feature information.
[0069] Among them, the third feature information may be the image feature information after passing through the image feature extraction module, the third dimension may be the dimension of the image feature information after passing through the image feature extraction module, the fourth feature information may be the image feature information after passing through the fully connected module, the fourth dimension may be the dimension of the image feature information after passing through the fully connected module, the third fully connected module may be a picture fully connected module, which is used to convert the picture feature information into a preset dimension, and the second dimension and the fourth dimension are equal in number, so that the text feature information can match the picture feature information.
[0070] The image feature extraction module is used to extract the third feature information of the third dimension of each image in the preset image library. Specifically, the image feature extraction module can use a ResNet model to extract image features in the image to obtain image feature information of a preset dimension (for example, 4096 dimensions) f img .
[0071] Furthermore, the image fully connected module M is used FCimg The image feature information extracted in the above embodiment is converted into a dimension. Specifically, the following formula can be used to convert the 4096-dimensional image feature information f img Convert image feature information f to 2048 dimensions FCimg , so that the dimensions of the text feature information and the image feature information remain equal. Among them, the number of the image fully connected modules is at least one, that is, it can be one or more, and at least one fully connected module can more accurately enable the image feature information to obtain the preset dimension.
[0072] f FCimg =M FCimg (f img )
[0073] Based on the above embodiment, a joint feature extraction sub-model is used to map text feature information and image feature information to a higher dimensional space to obtain more complete text feature information and image feature information. Specifically, the following formula is used to map the 2048-dimensional image feature information f FCimg and text feature information f FCtext Input to the joint feature extraction sub-model M union , extract 1024-dimensional image feature information F img and text event feature information F text , so that image feature information and text feature information can be mapped into the same high-dimensional space.
[0074] F img =M union (f FCimg )
[0075] F text =M union (f FCtext )
[0076] S240: Match the text feature information with the picture feature information of each picture in a preset picture library.
[0077] S250: Determine the picture that matches the text feature information as the matching picture of the target text.
[0078] The technical solution of this embodiment is to extract summary information of the text content of the target text by using the summary extraction submodule in the text feature extraction module, and then further extract event information of the summary information of the target text by using the event extraction submodule, wherein the event extraction submodule mainly extracts the subject, predicate and object events in the summary event, and then uses the full connection module to extract the feature information of the text event of the target content, and inputs the extracted text feature information into the joint model to extract the text feature information of a higher dimension, and finally calculates the distance information between the text event feature information and the feature information of each picture of the same dimension, and selects the picture that best matches the target content in the preset picture library through the calculated distance, so as to realize automatic picture matching of the text content, thereby improving the visual quality of the text, stimulating the reading interest of the reader, and improving the reading experience of the reader.
[0079] Embodiment 3
[0080] Figure 3 A flowchart of a method for training a feature matching model provided in Embodiment 3 of the present invention. Embodiments of the present invention are optional embodiments of the above embodiments, and the embodiments of the present invention mainly introduce the steps of the method for training a feature extraction model involved in the above embodiments, wherein the explanations of the terms identical or corresponding to the above embodiments are not repeated here.
[0081] Specific as Figure 3 , the training method of the feature matching model provided in this embodiment includes:
[0082] S310: Obtain training samples, where the training samples include positive samples where the text matches the image and negative samples where the text does not match the image.
[0083] In the embodiment of the present invention, the text content with pictures is obtained, and the constructed pairs of text text and picture img are used as the training set of the feature matching model. The data representation form of the training set can be:
[0084] data train ={(text1,img1),(text2,img2),...,(text n ,img n )}
[0085] Among them, is the total number of training samples. In the training samples, the text with matching text and picture is taken as positive sample, and the sample with mismatching text and picture is taken as negative sample. The feature extraction model is trained with positive samples and negative samples to obtain the trained feature extraction model.
[0086] S320, respectively input the text and image in the training sample into the text feature extraction sub-model and the image feature extraction sub-model in the feature extraction model to be trained, and obtain the text training feature information and the image training feature information output by the joint feature extraction sub-model.
[0087] Specifically, the steps of respectively inputting the text and images in the training samples into the text feature extraction sub-model and the image feature extraction sub-model in the feature extraction model to be trained, and obtaining the text training feature information and the image training feature information output by the joint feature extraction sub-model have been explained in detail in the above embodiments, and will not be repeated in this embodiment.
[0088] S330: Input text training feature information and image training feature information into a classification model, and output matching classification results of text and images in the training samples.
[0089] Specifically, the extracted 1024-dimensional image feature information F img_i (represents the extracted i-th image feature information) and text feature information F text_j(represents the jth text feature information extracted) is input into the classification model for classification training. During the training process, the image feature information and text feature information in the same text with images have the same label, that is, when i=j, it means that the image and text are from the same text with images and are matched, so they have the same label; when i≠j, it means that the image and text are not from the same text with images and are not matched, so they have different labels. Specifically, the training samples are fed into the classification model, and the classification results and training matching labels output by the model are obtained.
[0090] S340, generating a loss function according to the matching classification results and the matching labels of the training samples, as well as the text training feature information and the image training feature information, and adjusting parameters of the feature extraction model to be trained based on the loss function.
[0091] In the embodiment of the present invention, the loss function includes a feature loss function and a label loss function. Specifically, during the model training process, the loss function of the feature matching model in training is generated based on the training samples in the training set. The expression of the loss function in the embodiment of the present invention is as follows:
[0092]
[0093] Where n is the number of training data sets, ||·|| F The F-norm is calculated for the matrix, P is the projection matrix of the linear classifier, and L is the true label of the training set. The parameters of the feature extraction model to be trained are adjusted based on this loss function.
[0094] S350: When the training process of the feature extraction model meets the training stop condition, a trained feature extraction model is obtained.
[0095] Specifically, the feature matching model in training is repeatedly trained based on the loss function of the above embodiment until the model converges in the training samples, that is, the loss value of the model tends to zero or tends to be stable for a long time and no longer changes with the increase in the number of training times, and it is determined that the feature extraction model at this time meets the training stop condition, that is, the model training is completed, and the trained feature extraction model is obtained.
[0096] The embodiment of the present invention provides a training method for a feature matching model. The technical solution of the embodiment of the present invention uses a pre-trained feature extraction model to extract text feature information of an acquired target text, thereby removing a large amount of redundant information in the target text and reducing the amount of calculation for the text information. The distance information of the acquired text feature information and the image feature information of each image in a preset gallery are then checked, and the image in the preset gallery that best matches the target text is screened out through the calculated distance, thereby realizing automatic image matching of the text, thereby improving the visual quality of the text, stimulating the reader's interest in reading, and improving the reader's reading experience.
[0097] Embodiment 4
[0098] The embodiment of the present invention is an optional embodiment of the above embodiment. The embodiment of the present invention mainly introduces the specific model structure of the feature extraction model involved in the above embodiment. The structure and the methods of the above embodiments belong to the same inventive concept. For details not described in detail in this embodiment, please refer to the above embodiments.
[0099] Specific as Figure 4 The specific structure of the feature matching model provided in this embodiment includes:
[0100] A text feature extraction sub-model 410, a picture feature extraction sub-model 420, and a joint feature extraction sub-model 430 connected to the text feature extraction sub-model 410 and the picture feature extraction sub-model 420 respectively.
[0101] Optionally, the feature matching model is mainly used to input the text event information and the pictures in the preset gallery into the text feature extraction submodel 410 and the picture feature extraction submodel 420 of the pre-trained feature extraction model respectively, and obtain the text feature information and picture feature information output by the joint feature extraction submodel 430.
[0102] Among them, the text feature extraction submodel 410 includes a text feature extraction module 411 and at least one first fully connected module 412. Specifically, the text feature extraction module 411 is used to extract the first feature information of the first dimension of the target text, for example, it can be the text feature information after passing through the text feature extraction module 411. At least one first fully connected module 412 is used to extract the second feature information of the second dimension based on the first feature information, for example, it can be to convert the dimension of the text feature information after passing through the text feature extraction module 411, converting the 300-dimensional text feature information into the 2048-dimensional text feature information, so that the dimensions of the text feature information and the image feature information remain equal.
[0103] The image feature extraction submodel 420 includes an image feature extraction module 421 and at least one second fully connected module 422. Specifically, the image feature extraction module 421 is used to extract third feature information of a third dimension of the image, for example, the image feature information after passing through the image feature extraction module 421. The at least one second fully connected module 422 is used to extract fourth feature information of a fourth dimension based on the third feature information, for example, further feature processing can be performed on the image feature information after passing through the image feature extraction module 421, and the image feature information of 4096 dimensions is converted into the image feature information of 2048 dimensions, so that the dimensions of the text feature information and the image feature information remain equal.
[0104] On the basis of the above embodiment, a joint feature extraction sub-model 430 is used to map text feature information and image feature information into a higher dimensional space to obtain more sufficient text feature information and image feature information.
[0105] The result of the feature matching model provided by the embodiment of the present invention includes a text feature extraction sub-model, a picture feature extraction sub-model and a joint feature extraction sub-model connected to the text feature extraction sub-model and the picture feature extraction sub-model 420 respectively. By using the pre-trained feature extraction model to extract text feature information of the acquired target text, a large amount of redundant information in the target text is removed, and the amount of calculation for the text information is reduced. Then, the distance information of the acquired text feature information and the picture feature information of each picture in the preset gallery are checked, and the picture in the preset gallery that best matches the target text is screened out through the calculated distance, so as to realize automatic text matching, thereby improving the visual quality of the text, stimulating the reader's reading interest, and enhancing the reader's reading experience.
[0106] Embodiment 5
[0107] Figure 5 This is a schematic diagram of the structure of the image matching device provided in the fourth embodiment of the present invention. The device and the image matching method of the above embodiments belong to the same inventive concept. For details not described in detail in the embodiment of the image matching device, reference can be made to the embodiment of the above image matching method. This embodiment is applicable to the case of selecting an image matching the target text from a preset image library.
[0108] Specifically, the structure of the image matching device includes: a text feature information acquisition module 510, a text feature information matching module 520 and a matching image determination module 530; wherein,
[0109] The text feature information acquisition module 510 is used to acquire a target text and extract text feature information of the target text based on a pre-trained feature extraction model.
[0110] The text feature information matching module 520 is used to match the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model.
[0111] The matching picture determination module 530 is used to determine a picture that matches the text feature information as a matching picture of the target text.
[0112] The technical solution of the embodiment of the present invention uses a pre-trained feature extraction model to extract text feature information from the acquired target text, thereby removing a large amount of redundant information in the target text and reducing the amount of calculation on the text information. The distance information of the acquired text feature information and the image feature information of each image in the preset gallery are then checked, and the image in the preset gallery that best matches the target text is screened out through the calculated distance, thereby realizing automatic image matching for the text, thereby improving the visual quality of the text, stimulating the reader's interest in reading, and enhancing the reader's reading experience.
[0113] Based on the above technical solution, the text feature information acquisition module 510 includes:
[0114] The text feature information acquisition unit is used to determine the text event information in the target text, input the text event information into the text feature extraction sub-model of the pre-trained feature extraction model, and obtain the text feature information output by the joint feature extraction sub-model.
[0115] Based on the above technical solution, the text feature extraction sub-model includes: a text feature extraction module and at least one first fully-connected module, the text feature extraction module is used to extract the first feature information of the first dimension of the target text, and the at least one first fully-connected module is used to extract the second feature information of the second dimension based on the first feature information.
[0116] Based on the above technical solution, the image feature extraction submodel includes: an image feature extraction module and at least one second fully connected module, wherein the image feature extraction module is used to extract third feature information of the third dimension of the image, and the at least one second fully connected module is used to extract fourth feature information of the fourth dimension based on the third feature information.
[0117] Based on the above technical solution, the training process of the feature extraction model includes:
[0118] Acquire training samples, wherein the training samples include positive samples in which the text matches the image and negative samples in which the text does not match the image;
[0119] Inputting the text and the picture in the training sample into the text feature extraction submodel and the picture feature extraction submodel in the feature extraction model to be trained respectively, and obtaining the text training feature information and the picture training feature information output by the joint feature extraction submodel;
[0120] Input the text training feature information and the picture training feature information into the classification model, and output the matching classification results of the text and the picture in the training sample;
[0121] Generate a loss function according to the matching classification result and the matching label of the training sample, as well as the text training feature information and the image training feature information, and adjust parameters of the feature extraction model to be trained based on the loss function;
[0122] When the training process of the feature extraction model meets the training stop condition, a trained feature extraction model is obtained.
[0123] Based on the above technical solution, the loss function includes a feature loss function and a label loss function.
[0124] Based on the above technical solution, the matching picture determination module 530 includes:
[0125] The distance information determination unit is used to respectively determine the distance information between the picture feature information of each picture and the text feature information.
[0126] Accordingly, the matching picture determination module 530 includes:
[0127] The matching picture determination unit is used to determine the picture corresponding to the minimum distance information as the matching picture of the target text.
[0128] The image matching device provided in the embodiment of the present invention can execute the image matching method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0129] It is worth noting that in the embodiment of the above-mentioned image matching device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0130] Embodiment 6
[0131] Figure 6A schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention. Figure 6 A block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 6 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0132] like Figure 6 As shown, the electronic device 12 is in the form of a general purpose computing electronic device. The components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting various system components (including the system memory 28 and the processing unit 16).
[0133] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0134] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0135] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 6 not shown, usually called a "hard drive"). Although Figure 6 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The system memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0136] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. Program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0137] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) through a network adapter 20. Figure 6 As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that although Figure 6 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0138] The processing unit 16 executes various functional applications and sample data acquisition by running the program stored in the system memory 28, for example, implementing a picture matching method provided in the embodiment of the present invention, the picture matching method comprising:
[0139] Acquire a target text, and extract text feature information of the target text based on a pre-trained feature extraction model;
[0140] Matching the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model;
[0141] The picture matching the text feature information is determined as the matching picture of the target text.
[0142] Of course, those skilled in the art can understand that the processor can also implement the technical solution of the sample data acquisition method provided by any embodiment of the present invention.
[0143] Embodiment 7
[0144] This embodiment 7 provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, for example, steps of a picture matching method provided in this embodiment are implemented. The picture matching method includes:
[0145] Acquire a target text, and extract text feature information of the target text based on a pre-trained feature extraction model;
[0146] Matching the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model;
[0147] The picture matching the text feature information is determined as the matching picture of the target text.
[0148] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0149] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0150] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0151] Computer program code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0152] It should be understood by those skilled in the art that the modules or steps of the present invention described above can be implemented by a general-purpose computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, optionally, they can be implemented by a program code executable by a computer device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0153] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A picture matching method, characterized in that: include: Acquire a target text, and extract text feature information of the target text based on a pre-trained feature extraction model; Matching the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model; Determine a picture that matches the text feature information as a matching picture of the target text; The extracting text feature information of the target text based on the pre-trained feature extraction model includes: Determine text event information in the target text, input the text event information into a text feature extraction submodel of a pre-trained feature extraction model, and obtain text feature information output by the joint feature extraction submodel; The text event information of the target text is the subject information, predicate information and object information of each sentence in the text summary information of the target text; The text feature extraction sub-model comprises: a text feature extraction module and at least one first fully connected module, wherein the text feature extraction module is used to extract first feature information of a first dimension of the target text, and the at least one first fully connected module is used to extract second feature information of a second dimension based on the first feature information; The image feature extraction sub-model includes: an image feature extraction module and at least one second fully connected module, wherein the image feature extraction module is used to extract third feature information of a third dimension of the image, and the at least one second fully connected module is used to extract fourth feature information of a fourth dimension based on the third feature information.
2. The method according to claim 1, characterized in that The training process of the feature extraction model includes: Acquire training samples, wherein the training samples include positive samples in which the text matches the image and negative samples in which the text does not match the image; Inputting the text and the picture in the training sample into the text feature extraction submodel and the picture feature extraction submodel in the feature extraction model to be trained respectively, and obtaining the text training feature information and the picture training feature information output by the joint feature extraction submodel; Input the text training feature information and the picture training feature information into the classification model, and output the matching classification results of the text and the picture in the training sample; Generate a loss function according to the matching classification result and the matching label of the training sample, as well as the text training feature information and the image training feature information, and adjust parameters of the feature extraction model to be trained based on the loss function; When the training process of the feature extraction model meets the training stop condition, a trained feature extraction model is obtained.
3. The method according to claim 2, characterized in that The loss function includes a feature loss function and a label loss function.
4. The method according to claim 1, characterized in that: The matching of the text feature information with the picture feature information of each picture in the preset picture library includes: Determine the distance information between the picture feature information of each picture and the text feature information respectively; Correspondingly, determining the picture matching the text feature information as the matching picture of the target text includes: The picture corresponding to the minimum distance information is determined as the matching picture of the target text.
5. A picture matching device, characterized in that: include: A text feature information acquisition module, used to acquire a target text and extract text feature information of the target text based on a pre-trained feature extraction model; A text feature information matching module, used for matching the text feature information with the picture feature information of each picture in a preset picture library, wherein the picture feature information of each picture is extracted from each picture based on the pre-trained feature extraction model, and the feature extraction model includes a text feature extraction sub-model, a picture feature extraction sub-model, and a joint feature extraction sub-model respectively connected to the text feature extraction sub-model and the picture feature extraction sub-model; A matching picture determination module, used to determine a picture that matches the text feature information as a matching picture of the target text; The text feature information acquisition module includes: a text feature information acquisition unit, which is used to determine the text event information in the target text, input the text event information into the text feature extraction submodel of the pre-trained feature extraction model, and obtain the text feature information output by the joint feature extraction submodel; The text event information of the target text is the subject information, predicate information and object information of each sentence in the text summary information of the target text; The text feature extraction sub-model includes: A text feature extraction module and at least one first fully connected module, wherein the text feature extraction module is used to extract first feature information of a first dimension of the target text, and the at least one first fully connected module is used to extract second feature information of a second dimension based on the first feature information; The picture feature extraction sub-model includes: An image feature extraction module and at least one second fully connected module, wherein the image feature extraction module is used to extract third feature information of a third dimension of the image, and the at least one second fully connected module is used to extract fourth feature information of a fourth dimension based on the third feature information.
6. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image matching method as described in any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the image matching method as described in any one of claims 1 to 4 is implemented.
