Visual question answering method and device based on artificial intelligence
By performing feature extraction and attention feature calculation on images and questions, and using the attention model to generate pre-selected data, the problem of low answer accuracy in existing visual question and answer technology is solved, and the answer accuracy of the visual question and answer model is improved.
Patent Information
- Application Number
- CN202410650207.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-05-24
AI Technical Summary
Existing visual question answering technology does not have high accuracy when answering questions.
An artificial intelligence-based method is used to extract features from images and questions through extraction models, perform attention feature calculations, use attention models to generate pre-selected data, and perform score calculations on these data to obtain better pre-selected answers.
The accuracy of the answers of the visual question and answer model is improved. Through the calculation of attention features and the calculation of multiple pre-selected data of attention features, more accurate pre-selected answers are obtained.
Smart Images

Figure CN118227768B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and specifically relates to a visual question answering method and device based on artificial intelligence. Background Art
[0002] With the continuous development of artificial intelligence technology, intelligent customer service has become an important means for many companies to improve the quality of customer service. The application of visual question-answering technology can make intelligent customer service more intelligent and efficient. Visual question-answering technology refers to the use of computer vision technology and natural language processing technology to enable computers to understand questions raised by users and give corresponding answers. In intelligent customer service, visual question-answering technology can be applied to the following scenarios: image recognition, video question-answering, and voice question-answering.
[0003] Visual question answering is to automatically generate an answer to a question by inputting an image and a natural language question related to the image. However, the existing visual question answering methods do not give accurate answers to questions. Summary of the invention
[0004] In order to solve the above technical problems, the present invention provides a visual question answering method and device based on artificial intelligence, which is used to solve the technical problem that the answers given by the existing visual question answering are not accurate when answering questions.
[0005] In a first aspect, the invention provides the following technical solution: a visual question answering method based on artificial intelligence, the method comprising: acquiring an image and a question, and performing feature extraction on the image and the question respectively using an extraction model to obtain a feature image of the image and a feature text of the question;
[0006] Calculating attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image;
[0007] Inputting the image attention feature and the text attention feature into a preset attention model respectively to obtain an attention image feature and an attention text feature respectively;
[0008] A plurality of pre-selected data are calculated based on the focus image feature and the focus text feature, and scores are calculated for the plurality of pre-selected data to obtain a pre-selected answer.
[0009] Compared with the prior art, the beneficial effects of the present application are as follows: by performing the step of calculating the attention features of the feature text and the feature image, the text attention features of the feature text and the image attention features of the feature image can be obtained, so as to help the visual question answering model know which text and which area images should be paid attention to, so as to improve the accuracy of the answers given by the visual question answering model; in addition, by performing the step of obtaining multiple pre-selected data based on the attention image features and the attention text features, and performing score calculation on the multiple pre-selected data to obtain pre-selected answers, multiple pre-selected data can be calculated to achieve a better pre-selected data (i.e., a pre-selected answer), thereby further improving the accuracy of the answers given by the visual question answering model.
[0010] Furthermore, the step of calculating the attention features of the feature text and the feature image to obtain the text attention features of the feature text and the image attention features of the feature image includes:
[0011] Given a query, a key-value pair and a value of the feature image and the feature text, calculating a dot product of the query and the key-value pair based on proportional dot product attention, and obtaining an attention evaluation value based on the dot product calculation using a first calculation formula;
[0012] Using a first screening function to screen out a preset number of screening values from the attention evaluation value, and using a second screening function to select the screening values that are greater than a second threshold;
[0013] The second calculation formula is used to calculate based on the screening value greater than the second threshold value to obtain the text attention feature of the feature text and the image attention feature of the feature image.
[0014] Furthermore, the first calculation formula includes:
[0015] ;
[0016] In the formula, Denoted as the attention evaluation value, Expressed as a dot product, Dimensions represented as key-value pairs;
[0017] The first screening function comprises:
[0018] ;
[0019] in , Represented as a preset number of filter values, Represented as the attention evaluation value of the nth row filter values, It is represented as the attention evaluation value of the mth item in the nth row, and T is represented as a preset number of values;
[0020] The second screening function includes:
[0021] ;
[0022] in, represents the screening value greater than the second threshold, Indicates that attention is paid to the screening values in the xth row and yth column that are greater than the second threshold value. Denoted as the second threshold, It is represented as the first weight;
[0023] The second calculation formula includes:
[0024] ;
[0025] in, Represented as text attention features and image attention features, Denoted as the second weight, Represented as a value.
[0026] Further, the step of selecting the screening value greater than the second threshold value by using the second screening function includes:
[0027] Calculate a first weight of the screening value using a first activation function, and select the screening value greater than a second threshold based on the first weight using a second screening function;
[0028] The step of calculating by using a second calculation formula based on the screening value greater than a second threshold value comprises:
[0029] The screening value greater than the second threshold is input into a second activation function to obtain a second weight of the screening value greater than the second threshold, and a second calculation formula is used to calculate based on the second weight.
[0030] Furthermore, the step of using the extraction model to extract features from the image and the question respectively to obtain a feature image of the image and a feature text of the question includes:
[0031] Dividing the image using an image extraction model to obtain a plurality of region images, and predicting a boundary and a score for each of the region images;
[0032] According to the scores of the regional images, the regional images exceeding a first threshold are screened out, and the regional images exceeding the first threshold are linearly transformed to obtain feature images;
[0033] Mark all the words of the question and input all the words of the question into the embedding model to obtain a word embedding sequence;
[0034] The word embedding sequence is input into the memory model to obtain feature text.
[0035] Furthermore, the step of inputting the image attention feature and the text attention feature into a preset attention model to obtain the attention image feature and the attention text feature respectively includes:
[0036] Inputting the image attention feature and the text attention feature into a preset attention model respectively, so as to obtain the image attention feature and the text attention feature of the same dimension respectively;
[0037] The third weight of the image attention feature and the third weight of the text attention feature are calculated, and the attention image feature is calculated according to the third weight of the image attention feature, and the attention text feature is calculated according to the third weight of the text attention feature.
[0038] Furthermore, the step of calculating a plurality of pre-selected data based on the focus image feature and the focus text feature, and performing score calculation on the plurality of pre-selected data to obtain a pre-selected answer includes:
[0039] Projecting the image feature of interest and the text feature of interest to the same dimension, and linearly fusing the projection results to obtain a fused feature;
[0040] Input the fusion feature into a training set to obtain a plurality of pre-selected data of the same dimension, calculate the score of each of the pre-selected data, and use a hinge function to calculate according to the score of the pre-selected data to obtain a pre-selected answer;
[0041] The hinge function includes:
[0042] ;
[0043] in, Represents the number of pre-selected data. It is expressed as the score of the pre-selected answer higher than the remaining answers. The score of the preset answer, Expressed as The fraction of pre-selected data.
[0044] In a second aspect, the invention provides the following technical solution, wherein the visual question-answering device based on artificial intelligence comprises:
[0045] An extraction module, used to obtain an image and a question, and use an extraction model to perform feature extraction on the image and the question respectively, so as to obtain a feature image of the image and a feature text of the question;
[0046] A calculation module, used for calculating attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image;
[0047] An input module, used for inputting the image attention feature and the text attention feature into a preset attention model to obtain an attention image feature and an attention text feature respectively;
[0048] The pre-selection module is used to calculate a plurality of pre-selected data based on the focus image feature and the focus text feature, and perform score calculation on the plurality of pre-selected data to obtain a pre-selected answer.
[0049] In a third aspect, the invention provides the following technical solution: a computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned artificial intelligence-based visual question answering method when executing the computer program.
[0050] In a fourth aspect, the invention provides the following technical solution: a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-mentioned artificial intelligence-based visual question answering method. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0052] Figure 1 A flowchart of a visual question answering method based on artificial intelligence provided by the first embodiment of the present invention;
[0053] Figure 2 A schematic diagram of a framework of an artificial intelligence-based visual question answering method provided in the first embodiment of the present invention;
[0054] Figure 3 A flowchart of a visual question answering method based on artificial intelligence provided by a second embodiment of the present invention;
[0055] Figure 4 A structural block diagram of a visual question-answering device based on artificial intelligence provided in the third embodiment of the present invention;
[0056] Figure 5 A schematic diagram of the hardware structure of a computer provided in accordance with the fourth embodiment of the present invention.
[0057] The embodiments of the present invention will be further described below with reference to the accompanying drawings. DETAILED DESCRIPTION
[0058] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the embodiments of the present invention, and should not be construed as limiting the present invention.
[0059] In the description of the embodiments of the present invention, it should be understood that the terms "length", "width", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside" and "outside" etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the embodiments of the present invention and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present invention.
[0060] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0061] Embodiment 1
[0062] In a first embodiment of the present invention, Figure 1 and Figure 2 As shown, a visual question answering method based on artificial intelligence includes the following steps S01 to S04:
[0063] S01, obtaining an image and a question, and using an extraction model to perform feature extraction on the image and the question respectively, so as to obtain a feature image of the image and a feature text of the question;
[0064] In a specific implementation, obtaining visual data to be predicted, the visual data to be predicted includes an image and a question, wherein the visual data may be video data of a robot;
[0065] Dividing the image using an image extraction model to obtain a plurality of region images, and predicting a boundary and a score for each of the region images;
[0066] According to the scores of the regional images, the regional images exceeding a first threshold are screened out, and the regional images exceeding the first threshold are linearly transformed to obtain feature images;
[0067] Mark all the words of the question and input all the words of the question into the embedding model to obtain a word embedding sequence;
[0068] Inputting the word embedding sequence into a memory model to obtain feature text;
[0069] Specifically, the extraction model includes a regional network and a detection network. The regional network is a fully convolutional network. The regional network inputs the image in the visual question answering dataset into the extraction model for end-to-end training, and predicts the target boundary and target score for each image region to obtain a number of regional images, and then the regional network and the detection network share the full image convolution feature to guide the extraction model to focus on which regional images among the several regional images, and then linearly transform the focused regional image to obtain a feature image, wherein the dimension of the feature image is consistent with the dimension of the feature text, so as to facilitate subsequent calculations; in this embodiment, the extraction model can be a Faster R-CNN model, which is initialized by the ResNet-101 model and trained based on the Visual Genome dataset;
[0070] Specifically, all words in the input question are marked as individual words, and then these words are input into the embedding model to obtain a word embedding sequence, and the word embedding sequence is input into the memory model to obtain feature text; in this embodiment, the embedding model is the GloVe model, and the memory model is the LongShort-TemMemort model, wherein the dimensions of the feature text and the feature image are both 512.
[0071] S02, calculating attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image;
[0072] Specifically, the step of calculating the attention features of the feature text and the feature image to obtain the text attention features of the feature text and the image attention features of the feature image includes:
[0073] Given a query, a key-value pair and a value of the feature image and the feature text, calculating a dot product of the query and the key-value pair based on proportional dot product attention, and obtaining an attention evaluation value based on the dot product calculation using a first calculation formula;
[0074] Using a first screening function to screen out a preset number of screening values from the attention evaluation value, and using a second screening function to select the screening values that are greater than a second threshold;
[0075] The second calculation formula is used to calculate based on the screening value greater than the second threshold value to obtain the text attention feature of the feature text and the image attention feature of the feature image.
[0076] Specifically, the first calculation formula includes:
[0077] ;
[0078] In the formula, Denoted as the attention evaluation value, Expressed as a dot product, Dimensions represented as key-value pairs;
[0079] The first screening function comprises:
[0080] ;
[0081] in , Represented as a preset number of filter values, Represented as the attention evaluation value of the nth row filter values, It is represented as the attention evaluation value of the mth item in the nth row, and T is represented as a preset number of values;
[0082] The second screening function includes:
[0083] ;
[0084] in, represents the screening value greater than the second threshold, Indicates that attention is paid to the screening values in the xth row and yth column that are greater than the second threshold value. Denoted as the second threshold, It is represented as the first weight;
[0085] The second calculation formula includes:
[0086] ;
[0087] in, Represented as text attention features and image attention features, Denoted as the second weight, Represented as a value.
[0088] Specifically, the step of selecting the screening value greater than the second threshold value by using the second screening function includes:
[0089] Calculate a first weight of the screening value using a first activation function, and select the screening value greater than a second threshold based on the first weight using a second screening function;
[0090] The step of calculating by using a second calculation formula based on the screening value greater than a second threshold value comprises:
[0091] The screening value greater than the second threshold is input into a second activation function to obtain a second weight of the screening value greater than the second threshold, and a second calculation formula is used to calculate based on the second weight.
[0092] In this embodiment, the first activation function and the second activation function are softmax activation functions for calculating weights.
[0093] S03, inputting the image attention feature and the text attention feature into a preset attention model respectively, so as to obtain an attention image feature and an attention text feature respectively;
[0094] Specifically, the step of inputting the image attention feature and the text attention feature into a preset attention model to obtain the attention image feature and the attention text feature respectively includes:
[0095] Inputting the image attention feature and the text attention feature into a preset attention model respectively, so as to obtain the image attention feature and the text attention feature of the same dimension respectively;
[0096] Calculating a third weight of the image attention feature and a third weight of the text attention feature, obtaining an attention image feature according to the third weight of the image attention feature, and obtaining an attention text feature according to the third weight of the text attention feature;
[0097] In this embodiment, the attention model can be a Multi-Layer Perceptron model, which compresses the dimensions of the image attention feature and the text attention feature to 512, and the third weight is also calculated by the softmax activation function; when calculating the attention text feature and the attention image feature, the third calculation is used, wherein the third calculation formula includes
[0098] ;
[0099] In the formula, Represents the third weight corresponding to the image attention feature, Denoted as image attention feature, Represents the image feature of interest, It is expressed as the number of image attention features; similarly, when calculating the attention text features, Represents the third weight corresponding to the text attention feature, Represented as text attention features, Represented as text attention features, It is expressed as the number of text attention features;
[0100] S04, calculating a plurality of pre-selected data based on the focus image feature and the focus text feature, and performing score calculation on the plurality of pre-selected data to obtain a pre-selected answer;
[0101] Specifically, the step of calculating a plurality of pre-selected data based on the focus image feature and the focus text feature, and performing score calculation on the plurality of pre-selected data to obtain a pre-selected answer includes:
[0102] Projecting the image feature of interest and the text feature of interest to the same dimension, and linearly fusing the projection results to obtain a fused feature;
[0103] Input the fusion feature into a training set to obtain a plurality of pre-selected data of the same dimension, calculate the score of each of the pre-selected data, and use a hinge function to calculate according to the score of the pre-selected data to obtain a pre-selected answer;
[0104] The hinge function includes:
[0105] ;
[0106] in, Represents the number of pre-selected data. It is expressed as the score of the pre-selected answer higher than the remaining answers. The score of the preset answer, Expressed as The score of the pre-selected data. In this embodiment, the pre-selected answer can be understood as the correct answer, the hinge function is the Hing Loss function, and the highest score is the correct answer.
[0107] In this embodiment, a layer normalization function is used to linearly fuse the projection results. The normalization function is as follows:
[0108] ;
[0109] In the formula, Represented as fusion features, Denoted as the layer normalization function, , Expressed as a linear projection parameter matrix, Represents the image feature of interest, Indicates that it is concerned with text features. It can be calculated by the third calculation formula.
[0110] In summary, by performing the step of calculating the attention features of the feature text and the feature image, the text attention features of the feature text and the image attention features of the feature image can be obtained, so as to help the visual question answering model know which text and which area images should be paid attention to, so as to improve the accuracy of the answers given by the visual question answering model. In addition, by performing the step of obtaining multiple pre-selected data based on the attention image features and the attention text features, and performing score calculation on the multiple pre-selected data to obtain pre-selected answers, multiple pre-selected data can be calculated to achieve a better pre-selected data (i.e., a pre-selected answer), thereby further improving the accuracy of the answers given by the visual question answering model.
[0111] Embodiment 2
[0112] like Figure 3 As shown, a second embodiment of the present invention provides a visual question answering method based on artificial intelligence. The difference between the visual question answering method based on artificial intelligence provided in the second embodiment and the visual question answering method based on artificial intelligence provided in the first embodiment is that: it includes steps S11 to S17;
[0113] S11, obtaining visual data to be predicted, where the visual data to be predicted includes an image and a problem to be predicted;
[0114] S12, using model identification, dictionary identification and rule identification in sequence to identify the problem to be predicted to obtain three identification problems to be predicted, and taking the union of the three identification problems to be predicted to obtain an identification problem;
[0115] Among them, the model is identified as the ALBERT-BiLSTM-CRF model;
[0116] S13, matching the recognition question with a synonym library to obtain a plurality of question matching words that match the recognition question, and sorting the question matching words using a BERT model, with the top-ranked words being the question.
[0117] S14, using the extraction model to perform feature extraction on the image and the question respectively, so as to obtain a feature image of the image and a feature text of the question;
[0118] S15, calculating attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image;
[0119] S16, inputting the image attention feature and the text attention feature into a preset attention model respectively to obtain an attention image feature and an attention text feature respectively;
[0120] S17, calculating a plurality of pre-selected data based on the focus image feature and the focus text feature, and performing score calculation on the plurality of pre-selected data to obtain a pre-selected answer.
[0121] In summary, by taking the union of the three recognition questions to be predicted, the question to be predicted can be refined, and then by matching the recognition question with the synonym library and using the BERT model to sort the matching words of the question, the question can be made more precise, further improving the accuracy of the answer given by the visual question answering model.
[0122] Embodiment 3
[0123] like Figure 4 As shown, in the third embodiment of the present invention, a visual question answering device based on artificial intelligence is provided, comprising:
[0124] An extraction module 10 is used to obtain an image and a question, and to perform feature extraction on the image and the question respectively using an extraction model to obtain a feature image of the image and a feature text of the question;
[0125] A calculation module 20, configured to calculate attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image;
[0126] An input module 30, used to input the image attention feature and the text attention feature into a preset attention model to obtain an attention image feature and an attention text feature respectively;
[0127] The pre-selection module 40 is used to calculate a plurality of pre-selected data based on the focus image feature and the focus text feature, and perform score calculation on the plurality of pre-selected data to obtain a pre-selected answer.
[0128] In some optional embodiments, the calculation module 20 includes:
[0129] A fitting unit, configured to calculate a dot product of the query and the key-value pair based on proportional dot product attention given the query, the key-value pair and the value of the feature image and the feature text, and obtain an attention evaluation value based on the dot product calculation using a first calculation formula;
[0130] Using a first screening function to screen out a preset number of screening values from the attention evaluation value, and using a second screening function to select the screening values that are greater than a second threshold;
[0131] The second calculation formula is used to calculate based on the screening value greater than the second threshold value to obtain the text attention feature of the feature text and the image attention feature of the feature image.
[0132] In some optional embodiments, the calculation module 20 further includes:
[0133] The calculation unit, used for the first calculation formula, includes:
[0134] ;
[0135] In the formula, Denoted as the attention evaluation value, Expressed as a dot product, Dimensions represented as key-value pairs;
[0136] The first screening function comprises:
[0137] ;
[0138] in , Represented as a preset number of filter values, Represented as the attention evaluation value of the nth row filter values, It is represented as the attention evaluation value of the mth item in the nth row, and T is represented as a preset number of values;
[0139] The second screening function includes:
[0140] ;
[0141] in, represents the screening value greater than the second threshold, Indicates that attention is paid to the screening values in the xth row and yth column that are greater than the second threshold value. Denoted as the second threshold, It is represented as the first weight;
[0142] The second calculation formula includes:
[0143] ;
[0144] in, Represented as text attention features and image attention features, Denoted as the second weight, Represented as a value.
[0145] In some optional embodiments, the calculation module 20 further includes:
[0146] The screening unit is used for selecting the screening value greater than the second threshold value by using the second screening function, comprising:
[0147] Calculate a first weight of the screening value using a first activation function, and select the screening value greater than a second threshold based on the first weight using a second screening function;
[0148] The step of calculating by using a second calculation formula based on the screening value greater than a second threshold value comprises:
[0149] The screening value greater than the second threshold is input into a second activation function to obtain a second weight of the screening value greater than the second threshold, and a second calculation formula is used to calculate based on the second weight.
[0150] In some optional embodiments, the extraction module 10 includes:
[0151] A transformation unit, configured to divide the image using an image extraction model to obtain a plurality of region images, and predict a boundary and a score for each of the region images;
[0152] According to the scores of the regional images, the regional images exceeding a first threshold are screened out, and the regional images exceeding the first threshold are linearly transformed to obtain feature images;
[0153] Mark all the words of the question and input all the words of the question into the embedding model to obtain a word embedding sequence;
[0154] The word embedding sequence is input into the memory model to obtain feature text.
[0155] In some optional embodiments, the input module 30 includes:
[0156] An output unit, used for inputting the image attention feature and the text attention feature into a preset attention model respectively, so as to obtain the image attention feature and the text attention feature of the same dimension respectively;
[0157] The third weight of the image attention feature and the third weight of the text attention feature are calculated, and the attention image feature is calculated according to the third weight of the image attention feature, and the attention text feature is calculated according to the third weight of the text attention feature.
[0158] In some optional embodiments, the pre-selection module 40 includes:
[0159] A fusion unit, used for projecting the image feature of interest and the text feature of interest to the same dimension, and linearly fusing the projection results to obtain a fused feature;
[0160] Input the fusion feature into a training set to obtain a plurality of pre-selected data of the same dimension, calculate the score of each of the pre-selected data, and use a hinge function to calculate according to the score of the pre-selected data to obtain a pre-selected answer;
[0161] The hinge function includes:
[0162] ;
[0163] in, Represents the number of pre-selected data. It is expressed as the score of the pre-selected answer higher than the remaining answers. The score of the preset answer, Expressed as The fraction of pre-selected data.
[0164] The artificial intelligence-based visual question-answering device provided in the embodiment of the present invention has the same implementation principle and technical effects as those in the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the system embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0165] Embodiment 4
[0166] like Figure 5 As shown, in the fourth embodiment of the present invention, the embodiment of the present invention provides the following technical solution: a computer, comprising a memory 202, a processor 201, and a computer program stored in the memory 202 and executable on the processor 201, wherein the processor 201 implements the artificial intelligence-based visual question answering method as described above when executing the computer program.
[0167] Specifically, the processor 201 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0168] Among them, the memory 202 may include a large-capacity memory for data or instructions. For example, but not limitation, the memory 202 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 202 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 202 may be inside or outside the data processing device. In a specific embodiment, the memory 202 is a non-volatile memory. In a specific embodiment, the memory 202 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM) or a flash memory (FLASH), or a combination of two or more of these. Under appropriate circumstances, the RAM can be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM can be a fast page mode dynamic random access memory (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0169] The memory 202 may be used to store or cache various data files that need to be processed and / or used for communication, as well as possible computer program instructions executed by the processor 201 .
[0170] The processor 201 implements the above-mentioned artificial intelligence-based visual question answering method by reading and executing computer program instructions stored in the memory 202.
[0171] In some embodiments, the computer may further include a communication interface 203 and a bus 200. Figure 5 As shown, the processor 201, the memory 202, and the communication interface 203 are connected via a bus 200 and communicate with each other.
[0172] The communication interface 203 is used to implement communication between the modules, devices, units and / or equipment in the embodiment of the present application. The communication interface 203 can also implement data communication with other components such as: external devices, image / data acquisition equipment, databases, external storage, and image / data processing workstations.
[0173] The bus 200 includes hardware, software or both, and couples the components of the computer to each other. The bus 200 includes but is not limited to at least one of the following: a data bus, an address bus, a control bus, an expansion bus, and a local bus. By way of example and not limitation, bus 200 may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses or a combination of two or more of these. Where appropriate, bus 200 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0174] Embodiment 5
[0175] In the fifth embodiment of the present invention, in combination with the above-mentioned artificial intelligence-based visual question answering method, the embodiment of the present invention provides the following technical solution, a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned artificial intelligence-based visual question answering method is implemented.
[0176] Those skilled in the art will appreciate that the logic and / or steps represented by data in the flowchart or otherwise described herein, for example, can be considered as a sequenced data table of executable instructions for implementing logical functions, can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0177] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0178] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0179] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0180] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A visual question answering method based on artificial intelligence, characterized in that: The method comprises: Acquire an image and a question, and use an extraction model to perform feature extraction on the image and the question respectively, so as to obtain a feature image of the image and a feature text of the question; Calculating attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image; Inputting the image attention feature and the text attention feature into a preset attention model respectively to obtain an attention image feature and an attention text feature respectively; Calculating a plurality of pre-selected data based on the focus image feature and the focus text feature, and performing score calculation on the plurality of pre-selected data to obtain a pre-selected answer; The step of calculating the attention features of the feature text and the feature image to obtain the text attention features of the feature text and the image attention features of the feature image comprises: Given a query, a key-value pair and a value of the feature image and the feature text, calculating a dot product of the query and the key-value pair based on proportional dot product attention, and obtaining an attention evaluation value based on the dot product calculation using a first calculation formula; Using a first screening function to screen out a preset number of screening values from the attention evaluation value, and using a second screening function to select the screening values that are greater than a second threshold; Calculating using a second calculation formula based on the screening value greater than a second threshold value to obtain a text attention feature of the feature text and an image attention feature of the feature image; The step of calculating a plurality of pre-selected data based on the focus image feature and the focus text feature, and performing score calculation on the plurality of pre-selected data to obtain a pre-selected answer comprises: Projecting the image feature of interest and the text feature of interest to the same dimension, and linearly fusing the projection results to obtain a fused feature; Inputting the fused features into a training set to obtain a plurality of pre-selected data of the same dimension, calculating a score of each of the pre-selected data, and using a hinge function to calculate based on the scores of the pre-selected data to obtain a pre-selected answer; The hinge function includes: ; in, It is expressed as the number of pre-selected data. It is expressed as the score of the pre-selected answer higher than the remaining answers. The score of the preset answer, Expressed as The fraction of pre-selected data; The attention model is a Multi-Layer Perceptron model.
2. The artificial intelligence-based visual question answering method according to claim 1, characterized in that: The first calculation formula includes: ; In the formula, Denoted as the attention evaluation value, Expressed as a dot product, Dimensions represented as key-value pairs; The first screening function comprises: ; in , Represented as a preset number of filter values, Represented as the attention evaluation value of the nth row filter values, It is represented as the attention evaluation value of the mth item in the nth row, and T is represented as a preset number of values; The second screening function includes: ; in, represents the screening value greater than the second threshold, Indicates that attention is paid to the screening values in the xth row and yth column that are greater than the second threshold value. Denoted as the second threshold, It is represented as the first weight; The second calculation formula includes: ; in, Represented as text attention features and image attention features, Denoted as the second weight, Represented as a value.
3. The artificial intelligence-based visual question answering method according to claim 1, characterized in that: The step of selecting the screening value greater than the second threshold value by using the second screening function comprises: Calculate a first weight of the screening value using a first activation function, and select the screening value greater than a second threshold based on the first weight using a second screening function; The step of calculating by using a second calculation formula based on the screening value greater than a second threshold value comprises: The screening value greater than the second threshold is input into a second activation function to obtain a second weight of the screening value greater than the second threshold, and a second calculation formula is used to calculate based on the second weight.
4. The artificial intelligence-based visual question answering method according to claim 1, characterized in that: The step of using the extraction model to extract features from the image and the question respectively to obtain a feature image of the image and a feature text of the question comprises: Dividing the image using an image extraction model to obtain a plurality of region images, and predicting a boundary and a score for each of the region images; According to the scores of the regional images, the regional images exceeding a first threshold are screened out, and the regional images exceeding the first threshold are linearly transformed to obtain feature images; Mark all the words of the question and input all the words of the question into the embedding model to obtain a word embedding sequence; The word embedding sequence is input into the memory model to obtain feature text.
5. The artificial intelligence-based visual question answering method according to claim 1, characterized in that: The step of inputting the image attention feature and the text attention feature into a preset attention model to obtain the attention image feature and the attention text feature respectively comprises: Inputting the image attention feature and the text attention feature into a preset attention model respectively, so as to obtain the image attention feature and the text attention feature of the same dimension respectively; The third weight of the image attention feature and the third weight of the text attention feature are calculated, and the attention image feature is calculated according to the third weight of the image attention feature, and the attention text feature is calculated according to the third weight of the text attention feature.
6. A visual question-answering device based on artificial intelligence, characterized in that: The device comprises: An extraction module, used to obtain an image and a question, and use an extraction model to perform feature extraction on the image and the question respectively, so as to obtain a feature image of the image and a feature text of the question; A calculation module, used for calculating attention features of the feature text and the feature image to obtain text attention features of the feature text and image attention features of the feature image; An input module, used for inputting the image attention feature and the text attention feature into a preset attention model to obtain an attention image feature and an attention text feature respectively; A pre-selection module, configured to calculate a plurality of pre-selected data based on the image feature of interest and the text feature of interest, and perform score calculation on the plurality of pre-selected data to obtain a pre-selected answer; The calculation module comprises: A fitting unit, configured to calculate a dot product of the query and the key-value pair based on proportional dot product attention given the query, the key-value pair and the value of the feature image and the feature text, and obtain an attention evaluation value based on the dot product calculation using a first calculation formula; Using a first screening function to screen out a preset number of screening values from the attention evaluation value, and using a second screening function to select the screening values that are greater than a second threshold; Calculating using a second calculation formula based on the screening value greater than a second threshold value to obtain a text attention feature of the feature text and an image attention feature of the feature image; The pre-selection module comprises: A fusion unit, used for projecting the image feature of interest and the text feature of interest to the same dimension, and linearly fusing the projection results to obtain a fused feature; Inputting the fused features into a training set to obtain a plurality of pre-selected data of the same dimension, calculating a score of each of the pre-selected data, and using a hinge function to calculate based on the scores of the pre-selected data to obtain a pre-selected answer; The hinge function includes: ; in, It is expressed as the number of pre-selected data. It is expressed as the score of the pre-selected answer higher than the remaining answers. The score of the preset answer, Expressed as The fraction of pre-selected data; The attention model is a Multi-Layer Perceptron model.
7. A computer comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the artificial intelligence-based visual question answering method according to any one of claims 1 to 5 is implemented.
8. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the artificial intelligence-based visual question answering method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Diversity preference information pushing method and system based on multi-modal attention, medium and equipment
CN110321473A
Visual question-answering method and device, and medium
CN113780486A
