Explanatable image textualization description method based on multi-model fusion
Through multi-model fusion and custom attention mechanism, combined with LoRA fine-tuning technology, the problem of insufficient generalization ability and interpretability of image to text in the existing technology is solved, and efficient understanding and accurate description of complex image content are achieved. Improved model adaptability and computational efficiency.
Patent Information
- Application Number
- CN202410750467.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-12
AI Technical Summary
It is difficult for existing image-to-text technology to fully understand the details, emotions, and contextual information in images, especially when dealing with abstract concepts or complex scenes. The model's generalization capabilities and real-time processing capabilities are insufficient, and it lacks interpretability, resulting in diverse situations. The generated text descriptions lack creativity and adaptability when the content of images is localized and uncommon.
Using an interpretable image textual description method based on multi-model fusion, high-quality prompts are generated through the DiffusionDB_2M data set and ChatGPT, a CLIP model with a custom attention mechanism is applied, and LoRA fine-tuning technology is introduced into the model for feature extraction and prediction results. Integration and fusion improve model adaptability and computational efficiency.
It improves the accuracy of image feature extraction and the interpretability of prediction results, enhances the model's ability to understand and describe complex image content, reduces computing resource requirements, and improves recognition accuracy and efficiency in diverse scenarios.
Smart Images

Figure CN118736362A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision and natural language processing methods, and specifically relates to an interpretable image text description method based on multi-model fusion. Background Art
[0002] In the field of computer vision and natural language processing, image-to-text technology aims to understand and describe the content of images. For humans, a complex image scene can be quickly summarized in a few sentences within a few minutes, but for computers, this process is much more difficult. The main problems faced in this field include the complexity and diversity of image content and how to accurately and naturally convert visual information into text descriptions. Existing technologies have difficulty in fully understanding the details, emotions and contextual information in images, especially when dealing with abstract concepts, metaphors or complex scenes. In addition, current technologies have limitations in explaining the internal operating mechanisms such as decision paths, weight allocations and activation functions at each layer of the model, which restricts the in-depth understanding of the model layer. In the field of machine learning, accurately understanding these internal structures is crucial to enhance the credibility of the model and improve the transparency of decision-making. Relying on "black box" models to make critical decisions may bring risks, especially in application scenarios that may affect people's lives. Therefore, it is particularly important to develop machine learning models that can provide a higher level of interpretability to better review and verify their internal operating mechanisms. In addition, its generalization, real-time processing capabilities and accuracy still need to be improved to meet the growing application needs, such as assisting the visually impaired, intelligent content creation, etc., which have high requirements on the accuracy and efficiency of model recognition.
[0003] Existing processing models work by extracting image features and converting them into text descriptions. Although some progress has been made, existing methods have several major shortcomings: First, the model is highly dependent on training data. The current common dataset is the COCO dataset developed and maintained by Microsoft in 2014. The dataset lacks diversity, that is, its images may be biased towards certain regions (for example, North America) and ignore scenes and object types in other regions. In addition, with the development of technology and changes in society, the relevance and timeliness of datasets have gradually decreased. These have led to insufficient generalization of the model, and its performance has dropped significantly when facing unseen image types or scenes. Finally, since most models use adaptive neural network methods and establish more complex image analysis networks, the extracted image features have anonymous attributes, which often makes the results lack interpretability.
[0004] According to the current state of the art, existing image2text models show certain limitations in generalization ability. These models usually perform well on training datasets, but their performance is often affected when applied to new data outside the training data, resulting in their inability to effectively process and recognize image types or scenes that were not encountered during training. In addition, due to the high computing resources consumed by the model, the real-time performance of the model recognition is lacking. In the current research field, widely used datasets such as Microsoft COCO, despite their important historical value, have relatively old data composition and lack of reflection of the latest social environment and technological development. This lack of data timeliness leads to application limitations in the context of a rapidly changing modern society. Due to the limitations of the model in understanding and interpreting complex elements, levels of detail, and abstract concepts in images, existing technologies may lack accuracy when generating text descriptions, especially when describing complex or abstract image content. This leads to omissions or misunderstandings of information. In addition, due to the limitations of the model architecture, existing models often lack diversity when generating text descriptions. This results in the model being unable to generate creative and adaptable text descriptions when dealing with diverse and uncommon image content. Summary of the invention
[0005] The purpose of the present invention is to provide an interpretable image text description method based on multi-model fusion, which solves the problem of existing computing resource requirements limitations.
[0006] The technical solution adopted by the present invention is an interpretable image text description method based on multi-model fusion, which extracts features from the input image, then inputs the extracted image features into the prediction model, and finally obtains the prediction result.
[0007] The present invention is also characterized in that:
[0008] Follow the steps below to implement it:
[0009] Step 1: Initialize the preprocessed data set;
[0010] Step 2: Model preparation;
[0011] Step 3: instantiate the predictor;
[0012] Step 4: Integrate and fuse the prediction results.
[0013] In step 1, the DiffusionDB_2M dataset is used, and datasets related to the image description task are given priority. Duplicate data with a similarity score higher than 0.8 are removed. Then, high-quality and diverse prompts are input into ChatGPT to generate images that are more in line with the specifications. The input prompts and the generated images are made to correspond one to one, and the input prompts are dynamically adjusted according to the results of model training, finally forming a dataset of high-quality prompts.
[0014] In step 2, we define the architecture of the model, add a custom attention mechanism to the model, and define two PyTorch modules.
[0015] In step 3, the predictor loads the trained model, including reading the model file stored in a specific path and loading it into memory; after the model is loaded, the predictor will also load the data set to be predicted, including reading data from the database, file system or network source, and performing necessary preprocessing to ensure that the data format is consistent with the format during training; then the data is forward-passed by the predictor through the model. During this process, the data passes through each layer of the model, and the model analyzes and processes the data according to its learned features and rules. After the forward pass is completed, the model outputs the original prediction result.
[0016] The beneficial effects of the present invention are:
[0017] The present invention is an interpretable image text description method based on multi-model fusion. In terms of data sets, a high-quality data set is formed by inputting strict prompts into ChatGPT to generate corresponding pictures. In terms of models, the CLIP model with added analytical attention mechanism is applied to extract high-level features of the input image, and its powerful cross-modal understanding ability is used to provide support for subsequent tasks. The LoRA fine-tuning technology is applied to the three models respectively, so that the model can adapt to the feature relationship of different regions more flexibly, and flexibly adjust the attention in the local area, thereby reducing the computational burden of the model. Finally, the prediction accuracy is improved by integrating the prediction results of the three models. In addition, the different parts of the model are modularly designed to improve the scalability and flexibility of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flow chart of the algorithm model of the present invention;
[0019] Figure 2 It is the flow chart of LoRALinearLayer and LoRALinear algorithm of the present invention;
[0020] Figure 3 It is a flow chart of the LoRA algorithm applied to the BLIP2 model layer of the present invention;
[0021] Figure 4 This is a flow chart of the LoRA algorithm applied to the ConvNeXtxxlarge model layer of the present invention;
[0022] Figure 5 It is a forward propagation flow chart of the LoRACLIPAttention module of the present invention. DETAILED DESCRIPTION
[0023] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] The present invention provides an interpretable image text description method based on multi-model fusion, such as Figure 1 As shown, the input image is subjected to feature extraction, and then the extracted image features are input into the prediction model, and finally the prediction result is obtained.
[0025] Follow the steps below to implement it:
[0026] Step 1: Initialize the preprocessed data set;
[0027] Use the DiffusionDataset class to load image data and target embedding vectors. In order to enhance the accuracy of model recognition, it is very important to have diverse and high-quality data. To achieve this, the DiffusionDB_2M dataset is used in step 1, and datasets related to image description tasks are prioritized, including COCOCaptions, VizWiz, Open Image, ADE20K, Flickr30K, and TextCaps. Duplicate data with a similarity score higher than 0.8 are removed, and high-quality and diverse prompts are input to ChatGPT to generate more standardized images, so that the input prompts and the generated images correspond one to one, and the input prompts are dynamically adjusted according to the results of model training. Finally, a dataset of about 2 million high-quality prompts is formed, called "PROMPTS_HQ";
[0028] For each prompt, 2 images are generated using different random seeds. COYO-700M is a large-scale dataset containing 747M image-text pairs, and this dataset is used for pre-training. From this large dataset, about 6.6 million samples with a similarity greater than 0.3 between images and texts are selected, and duplicates are removed. Then, these texts are used as prompts and input into Stable Diffusion. This dataset is called "PROMPTS_LQ".
[0029] Step 2: Model preparation;
[0030] In step 2, we define the architecture of the model, add a custom attention mechanism to the model, and define two PyTorch modules.
[0031] Step 3: instantiate the predictor;
[0032] In step 3, the predictor loads the trained model, including reading the model file stored in a specific path and loading it into memory. After the model is loaded, the predictor will also load the data set to be predicted, including reading data from a database, file system or network source, and performing necessary preprocessing to ensure that the data format is consistent with the format during training. The data is then forward-passed by the predictor through the model. During this process, the data passes through each layer of the model, and the model analyzes and processes the data based on its learned features and rules. After the forward pass is completed, the model outputs the original prediction result.
[0033] Step 4: Integrate and fuse the prediction results.
[0034] The present invention is based on a multi-model fusion interpretable image text description method, as shown in the following embodiments:
[0035] Example 1
[0036] In step 2, define the architecture of the model, add a custom attention mechanism to the model, and define two PyTorch modules, LoRALinearLayer and LoRALinear, which implement a special neural network layer called LoRA (Low-Rank Adaptation), such as Figure 2 LoRA is a technique for adjusting pre-trained deep learning models by introducing a low-rank matrix to modify the weights of the model instead of directly fine-tuning all weights, which greatly reduces the number of parameters that need to be trained, thereby saving memory and computing resources.
[0037] LoRA technology is applied to the BLIP2, ConvNeXtxxlarge and CLIP model layers to improve the adaptability and performance of the model. LoRA technology is applied to specific layers of the BLIP2 model, such as Figure 3 As shown. First calculate the total number of encoding layers in the model, then determine the number of layers to use LoRA based on the lora rate. Based on the number of layers, traverse the last few layers in the encoder. For each layer, get the current attention layer and multi-layer perceptron (MLP) layer, replace the attention layer with the LoRA attention layer, and use LoRALiner to create a LoRA version for each fully connected layer of the MLP and replace the original layer.
[0038] LoRA technology applied to specific layers of the ConvNeXtxxlarge model such as Figure 4As shown in the figure, the main modifications in the ConvNeXt-XXLarge model are the convolutional layers and the MLP layers in the tail stage. This selective adjustment helps to effectively fine-tune the model while maintaining its core structure and pre-training knowledge, making the model more interpretable.
[0039] The forward propagation process of the LoRACLIPAttention module applied to the CLIP model layer is as follows Figure 5 As shown. The module receives the hidden state of the input, which is converted into corresponding vectors through query, key, and value projection layers. The query and key vectors are scaled by LoRA (Low-Rank Adaptation) technology to enhance the expressiveness of the model. Next, the tensors are prepared for the calculation of the attention mechanism through the reshaping operation. The causal attention mask and the additional attention mask are applied to these vectors to ensure the correctness and focus when generating sequences. The attention weights are calculated by the Softmax function and LoRA scaling is applied again. In order to reduce overfitting, the Dropout mechanism is introduced. Finally, the calculated attention weights are combined with the value vector to generate the attention output, which is passed through the linear projection layer to obtain the final module output. This process optimizes the computational efficiency of the model and greatly improves the accuracy of image feature extraction.
[0040] Example 2
[0041] In step 3, the predictor is instantiated, which involves creating an instance of the Predictor class. This process is not just about simply instantiating a class, but about ensuring that the predictor can effectively and accurately manage the entire prediction process. To this end, the predictor's parameters are carefully configured, including the model loading path, pre-processing and post-processing configurations, and any necessary hardware optimization settings, such as GPU acceleration. These configurations ensure that the predictor can process data quickly and accurately.
[0042] The predictor is then responsible for loading the trained model. This step usually involves reading the model file stored in a specific path and loading it into memory. Once the model is loaded, the predictor will also load the dataset to be predicted. This involves reading the data from a database, file system, or network source and performing any necessary preprocessing, such as scaling, cropping, or normalization, to ensure that the data format is consistent with the format used during training.
[0043] The data is then forward-passed by the predictor through the model. During this process, the data passes through the various layers of the model, and the model analyzes and processes the data based on the features and patterns it has learned. After the forward pass is completed, the model outputs the original prediction results.
[0044] Example 3
[0045] In step 4, the prediction results of the three models are integrated and fused to obtain a powerful prediction model that combines the advantages of each individual model. This integration method not only combines the unique capabilities of each model in processing different features and data, but also enhances the robustness of the final model in the face of various data changes. Specifically, it can be achieved through a variety of integration techniques, such as averaging, weighted averaging, stacking, blending, or voting mechanisms (soft voting and hard voting).
[0046] The present invention is based on a multi-model fusion interpretable image text description method, and ChatGPT self-constructs a large data set to increase the accuracy and diversity of the training image set, so that the data set is more suitable for daily use scenarios. The model adds a model layer that improves the analysis of the attention mechanism, that is, the CLIP model that analyzes and interprets the internal attention layer. The improved attention mechanism can deeply analyze and interpret the attention layer inside the model. This mechanism accurately reflects the interdependence between different input features by dynamically adjusting the weights. Whenever the model makes a prediction, the mechanism provides a clear explanation path, detailing which features play a key role in the prediction results and how these features interact to form the final output, thereby improving the interpretability of the prediction results when the model processes the image input. In addition, through this analysis and visualization of the internal attention layer, the present invention optimizes the efficiency of the feature extraction process, so that the model can process and understand complex image content more efficiently. Finally, the prediction results of multiple improved models are integrated and fused, further enhancing the ability to understand and describe complex image content. Specifically, a deep learning framework based on the attention mechanism is introduced in the three models, so that the model can focus on the key areas of the image more accurately and generate more accurate and natural text descriptions. And the LoRA (LocalRank Adaptation) fine-tuning technology is introduced in the self-attention layer, allowing the model to be effectively fine-tuned while keeping most of the parameters fixed. This allows the model to be efficiently trained on a smaller data set without the need to retrain the entire network, reducing the computational burden of the model. Through these improvements, it is expected that the present invention will be able to demonstrate excellent performance in various application scenarios. Specifically, in terms of image content interpretation, the present invention can more accurately analyze and identify elements and scenes in images, so that it can be applied to image content search, etc.; in terms of assisting the visually impaired, it can provide clearer and more targeted visual descriptions, and in terms of actual marginal deployment, it reduces the demand for computing resources, reduces costs, and ensures recognition efficiency and accuracy to improve their daily life experience; in the field of intelligent content creation, the present invention can automatically generate creative and high-quality visual and text content.
Claims
1. An interpretable image text description method based on multi-model fusion, It is characterized in that The input image is subjected to feature extraction, and then the extracted image features are input into the prediction model to finally obtain the prediction result.
2. According to the method for interpretable image text description based on multi-model fusion according to claim 1, It is characterized in that Follow the steps below to implement it: Step 1: Initialize the preprocessed data set; Step 2: Model preparation; Step 3: instantiate the predictor; Step 4: Integrate and fuse the prediction results.
3. According to the method for interpretable image text description based on multi-model fusion according to claim 2, It is characterized in that In step 1, the DiffusionDB_2M dataset is used, and datasets related to the image description task are preferentially selected. Duplicate data with a similarity score higher than 0.8 are removed, and high-quality and diverse prompts are input into ChatGPT to generate images that are more in line with the specifications. The input prompts and the generated images are made to correspond one to one, and the input prompts are dynamically adjusted according to the results after model training, finally forming a dataset of high-quality prompts.
4. The method for interpretable image text description based on multi-model fusion according to claim 2, It is characterized in that In step 2, the architecture of the model is defined, a custom attention mechanism is added to the model, and two PyTorch modules are defined.
5. The method for interpretable image text description based on multi-model fusion according to claim 2, It is characterized in that In step 3, the predictor loads the trained model, including reading the model file stored in a specific path and loading it into the memory; after the model is loaded, the predictor will also load the data set to be predicted, including reading data from a database, file system or network source, and performing necessary preprocessing to ensure that the data format is consistent with the format during training; then the data is forward-transferred by the predictor through the model. During this process, the data passes through each layer of the model, and the model analyzes and processes the data according to its learned features and rules. After the forward transfer is completed, the model outputs the original prediction result.
Citation Information
Patent Citations
Industrial scene-oriented method and system for constructing multi-modal large language model and application method
CN117292146A
Training and deployment of image generation models
US11995803B1
Cited By
Power question query method based on multi-model fusion
CN119988443A
