Image processing method, device, equipment and readable storage medium
By performing structured information recognition and text generation on original images, a graphic and text data set is constructed, which solves the unreliable problem of graphic and text data sets in the existing technology, achieves higher quality data set generation, and reduces hallucinations and prompts. Design dependencies.
Patent Information
- Application Number
- CN202410853502.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-28
AI Technical Summary
It is difficult to construct a reliable graphic and text multi-modal pre-training data set with existing technology, resulting in poor text generation capabilities and difficulty in prompt language design during model training, which affects the reliability of the data set.
By identifying structured information on the original image, structured data is generated, and a text generation model is used to generate description text based on the data, directly correlating the image and text, and constructing a graphic and text data set, avoiding the limitations of prompt design.
It improves the reliability of the graphic data set, enhances the semantic expression ability of the data set, reduces the occurrence of hallucinations, and provides a more solid data set foundation.
Smart Images

Figure CN118397643B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to an image processing method, device, equipment and readable storage medium. Background Art
[0002] Multimodal pre-trained models for text and images have gradually become an important foundation for various natural language processing and computer vision tasks. A major feature of these multimodal pre-trained models is that they can process multimodal data, such as data containing both text and image information.
[0003] In order to train these models, it is necessary to build a large-scale pre-training dataset of multimodal images and texts (i.e., image-text datasets) to provide rich multimodal data samples. When building a pre-training dataset of multimodal images and texts, attention should be paid to data collection and processing, data alignment and correspondence. Among them, the most critical is data alignment and correspondence, that is, to establish a correspondence between text and images, and ensure their consistency in time and space.
[0004] Use an open source model that supports multimodality, design a prompt, and then let the multimodal model generate a description of the image, and finally associate the generated text with the original image. This method has high requirements for prompt design. Images from different sources need to use different prompts, otherwise the quality of the generated text is very poor. In addition, there are few high-quality open source multimodal models. The current open source multimodal models have average image-to-text capabilities and are prone to hallucinations. In other words, the image datasets constructed by the existing solutions are not reliable, and unreliable image and text datasets seriously affect model training.
[0005] In summary, how to construct a reliable image and text dataset is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0006] The object of the present invention is to provide an image processing method, apparatus, device and readable storage medium, which can construct a reliable image and text data set.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] An image processing method, comprising:
[0009] Acquire an image data set; wherein the image data set includes a plurality of original images;
[0010] Identifying structured information in the original image to obtain structured data;
[0011] Using the structured data to generate a natural language description to obtain a description text;
[0012] Associating the original image with the corresponding description text to obtain an image and text sample corresponding to the original image;
[0013] A picture and text dataset is constructed using a number of picture and text samples corresponding to the original images.
[0014] Preferably, identifying the structured information in the original image to obtain structured data includes:
[0015] Inputting the original image into a structured model to perform structured information recognition to obtain the structured data; wherein the structured information includes at least one of an object, a scene, and an emotion;
[0016] Accordingly, after constructing the image and text data set using the image and text samples corresponding to the original images, the method further includes:
[0017] The image processing model is trained using the image and text dataset; wherein the image processing model is at least one of object recognition, scene recognition and emotion recognition.
[0018] Preferably, the structured data is used to perform natural language description generation processing to obtain a description text, including:
[0019] The structured data is input into a text generation model for description generation processing to obtain the description text.
[0020] Preferably, acquiring an image dataset includes:
[0021] Images acquired from different data sources;
[0022] The acquired image is cleaned, and the cleaned image is stored in a newly created data set to obtain the image data set.
[0023] Preferably, associating the original image with the corresponding description text to obtain a graphic sample corresponding to the original image includes:
[0024] Creating a blank label for the original image;
[0025] Writing a description text corresponding to the original image into the blank label;
[0026] An original image with a non-empty label is determined as the image-text sample.
[0027] Preferably, after the structured data is used to perform natural language description generation processing to obtain the description text, the method further includes:
[0028] Determining whether the description text contains hallucination words;
[0029] If yes, deleting the hallucination words in the description text;
[0030] If not, the original image is associated with the corresponding description text to obtain a graphic and text sample corresponding to the original image.
[0031] Preferably, determining whether the description text contains hallucination words includes:
[0032] Performing word segmentation processing on the description text to obtain component words;
[0033] Extracting component nouns from the component words;
[0034] Determining whether the component noun matches the structured data;
[0035] If yes, determining that the description text does not contain the hallucination word;
[0036] If not, it is determined that the description text contains the hallucination word.
[0037] Preferably, determining whether the description text contains hallucination words includes:
[0038] Performing word segmentation processing on the description text to obtain component words;
[0039] Extracting component nouns from the component words;
[0040] Performing recognition detection on the original image to obtain an inspection result;
[0041] If the inspection result corresponds to the component noun, it is determined that the description text does not contain hallucination words;
[0042] If the checking result does not correspond to the constituent nouns, it is determined that the description text has hallucination words.
[0043] Preferably, the structured data is used to perform natural language description generation processing to obtain a description text, including:
[0044] Inputting the structured data into a first text generation model for natural language description generation processing to obtain a first description text;
[0045] Inputting the structured data into a second text generation model for natural language description generation processing to obtain a second description text;
[0046] Outputting the first description text and the second description text on a visual interface;
[0047] In response to the operation information fed back by the visual interface, the description text is determined from the first description text and the second description text.
[0048] Preferably, the structured data is used to perform natural language description generation processing to obtain a description text, including:
[0049] Inputting the structured data into a text generation model for description generation processing to obtain output text;
[0050] Performing grammatical error detection on the output text;
[0051] If the output text has grammatical errors, the structured data is input into a text generation model for description generation processing to obtain a new output text, and the output text is returned for grammatical error detection;
[0052] If the output text does not have any grammatical errors, the output text is determined to be a description text.
[0053] Preferably, performing grammatical error detection on the output text includes:
[0054] The output text is input into a grammatical error checking model to perform grammatical error detection to obtain a grammatical error detection result.
[0055] An image processing device, comprising:
[0056] An image acquisition module, used to acquire an image data set; wherein the image data set includes a plurality of original images;
[0057] An object recognition module, used to recognize structured information in the original image to obtain structured data;
[0058] A text description module, used to perform natural language description generation processing using the structured data to obtain a description text;
[0059] An image-text association module is used to associate the original image with the corresponding description text to obtain an image-text sample corresponding to the original image;
[0060] The data set generation module is used to construct a data set of images and texts using the image and text samples corresponding to the original images.
[0061] An electronic device, comprising:
[0062] Memory for storing computer programs;
[0063] A processor is used to implement the steps of the above-mentioned image processing method when executing the computer program.
[0064] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned image processing method are implemented.
[0065] A computer program product comprises a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned image processing method.
[0066] Apply the method provided in the embodiment of the present invention to obtain an image data set; wherein the image data set includes several original images; identify the structured information in the original images to obtain structured data; use the structured data to perform natural language description generation processing to obtain description text; associate the original images with the corresponding description text to obtain image and text samples corresponding to the original images; and use the image and text samples corresponding to the several original images to construct an image and text data set.
[0067] Due to the poor text generation capability of the relevant models and the difficulty in designing prompts, the generated image and text data sets are not reliable. Therefore, another idea is provided in the present invention to construct the image and text data sets. Specifically, in the present invention, the structured information of the original image is directly identified to obtain the structured data of the original image. Then, when generating the description text corresponding to the original image, the text generation process is not directly performed on the original image based on the prompts, but the description text is generated based on the structured data. Finally, the original image and the description text are associated to obtain the image and text samples. The image and text data sets are finally constructed based on the image and text samples. It can be seen that in the present invention, there is no need to design prompts, but to directly extract structured data from the original image, and then generate description text based on the structured data. In this way, it is no longer limited by the prompt design and the limitations of the relevant models, and the reliability of the image and text data sets can be effectively improved.
[0068] Technical effect: It is possible to build a reliable image and text dataset, laying a solid foundation for subsequent applications based on the image and text dataset.
[0069] Correspondingly, the embodiments of the present invention also provide image processing devices, equipment, readable storage media and computer program products corresponding to the above-mentioned image processing methods, which have the above-mentioned technical effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments or related technical descriptions are 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 work.
[0071] Figure 1 is a flowchart of an implementation method of an image processing method in an embodiment of the present invention;
[0072] Figure 2is a schematic structural diagram of an image processing device according to an embodiment of the present invention;
[0073] FIG3 is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention;
[0074] Figure 4 The figure is a schematic diagram of a specific structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0075] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0076] Please refer to Figure 1 , Figure 1 This is a flowchart of an image processing method in an embodiment of the present invention, the method comprising the following steps:
[0077] S101: Obtain an image dataset.
[0078] The image data set includes several original images.
[0079] In this embodiment, the image data set can be obtained by downloading from the network, receiving from other devices, directly reading from a readable storage medium, or performing real-time image acquisition through an image acquisition system.
[0080] The original images in the image dataset are the images in the generated image and text dataset.
[0081] In other words, generating samples in the image-text dataset requires building an association between images and texts. By acquiring the image dataset, the images in the image-text dataset can be acquired.
[0082] In one embodiment of the present invention, obtaining an image data set includes:
[0083] Images acquired from different data sources;
[0084] The acquired image is cleaned, and the cleaned image is stored in a newly created data set to obtain an image data set.
[0085] For ease of description, the above two steps are combined for explanation below.
[0086] Considering that images acquired from different data sources have different qualities or sizes, in this embodiment, after acquiring the image, the image may be cleaned, and of course the image may be normalized in dimensions such as size and color. Data cleaning may specifically be to remove duplicate, incomplete or unusable images.
[0087] After completing data cleaning, the cleaned images can be stored in a new data set to obtain an image data set.
[0088] S102: Identify structured information in the original image to obtain structured data.
[0089] Structured data is also called row data. It is data that is logically expressed and implemented by a two-dimensional table structure. It strictly follows data format and length specifications and is mainly stored and managed through relational databases.
[0090] The image itself contains structured content. For example, if an original image corresponds to a photo of a dog, then the object in the original image is a dog. Furthermore, the dog's category, size, color and other characteristics can also be clearly identified.
[0091] Therefore, in this embodiment, in order to establish the correspondence between the image and the text, in this embodiment, the structured information in the original image is directly identified to obtain structured data. The structured data refers to the specific structured information in the original image.
[0092] In one embodiment of the present invention, the structured information in the original image is identified to obtain structured data, including:
[0093] Inputting the original image into the structured model to perform structured information recognition to obtain structured data; wherein the structured information includes at least one of an object, a scene, and an emotion;
[0094] Accordingly, after constructing the image and text dataset using the image and text samples corresponding to several original images, it also includes:
[0095] An image processing model is trained using a graphic and text dataset; wherein the image processing model is at least one of object recognition, scene recognition, and emotion recognition.
[0096] For ease of description, the above steps are combined for explanation below.
[0097] The structured model may be a general structured model or a face structured model. General structured models (including all types of image recognition such as faces and landscapes) include R-CNN (Region-CNN, the first algorithm that successfully applied deep learning to target detection) and YOLO (You Only Look Once, an algorithm that uses convolutional neural networks for target detection).
[0098] Face structured models (open source), such as MTCNN (Multi-task Cascaded Convolutional Networks) and OpenCV (Open Source Computer Vision Library), an open source computer vision and machine learning software library.
[0099] For example, an image recognition model (a structured model) generates structured data: First, the original image is fed into the image recognition model, which can analyze and understand the original image and identify structured information such as objects, scenes, and emotions. These structured data can be object labels, scene descriptions, sentiment analysis results, etc., providing a detailed understanding of the image content.
[0100] Accordingly, since the structured information recognized by the graphic and text dataset includes at least one of objects, scenes and emotions; accordingly, the subsequently generated descriptive text also corresponds to at least one of the corresponding objects, scenes and emotions, therefore, the subsequently obtained graphic and text dataset can train at least one image processing model of object recognition, scene recognition and emotion recognition.
[0101] S103: Using the structured data to generate a natural language description, a description text is obtained.
[0102] After obtaining the structured data, a natural language description generation process can be performed based on the structured data to obtain a description text about the original image. For specific information on how to generate the description text based on the structured data, reference can be made to the relevant natural language description generation scheme, which will not be described in detail here.
[0103] In one embodiment of the present invention, natural language description generation processing is performed using structured data to obtain a description text, including:
[0104] The structured data is input into the text generation model for description generation processing to obtain the description text.
[0105] That is, the structured data generated in step S102 can be passed to the text generation model. The text generation model can convert the structured data into natural language descriptions and generate description text related to the image content in the original image. Specifically, the text generation model can generate rich and vivid text descriptions based on information such as objects and emotions in the structured data to enhance the expression and understanding of the image content.
[0106] The text generation models that can be used include but are not limited to qwen1.5-70B (Tongyi Qianwen, a chat and pre-trained large language model), chatglm-6B (a conversational robot), baichuan-13B (a large multilingual language model), and other models.
[0107] It should be noted that since structured data is used to form sentences, the structured data actually corresponds to multiple words, so the generated description text will contain all the words provided and will not arbitrarily add additional nouns, thus avoiding the creation of hallucinations, that is, the generated text will not contain object nouns other than the multiple words provided.
[0108] S104: Associating the original image with the corresponding description text to obtain an image and text sample corresponding to the original image.
[0109] The generated text description is associated with the corresponding original image to form the final image-text sample data. In other words, in each image-text sample, the original image has a description text associated with it. Such an image-text sample contains both the visual information of the image and the semantic understanding of the image content, providing rich information for subsequent applications and analysis.
[0110] In one embodiment of the present invention, an original image is associated with a corresponding description text to obtain a graphic sample corresponding to the original image, including:
[0111] Create a blank label for the original image;
[0112] Write the description text corresponding to the original image in the blank label;
[0113] The original images with non-empty labels are determined as image-text samples.
[0114] For ease of description, the above steps are combined for explanation below.
[0115] In order to establish the association between the image and the text, in this embodiment, a blank label can be created for each original image, and then the description text corresponding to the original image can be written into the blank label. In this way, for an original image, if it has a non-empty label, it is a picture-text sample.
[0116] Of course, in practical applications, a key-value pair method may also be used to establish an association relationship between the original image and the text description corresponding to the original image, which will not be described in detail here.
[0117] S105: constructing a picture and text dataset using picture and text samples corresponding to a number of original images.
[0118] That is to say, in the image-text dataset, each image has a description text associated with it. Such a dataset contains both the visual information of the image and the semantic understanding of the image content, providing rich information for subsequent applications and analysis. In this way, the relevant image-text multimodal pre-training model can be trained based on the image-text dataset.
[0119] Apply the method provided in the embodiment of the present invention to obtain an image data set; wherein the image data set includes several original images; identify the structured information in the original images to obtain structured data; use the structured data to perform natural language description generation processing to obtain description text; associate the original images with the corresponding description text to obtain image and text samples corresponding to the original images; and use the image and text samples corresponding to the several original images to construct an image and text data set.
[0120] Due to the poor text generation capability of the relevant models and the difficulty in designing prompts, the generated image and text data sets are not reliable. Therefore, another idea is provided in the present invention to construct the image and text data sets. Specifically, in the present invention, the structured information of the original image is directly identified to obtain the structured data of the original image. Then, when generating the description text corresponding to the original image, the text generation process is not directly performed on the original image based on the prompts, but the description text is generated based on the structured data. Finally, the original image and the description text are associated to obtain the image and text samples. The image and text data sets are finally constructed based on the image and text samples. It can be seen that in the present invention, there is no need to design prompts, but to directly extract structured data from the original image, and then generate description text based on the structured data. In this way, it is no longer limited by the prompt design and the limitations of the relevant models, and the reliability of the image and text data sets can be effectively improved.
[0121] Technical effect: It is possible to build a reliable image and text dataset, laying a solid foundation for subsequent applications based on the image and text dataset.
[0122] It should be noted that, based on the above embodiments, the embodiments of the present invention also provide corresponding improved solutions. In the preferred / improved embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be described one by one in the preferred / improved embodiments of this article.
[0123] In one embodiment of the present invention, after the natural language description generation process is performed using the structured data to obtain the description text, the following further comprises:
[0124] Determine whether the description text contains hallucination words;
[0125] If so, remove the hallucination words from the description text;
[0126] If not, the original image is associated with the corresponding description text to obtain an image-text sample corresponding to the original image.
[0127] That is to say, in this embodiment, after the description text is obtained, hallucination vocabulary detection may be performed on the description text to remove the hallucination vocabulary.
[0128] Specifically, after obtaining the description text, before establishing the association relationship between the original image and the description text, the description text can be subjected to hallucination word detection, and when hallucination words are detected, the hallucination words in the description text are deleted. Of course, if the hallucination words are deleted, the grammatical errors can be further corrected. When the hallucination words are not detected, the step of establishing the association relationship between the original image and the description text can be directly entered to obtain the image and text sample.
[0129] Specifically, delete hallucination words in the description text, including:
[0130] determining the location of the hallucination word from the descriptive text;
[0131] Read the words before and after that position;
[0132] Determine whether the word is closely related to the hallucination word;
[0133] If so, delete the word;
[0134] If not, keep the word and rearrange the word order.
[0135] That is to say, in the present embodiment, the semantics and word order of the illusion vocabulary after deletion can also be rearranged. Specifically, since the illusion vocabulary is generally a noun, and in the general natural language description, the words before and after the noun are often closely related to the noun, for example, the adjectives and verbs before the noun, and the words after the noun often appear to supplement the noun, etc. Therefore, the closeness of the words before and after the illusion vocabulary and the environmental vocabulary can be judged. Thus, it can be retained or deleted according to the situation. After deleting the vocabulary, the word order is often confused, and at this time, the word order can be re-arranged to ensure that the word order is correct.
[0136] In one embodiment of the present invention, determining whether the description text contains hallucination words includes:
[0137] Perform word segmentation on the description text to obtain the constituent words;
[0138] Extract the component nouns from the component words;
[0139] Determine whether the constituent nouns match the structured data;
[0140] If yes, then make sure there are no hallucination words in the description text;
[0141] If not, it is determined that the description text has hallucination words.
[0142] Hallucination words are the contents that are not presented in the original image. Therefore, to detect hallucination words, the description text can be segmented to obtain the constituent words. Since hallucinations are often related to nouns, such as there is no dog in the image, but the description text involves a dog, and it is obvious that the dog is the hallucination word. Therefore, in this embodiment, the focus is on detecting whether there are problems with the constituent nouns. Specifically, since the structured data includes the corresponding objects detected in the original image. Therefore, in this embodiment, the constituent nouns and the structured data can be matched. If the two match, it is determined that there are no hallucination words in the description text. If the two do not match, it is determined that there are hallucination words in the description text.
[0143] For example: when there are three nouns ABC in the description text, if the structured data includes these three nouns, then it is determined that the two match and there is no hallucination word; if the structured data only includes two nouns AB, then it is determined that the two do not match and there is a hallucination word C in the description text.
[0144] In one embodiment of the present invention, determining whether the description text contains hallucination words includes:
[0145] Perform word segmentation on the description text to obtain the constituent words;
[0146] Extract the component nouns from the component words;
[0147] Perform recognition and detection on the original image to obtain the inspection result;
[0148] If the check result corresponds to the constituent nouns, it is determined that the description text does not contain hallucination words;
[0149] If the check result does not correspond to the constituent nouns, it is determined that the description text has hallucination words.
[0150] Since the description text should be a description of the original image, the content in the description text should correspond to the original image. Therefore, to determine whether hallucination words are generated in the description text, the original image can also be tested again, and the inspection results can be compared with the component nouns obtained by word segmentation of the description text. If the two correspond, it can be determined that there are no hallucination words in the description text. If the two do not correspond (the component noun is partially or completely missing in the inspection result), it can be determined that the description text contains hallucination words.
[0151] In one embodiment of the present invention, natural language description generation processing is performed using structured data to obtain a description text, including:
[0152] Inputting the structured data into a first text generation model for natural language description generation processing to obtain a first description text;
[0153] Inputting the structured data into a second text generation model for natural language description generation processing to obtain a second description text;
[0154] Outputting the first description text and the second description text on the visual interface;
[0155] In response to the operation information fed back by the visualization interface, a description text is determined from the first description text and the second description text.
[0156] The first and second in the first text generation module and the second text generation model are only used to distinguish the existence of two different text generation models, and have no other limiting meaning. Accordingly, the first description text and the second description text correspond to the output texts of the corresponding text generation models.
[0157] In this embodiment, the structured data may be input into the first text generation model and the second text generation model respectively to perform natural language description generation processing, thereby obtaining the first description text and the second description text.
[0158] In order to further improve accuracy, two description texts may be output to the user for selection, so that the description text selected by the user is used as the final description text.
[0159] Of course, in practical applications, the number of text generation models can be 3 or more. In addition, the visualization interface can also provide a function for inputting description texts, so that the user can directly input description texts when he feels that there is no accurate model output.
[0160] In one embodiment of the present invention, natural language description generation processing is performed using structured data to obtain a description text, including:
[0161] Input the structured data into the text generation model for description generation processing to obtain output text;
[0162] Detect grammatical errors in the output text;
[0163] If the output text has grammatical errors, the structured data is input into the text generation model for description generation processing to obtain a new output text, and the output text is returned for grammatical error detection;
[0164] If there is no grammatical error in the output text, the output text is determined as a description text.
[0165] That is, in this embodiment, the input text of the text generation model can also be checked for grammatical errors. If a grammatical error is detected, the previous step is returned to regenerate a new output text and continue to enter the grammatical error detection step; if no grammatical error is detected, the output text can be directly determined as a description text. In this way, grammatical errors can be avoided in the text of the image and text sample.
[0166] Specifically, the output text is checked for grammatical errors, including:
[0167] The output text is input into the grammatical error checking model for grammatical error detection to obtain the grammatical error detection result.
[0168] In other words, we can train a grammatical error detection model to detect grammatical errors, thereby quickly obtaining grammatical error detection results. Of course, in practical applications, the grammatical error detection model can be used as a training branch of the text generation model, so that the text generation model can generate descriptive text without grammatical errors.
[0169] In order to help those skilled in the art to better understand the specific implementation and technical effects of the image processing method adopted in the embodiment of the present invention, a comparative explanation is given below in combination with relevant technical solutions.
[0170] In the relevant scheme, you first need to select a suitable model and the original image. This model usually combines text and image processing technology, can process various types of input data, and generate corresponding descriptions. For example, you can choose OpenAI's CLIP model or Qwen-VL model. The next steps can be divided into the following parts:
[0171] 1. Choose the right prompt: The prompt is the text that provides input to the model to guide it to generate descriptions. When designing the prompt, you need to consider the theme, style, and content of the image to be described. The prompt should be concise and clear, and clearly guide the model to generate relevant descriptions.
[0172] 2. Image description generation: Use the designed prompt to input the image into the multimodal model and let the model generate a description of the image. The model will consider both the image and the prompt, and then generate a text description associated with it. This description can include information such as the object, scene, emotion, etc. in the image.
[0173] 3. Associate text and original images: The generated text description and the original image need to be associated. The generated text description can be associated with the file name or identifier of the original image so that the correct image can be matched during subsequent retrieval or display. In addition, the text description and the image can be saved together in the database and associated with a unified index.
[0174] 4. Store and manage associated data: After associating the generated text description with the original image, you need to store and manage this data. You can choose to use a database or file system to store this data, and design a suitable data structure to manage the association between the text description and the image.
[0175] It can be seen that this related solution has the following problems or defects:
[0176] 1. Challenges in model selection: Selecting an appropriate multimodal model is a critical step. Different models may differ in processing power, effects, and resource consumption. Moreover, with the development of technology, the performance and applicable scenarios of models are constantly changing, and it is necessary to evaluate and select existing models.
[0177] 2. Subjectivity of prompt design: Prompt design requires a certain amount of subjective judgment and domain knowledge, and different prompts may lead to different generated descriptions. It is a challenge to design a prompt that can accurately guide the model and meet user needs.
[0178] 3. Accuracy and consistency of descriptions: The descriptions generated by multimodal models may have problems with accuracy and consistency. Sometimes the model may generate descriptions that do not match the image, or generate inconsistent descriptions when similar images are continuously input. This needs to be verified and adjusted in actual applications.
[0179] From the above, it can be seen that in order to solve the problems of poor model text generation capability and difficult prompt design in related technologies, the present invention provides another approach to generate descriptive text for images, namely, adding a model for generating structured data, and then using the text generation model to perform joint text generation on the structured data to form the final text description of the original image.
[0180] The core principle of the present invention is to feed the image into the image recognition model to generate structured data, and then use the text generation model to combine the structured data to generate a piece of text, which is then associated with the original image to form the final image-text data set.
[0181] The specific implementation process includes:
[0182] 1. Image recognition model generates structured data: First, the image is fed into the image recognition model, which can analyze and understand the image and identify structured information such as objects, scenes, and emotions. These structured data can be object labels, scene descriptions, sentiment analysis results, etc., providing a detailed understanding of the image content.
[0183] 2. Text generation model generates description: Next, the generated structured data is passed to the text generation model. This model can convert structured data into natural language descriptions and generate text related to the image content. The text generation model can generate rich and vivid text descriptions based on the objects, emotions and other information in the structured data, enhancing the expression and understanding of the image content.
[0184] 3. Jointly generate image and text datasets: Finally, the generated text descriptions are associated with the original images to form the final image and text dataset. Each image has a text description associated with it. Such a dataset contains both the visual information of the image and the semantic understanding of the image content, providing rich information for subsequent applications and analysis.
[0185] The differences between the processing results of the present invention and related solutions are compared by examples below:
[0186] Using the Qwen-VL model, we generate text from images for the same image (in which a man wearing a black windbreaker and a white shirt can be seen with the naked eye, with only the lower half of his face showing, standing in the snow with a smile):
[0187] 1. Use prompt: Please provide a detailed description of each object in the picture.
[0188] Result: The image shows a man standing in the snow wearing a long black down jacket. The collar and buttons of the down jacket are black. The man is wearing glasses, black pants, and a pair of black shoes. In the background of the picture, there are several cars parked, including a white Audi and several other brands of cars. In addition, there is a light in the upper left and upper right corners of the picture.
[0189] 2. Use prompts: Please provide a detailed description for each object shown in the image.
[0190] Generated result: In this photo, a young man wearing a long black down jacket, black pants, glasses, and a pair of white sneakers stands on a snow-covered street. His glasses are dark, and the street lights in the distance emit a yellowish light, dyeing the snow pink. There are license plates on the white vehicles parked on the roadside and on the street lights in the distance.
[0191] 3. Use prompt: Please describe this picture comprehensively and carefully.
[0192] Generated result: In this picture, a man wearing a long black down jacket, a white striped sweater, a blue shirt and black pants is standing in the snow. The down jacket has a black hood at the collar and the length of the jacket is to the waist. The zipper of the down jacket is silver. There are 6 cars parked in the snow on the left side of the picture. The cars are of different shapes and sizes, and the vehicles tend to be covered by snow. The background of the picture is dark red, which may be caused by the light from the street lamp.
[0193] These three prompts can generate text descriptions, but all of them have hallucinations, that is, the text description contains things that do not exist in the picture, such as: wearing a pair of black shoes on the feet.
[0194] It can be seen that the quality of the text results obtained by the above three prompts is relatively poor. First, this is because the model itself is not capable of generating images. Second, prompt design is difficult. Even if a good prompt is designed for similar images, the generation result of the model may still deteriorate after changing the type of image, and the prompt needs to be redesigned. This brings certain difficulties to the large-scale generation of image descriptions.
[0195] The text description generated by the method provided by the embodiment of the present invention is as follows:
[0196] 1. Extract structured data and get the following data: male, black windbreaker, white shirt, lower half of face, smiling, standing, snow.
[0197] 2. Generate text (use prompt: Please use the following words to make a sentence:), you can get the text: On the snow, a man wearing a black windbreaker and a white shirt stands with a smile, and his lower face is clearly visible.
[0198] It can be seen from the above examples that by using the method provided in the embodiment of the present invention, firstly, the influence of prompt on the image description can be ignored, because the extraction of structured data does not require prompt; secondly, the image content can be described more accurately, and the illusion effect caused by directly generating text from images can be basically ignored.
[0199] It should be noted that Qwen-VL, as an excellent open source multimodal model, has ranked high among many models in terms of image-to-text quality, but its image-to-text quality is still worrying and cannot meet the requirements for building a high-quality multimodal dataset. The method provided by the embodiment of the present invention reduces the dependence on prompts, and can generate high-quality image text descriptions regardless of the source of the image; reduces hallucinations, that is, reduces the text descriptions of objects that do not exist in the image, which improves the quality of the dataset to a certain extent.
[0200] The present invention relates to the generation of multimodal image-text datasets, and proposes a solution to expand text descriptions using structured data. The solution mainly uses a model to extract the structured data of the image first, which can accurately identify various objects, scenes and other information in the image, thereby improving the accuracy and richness of subsequent text generation; and then uses a large model to construct sentences for the structured data.
[0201] Specifically, since multiple words are used to form sentences, the generated text will contain all the words provided and will not arbitrarily add additional nouns, thus avoiding the generation of hallucinations, that is, the generated text will not contain object nouns other than the multiple words provided.
[0202] It can be seen that the text description generated by the image processing method provided in the embodiment of the present invention has higher semantic expression ability and can describe the image content more accurately and vividly, thereby obtaining a more reliable image and text data set.
[0203] Corresponding to the above method embodiment, the embodiment of the present invention further provides an image processing device. The image processing device described below and the image processing method described above can be referred to in correspondence with each other.
[0204] See also Figure 2 As shown, the device includes the following modules:
[0205] The image acquisition module 101 is used to acquire an image data set; wherein the image data set includes a plurality of original images;
[0206] The object recognition module 102 is used to recognize the structured information in the original image and obtain structured data;
[0207] The text description module 103 is used to perform natural language description generation processing using structured data to obtain a description text;
[0208] The image-text association module 104 is used to associate the original image with the corresponding description text to obtain an image-text sample corresponding to the original image;
[0209] The data set generation module 105 is used to construct a data set of images and texts using image and text samples corresponding to a number of original images.
[0210] The device provided by the embodiment of the present invention is used to obtain an image data set; wherein the image data set includes a plurality of original images; structured information in the original images is identified to obtain structured data; natural language description generation processing is performed using the structured data to obtain description text; the original images are associated with corresponding description texts to obtain image and text samples corresponding to the original images; and an image and text data set is constructed using the image and text samples corresponding to the plurality of original images.
[0211] Due to the poor text generation capability of the relevant models and the difficulty in designing prompts, the generated image and text data sets are not reliable. Therefore, another idea is provided in the present invention to construct the image and text data sets. Specifically, in the present invention, the structured information of the original image is directly identified to obtain the structured data of the original image. Then, when generating the description text corresponding to the original image, the text generation process is not directly performed on the original image based on the prompts, but the description text is generated based on the structured data. Finally, the original image and the description text are associated to obtain the image and text samples. The image and text data sets are finally constructed based on the image and text samples. It can be seen that in the present invention, there is no need to design prompts, but to directly extract structured data from the original image, and then generate description text based on the structured data. In this way, it is no longer limited by the prompt design and the limitations of the relevant models, and the reliability of the image and text data sets can be effectively improved.
[0212] Technical effect: It is possible to build a reliable image and text dataset, laying a solid foundation for subsequent applications based on the image and text dataset.
[0213] In a specific embodiment of the present invention, the object recognition module is specifically used to input the original image into the structured model to perform structured information recognition to obtain structured data; wherein the structured information includes at least one of an object, a scene, and an emotion;
[0214] Accordingly, after constructing the image and text dataset using the image and text samples corresponding to several original images, it also includes:
[0215] An image processing model is trained using a graphic and text dataset; wherein the image processing model is at least one of object recognition, scene recognition, and emotion recognition.
[0216] In a specific implementation of the present invention, the text description module is specifically used to input structured data into a text generation model for description generation processing to obtain a description text.
[0217] In a specific embodiment of the present invention, the image acquisition module is specifically used to acquire images from different data sources;
[0218] The acquired image is cleaned, and the cleaned image is stored in a newly created data set to obtain an image data set.
[0219] In a specific embodiment of the present invention, the image-text association module is specifically used to create a blank label for the original image;
[0220] Write the description text corresponding to the original image in the blank label;
[0221] The original images with non-empty labels are determined as image-text samples.
[0222] In a specific embodiment of the present invention, the hallucination processing module is used to perform natural language description generation processing using structured data, and after obtaining the description text, determine whether the description text contains hallucination words;
[0223] If so, remove the hallucination words from the description text;
[0224] If not, the original image is associated with the corresponding description text to obtain an image-text sample corresponding to the original image.
[0225] In a specific embodiment of the present invention, the hallucination processing module is specifically used to perform word segmentation processing on the description text to obtain component words;
[0226] Extract the component nouns from the component words;
[0227] Determine whether the constituent nouns match the structured data;
[0228] If yes, then make sure there are no hallucination words in the description text;
[0229] If not, it is determined that the description text has hallucination words.
[0230] In a specific embodiment of the present invention, the hallucination processing module is specifically used to perform word segmentation processing on the description text to obtain component words;
[0231] Extract the component nouns from the component words;
[0232] Perform recognition and detection on the original image to obtain the inspection result;
[0233] If the check result corresponds to the constituent nouns, it is determined that the description text does not contain hallucination words;
[0234] If the check result does not correspond to the constituent nouns, it is determined that the description text has hallucination words.
[0235] In a specific embodiment of the present invention, the text description module is specifically used to input the structured data into the first text generation model for natural language description generation processing to obtain a first description text;
[0236] Inputting the structured data into a second text generation model for natural language description generation processing to obtain a second description text;
[0237] Outputting the first description text and the second description text on the visual interface;
[0238] In response to the operation information fed back by the visualization interface, a description text is determined from the first description text and the second description text.
[0239] In a specific embodiment of the present invention, the text description module is specifically used to input structured data into the text generation model for description generation processing to obtain output text;
[0240] Detect grammatical errors in the output text;
[0241] If the output text has grammatical errors, the structured data is input into the text generation model for description generation processing to obtain a new output text, and the output text is returned for grammatical error detection;
[0242] If there is no grammatical error in the output text, the output text is determined as a description text.
[0243] In a specific implementation of the present invention, the text description module is specifically used to input the output text into a speech error checking model to perform speech error detection and obtain a speech error detection result.
[0244] Corresponding to the above method embodiment, an embodiment of the present invention further provides an electronic device. The electronic device described below and the image processing method described above can refer to each other.
[0245] As shown in FIG3 , the electronic device includes:
[0246] A memory 332, for storing computer programs;
[0247] The processor 322 is used to implement the steps of the image processing method of the above method embodiment when executing a computer program.
[0248] For details, please refer to Figure 4 , Figure 4A schematic diagram of the specific structure of an electronic device provided for this embodiment, which may have relatively large differences due to different configurations or performances, may include one or more processors (central processing units, CPU) (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
[0249] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0250] The steps in the image processing method described above can be implemented by the structure of an electronic device.
[0251] Corresponding to the above method embodiment, an embodiment of the present invention further provides a readable storage medium. The readable storage medium described below and the image processing method described above can refer to each other.
[0252] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image processing method of the above method embodiment are implemented.
[0253] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0254] Corresponding to the above method embodiment, the embodiment of the present invention further provides a computer program product. The computer program product described below and the image processing method described above can be referred to in correspondence with each other.
[0255] A computer program product includes a computer program / instruction. When the computer program / instruction is executed by a processor, the steps of the above-mentioned image processing method are implemented.
[0256] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0257] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0258] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0259] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0260] Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. An image processing method, characterized in that: include: Acquire an image data set; wherein the image data set includes a plurality of original images; Identifying structured information in the original image to obtain structured data; Using the structured data to generate a natural language description to obtain a description text; Determining whether the description text contains hallucination words; If yes, deleting the hallucination words in the description text; If not, then associating the original image with the corresponding description text to obtain an image and text sample corresponding to the original image; Using a number of image and text samples corresponding to the original images, construct an image and text dataset; Wherein, judging whether the description text contains hallucination words includes: Performing word segmentation processing on the description text to obtain component words; Extracting component nouns from the component words; Determining whether the component noun matches the structured data; If yes, determining that the description text does not contain the hallucination word; If not, it is determined that the description text contains the hallucination word.
2. The method according to claim 1, characterized in that: Identifying the structured information in the original image to obtain structured data includes: Inputting the original image into a structured model to perform structured information recognition to obtain the structured data; wherein the structured information includes at least one of an object, a scene, and an emotion; Accordingly, after constructing the image and text data set using the image and text samples corresponding to the original images, the method further includes: The image processing model is trained using the image and text dataset; wherein the image processing model is at least one of object recognition, scene recognition and emotion recognition.
3. The method according to claim 1, characterized in that The structured data is used to generate a natural language description to obtain a description text, including: The structured data is input into a text generation model for description generation processing to obtain the description text.
4. The method according to claim 1, characterized in that: Get image datasets, including: Images acquired from different data sources; The acquired image is cleaned, and the cleaned image is stored in a newly created data set to obtain the image data set.
5. The method according to claim 1, characterized in that Associating the original image with the corresponding description text to obtain a graphic sample corresponding to the original image, including: creating a blank label for the original image; Writing a description text corresponding to the original image into the blank label; An original image with a non-empty label is determined as the image-text sample.
6. The method according to claim 1, characterized in that Determining whether the description text contains hallucination words includes: Performing word segmentation processing on the description text to obtain component words; Extracting component nouns from the component words; Performing recognition detection on the original image to obtain an inspection result; If the inspection result corresponds to the component noun, it is determined that the description text does not contain hallucination words; If the checking result does not correspond to the constituent nouns, it is determined that the description text has hallucination words.
7. The method according to claim 1, characterized in that The structured data is used to generate a natural language description to obtain a description text, including: Inputting the structured data into a first text generation model for natural language description generation processing to obtain a first description text; Inputting the structured data into a second text generation model for natural language description generation processing to obtain a second description text; Outputting the first description text and the second description text on a visual interface; In response to the operation information fed back by the visual interface, the description text is determined from the first description text and the second description text.
8. The method according to claim 1, characterized in that The structured data is used to generate a natural language description to obtain a description text, including: Inputting the structured data into a text generation model for description generation processing to obtain output text; Performing grammatical error detection on the output text; If the output text has grammatical errors, the structured data is input into a text generation model for description generation processing to obtain a new output text, and the output text is returned for grammatical error detection; If the output text does not have any grammatical errors, the output text is determined to be a description text.
9. The method according to claim 8, characterized in that Performing grammatical error detection on the output text includes: The output text is input into a grammatical error checking model to perform grammatical error detection to obtain a grammatical error detection result.
10. An image processing device, characterized in that: include: An image acquisition module, used to acquire an image data set; wherein the image data set includes a plurality of original images; An object recognition module, used to recognize structured information in the original image to obtain structured data; A text description module, used to perform natural language description generation processing using the structured data to obtain a description text; An image-text association module is used to associate the original image with the corresponding description text to obtain an image-text sample corresponding to the original image; A data set generation module, used to construct a data set of images and texts using a number of image and text samples corresponding to the original images; The structured data is used to perform natural language description generation processing, and after obtaining a description text, it is determined whether the description text contains hallucination words; if so, the hallucination words in the description text are deleted; if not, the image-text association module is triggered; wherein, determining whether the description text contains hallucination words includes: performing word segmentation processing on the description text to obtain constituent words; extracting constituent nouns from the constituent words; determining whether the constituent nouns match the structured data; if so, determining that the description text does not contain the hallucination words; if not, determining that the description text contains the hallucination words.
11. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the image processing method according to any one of claims 1 to 9 when executing the computer program.
12. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image processing method according to any one of claims 1 to 9 are implemented.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the image processing method according to any one of claims 1 to 9 are implemented.
