WO2025201056A1 - 数据处理方法、系统、设备和存储介质 - Google Patents

数据处理方法、系统、设备和存储介质

Info

Publication number
WO2025201056A1
WO2025201056A1 PCT/CN2025/082071 CN2025082071W WO2025201056A1 WO 2025201056 A1 WO2025201056 A1 WO 2025201056A1 CN 2025082071 W CN2025082071 W CN 2025082071W WO 2025201056 A1 WO2025201056 A1 WO 2025201056A1
Authority
WO
WIPO (PCT)
Prior art keywords
sample
image
sample image
data set
model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
PCT/CN2025/082071
Other languages
English (en)
French (fr)
Inventor
张嘉诚
吴捷
肖学锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Publication of WO2025201056A1 publication Critical patent/WO2025201056A1/zh
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/00Two-dimensional [2D] image generation
    • G06T11/60Creating or editing images; Combining images with text
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/30Semantic analysis
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0475Generative networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/094Adversarial learning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N5/00Computing arrangements using knowledge-based models
    • G06N5/04Inference or reasoning models
    • G06N5/041Abduction

Definitions

  • the present disclosure relates to the field of computer technology, and in particular to a data processing method, system, device, and storage medium.
  • the text-based graph model uses prompt words as a guide to generate images that match the prompt words. Both initial training and fine-tuning of the text-based graph model require a large number of prompt words as training samples. The accuracy and rationality of the training samples significantly impact the accuracy of the text-based graph model.
  • embodiments of the present disclosure provide a data processing method, a data processing system, an electronic device, and a computer-readable storage medium.
  • the present disclosure provides a data processing method, the method comprising:
  • FIG4 shows a schematic diagram of the process of the first stage training provided by an embodiment of the present application
  • FIG5 shows a schematic diagram of module interaction of the first phase training in FIG4 ;
  • FIG6 shows a schematic diagram of module interaction in the first phase of training provided by another embodiment of the present application.
  • FIG7 shows a schematic diagram of the process of the second stage training provided by an embodiment of the present application.
  • FIG9 shows a schematic diagram of module interaction in the second phase of training provided by another embodiment of the present application.
  • FIG10 shows a module diagram of a data processing system provided by an embodiment of the present application.
  • FIG11 shows a schematic diagram of an electronic device provided by an embodiment of the present application.
  • the context-sensitive graph model can be a diffusion model. Prompts are used to guide the context-sensitive graph model in generating the desired image. For example, if the context-sensitive graph model is required to generate an image of three children sitting on a couch, the prompt might be "Three children on a couch, full shot.” Another example is if the context-sensitive graph model is required to generate a night scene of the moon and a park, the prompt might be "The moon is very bright in the night sky, casting a gentle light over the abandoned amusement park.”
  • the Wensheng graph model generates images by using a prompt word as a guide and performing denoising on an initial image Xt containing random noise at multiple time steps to produce an image that matches the prompt word.
  • Xt -1 represents the image obtained after the first denoising step on the initial image Xt
  • Xt -2 represents the image obtained after the second denoising step on Xt -1 .
  • the image X0 obtained after multiple denoising steps can then be used as the image that matches the prompt word.
  • the denoising methods used to denoise the initial image Xt at multiple time steps can vary, allowing the text graph model to generate different images for different prompt words.
  • the training process for the text graph model involves providing a large number of prompt words as training samples, allowing the text graph model to learn denoising methods that match the prompt words.
  • the text graph model Once the text graph model is trained, it can use the input prompt words and the learned denoising knowledge to denoise the initial image Xt using the denoising method that matches the prompt words, thereby generating an image that matches the prompt words.
  • the present application provides a data processing method that can solve the above problems and improve the accuracy of the model.
  • the data processing method can be applied to electronic devices.
  • Electronic devices include but are not limited to tablet computers, laptop computers, desktop computers, servers, etc.
  • FIG 2 a flow chart of a data processing method provided in one embodiment of the present application is shown.
  • the data processing method includes:
  • Step S21 Acquire multiple sample prompt words for model training.
  • the sample prompt words obtained in step S21 may be selected from prompt words input by online users.
  • Online users may be users who use the text graph model to generate images on the Internet.
  • the sample prompt words obtained here may have problems such as insufficient complexity, narrow distribution range, and high redundancy.
  • the sample prompt words may be obtained based on other channels, such as obtaining multiple sample prompt words from a public prompt word dataset. This application does not limit the method of obtaining the sample prompt words in step S21.
  • Step S22 parsing the correspondence between entities and entity attributes in the sample prompt words, and extracting the sample prompt words whose correspondence reaches the complexity index to obtain a first data set.
  • entities can be objects that form the basic structure of a sample prompt word.
  • the initiator of an action, the recipient of an action, and the modified object can all serve as entities.
  • Entity attributes are used to characterize the characteristics of an entity.
  • the action initiated by the initiator can serve as an entity attribute of the initiator; the action received by the recipient can serve as an entity attribute of the recipient; and the words used to modify the initiator can serve as an entity attribute of the initiator.
  • the correspondence between entities and entity attributes can be represented by a parse tree.
  • the entity attribute that has a connection relationship with an entity is the entity attribute corresponding to the entity.
  • the entity attribute corresponding to the entity For example, in Figure 3, with the entity "bird” as the center, there are 3 entity attributes connected to the entity “bird”, indicating that there are 3 entity attributes and the entity “bird” have a corresponding relationship; with the entity “cat” as the center, there are 2 entity attributes connected to the entity "cat”, indicating that there are 2 entity attributes and the entity "cat” have a corresponding relationship.
  • Complexity metrics can be used to define the complexity requirements for the correspondences between entities and entity attributes in sample prompt words. For example, these metrics include the total number of correspondences, the number of correspondences between a single entity and entity attributes, and the part of speech of the entity attributes connected to the entity (e.g., verb, noun, adjective, etc.). Complexity metrics can be specified based on actual needs.
  • the sample prompt word is extracted into the first data set:
  • the number of correspondences between entities and entity attributes reaches the minimum number of correspondences.
  • the minimum number of correspondences is 3.
  • the number of correspondences between the entity “cat” and the entity attribute is 2, and the number of correspondences between the entity "bird” and the entity attribute is 3. Since the number of correspondences between the entity "bird” and the entity attribute reaches the minimum number of correspondences, the sample prompt "A black cat is chasing a small brown bird" can be extracted into the first dataset.
  • the sample prompt "A black cat is chasing a small brown bird” does not have the minimum number of correspondences between entities and entity attributes, so the sample prompt "A black cat is chasing a small brown bird" cannot be extracted into the first data set.
  • Step S23 extracting sample prompt words that meet the difference index from the first data set to obtain a second data set.
  • the difference index can be used to indicate the required difference between any two sample prompt words in the second data set. For example, the difference between any two sample prompt words in the second data set needs to reach 80%.
  • the difference index can be represented by the similarity between the sample prompt words. For example, requiring the difference between the sample prompt words to reach 80% means that the similarity between the sample prompt words needs to be less than 20%.
  • the difference index can include a first similarity threshold (such as 20%) that the similarity between the sample prompt words needs to be lower than. Based on the first similarity threshold, the sample prompt words that meet the difference index are extracted from the first data set, which may include:
  • the first data set after deleting the sample prompt words is used as the second data set.
  • the data in the second dataset can have a wider distribution and lower redundancy in the sample prompt words.
  • first data set searching for multiple groups of first sample prompt words and second sample prompt words whose feature vector distances are within a preset distance range, and calculating the second similarity of each group of first sample prompt words and second sample prompt words respectively;
  • the first data set is used as the second data set.
  • Step S24 Perform model training based on the second data set.
  • the sample prompt words are screened according to a complexity index to eliminate sample prompt words with low semantic complexity. Furthermore, the sample prompt words are screened according to a difference index to reduce the redundancy of the sample prompt words and expand the data distribution range of the sample prompt words. Training the model based on the sample prompt words screened by complexity and difference can achieve better training results, thereby improving the accuracy of the trained model.
  • fine-tuning training can also be performed on the text graph model.
  • Fine-tuning training can include first-stage training and second-stage training.
  • Figure 4 is a flow chart of the first-stage training provided by one embodiment of the present application.
  • Figure 5 is a schematic diagram of the module interaction of the first-stage training in Figure 4.
  • the first-stage training includes the following steps:
  • Step S41 obtaining a first sample image and performing noise reduction processing on the first sample image to obtain a second sample image.
  • the first sample image may be a standard image that needs to be generated by a Wensheng graph model. After obtaining the first sample image, random noise may be added to the first sample image to obtain a second sample image.
  • Step S42 inputting the second sample image into the Wensheng graph model to convert the second sample image into a third sample image through the Wensheng graph model.
  • the third sample image is an image obtained by denoising the second sample image based on the denoising knowledge learned by the Wensheng graph model during the initial training process.
  • the third sample image should be consistent with the first sample image, or the difference between the third sample image and the first sample image should be within an acceptable threshold.
  • the difference between the third sample image and the first sample image can be used to evaluate the accuracy of the Vincent graph model. Simply put, the smaller the difference between the third sample image and the first sample image, the higher the accuracy of the Vincent graph model; and the larger the difference between the third sample image and the first sample image, the lower the accuracy of the Vincent graph model.
  • Step S43 comparing the first sample image and the third sample image to obtain quality difference values between the first sample image and the third sample image in various quality dimensions representing image quality.
  • the quality dimension is used to determine the image quality of the third sample image.
  • the image quality of the third sample image represents the degree of similarity between the third sample image and the first sample image. A higher degree of similarity between the third sample image and the first sample image indicates better image quality, while a lower degree of similarity between the third sample image and the first sample image indicates worse image quality.
  • the third sample image and the first sample image can be compared along multiple dimensions.
  • the multiple dimensions used herein can be referred to as quality dimensions.
  • the difference between the third sample image and the first sample image in each quality dimension can be represented by a quality difference value. Specifically, if the difference between the third sample image and the first sample image in a quality dimension is large, then the quality difference value between the third sample image and the first sample image in that quality dimension can be large. Conversely, if the difference between the third sample image and the first sample image in a quality dimension is small, then the quality difference value between the third sample image and the first sample image in that quality dimension can be correspondingly small.
  • the quality difference value includes an instance difference value between the third sample image and the first sample image in the instance dimension, and a style difference value between the third sample image and the first sample image in the image style dimension.
  • the first sample image may be instance-labeled so that the first sample image has instance segmentation annotations. Based on this, from the instance dimension, the above-mentioned comparison of the first sample image and the third sample image may include:
  • the difference value between the instance segmentation annotation and the instance segmentation result is used as the instance difference value between the third sample image and the first sample image in the instance dimension.
  • performing instance segmentation on the third sample image and determining the difference between the instance segmentation result of the third sample image and the instance segmentation annotation of the first sample image can be achieved by using a trained instance segmentation model.
  • Performing instance segmentation on an image is a technique that should be known to those skilled in the art and will not be described in detail here. In this application:
  • m I (x′ 0 ) to represent the instance segmentation result of the third sample image, where m I represents an instance segmentation network that performs instance segmentation on the third sample image, and x′ 0 represents the third sample image;
  • L instance (m I (x′ 0 ), GT(x 0 )) is used to represent the quality difference value (i.e., instance difference value) between the third sample image and the first sample image in the instance dimension. If the difference between the instance segmentation result of the third sample image and the instance segmentation annotation of the first sample image is large, the value of L instance (m I (x′ 0 ), GT(x 0 )) can be large; if the difference between the instance segmentation result of the third sample image and the instance segmentation annotation of the first sample image is small, the value of L instance (m I (x′ 0 ), GT(x 0 )) can be small.
  • Gram(V(x 0 )) is used to represent the first style value of the first sample image style, where x 0 represents the first sample image, V represents the image style extraction network for extracting image style features, and Gram represents the calculation of the extracted image style features using the Gram matrix.
  • the calculated result can be used as the second style value;
  • Gram(V(x′ 0 )) is used to represent the second style value of the third sample image style, wherein x′ 0 represents the third sample image.
  • V and Gram can refer to the relevant description of Gram(V(x 0 )), which is not repeated here.
  • Step S44 in response to the quality difference value indicating that the first sample image and the third sample image do not match, performing a first stage training on the Vincent graph model according to the quality difference value.
  • whether the first sample image and the third sample image match can be determined separately according to the quality difference value of each quality dimension. For example, for the instance dimension, if the instance difference value of the first sample image and the third sample image in the instance dimension is less than a first threshold value (such as 0.5), it can be indicated that the first sample image and the third sample image match in the instance dimension; if the instance difference value of the first sample image and the third sample image in the instance dimension is not less than the first threshold value, it can be indicated that the first sample image and the third sample image do not match in the instance dimension.
  • a first threshold value such as 0.5
  • the style difference value of the first sample image and the third sample image in the image style dimension is less than a second threshold value (such as 0.3), it can be indicated that the first sample image and the third sample image match in the image style dimension; if the instance difference value of the first sample image and the third sample image in the image style dimension is not less than the second threshold value, it can be indicated that the first sample image and the third sample image do not match in the image style dimension.
  • a second threshold value such as 0.3
  • the first phase of training for the Vincent graph model can be performed based on the quality difference values for each quality dimension. For example, if the instance difference value for the instance dimension determines that the first sample image and the second sample image do not match, the first phase of training for the Vincent graph model can be performed based on the instance difference value to ensure that the first sample image and the third sample image match in the instance dimension. Similarly, if the style difference value for the image style dimension determines that the first sample image and the second sample image do not match, the first phase of training for the Vincent graph model can be performed based on the style difference value to ensure that the first sample image and the third sample image match in the image style dimension.
  • the first-stage training of the Vincent graph model based on the quality difference value of that quality dimension can be eliminated. For example, if the first sample image and the second sample image are determined to be mismatched based on the instance difference value of the instance dimension, but are matched based on the style difference value of the image style dimension, then the first-stage training of the Vincent graph model based on the instance difference value can be eliminated.
  • a loss function as shown in Expression (2) can be constructed to train the text image model from the image style dimension:
  • the trained Vincent graph model can generate a third sample image that matches the first sample image according to each quality dimension.
  • the present application splits and compares the first and third sample images according to each quality dimension, and based on the results of the split comparison, trains the Vincent graph model separately from each quality dimension. In this way, the training of the Vincent graph model is more refined, so that the trained Vincent graph model can have higher accuracy, which in turn can improve the accuracy of the generated image.
  • the first phase of training may further include:
  • each aesthetic dimension may correspond to a trained sub-scoring model for scoring the aesthetic quality of the third sample image in that aesthetic dimension.
  • the lighting scoring model may be used to score the lighting effects of the third sample image
  • the color scoring model may be used to score the colors of the third sample image.
  • the higher the aesthetic score output by that sub-scoring model the better the aesthetic quality of the third sample image in the corresponding aesthetic dimension.
  • the Vincent graph model can be trained separately so that the aesthetic scores of the third sample images generated by the trained Vincent graph model meet the scoring threshold in each aesthetic dimension. This improves the aesthetic quality of the third sample images.
  • a loss function as shown in Expression (3) can be constructed to train the text graph model from the aesthetic dimension:
  • the Wensheng graph model After completing the first phase of training, the Wensheng graph model has already achieved relatively good performance in terms of image quality and image aesthetics. Based on the Wensheng graph model obtained after the first phase of training, the second phase of training can be continued to further improve the inference speed of the Wensheng graph model.
  • Step S71 inputting the first sample image and the third sample image into a trained total score model, so as to output a first image score of the first sample image and a second image score of the third sample image through the total score model.
  • ra ( x0 ) is used to represent the first image score output by the total scoring model for the first sample image
  • ra ( x′0 ,c) is used to represent the second image score output by the total scoring model for the third sample image
  • ra represents the total scoring model
  • x0 represents the first sample image
  • x′0 represents the third sample image
  • c represents the prompt word that guides the text graph model to generate the third sample image.
  • a loss function as shown in Expression (4) can be constructed to train the Wensheng graph model:
  • Step S73 Based on the first image score and the second image score, the total score model is trained so that the first image score output by the total score model is increased and the second image score is decreased.
  • the third sample image generated by the Vincent graph model will become better and better, that is, the second image score r d (x′ 0 ,c) will become higher and higher.
  • the total score model can be trained based on the first image score and the second image score, so that the total score model has increasingly strict requirements for the third sample image.
  • the total score model should lower the second image score of the third sample image. In this way, the Vincent graph model can continue to be trained under lower second image scores.
  • This training process can also be called an adversarial training process.
  • the total score model can treat the first sample image as a good image and output a high first image score for the first sample image, and treat the third sample image as a bad image and output a low second image score for the third sample image. In this way, the accuracy of the Vincent graph model can be improved through such adversarial training.
  • a loss function as shown in Expression (5) can be constructed based on the first image score and the second image score to train the total score model:
  • is the adjustment parameter.
  • the third sample image with a low number of denoising steps can also receive sufficient feedback optimization, so that after completing the second stage of training, the third sample image obtained by the Vincent graph model using fewer denoising steps can also have better image quality, which is equivalent to speeding up the inference speed of the Vincent graph model.
  • Figure 9 a schematic diagram of the module interactions during the second phase of training, provided in another embodiment of the present application.
  • the document graph model is trained based on the overall scoring model, it can also be trained based on multiple sub-scoring models. This further improves the accuracy of the document graph model.
  • the principles of the sub-scoring models can be found in Figure 6 and will not be further elaborated here.
  • the Wensheng graph model after the first and second phases of training, can achieve higher accuracy and inference speed.
  • the image generation system includes:
  • a data acquisition module is used to obtain multiple sample prompt words for model training
  • a first data extraction module is configured to analyze the correspondence between entities and entity attributes in the sample prompt words, and extract the sample prompt words whose correspondences meet the complexity index to obtain a first data set;
  • a second data extraction module is used to extract sample prompt words that meet the difference index from the first data set to obtain a second data set
  • the electronic device includes a processor and a memory, wherein the memory is used to store a computer program.
  • the computer program is executed by the processor, the above method is implemented.
  • Memory as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as the program instructions/modules corresponding to the methods in the embodiments of the present disclosure.
  • the processor executes the non-transitory software programs, instructions, and modules stored in the memory to perform various processor functions and data processing, thereby implementing the methods in the aforementioned method embodiments.
  • the memory may 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; the data storage area may store data created by the processor, etc.
  • the memory may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device.
  • the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
  • One embodiment of the present application further provides a computer-readable storage medium, which is used to store a computer program.
  • a computer program When the computer program is executed by a processor, the above method is implemented.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Evolutionary Computation (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Mathematical Physics (AREA)
  • Computing Systems (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Software Systems (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Biology (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本公开涉及计算机技术领域,公开一种数据处理方法、系统、设备和存储介质,方法包括获取用于模型训练的多个样本提示词;解析样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集;从第一数据集中提取满足差异性指标的样本提示词,得到第二数据集;基于第二数据集进行模型训练。

Description

数据处理方法、系统、设备和存储介质
相关申请的交叉引用
本申请要求于2024年3月27日提交的,申请号为202410362148.3、发明名称为“数据处理方法、系统、设备和存储介质”的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本公开涉及计算机技术领域,具体涉及一种数据处理方法、系统、设备和存储介质。
背景技术
文生图模型是以提示词作为引导,生成与提示词相匹配的图像。不管是对文生图模型进行初始训练还是微调训练,都需要提供大量的提示词作为训练样本。训练样本的选择是否准确合理,对文生图模型的精度有很大影响。
目前,选择的训练样本普遍存在不合理的问题,导致训练得到的文生图模型的精度偏低,生成的图像会出现扭曲等问题。
因此,亟需一种可以提高模型精度的方法。
发明内容
有鉴于此,本公开实施方式提供了一种数据处理方法、数据处理系统、电子设备和计算机可读存储介质。
本公开一方面提供了一种数据处理方法,所述方法包括:
获取用于模型训练的多个样本提示词;
解析所述样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集;
从所述第一数据集中提取满足差异性指标的样本提示词,得到第二数据集;
基于所述第二数据集进行模型训练。
本公开一方面提供了一种数据处理系统,所述系统包括:
数据获取模块,用于获取用于模型训练的多个样本提示词;
第一数据提取模块,用于解析所述样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集;
第二数据提取模块,用于从所述第一数据集中提取满足差异性指标的样本提示词,得到第二数据集;
训练模块,用于基于所述第二数据集进行模型训练。
本公开另一方面还提供了一种计算机可读存储介质,所述计算机可读存储介质用于存储计算机程序,所述计算机程序被处理器执行时,实现如上所述的方法。
本公开另一方面还提供了一种电子设备,所述电子设备包括处理器和存储器,所述存储器用于存储计算机程序,所述计算机程序被所述处理器执行时,实现如上所述的方法。
附图说明
通过参考附图会更加清楚的理解本公开的特征和优点,附图是示意性的而不应理解为对本公开进行任何限制,在附图中:
图1示出了一些文生图模型生成图像的示意图;
图2示出了本申请的一个实施例提供的数据处理方法的流程示意图;
图3示出了本申请一个实施例提供的解析树的示意图;
图4示出了本申请的一个实施例提供的第一阶段训练的流程示意图;
图5示出了图4中的第一阶段训练的模块交互示意图;
图6示出了本申请的另一个实施例提供的第一阶段训练的模块交互示意图;
图7示出了本申请的一个实施例提供的第二阶段训练的流程示意图;
图8示出了图7中的第二阶段训练的模块交互示意图;
图9示出了本申请的另一个实施例提供的第二阶段训练的模块交互示意图;
图10示出了本申请的一个实施例提供的数据处理系统的模块示意图;
图11示出了本申请的一个实施例提供的电子设备的示意图。
具体实施方式
为使本公开实施方式的目的、技术方案和优点更加清楚,下面将结合本公开实施方式中的附图,对本公开实施方式中的技术方案进行清楚、完整地描述,显然,所描述的实施方式是本公开一部分实施方式,而不是全部的实施方式。基于本公开中的实施方式,本领域技术人员在没有作出创造性劳动前提下所获得的所有其它实施方式,都属于本公开保护的范围。
在本申请一些实施例的技术方案中,在获取到用于模型训练的样本提示词后,按照复杂度指标对样本提示词进行筛选,可以剔除语义复杂度较低的样本提示词;按照差异性指标对样本提示词进行筛选,可以降低样本提示词的冗余度,并扩大样本提示词的数据范围分布。按照复杂度和差异性筛选后的样本提示词对模型进行训练,训练效果可以较好,进而可以提高训练得到的模型精度。
结合参阅图1,为一些文生图模型生成图像的示意图。图1中,文生图模型可以是扩散模型。提示词用于引导文生图模型生成所需的图像。比如,需要文生图模型生成一张包括三个小孩且小孩坐在沙发上的图像时,提示词可以是“Three children on a couch,full shot”。又比如,需要文生图模型生成一张包括月亮和公园的夜景图时,提示词可以是“The moon is very bright in the night sky,casting a gentle light over the abandoned amusement park”。
文生图模型生成图像的原理是:以提示词作为引导,分多个时间步对包括随机噪声的初始图Xt进行降噪,得到与提示词相匹配的图像。比如图1中,Xt-1表示对初始图Xt进行第一次降噪后得到的图像,Xt-2表示在Xt-1基础上,对初始图Xt进行第二次降噪后得到的图像。通过多次降噪后得到的图像X0便可以作为与提示词相匹配的图像。
可以理解的是,基于不同的提示词,分多个时间步对初始图Xt进行降噪的降噪方式可以不完全相同,从而使得文生图模型可以为不同的提示词生成不同的图像。而对文生图模型的训练过程,就是提供大量的提示词作为训练样本,让文生图模型去学习与提示词相匹配的降噪方式,使得在文生图模型训练好后,文生图模型可以根据输入的提示词和已经学习到的降噪知识,按照与提示词相匹配的降噪方式对初始图Xt进行降噪,以生成与提示词相匹配的图像。
在文生图模型的训练过程中,提示词的选择是否合理,对文生图模型的精度有很大影响。但是目前,普遍是按随机选取的方式采集用于文生图模型训练的提示词。这种方式采集得到的提示词可能存在复杂度不够、提示词分布范围较窄、提示词冗余度高等问题,进而导致训练得到的文生图模型的精度不高。
鉴于此,本申请提供一种数据处理方法,可以解决上述问题,提高模型精度。数据处理方法可应用于电子设备。电子设备包括但不限于平板电脑、笔记本电脑、台式电脑、服务器等。结合参阅图2,为本申请的一个实施例提供的数据处理方法的流程示意图。图2中,数据处理方法包括:
步骤S21,获取用于模型训练的多个样本提示词。
在本实施例中,步骤S21中获取的样本提示词可以是从线上用户输入的提示词中选取得到的。线上用户可以是网络上使用文生图模型生成图像的用户。这里得到的样本提示词可能存在复杂度不够、分布范围较窄、冗余度高等问题。
在其它一些实施例中,可以基于其它的渠道获取样本提示词,比如从公开的提示词数据集中获取多个样本提示词。本申请对步骤S21中获取样本提示词的方式不作限制。
步骤S22,解析样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集。
具体的,实体可以是构成样本提示词基本结构的对象。比如,动作的发起对象、动作的承受对象、被修饰的对象均可以作为实体。实体属性则用于表征实体的特征。比如,动作发起对象发起的动作,可以作为动作发起者的实体属性;动作承受对象承受的动作,可以作为动作承受者的实体属性;用于修饰动作发起者的词语,可以作为动作发起者的实体属性。
为便于理解,以样本提示词“A black cat is chasing a small brown bird”为例进行说明。在该样本提示词中,“cat”和“bird”可以作为实体,“black”和“chasing”可以作为“cat”的实体属性,“small”、“brown”和“chasing”,可以作为“bird”的实体属性。
实体和实体属性的对应关系,可以通过解析树来表示。比如,对样本提示词“A black cat is chasing a small brown bird”进行解析后,得到的解析树可以如图3所示。在解析树中,与一个实体存在连接关系的实体属性,便是该实体对应的实体属性。比如,图3中,以实体“bird”为中心,存在3个实体属性与实体“bird”连接,表示有3个实体属性与实体“bird”存在对应关系;以实体“cat”为中心,存在2个实体属性与实体“cat”连接,表示有2个实体属性与实体“cat”存在对应关系。在本申请中,将实体对应的实体属性数量,称为实体与实体属性的对应关系数量。比如,实体“bird”对应3个实体属性,则实体“bird”与实体属性的对应关系数量为3。
复杂度指标可以用于限定样本提示词中实体和实体属性之间的对应关系需满足的复杂度要求,比如,对应关系的总数量、单个实体与实体属性的对应关系数量、实体连接的实体属性的词性(比如动词、名词、形容词等)。复杂度指标可以根据实际需要指定。
在本实施例中,复杂度指标包括实体与实体属性之间的最小对应关系数量。基于该复杂度指标,步骤S21中的提取对应关系达到复杂度指标的样本提示词,可以包括:
响应于一个样本提示词中存在满足如下条件的实体,将该样本提示词提取到第一数据集中:
实体与实体属性的对应关系数量达到最小对应关系数量。
比如,假设最小对应关系数量为3。以样本提示词“A black cat is chasing a small brown bird”为例,结合参阅图3。在该样本提示词中,实体“cat”与实体属性的对应关系数量为2,实体“bird”与实体属性的对应关系数量为3。由于实体“bird”与实体属性的对应关系数量达到了最小对应关系数量,故可以将样本提示词“A black cat is chasing a small brown bird”提取到第一数据集。
再比如,若最小对应关系数量为4。样本提示词“A black cat is chasing a small brown bird”中没有实体与实体属性的对应关系数量达到最小对应关系数量,故不可以将样本提示词“A black cat is chasing a small brown bird”提取到第一数据集。
按照复杂度指标对样本提示词进行筛选后,可以剔除语义复杂度较低的样本提示词,保留语义复杂度满足模型训练要求的样本提示词。基于满足语义复杂度要求的样本提示词对模型进行训练,可以大大提高模型的精度。
步骤S23,从第一数据集中提取满足差异性指标的样本提示词,得到第二数据集。
具体的,差异性指标可以用于指示第二数据集中任意两个样本提示词之间需达到的差异大小。比如,第二数据集中任意两个样本提示词之间的差异程度需要达到80%。
在本实施例中,差异性指标可以通过样本提示词之间的相似度来表示。比如,要求样本提示词之间的差异程度达到80%,就是要求样本提示词之间的相似度需要低于20%。鉴于此,差异性指标可以包括样本提示词之间的相似度需低于的第一相似度阈值(比如20%)。基于第一相似度阈值,上述从第一数据集中提取满足差异性指标的样本提示词,可以包括:
对各个样本提示词进行特征提取,得到各个样本提示词的特征向量;
查找特征向量的距离位于预设距离范围内的第一样本提示词和第二样本提示词,并确定第一样本提示词和第二样本提示词之间的第一相似度;
响应于第一相似度高于第一相似度阈值,从第一数据集中删除第二样本提示词或第一样本提示词;
将完成样本提示词删除后的第一数据集作为第二数据集。
具体的,特征向量的距离可以包括特征向量之间的余弦距离。针对第一数据集中的任一第一样本提示词A,可以根据样本提示词之间的余弦距离,在第一数据集中查找距离第一样本提示词A最近的预设数量(比如3个)的第二样本提示词。进而,可以将第一样本提示词A分别与各个第二样本提示词进行相似度计算。若第一样本提示词A与任一第二样本提示词B的相似度高于第一相似度阈值,表示第一样本提示词A与第二样本提示词B不满足差异性指标,这种情况下,可以从第一数据集中删除第一样本提示词A或第二样本提示词B。如此,针对第一数据集中未删除的每个样本提示词分别执行上述操作后,得到的数据集中,任意两个样本提示词之间便满足了差异性指标。因此,这个得到的数据集便可以作为第二数据集。
第二数据集中数据的分布范围可以较宽以及样本提示词冗余度可以较低。将第一数据集中的样本提示词按照差异性指标进行筛选,可以解决样本提示词的数据范围分布窄、冗余度高的问题,基于数据范围分布宽、冗余度低的样本提示词对模型进行训练,可以大大提高模型的精度。
进一步的,在一些实施例中,在依据第一相似度从第一数据集中提取第二数据集之前,本申请的数据处理方法还可以包括:
在第一数据集中,查找特征向量的距离位于预设距离范围内的多组第一样本提示词和第二样本提示词,并分别计算各组第一样本提示词和第二样本提示词的第二相似度;
响应于多组第一样本提示词和第二样本提示词的第二相似度的平均值低于第二相似度阈值,将第一数据集作为第二数据集。
具体的,多组第一样本提示词和第二样本提示词的第二相似度的平均值低于第二相似度阈值,可以表示第一数据集中的样本提示词的分布范围和冗余度可以达到模型训练的要求,这种情况下,可以直接将第一数据集作为第二数据集,如此,以减少数据筛选过程中的数据处理量。
步骤S24,基于第二数据集进行模型训练。
综上所述,在本申请一些实施例的技术方案中,在获取到用于模型训练的样本提示词后,按照复杂度指标对样本提示词进行筛选,可以剔除语义复杂度较低的样本提示词;按照差异性指标对样本提示词进行筛选,可以降低样本提示词的冗余度,并扩大样本提示词的数据范围分布。按照复杂度和差异性筛选后的样本提示词对模型进行训练,训练效果可以较好,进而可以提高训练得到的模型精度。
在一些实施例中,在基于第二数据集对文生图模型进行训练之后,还可以基于对文生图模型进行微调训练。微调训练可以包括第一阶段训练和第二阶段训练。结合参阅图4和图5。图4为本申请的一个实施例提供的第一阶段训练的流程示意图。图5为图4中的第一阶段训练的模块交互示意图。图4中,第一阶段训练包括如下步骤:
步骤S41,获取第一样本图像,并对第一样本图像进行噪声化处理,得到第二样本图像。
具体的,第一样本图像可以是需要文生图模型生成的标准图像。在获取到第一样本图像后,可以在第一样本图像中添加随机噪声,得到第二样本图像。
步骤S42,将第二样本图像输入文生图模型,以通过文生图模型将第二样本图像转换为第三样本图像。
具体的,第三样本图像即文生图模型基于初始训练过程中已经学习到的降噪知识,对第二样本图像进行降噪后得到的图像。
可以理解的是,在文生图模型精度较高,对第二样本图像降噪准确的情况下,第三样本图像应该与第一样本图像一致,或者第三样本图像与第一样本图像的差异大小位于可接受的阈值范围内。但是,在文生图模型的精度不高,对第二样本降噪不准确的情况下,第三样本图像则可能与第一样本图像存在较大差异。因此,第三样本图像和第一样本图像的差异大小,可以用于评估文生图模型的精度。简单来说,就是第三样本图像与第一样本图像的差异越小,文生图模型的精度越高;而第三样本图像与第一样本图像的差异越大,文生图模型的精度越低。
步骤S43,将第一样本图像和第三样本图像进行比对,得到第一样本图像和第三样本图像在各个表征图像质量的质量维度的质量差异值。
具体的,质量维度为确定第三样本图像的图像质量时所使用的维度。其中,第三样本图像的图像质量表征第三样本图像与第一样本图像的相似程度。第三样本图像与第一样本图像的相似程度越高,表示第三样本图像的图像质量越好,而第三样本图像与第一样本图像的相似程度越低,表示第三样本图像的图像质量越差。而在将第三样本图像和第一样本图像进行相似度比对时,可以对第三样本图像和第一样本图像按多个维度分别进行比对。此处所使用的多个维度,便可以称为质量维度。
在本实施例中,质量维度可以包括实例维度和图像风格维度。其中,从实例维度将第三样本图像和第一样本图像进行相似度比对,可以是将第三样本图像和第一样本图像的实例分割结果进行相似度比对。而从图像风格维度将第三样本图像和第一样本图像进行相似度比对,可以是将第三样本图像和第一样本图像的图像风格进行相似度比对。可以理解的是,可以根据实际需要进行选取,本实施例中,将质量维度划分为实例维度和图像风格,并不构成对本申请的限制。
第三样本图像和第一样本图像在各个质量维度的差异大小,可以通过质量差异值来表示。具体的,若第三样本图像和第一样本图像在一个质量维度的差异较大,那么第三样本图像和第一样本图像在该质量维度的质量差异值可以较大;反之,若第三样本图像和第一样本图像在一个质量维度的差异较小,那么第三样本图像和第一样本图像在该质量维度的质量差异值可以相应的较小。
在本实施例中,质量差异值包括第三样本图像和第一样本图像在实例维度的实例差异值,以及第三样本图像和第一样本图像在图像风格维度的风格差异值。
以下以实例维度和图像风格维度为例,说明如何将将第三样本图像和第一样本图像进行比对,以得到第三样本图像和第一样本图像在各个质量维度的质量差异值。
具体的,在一些实施例中,可以在步骤S41中获取到第一样本图像后,对第一样本图像进行实例标注,使得第一样本图像具有实例分割标注。基于此,从实例维度来说,上述将第一样本图像和第三样本图像进行比对,可以包括:
将第三样本图像进行实例分割,得到第三样本图像的实例分割结果;
将实例分割标注与实例分割结果之间的差异值,作为第三样本图像和第一样本图像在实例维度的实例差异值。
结合参阅图5,将第三样本图像进行实例分割,以及确定第三样本图像的实例分割结果与第一样本图像的实例分割标注之间的差异值,可以通过训练好的实例分割模型来实现。对图像进行实例分割为本领域技术人员应该知晓的技术,在此不赘述。本申请中:
使用mI(x′0)表示第三样本图像的实例分割结果,其中,mI表示对第三样本图像进行实例分割的实例分割网络,x′0表示第三样本图像;
使用GT(x0)表示第一样本图像的实例分割标注,其中,x0表示第一样本图像;
使用Linstance(mI(x′0),GT(x0))表示第三样本图像和第一样本图像在实例维度的质量差异值(即实例差异值)。若第三样本图像的实例分割结果和第一样本图像的实例分割标注之间的差异较大,Linstance(mI(x′0),GT(x0))的取值可以较大;若第三样本图像的实例分割结果和第一样本图像的实例分割标注之间的差异较小,Linstance(mI(x′0),GT(x0))的取值可以较小。
进一步的,在一些实施例中,从图像风格维度来说,上述将第一样本图像和第三样本图像进行比对,可以包括:
从第一样本图像提取表征第一样本图像风格的第一风格值,以及从第三样本图像提取表征第三样本图像风格的第二风格值;
将第一风格值和第二风格值之间的差异值,作为第一样本图像和第三样本图像在图像风格维度的风格差异值。
具体的,图像风格可以按照实际需要进行划分,比如图像风格可以划分为复古风格和现代风格。不同的图像风格可以具有不同的风格值。结合参阅图3,提取第一样本图像和第三样本图像的风格值,以及计算第一样本图像和第三样本图像的风格差异值,可以通过训练好的图像风格提取模型来实现。图像风格提取为本领域技术人员应该知晓的技术,在此不赘述。本申请中:
使用Gram(V(x0))表示第一样本图像风格的第一风格值,其中,x0表示第一样本图像,V表示图像风格提取网络,用于提取图像风格特征,Gram表示使用Gram矩阵对提取到的图像风格特征进行计算,计算得到的结果便可以作为第二风格值;
使用Gram(V(x′0))表示第三样本图像风格的第二风格值,其中,x′0表示第三样本图像,V和Gram可参见针对Gram(V(x0))的相关描述,此处不赘述。
使用||Gram(V(x′0))-Gram(V(x0))||2表示第三样本图像和第一样本图像在图像风格维度的质量差异值(即风格差异值)。若第三样本图像的图像风格和第一样本图像的图像风格差异较大,||Gram(V(x′0))-Gram(V(x0))||2的取值可以较大;若第三样本图像的图像风格和第一样本图像的图像风格差异较小,||Gram(V(x′0))-Gram(V(x0))||2的取值可以较小。
步骤S44,响应于质量差异值表征第一样本图像和第三样本图像不匹配,依据质量差异值对文生图模型进行第一阶段训练。
具体的,在本实施例中,可以按照各个质量维度的质量差异值,分别判断第一样本图像和第三样本图像是否匹配。比如,对于实例维度来说,若第一样本图像和第三样本图像在实例维度的实例差异值小于第一阈值(比如0.5),可以表示第一样本图像和第三样本图像在实例维度匹配;若第一样本图像和第三样本图像在实例维度的实例差异值不小于第一阈值,可以表示第一样本图像和第三样本图像在实例维度不匹配。对于图像风格维度来说,若第一样本图像和第三样本图像在图像风格维度的风格差异值小于第二阈值(比如0.3),可以表示第一样本图像和第三样本图像在图像风格维度匹配;若第一样本图像和第三样本图像在图像风格维度的实例差异值不小于第二阈值,可以表示第一样本图像和第三样本图像在图像风格维度不匹配。
针对各个质量维度的质量差异值,可以分别对文生图模型进行第一阶段训练。比如,若依据实例维度的实例差异值,确定第一样本图像和第二样本图像不匹配,那么可以依据实例差异值,对文生图模型进行第一阶段训练,使得第一样本图像和第三样本图像在实例维度相匹配。同理,若依据图像风格维度的风格差异值,确定第一样本图像和第二样本图像不匹配,那么可以依据风格差异值,对文生图模型进行第一阶段训练,使得第一样本图像和第三样本图像在图像风格维度相匹配。
进一步的,若第一样本图像和第二样本图像在其中一个质量维度相匹配,那么可以无需再基于这个质量维度的质量差异值,对文生图模型进行第一阶段训练。比如,若依据实例维度的实例差异值,确定第一样本图像和第二样本图像不匹配,但依据图像风格维度的风格差异值,确定第一样本图像和第二样本图像匹配,那么可以只基于实例差异值对文生图模型进行第一阶段训练,无需再基于风格差异值对文生图模型进行第一阶段训练。
在本实施例中,可以基于实例差异值,构建如表达式(1)所示的损失函数,以从实例维度对文生图模型进行训练:
其中,E表示期望,D表示第一样本图像集合,表示第三样本图像集合。
以及,可以基于风格差异值,构建如表达式(2)所示的损失函数,以从图像风格维度对文生图模型进行训练:
可以理解的是,从不同的质量维度分别对文生图模型进行训练后,训练完成的文生图模型可以按照各个质量维度,生成与第一样本图像相匹配的第三样本图像。相对于一些技术中的将第一样本图像和第三样本图像从整体上进行比对,并依据整体比对得到的结果对文生图模型进行训练,本申请将第一样本图像和第三样本图像按照各个质量维度进行拆分比对,并基于拆分比对的结果,从各个质量维度分别对文生图模型进行训练。如此,针对文生图模型的训练更加精细,使得训练好的文生图模型可以具有更高的精度,进而可以提高生成图像的精度。
结合参阅图6,为本申请的另一个实施例提供的第一阶段训练的模块交互示意图。在一些实施例中,在第一阶段训练还可以包括:
将第三样本图像输入子评分模型,以通过子评分模型按照表征图像美感的多个美感维度,分别对第三样本图像进行评分,得到第三样本图像在各个美感维度的美感评分;
若美感评分未超过评分阈值,依据美感评分对文生图模型进行训练。
具体的,美感维度包括但不限于图像光照效果、图像颜色、图像布局等。本申请对美感维度的划分不作限制。需要说明的是,美感维度是从第三样本图像的美感角度出发,对第三样本图像所进行的维度划分,而上述质量维度,是从第三样本图像与第一样本图像的相似性评估角度出发,对第三样本图像所进行的维度划分,因此,美感维度和质量维度可以相同,也可以不相同。
结合参阅图6,在本实施例中,每个美感维度可以分别对应一个训练好的子评分模型,用于对第三样本图像在相应美感维度的美感进行评分。比如,图6中,光照评分模型可用于对第三样本图像的光照效果进行评分,颜色评分模型可用于对第三样本图像的颜色进行评分。
针对任一子评分模型,该子评分模型输出的美感评分越高,表示第三样本图像在相应美感维度的美感越好。针对各个子评分模型输出的美感评分,可以分别对文生图模型进行训练,以使训练好的文生图模型所生成的第三样本图像在各个美感维度的美感评分均可达到评分阈值。如此,可以提高第三样本图像的美感。
具体的,可以基于各个子评分模型输出的美感评分,构建如表达式(3)所示的损失函数,以从美感维度对文生图模型进行训练:
其中,c表示用于引导文生图模型生成第三样本图像的提示词,x′0表示第三样本图像,rd表示子评分模型,rd(x′0,c)表示针对第三样本图像的美感评分,αd表示评分阈值,求和括号表示对第三样本图像的多个美感维度进行评分。在表达式(3)中,针对任一美感维度,第三样本图像在该美感维度的美感评分rd(x′0,c)达到评分阈值αd时,便可以停止基于该美感维度的美感评分rd(x′0,c)对文生图模型进行训练。
在完成第一阶段训练后,文生图模型在图像质量和图像美感两个方面已经可以有比较好的表现。基于第一阶段训练之后得到的文生图模型,可以继续进行第二阶段训练,以进一步提高文生图模型的推理速度。
具体的,结合参阅图7和图8。图7为本申请的一个实施例提供的第二阶段训练的流程示意图。图8为图7中的第二阶段训练的模块交互示意图。图7中,第二阶段训练具体可以包括如下步骤:
步骤S71,将第一样本图像和第三样本图像输入训练好的总评分模型,以通过总评分模型输出第一样本图像的第一图像评分和第三样本图像的第二图像评分。
具体的,图像评分可以表征样本图像的图像好坏程度。总评分模型可以是奖励模型。总评分模型输出的图像评分越高,表示图像越好,以及总评分模型输出的图像评分越低,表示图像越差。
在本实施例中,图像评分可以是以第一样本图像作为基准得到的分数。简单来说,就是将第一样本图像作为最好的图像,即第一样本图像的第一图像评分可以是最高的。第三样本图像与第一样本图像的相似度越高,那么第三样本图像的第二图像评分可以越高,反之,第三样本图像与第一样本图像的相似度越低,那么第三样本图像的第二图像评分可以越低。
在本申请中,使用ra(x0)表示总评分模型为第一样本图像输出的第一图像评分,以及使用ra(x′0,c)表示总评分模型为第三样本图像输出的第二图像评分,其中,ra表示总评分模型,x0表示第一样本图像,x′0表示第三样本图像,c表示引导文生图模型生成第三样本图像的提示词。
步骤S72,基于第二图像评分,对文生图模型进行第二阶段训练,以使文生图模型输出的第三样本图像的第二图像评分增高。
具体的,可以基于第二图像评分,构建如表达式(4)所示的损失函数,以对文生图模型进行训练:
其中,表达式(4)中,在rd1(x′0,c)之前添加负号的含义为:在第二图像评分ra(x′0,c)越高时,文生图模型的损失越小。
步骤S73,基于第一图像评分和第二图像评分,对总评分模型进行训练,以使总评分模型输出的第一图像评分增高,以及第二图像评分降低。
可以理解的是,基于表达式(4)对文生图模型进行训练后,文生图模型生成的第三样本图像会越来越好,即第二图像评分rd(x′0,c)会越来越高。这种情况下,为使文生图模型生成的第三样本图像能够越来越好,可以基于第一图像评分和第二图像评分,对总评分模型进行训练,以使总评分模型对第三样本图像的要求越来越严格。相应的,在越严格的标准下,总评分模型对第三样本图像的第二图像评分应该是降低的,如此,在较低的第二图像评分下,可以继续对文生图模型进行训练。这个训练过程又可称为对抗训练过程。具体的,在对抗训练过程中,总评分模型可以将第一样本图像作为好的图像,为第一样本图像输出高的第一图像评分,以及将第三样本图像作为差的图像,为第三样本图像输出低的第二图像评分。如此,以通过这样的对抗训练,提高文生图模型的精度。
具体的,在本实施例中,可以基于第一图像评分和第二图像评分,构建如表达式(5)所示的损失函数,以对总评分模型进行训练:
其中,σ为调节参数。
在第二阶段训练中,低去噪步数的第三样本图像也可以得到充分的反馈优化,使得在完成第二阶段训练之后,文生图模型使用较少降噪步数得到的第三样本图像也能具有较好的图像质量,这就相当于加快了文生图模型的推理速度。
结合参阅图9,为本申请的另一个实施例提供的第二阶段训练的模块交互示意图。图9中,在基于总评分模型对文生图模型进行训练的同时,还可以基于多个子评分模型对文生图模型进行训练。如此,以进一步提高文生图模型的精度。子评分模型的原理,可参见图6描述,在此不赘述。
到此,完成了第一阶段训练和第二阶段训练的全部阐述。经过第一阶段训练和第二阶段训练后的文生图模型可以具有更高的精度和推理速度。
结合参阅图10,为本申请的一个实施例提供的数据处理系统的模块示意图。图10中,图像生成系统包括:
数据获取模块,用于获取用于模型训练的多个样本提示词;
第一数据提取模块,用于解析所述样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集;
第二数据提取模块,用于从所述第一数据集中提取满足差异性指标的样本提示词,得到第二数据集;
训练模块,用于基于所述第二数据集进行模型训练。
结合参阅图11,为本申请的一个实施例提供的电子设备的示意图。电子设备包括处理器和存储器,存储器用于存储计算机程序,计算机程序被处理器执行时,实现上述的方法。
其中,处理器可以为中央处理器(Central Processing Unit,CPU)。处理器还可以为其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等芯片,或者上述各类芯片的组合。
存储器作为一种非暂态计算机可读存储介质,可用于存储非暂态软件程序、非暂态计算机可执行程序以及模块,如本公开实施方式中的方法对应的程序指令/模块。处理器通过运行存储在存储器中的非暂态软件程序、指令以及模块,从而执行处理器的各种功能应用以及数据处理,即实现上述方法实施方式中的方法。
存储器可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储处理器所创建的数据等。此外,存储器可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存储器可选包括相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至处理器。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
本申请一个实施方式还提供一种计算机可读存储介质,计算机可读存储介质用于存储计算机程序,计算机程序被处理器执行时,实现上述的方法。
虽然结合附图描述了本公开的实施方式,但是本领域技术人员可以在不脱离本公开的精神和范围的情况下作出各种修改和变型,这样的修改和变型均落入由所附权利要求所限定的范围之内。

Claims (12)

  1. 一种数据处理方法,包括:
    获取用于模型训练的多个样本提示词;
    解析所述样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集;
    从所述第一数据集中提取满足差异性指标的样本提示词,得到第二数据集;
    基于所述第二数据集进行模型训练。
  2. 如权利要求1所述的方法,其中所述复杂度指标包括实体与实体属性之间的最小对应关系数量;
    所述提取对应关系达到复杂度指标的样本提示词,包括:
    响应于一个所述样本提示词中存在满足如下条件的实体,将该样本提示词提取到所述第一数据集中:
    实体与实体属性的对应关系数量达到所述最小对应关系数量。
  3. 如权利要求1所述的方法,其中所述差异性指标包括样本提示词之间的相似度需低于的第一相似度阈值;
    所述从所述第一数据集中提取满足差异性指标的样本提示词,包括:
    对各个所述样本提示词进行特征提取,得到各个所述样本提示词的特征向量;
    查找特征向量的距离位于预设距离范围内的第一样本提示词和第二样本提示词,并确定所述第一样本提示词和所述第二样本提示词之间的第一相似度;
    响应于所述第一相似度高于所述第一相似度阈值,从所述第一数据集中删除所述第二样本提示词或所述第一样本提示词;
    将完成样本提示词删除后的第一数据集作为所述第二数据集。
  4. 如权利要求3所述的方法,其中在依据所述第一相似度从所述第一数据集中提取所述第二数据集之前,所述方法还包括:
    在所述第一数据集中,查找特征向量的距离位于预设距离范围内的多组第一样本提示词和第二样本提示词,并分别计算各组第一样本提示词和第二样本提示词的第二相似度;
    响应于所述多组第一样本提示词和第二样本提示词的第二相似度的平均值低于第二相似度阈值,将所述第一数据集作为所述第二数据集。
  5. 如权利要求1所述的方法,其中训练的模型包括文生图模型,所述文生图模型用于基于提示词生成图像;
    在基于所述第二数据集对所述文生图模型进行训练之后,基于如下方法对所述文生图模型进行微调训练:
    获取第一样本图像,并对所述第一样本图像进行噪声化处理,得到第二样本图像;
    将所述第二样本图像输入所述文生图模型,以通过所述文生图模型将所述第二样本图像转换为第三样本图像;
    将所述第一样本图像和所述第三样本图像进行比对,得到所述第一样本图像和所述第三样本图像在各个表征图像质量的质量维度的质量差异值;
    响应于所述质量差异值表征所述第一样本图像和所述第三样本图像不匹配,依据所述质量差异值对所述文生图模型进行第一阶段训练。
  6. 如权利要求5所述的方法,其中所述质量维度包括实例维度,所述质量差异值包括所述第一样本图像和所述第三样本图像在所述实例维度的实例差异值,所述第一样本图像具有实例分割标注;
    所述将所述第一样本图像和所述第三样本图像进行比对,包括:
    将所述第三样本图像进行实例分割,得到所述第三样本图像的实例分割结果;
    将所述实例分割标注与所述实例分割结果之间的差异值,作为所述第一样本图像和所述第三样本图像在所述实例维度的所述实例差异值。
  7. 如权利要求5所述的方法,其中所述质量维度包括图像风格维度,所述质量差异值包括所述第一样本图像和所述第三样本图像在所述图像风格维度的风格差异值;
    所述将所述第一样本图像和所述第三样本图像进行比对,包括:
    从所述第一样本图像提取表征第一样本图像风格的第一风格值,以及从所述第三样本图像提取表征第三样本图像风格的第二风格值;
    将所述第一风格值和所述第二风格值之间的差异值,作为所述第一样本图像和所述第三样本图像在所述图像风格维度的所述风格差异值。
  8. 如权利要求5所述的方法,其中在完成所述第一阶段训练之后,所述方法还包括:
    将所述第一样本图像和所述第三样本图像输入训练好的总评分模型,以通过所述总评分模型输出所述第一样本图像的第一图像评分和所述第三样本图像的第二图像评分;
    基于所述第一图像评分,对所述文生图模型进行第二阶段训练,以使所述文生图模型输出的所述第三样本图像的所述第一图像评分增高;
    基于所述第一图像评分和所述第二图像评分,对所述总评分模型进行训练,以使所述总评分模型输出的第一图像评分降低,以及所述第二图像评分增高。
  9. 如权利要求8所述的方法,其中在所述第一阶段训练和所述第二阶段训练中,至少一个阶段训练还包括:
    将所述第三样本图像输入子评分模型,以通过所述子评分模型按照表征图像美感的多个美感维度,分别对所述第三样本图像进行评分,得到所述第三样本图像在各个所述美感维度的美感评分;
    若所述美感评分未超过评分阈值,依据所述美感评分对所述文生图模型进行训练。
  10. 一种数据处理系统,包括:
    数据获取模块,用于获取用于模型训练的多个样本提示词;
    第一数据提取模块,用于解析所述样本提示词中的实体与实体属性之间的对应关系,并提取对应关系达到复杂度指标的样本提示词,得到第一数据集;
    第二数据提取模块,用于从所述第一数据集中提取满足差异性指标的样本提示词,得到第二数据集;
    训练模块,用于基于所述第二数据集进行模型训练。
  11. 一种计算机可读存储介质,其中所述计算机可读存储介质用于存储计算机程序,所述计算机程序被处理器执行时,实现如权利要求1至9中任一所述的方法。
  12. 一种电子设备,其中所述电子设备包括处理器和存储器,所述存储器用于存储计算机程序,所述计算机程序被所述处理器执行时,实现如权利要求1至9中任一所述的方法。
PCT/CN2025/082071 2024-03-27 2025-03-12 数据处理方法、系统、设备和存储介质 Pending WO2025201056A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202410362148.3 2024-03-27
CN202410362148.3A CN120726179A (zh) 2024-03-27 2024-03-27 数据处理方法、系统、设备和存储介质

Publications (1)

Publication Number Publication Date
WO2025201056A1 true WO2025201056A1 (zh) 2025-10-02

Family

ID=97167431

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2025/082071 Pending WO2025201056A1 (zh) 2024-03-27 2025-03-12 数据处理方法、系统、设备和存储介质

Country Status (2)

Country Link
CN (1) CN120726179A (zh)
WO (1) WO2025201056A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111709247A (zh) * 2020-05-20 2020-09-25 北京百度网讯科技有限公司 数据集处理方法、装置、电子设备和存储介质
CN115205164A (zh) * 2022-09-15 2022-10-18 腾讯科技(深圳)有限公司 图像处理模型的训练方法、视频处理方法、装置及设备
CN116580283A (zh) * 2023-07-13 2023-08-11 平安银行股份有限公司 一种图像提示词生成方法、装置、电子设备及存储介质
CN117315067A (zh) * 2023-09-28 2023-12-29 中国工商银行股份有限公司 一种文生图方法、装置及计算机设备
CN117744662A (zh) * 2023-11-30 2024-03-22 中国工商银行股份有限公司 用于处理提示信息的方法、装置、电子设备及介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111709247A (zh) * 2020-05-20 2020-09-25 北京百度网讯科技有限公司 数据集处理方法、装置、电子设备和存储介质
CN115205164A (zh) * 2022-09-15 2022-10-18 腾讯科技(深圳)有限公司 图像处理模型的训练方法、视频处理方法、装置及设备
CN116580283A (zh) * 2023-07-13 2023-08-11 平安银行股份有限公司 一种图像提示词生成方法、装置、电子设备及存储介质
CN117315067A (zh) * 2023-09-28 2023-12-29 中国工商银行股份有限公司 一种文生图方法、装置及计算机设备
CN117744662A (zh) * 2023-11-30 2024-03-22 中国工商银行股份有限公司 用于处理提示信息的方法、装置、电子设备及介质

Also Published As

Publication number Publication date
CN120726179A (zh) 2025-09-30

Similar Documents

Publication Publication Date Title
CN117423108B (zh) 指令微调多模态大模型的图像细粒度描述方法及系统
CN107832286B (zh) 智能交互方法、设备及存储介质
US12050867B2 (en) Language model based writing aid method, device and system
EP4634883A1 (en) Automated evaluation of spatial relationships in images
CN111091809B (zh) 一种深度特征融合的地域性口音识别方法及装置
WO2024093578A1 (zh) 语音识别方法、装置、电子设备、存储介质及计算机程序产品
CN118736355A (zh) 视觉语言模型在定位任务中的性能评测方法及装置
WO2025232574A1 (zh) 知识图谱构建
CN114138929A (zh) 问答方法及装置
CN113378567A (zh) 一种针对低频词进行改善的中文短文本分类方法
CN114638239B (zh) 基于知识库的机器翻译方法及系统
CN113741864B (zh) 基于自然语言处理的语义化服务接口自动设计方法与系统
CN120409657A (zh) 多模态大模型驱动的人物知识图谱构建方法及系统
CN112133284B (zh) 一种医疗语音对话方法及装置
WO2025201056A1 (zh) 数据处理方法、系统、设备和存储介质
CN109472032A (zh) 一种实体关系图的确定方法、装置、服务器及存储介质
CN119783672A (zh) 语料扩展方法、设备及存储介质
CN112347196B (zh) 基于神经网络的实体关系抽取方法及装置
CN112328784B (zh) 数据信息分类方法及装置
CN115329129B (zh) 会议纪要文件生成方法、装置、电子设备及存储介质
CN115062691B (zh) 属性识别方法和装置
CN115238031A (zh) 目标答案获取方法、装置、电子设备及存储介质
CN120707655A (zh) 图像生成方法、系统、设备和存储介质
CN119851696B (zh) 播报测试方法及装置、可穿戴设备、存储介质
CN121075311B (zh) 基于人工智能的新闻播报方法及相关装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 25776462

Country of ref document: EP

Kind code of ref document: A1