Training data generation method, device, electronic device and storage medium
By obtaining sample requirement information, constructing text templates and generating image description information, the problem of low data collection and fine-tuning efficiency in model training is solved, and efficient training data generation and model iteration are achieved.
Patent Information
- Application Number
- CN202311234710.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-09-22
AI Technical Summary
In model training, existing technology is difficult to effectively connect data collection and model fine-tuning, resulting in low R&D efficiency. Especially when using a small amount of high-quality data for model fine-tuning, the need for rapid iteration is not met.
By obtaining sample requirement information, constructing text templates, expanding attribute information to generate image description information, generating sample images and determining image label information, and then constructing training data sets, natural language processing and computer vision technologies are used to achieve rapid data generation.
It improves the efficiency of training data generation, reduces R&D costs and workload, supports automatic and rapid model iteration, and enables mining of a small amount of high-quality data without human intervention, and is suitable for multiple categories of model training.
Smart Images

Figure CN117726897B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a training data generation method, device, electronic device and storage medium. Background Art
[0002] In the data-centric era, data mining is one of the most important links that cannot be avoided in any model training. Usually, R&D personnel need to collect a large amount of data in advance and then perform complex cleaning. Therefore, data preparation and model training are two relatively separate links in this process. Under the premise of a mature large model, how to use a small amount of high-quality data to fine-tune the model has become a hot research topic, and fine-tuning the model requires rapid iteration. Therefore, how to connect the two processes of collecting a small amount of high-quality data and fine-tuning the model to improve R&D efficiency more efficiently is a problem that needs to be solved at present. Summary of the invention
[0003] The embodiments of the present application provide a training data generation method, device, electronic device and storage medium, which can effectively improve the efficiency of training data generation.
[0004] The present application embodiment provides a method for generating training data, including:
[0005] Acquire sample requirement information, where the sample requirement information includes at least one sample image category;
[0006] Constructing a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category;
[0007] Expanding the attribute information to obtain at least one image description information corresponding to the sample image category;
[0008] Based on the image description information, generating a sample image corresponding to the image description information, and determining image label information corresponding to the sample image;
[0009] A training data set corresponding to the sample demand information is constructed according to the sample images and image label information, so as to perform training using the training data set.
[0010] Optionally, in some embodiments, constructing a text template corresponding to the sample image category includes:
[0011] Determining at least one attribute information of the sample image category;
[0012] Based on the sample image category and the attribute information, a text template corresponding to the sample image category is constructed.
[0013] Optionally, in some embodiments, the expanding the attribute information to obtain at least one image description information corresponding to the sample image category includes:
[0014] Determine the target attribute value corresponding to each type of attribute information;
[0015] The text template is expanded based on the target attribute value to obtain at least one image description information.
[0016] Optionally, in some embodiments, the expanding the text template based on the target attribute value to obtain at least one image description information includes:
[0017] Expanding the text template based on the target attribute value to obtain at least one candidate image description information;
[0018] The candidate image description information is screened to obtain at least one image description information corresponding to the sample image category.
[0019] Optionally, in some embodiments, generating a sample image corresponding to the image description information based on the image description information includes:
[0020] Inputting the image description information into a visual graphic model, and vectorizing the image description information using the visual graphic model to obtain an image description vector;
[0021] Performing spatial mapping on the image description vector to obtain semantic features of the image description information;
[0022] Based on the semantic features, a sample image corresponding to the image description information is generated.
[0023] Optionally, in some embodiments, determining the image label information corresponding to the sample image includes:
[0024] Using an image annotation model to identify the sample image, to obtain a target set of the sample image;
[0025] Based on the target set, image label information corresponding to the sample image is generated.
[0026] Optionally, in some embodiments, constructing a training data set corresponding to the sample demand information according to the sample image and image label information includes:
[0027] Comparing the image description information with the image label information, and determining the target image label information according to the comparison result;
[0028] Based on the target image label information and the sample image corresponding to the target image label information, a training data set corresponding to the sample requirement information is constructed.
[0029] Optionally, in some embodiments, comparing the image description information with the image label information and determining the target image label information according to the comparison result includes:
[0030] Perform similarity calculation on the image description information and image label information corresponding to each sample image to obtain a similarity result for each sample image;
[0031] The sample image whose similarity result is greater than or equal to a preset similarity threshold is determined as a target sample image, and the image label information corresponding to the target sample image is determined as the target image label information.
[0032] The method of constructing a training data set corresponding to the sample requirement information based on the target image label information and the sample image corresponding to the target image label information includes: constructing a training data set corresponding to the sample requirement information based on the target image label information and the target sample image corresponding to the target image label information.
[0033] Accordingly, the embodiment of the present application further provides a training data generating device, including:
[0034] An acquiring unit, configured to acquire sample requirement information, wherein the sample requirement information includes at least one sample image category;
[0035] A construction unit, configured to construct a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category;
[0036] An expansion unit, configured to expand the attribute information to obtain at least one image description information corresponding to the sample image category;
[0037] A generating unit, configured to generate a sample image corresponding to the image description information based on the image description information, and determine image label information corresponding to the sample image;
[0038] The training unit is used to construct a training data set corresponding to the sample demand information according to the sample image and image label information, so as to perform training using the training data set.
[0039] Optionally, in some embodiments, the construction unit may be specifically used to determine at least one attribute information of the sample image category; and construct a text template corresponding to the sample image category based on the sample image category and the attribute information.
[0040] Optionally, in some embodiments, the expansion unit may be specifically used to determine a target attribute value corresponding to each type of attribute information; and expand the text template based on the target attribute value to obtain at least one image description information.
[0041] Optionally, in some embodiments, the expansion unit can be specifically used to expand the text template based on the target attribute value to obtain at least one candidate image description information; and filter the candidate image description information to obtain at least one image description information corresponding to the sample image category.
[0042] Optionally, in some embodiments, the generating unit can be specifically used to input the image description information into a visual graphic model, and use the visual graphic model to vectorize the image description information to obtain an image description vector; perform spatial mapping on the image description vector to obtain semantic features of the image description information; and generate a sample image corresponding to the image description information based on the semantic features.
[0043] Optionally, in some embodiments, the generating unit may be specifically configured to identify the sample image using an image annotation model to obtain a target set of the sample image; and generate image label information corresponding to the sample image based on the target set.
[0044] Optionally, in some embodiments, the training unit can be specifically used to compare the image description information and the image label information, and determine the target image label information according to the comparison result; based on the target image label information and the sample image corresponding to the target image label information, construct a training data set corresponding to the sample requirement information.
[0045] Optionally, in some embodiments, the training unit can be specifically used to perform similarity calculation on the image description information and image label information corresponding to each sample image to obtain a similarity result for each sample image; determine the sample image whose similarity result is greater than or equal to a preset similarity threshold as the target sample image, and determine the image label information corresponding to the target sample image as the target image label information. Based on the target image label information and the target sample image corresponding to the target image label information, a training data set corresponding to the sample requirement information is constructed.
[0046] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any one of the training data generation methods provided in the embodiments of the present application.
[0047] In addition, an embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in any one of the training data generation methods provided in the embodiments of the present application are implemented.
[0048] According to one aspect of the present application, a computer program product or a computer program is provided, which includes computer instructions, which are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in various optional implementations of the above-mentioned training data generation.
[0049] This embodiment can obtain sample demand information, which includes at least one sample image category; then, construct a text template corresponding to the sample image category, which includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, according to the sample image and image label information, construct a training data set corresponding to the sample demand information, so as to use the training data set for training. This solution can effectively improve the efficiency of training data generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0051] Figure 1 It is a scenario diagram of the training data generation method provided in an embodiment of the present application;
[0052] Figure 2 is a first flow chart of the training data generation method provided in an embodiment of the present application;
[0053] Figure 3 is a second flow chart of the training data generating method provided in an embodiment of the present application;
[0054] Figure 4 is a third flow chart of the training data generating method provided in an embodiment of the present application;
[0055] Figure 5is a structural diagram of a training data generating device provided in an embodiment of the present application;
[0056] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0058] The principles of the present application are illustrated by implementation in an appropriate computing environment. In the following description, the specific embodiments of the present application will be described with reference to the steps and symbols executed by one or more computers, unless otherwise stated. Therefore, these steps and operations will be mentioned several times as being executed by a computer, and the computer execution referred to herein includes the operation of a computer processing unit by an electronic signal representing data in a structured form. This operation converts the data or maintains it at a location in the memory system of the computer, which can be reconfigured or otherwise change the operation of the computer in a manner familiar to testers in the field. The data structure maintained by the data is the physical location of the memory, which has specific characteristics defined by the data format. However, the principles of the present application are described in the above text, which does not represent a limitation, and testers in the field will understand that the following various steps and operations can also be implemented in hardware.
[0059] The term "unit" used in this article can be regarded as a software object executed on the computing system. The different components, units, engines and services described in this article can be regarded as implementation objects on the computing system. The devices and methods described in this article can be implemented in software, and of course can also be implemented in hardware, all within the scope of protection of this application.
[0060] The terms "first", "second", and "third" in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but some embodiments also include steps or units that are not listed, or some embodiments also include other steps or units inherent to these processes, methods, products, or devices.
[0061] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0062] The embodiments of the present application provide a training data generation method, device, electronic device and storage medium. The training data generation device can be integrated in an electronic device, which can be a server, a terminal or other device.
[0063] The training data generation method provided in the embodiment of the present application mainly utilizes natural language processing technology and computer vision technology in the field of artificial intelligence to generate training sample images, thereby realizing the rapid collection of training data.
[0064] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. Among them, artificial intelligence software technology mainly includes computer vision technology, machine learning / deep learning and other directions.
[0065] Among them, natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies. Among them, the key technologies of speech technology (Speech Technology) include automatic training data generation technology (ASR), speech synthesis technology (TTS) and voiceprint recognition technology. Enabling computers to listen, see, speak and feel is the development direction of human-computer interaction in the future, among which speech has become one of the most promising human-computer interaction methods in the future.
[0066] Among them, computer vision technology (Computer Vision, CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision such as using cameras and computers to replace human eyes to identify, track and measure targets, and further perform graphic processing to make computer processing into images that are more suitable for human eye observation or transmission to instrument detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Computer vision technology usually includes image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and map construction, and other technologies, as well as common biometric recognition technologies such as face recognition and fingerprint recognition.
[0067] For example, Figure 1As shown, first, the electronic device integrated with the training data generation device can obtain sample demand information, and the sample demand information includes at least one sample image category; then, construct a text template corresponding to the sample image category, and the text template includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, according to the sample image and image label information, construct a training data set corresponding to the sample demand information, so as to use the training data set for training. Because the scheme obtains the coarse-grained sample demand information of the training model for the sample data, and constructs a text template, and then expands the text template into a more refined variety of rich texts, and then generates high-quality sample images according to the more refined image description information. Finally, each generated sample image is re-labeled, and the obtained sample image and image label information can be directly given to the downstream model for fast fine-tuning training, which greatly improves the efficiency of generating training data, thereby improving the training efficiency of the model, and greatly reducing the cost and workload of research and development. And after the introduction of automated data mining, it is no longer limited to customized training of a single category, but can quickly support training of multiple categories of models, realizing the mining of small amounts of high-quality data without human intervention, thereby supporting automatic and rapid model iteration.
[0068] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0069] This embodiment will be described from the perspective of a training data generating device, which can be specifically integrated into an electronic device, which can be a server or a terminal. The terminal can include a mobile phone, a tablet computer, a laptop computer, and a personal computer (PC).
[0070] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0071] A training data generation method comprises: obtaining sample requirement information, the sample requirement information comprising at least one sample image category; then, constructing a text template corresponding to the sample image category, the text template comprising at least one attribute information of the sample image category; then, expanding the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generating a sample image corresponding to the image description information, and determining image label information corresponding to the sample image; then, constructing a training data set corresponding to the sample requirement information based on the sample image and the image label information, so as to use the training data set for training.
[0072] like Figure 2 As shown, the specific process of the training data generation method can be as follows:
[0073] 101. Obtain sample requirement information, where the sample requirement information includes at least one sample image category.
[0074] The sample requirement information may refer to information related to samples required for training data. For example, it may refer to information related to samples required for model training. The samples required for training data may be images, texts, or audios, etc. For example, when the samples required for training data are images, the sample requirement information includes at least one sample image category.
[0075] Optionally, sample image categories may include natural scenery, animals, people, buildings, etc., and may also be 3D style, Pixar style, hand-painted style, oil painting style, watercolor style, sketch style, cartoon style, retro style, etc., which can be determined according to the actual needs of the training data and are not limited here.
[0076] For example, when a training data generation request is received, sample requirement information of the training data can be obtained according to the training data generation request. For example, when training data generation is required, a training data generation request can be generated and sent to a training data generation device, so that the training data generation device obtains the sample requirement information, and constructs a text template using the obtained sample requirement information, generates a large amount of image description information according to the text template, and then generates a sample image using the image description information, etc.
[0077] 102. Construct a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category.
[0078] After obtaining the sample image category in the sample requirement information, a text template corresponding to the sample image category can be constructed. For example, at least one attribute information of the sample image category can be specifically determined; based on the sample image category and the attribute information, a text template corresponding to the sample image category is constructed.
[0079] The attribute information may refer to various features and attributes describing the image, such as gender, age, hair color, expression, clothing, posture and action, eye state, hairstyle, etc.
[0080] For example, the constructed text template may be [sample image category], [attribute 1], [attribute 2], [attribute 3], [attribute 4], and [attribute 5].
[0081] 103. Expand the attribute information to obtain at least one image description information corresponding to the sample image category.
[0082] There are many ways to expand the attribute information, for example, the attribute information can be expanded using a large language model, such as ChatGPT, Wenxinyiyan, etc. For example, a target attribute value corresponding to each attribute information can be specifically determined; the text template is expanded based on the target attribute value to obtain at least one image description information.
[0083] Among them, the target attribute value may refer to the attribute value corresponding to each attribute information. For example, the target attribute value of gender may include male, female, etc., the target attribute value of age may include 0-10, 11-20, 21-30, etc., the target attribute value of hair color may include black, white, brown, etc., the target attribute value of mood may include anger, happiness, sadness, surprise, etc., the target attribute value of posture and action may include standing, sitting, jumping, running, etc., the target attribute value of eye state may include open, closed, blinking, etc., the target attribute value of hairstyle may include straight hair, curly hair, etc., the target attribute value of skin color may include white, black, yellow, brown, etc., the target attribute value of glasses may include glasses, no glasses, sunglasses, etc. The target attribute value of makeup may include heavy makeup, natural makeup, etc. The target attribute value of background environment may include indoor, outdoor, urban landscape, natural scenery, etc. The target attribute value of scene and object may include beach, mountain, building, etc. The target attribute value of lighting condition may include bright, dark, side light, backlight, etc. They are not listed here one by one.
[0084] Optionally, after the text template is expanded using the target attribute value, the expanded information can be screened to determine the image description information required for the training data, further improving the quality and efficiency of generating the training data. For example, the text template can be expanded based on the target attribute value to obtain at least one candidate image description information; the candidate image description information can be screened to obtain at least one image description information corresponding to the sample image category.
[0085] For example, when image description information such as "male", "white hair", "angry", and "curly hair" is not needed, the image description information containing these target attribute values can be eliminated. It is also possible to eliminate unwanted target attribute values when determining the target attribute values, and so on.
[0086] 104. Based on the image description information, generate a sample image corresponding to the image description information, and determine image label information corresponding to the sample image.
[0087] There are many ways to generate sample images using image description information. For example, sample images can be generated based on the image description information using a trained visual graph-text model, or sample images can be generated through a visual question-answering model, and so on.
[0088] For example, the image description information can be specifically input into a visual graphic model, and the image description information can be vectorized using the visual graphic model to obtain an image description vector; the image description vector can be spatially mapped to obtain semantic features of the image description information; and based on the semantic features, a sample image corresponding to the image description information can be generated.
[0089] In order to improve the efficiency of training data generation, the preset visual image model can be trained first, and then the trained visual image model can be used to generate sample images. Optionally, the visual image model can be trained by multiple training samples. Specifically, it can be trained by other devices and then provided to the training data generation device, or the training data generation device can also perform training by itself. The training method is not limited here.
[0090] Since the generated sample images are uncontrollable, the generated sample images may not completely meet the content of the image description information. Therefore, an image annotation model can be introduced to identify the elements in the image and further determine the image label information corresponding to the generated sample images. For example, the image annotation model can be used to identify the sample images to obtain the target set of the sample images; based on the target set, the image label information corresponding to the sample images is generated.
[0091] 105. Construct a training data set corresponding to the sample demand information according to the sample image and the image label information, so as to perform training using the training data set.
[0092] In order to obtain better quality training data, the generated sample images can be screened, and the quality of the generated images can be determined by the similarity between the image description information and the image label information. For example, sample images with higher similarity are closer to the sample requirements.
[0093] For example, the image description information and the image label information may be specifically compared, and the target image label information may be determined according to the comparison result; based on the target image label information and the sample image corresponding to the target image label information, a training data set corresponding to the sample requirement information may be constructed.
[0094] Optionally, the step of "comparing the image description information with the image label information and determining the target image label information based on the comparison result" may specifically perform a similarity calculation on the image description information and the image label information corresponding to each sample image to obtain a similarity result for each sample image; determine the sample image whose similarity result is greater than or equal to a preset similarity threshold as the target sample image, and determine the image label information corresponding to the target sample image as the target image label information.
[0095] Then, the step of "constructing a training data set corresponding to the sample demand information based on the target image label information and the sample image corresponding to the target image label information" can specifically construct a training data set corresponding to the sample demand information based on the target image label information and the target sample image corresponding to the target image label information.
[0096] After obtaining a complete training data set, such as graphic data constructed based on sample images and image label information, the training data set can be directly given to the downstream model for training and fine-tuning.
[0097] As can be seen from the above, this embodiment can obtain sample demand information, which includes at least one sample image category; then, construct a text template corresponding to the sample image category, and the text template includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, according to the sample image and image label information, construct a training data set corresponding to the sample demand information, so as to use the training data set for training. Because the scheme obtains the coarse-grained sample demand information of the training model for the sample data, and constructs a text template, and then expands the text template into a more refined variety of rich texts, and then generates high-quality sample images according to the more refined image description information. Finally, each generated sample image is re-labeled, and the obtained sample image and image label information can be directly given to the downstream model for fast fine-tuning training, which greatly improves the efficiency of generating training data, thereby improving the training efficiency of the model, and greatly reducing the cost and workload of research and development. And after the introduction of automated data mining, it is no longer limited to customized training of a single category, but can quickly support training of multiple categories of models, realizing the mining of small amounts of high-quality data without human intervention, thereby supporting automatic and rapid model iteration.
[0098] According to the method described in the previous embodiment, an example is given below to further illustrate it in detail.
[0099] In this embodiment, the training data generating device is specifically integrated into an electronic device for explanation.
[0100] (I) First, the preset visual image model can be trained as follows:
[0101] In order to improve the efficiency of training data generation, the preset visual image model is first trained, and then the trained visual image model is used to generate sample images. Optionally, the training data generation model can be trained by multiple training samples. Specifically, it can be trained by other devices and provided to the electronic device, or it can be trained by the electronic device itself. For example, the visual image model can be Midjourney, etc.
[0102] (II) Using the trained sample image generation model, the target training data can be generated. For details, see Figure 3 and Figure 4 .
[0103] like Figure 3 As shown, a training data generation method, the specific process can be as follows:
[0104] 201. An electronic device obtains sample requirement information, where the sample requirement information includes at least one sample image category.
[0105] The sample requirement information may refer to information related to samples required for training data. For example, it may refer to information related to samples required for model training. The samples required for training data may specifically be images, and the sample requirement information includes at least one sample image category.
[0106] Optionally, the sample image categories may include natural scenery, animals, people, buildings, etc., and may also be 3D style, Pixar style, hand-painted style, oil painting style, watercolor style, sketch style, cartoon style, retro style, etc. For example, the general requirements of the data may be specified, such as the sample image categories may specifically be 3D style and Pixar style, and users may define iconic concepts according to training requirements.
[0107] For example, when receiving a training data generation request, the electronic device can obtain sample demand information of the training data according to the training data generation request. For example, when training data generation is required, a training data generation request can be generated and sent to the electronic device so that the electronic device can obtain the sample demand information.
[0108] 202. The electronic device constructs a text template corresponding to the sample image category, where the text template includes at least one type of attribute information of the sample image category.
[0109] In order to enable the visual graphic model to better generate high-quality images, it is usually necessary to input according to a certain template. After obtaining the sample image category in the sample demand information, a text template corresponding to the sample image category can be constructed.
[0110] For example, the electronic device may specifically determine at least one attribute information of the sample image category; and construct a text template corresponding to the sample image category based on the sample image category and the attribute information.
[0111] The attribute information may refer to various features and attributes describing the image, such as gender, age, hair color, expression, clothing, posture and action, eye state, hairstyle, etc.
[0112] For example, the constructed text template may be “[user-defined concept], [gender], [hair color], [age], [expression], [mood], [clothing], [common vocabulary]”. [User-defined concept] is the user’s required vocabulary in step 201, and [common vocabulary] may be restrictive vocabulary related to the quality of the image itself, such as “4K”, “high quality”, and “blurred background”. The other parts are variable positions reserved to increase the richness of the image.
[0113] 203. The electronic device expands the attribute information to obtain at least one image description information corresponding to the sample image category.
[0114] For example, a language model such as ChatGPT can be used to automatically expand and fill a text template, thereby obtaining multiple real texts under the text template, i.e., batch copywriting. For example, the electronic device can specifically determine the target attribute value corresponding to each attribute information; based on the target attribute value, the text template is expanded to obtain at least one image description information.
[0115] The target attribute value may refer to the attribute value corresponding to each attribute information. For example, the target attribute value of gender may include male, female, etc., the target attribute value of hair color may include black, white, brown, etc., the target attribute value of age may include 0-10, 11-20, 21-30, etc., and the target attribute value of mood may include anger, happiness, sadness, surprise, etc.
[0116] Optionally, after the text template is expanded using the target attribute value, the expanded information can be screened to determine the image description information required for the training data, further improving the quality and efficiency of generating the training data. For example, the electronic device can specifically expand the text template based on the target attribute value to obtain at least one candidate image description information; and screen the candidate image description information to obtain at least one image description information corresponding to the sample image category.
[0117] For example, when image description information such as "male", "white hair", "angry", and "curly hair" is not needed, the image description information containing these target attribute values can be eliminated. It is also possible to eliminate unwanted target attribute values when determining the target attribute values, and so on.
[0118] 204. The electronic device generates a sample image corresponding to the image description information based on the image description information.
[0119] For example, the obtained real text can be passed into the visual graphic model in sequence to obtain the corresponding high-quality image data.
[0120] For example, the electronic device can specifically input the image description information into a visual graphic model, and use the visual graphic model to vectorize the image description information to obtain an image description vector; perform spatial mapping on the image description vector to obtain semantic features of the image description information; and generate a sample image corresponding to the image description information based on the semantic features.
[0121] 205. The electronic device determines image label information corresponding to the sample image.
[0122] Since a fixed template is used to generate data in step 202, although the language model is used for filling, considering the uncontrollability of visual image and text model generation, the generated image may not completely meet the content of the template text. Therefore, an image label model or image and text tagging model can be additionally introduced, such as WaifuDiffusion v1.4 Tags, to identify elements in the image. For example, a text label of the type "a girl, black hair, smiling, standing, white short-sleeved, blue backpack" can be obtained, that is, image label information.
[0123] For example, the electronic device may specifically use an image annotation model to identify the sample image to obtain a target set of the sample image; and based on the target set, generate image label information corresponding to the sample image.
[0124] 206. The electronic device constructs a training data set corresponding to the sample demand information according to the sample image and the image label information.
[0125] In order to obtain better quality training data, the generated sample images can be screened, and the quality of the generated images can be determined by the similarity between the image description information and the image label information. For example, sample images with higher similarity are closer to the sample requirements.
[0126] For example, the electronic device can specifically compare the image description information with the image label information, determine the target image label information according to the comparison result, and construct a training data set corresponding to the sample requirement information based on the target image label information and the sample image corresponding to the target image label information.
[0127] Optionally, the electronic device can specifically perform similarity calculations on the image description information and image label information corresponding to each sample image to obtain a similarity result for each sample image; determine the sample image whose similarity result is greater than or equal to a preset similarity threshold as a target sample image, and determine the image label information corresponding to the target sample image as the target image label information; and construct a training data set corresponding to the sample requirement information based on the target image label information and the target sample image corresponding to the target image label information.
[0128] 207. The electronic device performs training using the training data set.
[0129] For example, after obtaining a complete training data set, such as graphic data constructed based on sample images and image label information, that is, high-quality graphic data, the high-quality graphic data can be directly given to the downstream model for training and fine-tuning to learn the style required by the user.
[0130] By organically combining the large language model with the visual graphic model, the real problems in model training are effectively solved. Compared with manual labeling and cleaning, this solution can complete model fine-tuning training more efficiently and at a lower cost, thereby supporting rapid iteration and launch. The entire data collection process can be completed within 30-60 minutes. And after the introduction of automated data mining, it is not limited to customized training of a single style, but can quickly support the training of models in multiple styles.
[0131] This solution can use the existing language model and closed-source visual text model (such as Midjourney) to expand the language model into more detailed and rich text according to the user's coarse-grained data needs, and then use the visual text model to generate the corresponding high-quality scene data. Finally, the image annotation model is used to re-label each generated image, and the obtained text data can be directly given to the downstream model for fast fine-tuning training.
[0132] As can be seen from the above, this embodiment can obtain sample demand information, which includes at least one sample image category; then, construct a text template corresponding to the sample image category, and the text template includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, according to the sample image and image label information, construct a training data set corresponding to the sample demand information, so as to use the training data set for training. Because the scheme uses a large language model and a visual graphic model, according to the user's coarse-grained demand for data, the large language model is expanded into a variety of more refined rich texts, and then the corresponding high-quality scene data is generated using the visual graphic model. Finally, the image annotation model is used to re-label each generated image, and the obtained graphic data can be directly given to the downstream model for rapid fine-tuning training, realizing a small amount of high-quality data mining without human intervention, thereby supporting automatic and rapid model iteration. By building a complete automated data mining link, the R&D efficiency can be better improved.
[0133] In order to better implement the above method, accordingly, the embodiment of the present application also provides a training data generating device, which can be integrated in an electronic device, and the electronic device can be a server, a terminal or other equipment.
[0134] For example, Figure 5 As shown, the training data generating device may include an acquiring unit 301, a constructing unit 302, an expanding unit 303, a generating unit 304 and a training unit 305, as follows:
[0135] An acquisition unit 301 is used to acquire sample requirement information, where the sample requirement information includes at least one sample image category;
[0136] A construction unit 302, configured to construct a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category;
[0137] An expansion unit 303, configured to expand the attribute information to obtain at least one image description information corresponding to the sample image category;
[0138] A generating unit 304 is configured to generate a sample image corresponding to the image description information based on the image description information, and determine image label information corresponding to the sample image;
[0139] The training unit 305 is used to construct a training data set corresponding to the sample demand information according to the sample images and image label information, so as to perform training using the training data set.
[0140] Optionally, in some embodiments, the construction unit 302 may be specifically used to determine at least one attribute information of the sample image category; and construct a text template corresponding to the sample image category based on the sample image category and the attribute information.
[0141] Optionally, in some embodiments, the expansion unit 303 may be specifically used to determine a target attribute value corresponding to each type of attribute information; and expand the text template based on the target attribute value to obtain at least one image description information.
[0142] Optionally, in some embodiments, the expansion unit 303 can be specifically used to expand the text template based on the target attribute value to obtain at least one candidate image description information; and filter the candidate image description information to obtain at least one image description information corresponding to the sample image category.
[0143] Optionally, in some embodiments, the generation unit 304 can be specifically used to input the image description information into a visual graphic model, and use the visual graphic model to vectorize the image description information to obtain an image description vector; perform spatial mapping on the image description vector to obtain semantic features of the image description information; and generate a sample image corresponding to the image description information based on the semantic features.
[0144] Optionally, in some embodiments, the generating unit 304 may be specifically configured to identify the sample image using an image annotation model to obtain a target set of the sample image; and generate image label information corresponding to the sample image based on the target set.
[0145] Optionally, in some embodiments, the training unit 305 can be specifically used to compare the image description information and the image label information, and determine the target image label information according to the comparison result; based on the target image label information and the sample image corresponding to the target image label information, construct a training data set corresponding to the sample requirement information.
[0146] Optionally, in some embodiments, the training unit 305 can be specifically used to perform similarity calculation on the image description information and image label information corresponding to each sample image to obtain a similarity result for each sample image; determine the sample image whose similarity result is greater than or equal to a preset similarity threshold as the target sample image, and determine the image label information corresponding to the target sample image as the target image label information. Based on the target image label information and the target sample image corresponding to the target image label information, a training data set corresponding to the sample requirement information is constructed.
[0147] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0148] As can be seen from the above, in this embodiment, the acquisition unit 301 can acquire sample demand information, and the sample demand information includes at least one sample image category; then, the construction unit 302 constructs a text template corresponding to the sample image category, and the text template includes at least one attribute information of the sample image category; then, the expansion unit 303 expands the attribute information to obtain at least one image description information corresponding to the sample image category; then, the generation unit 304 generates a sample image corresponding to the image description information based on the image description information, and determines the image label information corresponding to the sample image; then, the training unit 305 constructs a training data set corresponding to the sample demand information according to the sample image and image label information, so as to use the training data set for training. Because the scheme obtains the coarse-grained sample demand information of the training model for the sample data, and constructs a text template, and then expands the text template into more refined various rich texts, and then generates high-quality sample images according to the more refined image description information. Finally, each generated sample image is relabeled, and the obtained sample images and image label information can be directly given to the downstream model for rapid fine-tuning training, which greatly improves the efficiency of training data generation, thereby improving the efficiency of model training and greatly reducing the cost and workload of research and development. And after the introduction of automated data mining, it is not limited to customized training of a single category, but can quickly support the training of multiple categories of models, realizing the mining of a small amount of high-quality data without human intervention, thereby supporting automatic and rapid model iteration.
[0149] In addition, the present application also provides an electronic device, such as Figure 6 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:
[0150] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0151] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0152] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0153] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0154] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0155] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:
[0156] Acquire sample requirement information, wherein the sample requirement information includes at least one sample image category; then, construct a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, construct a training data set corresponding to the sample requirement information based on the sample image and the image label information, so as to use the training data set for training.
[0157] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0158] As can be seen from the above, this embodiment can obtain sample demand information, which includes at least one sample image category; then, construct a text template corresponding to the sample image category, and the text template includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, according to the sample image and image label information, construct a training data set corresponding to the sample demand information, so as to use the training data set for training. Because the scheme obtains the coarse-grained sample demand information of the training model for the sample data, and constructs a text template, and then expands the text template into a more refined variety of rich texts, and then generates high-quality sample images according to the more refined image description information. Finally, each generated sample image is re-labeled, and the obtained sample image and image label information can be directly given to the downstream model for fast fine-tuning training, which greatly improves the efficiency of generating training data, thereby improving the training efficiency of the model, and greatly reducing the cost and workload of research and development. And after the introduction of automated data mining, it is no longer limited to customized training of a single category, but can quickly support training of multiple categories of models, realizing the mining of small amounts of high-quality data without human intervention, thereby supporting automatic and rapid model iteration.
[0159] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0160] To this end, the embodiment of the present application further provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any training data generation method provided in the embodiment of the present application. For example, the instructions can execute the following steps:
[0161] Acquire sample requirement information, wherein the sample requirement information includes at least one sample image category; then, construct a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category; then, expand the attribute information to obtain at least one image description information corresponding to the sample image category; then, based on the image description information, generate a sample image corresponding to the image description information, and determine the image label information corresponding to the sample image; then, construct a training data set corresponding to the sample requirement information based on the sample image and the image label information, so as to use the training data set for training.
[0162] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0163] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0164] Since the instructions stored in the storage medium can execute the steps in any one of the training data generation methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the training data generation methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0165] The above is a detailed introduction to a training data generation method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for generating training data, characterized in that: include: Acquire sample requirement information, where the sample requirement information includes at least one sample image category; Constructing a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category; Expanding the attribute information to obtain at least one image description information corresponding to the sample image category; Based on the image description information, generating a sample image corresponding to the image description information, and determining image label information corresponding to the sample image; Comparing the image description information with the image label information, and determining the target image label information according to the comparison result; Based on the target image label information and the sample image corresponding to the target image label information, a training data set corresponding to the sample demand information is constructed so as to perform training using the training data set.
2. The method according to claim 1, characterized in that The step of constructing a text template corresponding to the sample image category includes: Determining at least one attribute information of the sample image category; Based on the sample image category and the attribute information, a text template corresponding to the sample image category is constructed.
3. The method according to claim 1, characterized in that The expanding the attribute information to obtain at least one image description information corresponding to the sample image category includes: Determine the target attribute value corresponding to each type of attribute information; The text template is expanded based on the target attribute value to obtain at least one image description information.
4. The method according to claim 3, characterized in that: The step of expanding the text template based on the target attribute value to obtain at least one image description information includes: Expanding the text template based on the target attribute value to obtain at least one candidate image description information; The candidate image description information is screened to obtain at least one image description information corresponding to the sample image category.
5. The method according to claim 1, characterized in that The step of generating a sample image corresponding to the image description information based on the image description information includes: Inputting the image description information into a visual graphic model, and vectorizing the image description information using the visual graphic model to obtain an image description vector; Performing spatial mapping on the image description vector to obtain semantic features of the image description information; Based on the semantic features, a sample image corresponding to the image description information is generated.
6. The method according to any one of claims 1 to 5, characterized in that: The determining the image label information corresponding to the sample image includes: Using an image annotation model to identify the sample image, to obtain a target set of the sample image; Based on the target set, image label information corresponding to the sample image is generated.
7. The method according to claim 1, characterized in that The comparing the image description information with the image label information and determining the target image label information according to the comparison result includes: Perform similarity calculation on the image description information and image label information corresponding to each sample image to obtain a similarity result for each sample image; Determine the sample image whose similarity result is greater than or equal to a preset similarity threshold as a target sample image, and determine the image label information corresponding to the target sample image as the target image label information; The method of constructing a training data set corresponding to the sample requirement information based on the target image label information and the sample image corresponding to the target image label information includes: constructing a training data set corresponding to the sample requirement information based on the target image label information and the target sample image corresponding to the target image label information.
8. A training data generating device, characterized in that: include: An acquiring unit, configured to acquire sample requirement information, wherein the sample requirement information includes at least one sample image category; A construction unit, configured to construct a text template corresponding to the sample image category, wherein the text template includes at least one attribute information of the sample image category; An expansion unit, configured to expand the attribute information to obtain at least one image description information corresponding to the sample image category; A generating unit, configured to generate a sample image corresponding to the image description information based on the image description information, and determine an image label corresponding to the sample image; A training unit, used for comparing the image description information with the image label information, and determining target image label information according to the comparison result; Based on the target image label information and the sample image corresponding to the target image label information, a training data set corresponding to the sample demand information is constructed so as to perform training using the training data set.
9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the training data generating method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the training data generating method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data processing method and device
CN109492684A
Cross-modal processing method and device, electronic equipment and computer storage medium
CN111461203A
Model training method, image description generation method and device, equipment and medium
CN114723996A
Image generation method and device based on interaction, electronic equipment and storage medium
CN116306588A
Method and device for generating modified text set and image intensifier, and electronic equipment
CN116402049A
