Image description method and device based on layer feature attention
By using the layer feature attention module in the image description algorithm, combining mid-level and low-level features with high-level features, dynamically learning the similarity relationship between each layer feature and the sequence semantic feature, solving the problem of small target information loss caused by deepening the convolutional layer, and improving improve the accuracy and effectiveness of image descriptions.
Patent Information
- Application Number
- CN202210787551.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-04
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing image description algorithms will filter out small target information during the deepening process of the convolutional layer, reducing the accuracy and effectiveness of image description semantics.
Using a method based on layer feature attention, the mid-level and low-level features are dimensionally converted so that they are input into the decoder together with the high-level features. The layer feature attention module is used to dynamically learn the similarity between each layer feature and the sequence semantic feature, and assign weights. to generate image descriptions.
It effectively prevents the loss of small target information, improves the semantic accuracy and effectiveness of image description, and makes the generated sentences more accurate and rich.
Smart Images

Figure CN115100482B_ABST
Abstract
Description
Background Art
[0002] Image caption is an important research direction in scene understanding tasks at the intersection of computer vision and natural language processing. Simply put, image captioning is "speaking by looking at the picture", that is, inputting a picture and outputting one or more sentences describing the image content.
[0003] With the development of deep learning, people have proposed a large number of image description methods based on this. In the related technology, the final classification layer using high-level semantic features has global information, which also has a significant impact on the generation of sentences. Therefore, the current image description algorithms disclosed at home and abroad basically select the highest layer of the basic network as the representation of scene features. However, high-level features will filter out a lot of useful small target information in the process of deepening the convolution layer, reducing the accuracy and effectiveness of the image description semantics.
[0004] Therefore, it is necessary to improve one or more problems existing in the above-mentioned related technical solutions.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The purpose of the embodiments of the present disclosure is to provide an image description method and device based on layer feature attention, thereby overcoming one or more problems caused by the limitations and defects of the related art at least to a certain extent.
[0007] According to a first aspect of an embodiment of the present disclosure, a method for describing an image based on layer feature attention is provided, comprising the following steps:
[0008] Collect the image to be described;
[0009] Performing encoding processing on the image to be described to obtain multi-layer features;
[0010] Performing dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features;
[0011] The multi-layer features after the dimension conversion process are input into a decoder, and the decoder decodes the multi-layer features to obtain a corresponding image description.
[0012] In an exemplary embodiment of the present disclosure, the multi-layer features after the dimension conversion process are input into a decoder, and the decoder decodes the multi-layer features to obtain a corresponding image description, including:
[0013] Input the multi-layer features after dimension conversion into the decoder;
[0014] The decoder assigns weights to the multi-layer features and performs decoding processing to obtain a corresponding image description.
[0015] In an exemplary embodiment of the present disclosure, the process of inputting the multi-layer features after dimension conversion into the decoder is:
[0016] The middle-level features, low-level features, and high-level features are all input into each stacked layer of the decoder.
[0017] In an exemplary embodiment of the present disclosure, the multi-layer features are dimensionally converted to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features, and then further include:
[0018] Input the features of each layer with the same dimension into the convolution layer;
[0019] Deform the dimensions of the features output by the convolutional layer;
[0020] Perform batch normalization on the features output by the fully connected layer;
[0021] Use activation function to map the batch normalized features.
[0022] In an exemplary embodiment of the present disclosure, the use of an activation function to map the batch-normalized features further includes:
[0023] Use global average pooling to compress the mapped features;
[0024] Reduce overfitting on compressed data.
[0025] In an exemplary embodiment of the present disclosure, the decoder performs decoding processing by comparing the multi-layer features with the standard sentence and then assigning weights to the multi-layer features.
[0026] In an exemplary embodiment of the present disclosure, the weight corresponding to the cross attention corresponding to the i-th layer image feature is:
[0027] α i =Sigmoid(W i ([X; cross_att i ]))
[0028] Among them, i is the number of layers of image features, W i represents the trainable weight matrix corresponding to the image features of the i-th layer; X represents the sequence information matrix; [;] represents connecting the two matrices, cross_att iRepresents the output of the Seq-to-image Attention module corresponding to the i-th layer image feature.
[0029] In an exemplary embodiment of the present disclosure, the following formula is used to assign weights:
[0030] lay_att=∑ i α i cross_att i ;
[0031] Among them, lay_att represents the output structure of the layer feature attention module.
[0032] In an exemplary embodiment of the present disclosure, the decoder is a Transformer decoder.
[0033] According to a second aspect of an embodiment of the present disclosure, there is provided an image description device based on layer feature attention, comprising:
[0034] An image acquisition module, used for acquiring images to be described;
[0035] An encoding module, used for encoding the image to be described to obtain multi-layer features;
[0036] A feature conversion module, used to perform dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features;
[0037] A decoding module, used for decoding the multi-layer features to obtain corresponding image descriptions;
[0038] Among them, the decoding module includes a layer feature attention module, which is used to assign weights to layer features using layer feature attention.
[0039] According to a third aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the steps of the image description method based on layer feature attention described in any one of the above embodiments are implemented.
[0040] According to a fourth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0041] Processor; and
[0042] A memory, configured to store executable instructions of the processor;
[0043] The processor is configured to execute the steps of the image description method based on layer feature attention in any of the above embodiments by executing the executable instructions.
[0044] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0045] In the embodiments of the present disclosure, low-level features and middle-level features are processed together with high-level features, so that each decoder stacking layer can process low-, middle-, and high-level multi-layer image features, preventing the loss of small target information during image description and improving the accuracy and effectiveness of image description semantics.
[0046] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0048] Figure 1 A flowchart showing an image description method based on layer feature attention in an exemplary embodiment of the present disclosure is shown;
[0049] Figure 2 A flowchart showing an exemplary embodiment of the present disclosure in which the multi-layer features after the dimension conversion process are input into a decoder, and the decoder decodes the multi-layer features to obtain a corresponding image description;
[0050] Figure 3 A flowchart showing a process of inputting multi-layer features after dimension conversion processing into a decoder in an exemplary embodiment of the present disclosure;
[0051] Figure 4 A flowchart is shown after the multi-layer features are dimensionally converted to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features in an exemplary embodiment of the present disclosure;
[0052] Figure 5 A flowchart is shown after the multi-layer features are dimensionally converted to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features in an exemplary embodiment of the present disclosure;
[0053] Figure 6 An overall model diagram showing an encoder-decoder structure in an exemplary embodiment of the present disclosure;
[0054] Figure 7 A schematic diagram showing the structure of a Transformer decoder based on layer feature attention in an exemplary embodiment of the present disclosure is shown;
[0055] Figure 8 A schematic diagram showing the structure of a single decoder layer in an exemplary embodiment of the present disclosure is shown;
[0056] Fig. 9 A schematic diagram showing a feature conversion module in an exemplary embodiment of the present disclosure;
[0057] Fig.10 A schematic diagram showing the structure of a mid-level feature attention module in an exemplary embodiment of the present disclosure is shown;
[0058] Fig.11 The test result of the exemplary embodiment of the present disclosure on MSCOCO is shown, wherein af is a plurality of images to be collected in the test;
[0059] Fig.12 A schematic diagram of a program product showing an image description method based on layer feature attention in an exemplary embodiment of the present disclosure;
[0060] Fig.13 A schematic diagram of an electronic device showing an image description method based on layer feature attention in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0061] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.
[0062] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0063] In this example implementation, a method for describing an image based on layer feature attention is first provided. Figure 1 As shown in , the following steps are included:
[0064] Step S101, collecting an image to be described;
[0065] Step S102, encoding the image to be described to obtain multi-layer features;
[0066] Step S103, performing dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features;
[0067] Step S104, inputting the multi-layer features after the dimension conversion processing into a decoder, and the decoder decodes the multi-layer features to obtain a corresponding image description.
[0068] In this embodiment, low-level features and middle-level features are processed together with high-level features, so that each decoder stacking layer can process low-, middle-, and high-level multi-layer image features, preventing the loss of small target information during image description and improving the accuracy and effectiveness of image description semantics.
[0069] It is understood that in some embodiments, reference Figure 2 As shown in , the step S104 may include steps S201 and S202:
[0070] Step S201, inputting the multi-layer features after dimension conversion into a decoder;
[0071] Step S202: the decoder assigns weights to the multi-layer features and then performs decoding processing to obtain a corresponding image description.
[0072] In this implementation, by comparing the mid-, high-, and low-level features with the standard sentences, weights are assigned to the mid-, high-, and low-level layers, so that the small target information description corresponding to the mid- and low-level features is more accurate, thereby improving the accuracy and effectiveness of the semantic description.
[0073] Specifically, in some embodiments, reference Figure 3 As shown in , the process of inputting the multi-layer features after dimension conversion processing into the decoder may include step S301:
[0074] Step S301, input the middle-level features, low-level features and high-level features into each stacked layer of the decoder.
[0075] In this embodiment, each stacked layer of the decoder corresponds to mid-, high-, and low-level features, and the similarity relationship between the semantic features of the standard sentence in the decoder of this layer and the features of each layer is dynamically established through training.
[0076] Specifically, in some embodiments, reference Figure 4 As shown in, the step S103 further includes steps S401-S404:
[0077] Step S401, input the features of each layer with the same dimension into the convolution layer;
[0078] Step S402, deforming the dimension of the feature output by the convolutional layer;
[0079] Step S403, performing batch normalization processing on the features output by the fully connected layer;
[0080] Step S404: Use an activation function to map the batch normalized features.
[0081] Specifically, in some embodiments, reference Figure 5 As shown in, the step S404 may further include steps S501-S502:
[0082] Step S501, using global average pooling to perform data compression on the mapped features;
[0083] Step S502: performing overfitting reduction processing on the compressed data.
[0084] In this embodiment, before the multi-layer features output by the encoder are input into the decoder, the multi-layer features need to be dimensionally transformed. When the features are dimensionally processed, the features are first pooled to achieve the purpose of reducing the dimension, removing redundant information, compressing the features, simplifying the network complexity, reducing the amount of calculation, and reducing memory consumption. Then the dimensions of the pooled features are deformed and input into the fully connected layer for dimension transformation. For example, high dimensions can be converted to low dimensions while retaining useful information. Batch normalization can then be performed, and then the features are mapped using an activation function. Batch normalization is intended to overcome the difficulty in training caused by deepening the neural network.
[0085] Specifically, please refer to Figure 6 , Figure 6 It is the overall model of the encoder-decoder structure of this application. The image encoder uses the EfficientNet convolutional neural network series model, and the sentence decoder uses a Transformer decoder based on layer feature attention. This decoder combines the cross attention in the existing structure of the Transformer decoder to design a layer feature attention module to dynamically learn the similarity between each layer feature and the sequence semantic features.
[0086] This application designs a Transformer decoder based on layer feature attention, please refer to Figure 7 , where P3, P5, and P7 represent the features of the third, fifth, and seventh layers, respectively. Figure 7 The method in this paper can simultaneously input multiple layers of features into each stacked layer of the decoder. The first layer of the decoder inputs the standard sentence and multiple feature layers, and dynamically establishes the similarity relationship between the semantic features of the standard sentence in this layer of the decoder and the features of each layer through training. Then the output result is input as the semantic feature to the next layer of the decoder. The process is repeated repeatedly, and the input of this layer is the output of the previous layer, which continuously strengthens the similarity relationship between the multi-layer features and the semantic features. The structure of a single decoder layer is as follows: Figure 8As shown, the overall structure is the same as the most basic Transformer. The processing of image features is concentrated on the cross attention of the third sublayer, and the input image features are three layers. In order to dynamically assign weights to the three layers of features, the present invention will redesign the original cross attention module and name it layer feature attention, that is, "Feature Layer Attention" in the figure.
[0087] The layer feature attention module is designed to assign weights to multi-layer features and dynamically learn the similarity between each layer of features and the semantic features of the sequence. First, before inputting each layer of features into the layer feature attention module, the multi-layer features of different dimensions are first dimensionally converted. This application abandons the simple and crude use of fully connected layers, pooling layers, and some sampling operations to convert multi-layer features into dimensions that can be input into the decoder, but instead uses a fusion network to design a feature conversion module. Then, combining the weighted attention idea with the cross-attention module in the Transformer decoder, a layer feature attention that specifically focuses on different feature layers is designed.
[0088] like Fig. 9 The feature conversion module designed in this application is shown, and the meaning of each submodule is marked in the figure. The 3rd, 5th, and 7th layer features extracted by EfficientNet-b0 used here are used as input, namely F3, F5, and F7 in the figure. The corresponding F7 dimension in the figure is 320×7×7, the F5 dimension is 112×14×14, and the F3 dimension is 40×28×28. First, the number of channels of F3 and F5 is converted to the same dimension as F7 by downsampling and convolution. Then, the number of channels is converted to 1280 again using the same 1280-core convolution as EfficientNet-b0. Since the data changes greatly when the parameters are updated, it is easy to cause the phenomenon of covariate shift. Using batch normalization to process the output of this layer can reduce the amplitude of the change in data distribution. In addition, using an activation function after normalization can effectively prevent the data from being converted into similar patterns before activation, so that the nonlinear feature distribution tends to be assimilated. Then, the data is compressed into a one-dimensional sequence feature using global average pooling, and the data dimension is still 1280 at this time. Finally, the fully connected layer converts the output dimension to the word embedding layer dimension in the sentence decoder. The features processed by the feature conversion module are P3, P5, and P7 in the figure. To prevent overfitting, a dropout layer can be added after the pooling layer.
[0089] The specific role of the layer feature attention module is described below.
[0090] In order to dynamically learn the similarity between the features of each layer and the semantic features of the sequence and improve the quality of the final generated sentence, when the decoder processes the features of each layer, the present invention combines the weighted attention idea with the cross attention module in the Transformer decoder to design a layer feature attention (Feature LayerAttention) that specifically focuses on different feature layers. The specific structure is as follows Fig.10 shown.
[0091] This application first uses the cross-attention module in the original Transformer decoder, namely Fig.10 In the "Seq-to-image Attention" in the figure, each cross-attention module inputs features from different layers, namely P3, P5, and P7 in the figure. In addition, each cross-attention module uses multi-head attention whose basic unit is dot product attention. The dot product attention calculates the similarity distribution between a single-layer feature and the sequence semantic feature, and then obtains the weighted sum of the single-layer feature. The dot product attention function is defined as:
[0092]
[0093] Where K i and V i Corresponding to the i-th layer image feature P input in the figure i , Q represents the sequence semantic feature, i.e. X in the figure, Represents the scaling factor.
[0094] Depend on Fig.10 It can be seen that the process of establishing similarity between each layer of image features and sequence semantic features is parallel. Although different layers of features are input each time, the input sequence semantic features are the same. After obtaining the similarity between each single layer of image features and sequence semantic information, weights are assigned to the processing results of the corresponding feature layers, and the attention of the sequence semantic features corresponding to each layer of image features can be obtained. The process of assigning weights is as follows: Fig.10 The formula is defined as:
[0095] lay_att=∑ i α i cross_att i S
[0096] Among them, lay_att represents the output structure of the layer feature attention module; cross_att i represents the output of the Seq-to-image Attention module corresponding to the image feature of the i-th layer, α i Indicates cross_att i The corresponding weight size. Its formula is defined as:
[0097] α i =Sigmoid(W i ([X; cross_att i ]))
[0098] Where W i represents the trainable weight matrix corresponding to the image features of the i-th layer; X represents the sequence information matrix; It means to concatenate two matrices.
[0099] The present invention uses the largest benchmark dataset COCO2017 in image description, which contains 118287 training set, 5000 validation set, and 5000 test set images. Most images of the COCO dataset contain multiple objects in complex scenes, and each image corresponds to five human-labeled descriptions. The images of the original training set and validation set are integrated and repartitioned, and the number of images contained in the training set, validation set, and test set is 113287, 5000, and 5000. We standardize all titles, convert all letters to lowercase, discard non-alphabetic characters, and replace all words that appear less than five times with <unk>, and then use spaces to separate all titles to form a vocabulary of 11,561. Finally, we use different metrics: Blue, Rouge-L, Cider, Meteor to evaluate the generated sentences from different perspectives.
[0100] In the experiment of the present invention, the image encoder uses EfficientNet-b0, and the decoder uses a three-layer stacked Transformer decoder based on layer feature attention, in which the dropout of each sublayer of the decoder is set to 0.2, and the feedforward dimension is set to 3072. Because the cross entropy loss function can calculate the probability distribution distance of the difference between the output value and the true value, it can be used for multi-classification tasks, so the present invention uses the cross entropy loss training model. In addition to the loss function, the choice of optimizer is also crucial. The present invention uses the fast-converging Ranger optimizer, which is insensitive to slight parameter adjustment, reducing the burden of parameter adjustment. During training, the learning rate and batch size will directly affect the learning effect of the model. If the learning rate is too high, the oscillation range of the model will be too large, which will directly lead to non-convergence; if the learning rate is too small, the model will converge very slowly, prolonging the training time. After many attempts, the warmup number is 10,000 times, and the initial value of the learning rate is set to 2. In addition, the batch size is set to 64 accordingly.
[0101] The model of the present invention was scored on the MSCOCO dataset. First, a simple feature dimension conversion module was compared with the feature conversion module designed by the present invention to verify the effectiveness of the feature conversion module of the present invention. Then, the model of the present invention was compared with the scores of the method using single-layer features or other methods introducing multi-layer features for decoding, thereby verifying the effectiveness of the layer feature attention module of the present invention.
[0102] (1) Analyze the impact of the feature conversion module on the overall model
[0103] Since the parallel model design of the paper "A multi-layer feature parallel processing method for image captioning" contains an image feature dimension conversion process similar to the model of the present invention, the feature conversion module designed by the present invention is compared with the feature dimension conversion of the paper. The comparison results are shown in Table 1, where "SPC-FT" represents the sequential parallel model using the feature conversion module designed by the present invention, and "RPC-FT" represents the reverse parallel model using the feature conversion module designed by the present invention.
[0104] It can be seen from the data in Table 1 that the feature conversion module proposed in the present invention has certain advantages, and various indicators have been improved. The previously unsatisfactory sequential parallel processing (SPC) has also been improved to a certain extent, such as CIDEr from 67.5 to 67.9, which verifies the importance of feature processing for model performance. When data of a certain dimension is needed, it is not advisable to simply and crudely transform the dimension, and important feature information should be expressed as much as possible. The inspiration for this part of the work mainly comes from the processing of features by convolutional neural networks. For example, two 3×3 convolution kernels are generally used instead of a 5×5 convolution kernel. Although they can obtain feature results with the same perception, if a 5×5 convolution kernel is used directly, too many parameters will reduce the number of network layers, thereby affecting the expression ability of the features. Therefore, although the desired feature dimension can be directly obtained through a convolution, the feature conversion module designed by the present invention can better capture the expression of important information in each layer of features.
[0105] Table 1 Scoring results of various models using two feature conversion modules
[0106]
[0107] (2) Advantages of the feature attention module at the analysis layer
[0108] In order to dynamically learn the similarity between the features of each layer and the semantic features of the sequence and improve the quality of the final generated sentences, the present invention designs a layer attention module so that each decoder stacking layer can determine the attention size to the features of each layer as needed. The present invention evaluates the image description model based on layer feature attention, and the results are shown in Table 2. First, we use the result of using only a certain high-level feature as the decoder input as a benchmark and compare it with the model proposed in the present invention. Secondly, in order to explore a more efficient image description method based on multi-layer features, we compare the model of the present invention with two other methods that can simultaneously introduce high-level features and low-level features. "Caption-Lay-att" in the table represents the image description model based on layer feature attention proposed in the present invention.
[0109] Table 2 shows the effectiveness of the proposed model. First, the various indicators of "Caption-Lay-att" are much higher than the baseline model, indicating that the proposed model has improved the performance of the overall model on the basis of introducing multi-layer features. The BLEU-4 score has increased from 17.5 to 20.8, and the CIDEr score has increased from 66.9 to 68.7. Then, we compared the scoring results of two parallel models ("SPC-FT" and "RPC-FT") using feature conversion modules with "Caption-Lay-att", and found that various indicators have also been significantly improved, such as the BLEU-4 score from 18.7 to 20.8, and the CIDEr score from 68.1 to 68.7. The experimental results show that compared with directly introducing multi-layer features into the decoder in a specific way, the similarity relationship between multi-layer features and sequence semantic features is dynamically learned by combining the layer feature attention of the existing structure design of the decoder, which further improves the performance of the image description model.
[0110] Table 2 Comparison results of layer feature attention and other models proposed in this invention
[0111]
[0112] Fig.11 This is the result of our test on MSCOCO. In the figure, "NIC-T" represents the most basic neural network image description model result; "Ours" represents the test result of the model proposed by the present invention. The underlined words are the target information in the picture. Obviously, compared with the ordinary "NIC-T", the model of the present invention can describe as much small target information as possible while describing the key information of the picture, such as: Fig.11 (b) "cake" and "candle", Fig.11 (c) "dog", Fig.11 (e) "Frisbee", etc. In terms of sentence quality, the model of the present invention can generate sentences with richer semantics, more accurate expressions and smoother structures, which proves the effectiveness of the model of the present invention.
[0113] This application combines the existing structure of the Transformer decoder to design a layer feature attention module, which can process multiple layers of features simultaneously in each decoder stacking layer, so that each decoder stacking layer can determine the attention size of each layer of features as needed, and dynamically learn the similarity relationship between each layer of features and sequence semantic features.
[0114] It should be noted that, although the steps of the method in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc. In addition, it is also easy to understand that these steps may be, for example, executed synchronously or asynchronously in multiple modules / processes / threads.
[0115] In this example implementation, a device for describing an image based on layer feature attention is also provided. The device may include the following modules:
[0116] An image acquisition module, used for acquiring images to be described;
[0117] An encoding module, used for encoding the image to be described to obtain multi-layer features;
[0118] A feature conversion module, used to perform dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features;
[0119] A decoding module, used for decoding the multi-layer features to obtain corresponding image descriptions;
[0120] Among them, the decoding module includes a layer feature attention module, which is used to assign weights to layer features using layer feature attention.
[0121] 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.
[0122] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of a module or unit described above can be further divided into multiple modules or units for concretization. The components displayed as modules or units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed scheme. Those of ordinary skill in the art can understand and implement it without paying creative work.
[0123] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a computer program is stored, and when the program is executed by, for example, a processor, the steps of the image description method based on layer feature attention described in any of the above embodiments can be implemented. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps of various exemplary embodiments of the present invention described in the above-mentioned image description method based on layer feature attention section of this specification.
[0124] refer to Fig.12 As shown, a program product 600 for implementing the above method according to an embodiment of the present invention is described, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0125] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may 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 readable storage media include: an electrical connection with one or more wires, a portable 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.
[0126] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0127] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0128] In an exemplary embodiment of the present disclosure, an electronic device is further provided, which may include a processor and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the steps of the image description method based on layer feature attention in any of the above embodiments by executing the executable instructions.
[0129] Those skilled in the art will appreciate that various aspects of the present invention may be implemented as systems, methods or program products. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0130] Refer to the following Fig.13 The electronic device 600 according to this embodiment of the present invention is described. Fig.13 The electronic device 600 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.
[0131] like Fig.13 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.
[0132] The storage unit stores a program code, which can be executed by the processing unit 610, so that the processing unit 610 performs the steps of various exemplary embodiments of the present invention described in the above-mentioned image description method based on layer feature attention. For example, the processing unit 610 can perform the following steps: Figure 2 Follow the steps shown in .
[0133] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .
[0134] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 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 the implementation of a network environment.
[0135] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0136] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0137] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including a number of instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above-mentioned image description method based on layer feature attention according to the implementation of the present disclosure.
[0138] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.< / unk>
Claims
1. An image description method based on layer feature attention, It is characterized in that The following steps are involved: Collect the image to be described; Performing encoding processing on the image to be described to obtain multi-layer features; Performing dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features; Inputting the multi-layer features after the dimension conversion processing into a decoder, the decoder decodes the multi-layer features to obtain a corresponding image description; The step of inputting the multi-layer features after the dimension conversion process into a decoder, and the decoder decoding the multi-layer features to obtain a corresponding image description includes: Input the multi-layer features after dimension conversion into the decoder; The decoder performs decoding processing after assigning weights to the multi-layer features to obtain a corresponding image description; the decoder compares the multi-layer features with the standard sentence, and then performs decoding processing after assigning weights to the multi-layer features; The process of inputting the multi-layer features after dimension conversion into the decoder is: The middle-level features, low-level features, and high-level features are all input into each stacked layer of the decoder.
2. The image description method based on layer feature attention according to claim 1, It is characterized in that The step of performing dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features further includes: Input the features of each layer with the same dimension into the convolution layer; Deform the dimensions of the features output by the convolutional layer; Perform batch normalization on the features output by the fully connected layer; Use activation function to map the batch normalized features.
3. According to the image description method based on layer feature attention according to claim 2, It is characterized in that The activation function is used to map the batch normalized features, and then further includes: Use global average pooling to compress the mapped features; Reduce overfitting on compressed data.
4. The image description method based on layer feature attention according to claim 1, It is characterized in that The weight corresponding to the cross attention corresponding to the image feature of the i-th layer is: Among them, i is the number of layers of image features, represents the trainable weight matrix corresponding to the image features of the i-th layer; X represents the sequence information matrix; It means to connect two matrices. Represents the output of the cross attention corresponding to the image features of the i-th layer.
5. The image description method based on layer feature attention according to claim 4, It is characterized in that The following formula is used to assign weights: 。 6. The image description method based on layer feature attention according to claim 1, It is characterized in that The decoder is a Transformer decoder.
7. An image description device based on layer feature attention, It is characterized in that include: An image acquisition module, used for acquiring images to be described; An encoding module, used for encoding the image to be described to obtain multi-layer features; A feature conversion module, used to perform dimension conversion processing on the multi-layer features to convert the dimensions of the middle-layer features and the low-layer features into the dimensions of the high-layer features; A decoding module, used for decoding the multi-layer features to obtain corresponding image descriptions; Wherein, the decoding module includes a layer feature attention module, which is used to assign weights to layer features using layer feature attention; The multi-layer features after the dimension conversion are input into the decoder, and the decoder decodes the multi-layer features to obtain the corresponding image description, including: Input the multi-layer features after dimension conversion into the decoder; The decoder assigns weights to the multi-layer features and then performs decoding processing to obtain the corresponding image description; the decoder compares the multi-layer features with the standard sentence, and then assigns weights to the multi-layer features and then performs decoding processing; The process of inputting the multi-layer features after dimension conversion into the decoder is: The middle-level features, low-level features, and high-level features are all input into each stacked layer of the decoder.
Citation Information
Patent Citations
Image segmentation method and device, storage medium and electronic equipment
CN111260653A
Facial expression recognition method and system combined with attention mechanism
CN112418095A
Universal image target detection method and device based on self-attention mechanism
CN113902926A
Personnel and vehicle monitoring method and system based on capsule network
CN114022726A
