Data augmentation methods and electronic devices
By introducing random parameters with continuous probability distributions into data augmentation, more accurate labels are generated, solving the problem of inaccurate labels for mixed images in existing technologies and improving the training effect and robustness of network models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2026-03-13
AI Technical Summary
Existing data augmentation methods are not accurate enough in generating labels for mixed images, leading to overfitting and labeling errors during network model training.
By sampling random parameters from a continuous probability distribution and combining them with the labels of the images to generate labels for the third images, the uncertainty of human labeling is simulated. The RandMix scheme is used to generate the third images and add them to the training set.
It improved the accuracy of labels, expanded the training set, increased the capacity and performance of the network model, and enhanced the robustness of the model.
Smart Images

Figure CN115272792B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this disclosure primarily relate to the field of computer technology, and more specifically, to methods, apparatus, electronic devices, computer-readable storage media, and computer program products for data enhancement. Background Technology
[0002] With the development of technology, artificial intelligence (AI) has been applied to various industries. The application of AI in various fields relies on network models, which are often trained on large amounts of data.
[0003] Generally speaking, the more data in a training dataset, the better it is for the network model. Therefore, how to expand the dataset through data augmentation is one of the problems that needs to be solved. Summary of the Invention
[0004] According to an example embodiment of this disclosure, a data augmentation scheme is provided that can obtain new images for the expansion of a dataset.
[0005] In a first aspect of this disclosure, a data augmentation method is provided, comprising: generating a third image based on a first portion of a first image and a second portion of a second image, the first image having a first label and the second image having a second label; obtaining random parameters by random sampling from a continuous probability distribution; determining a third label of the third image based on the first label, the second label and the random parameters; and adding the third image with the third label to a training set for training a network model.
[0006] In a second aspect of this disclosure, an electronic device is provided, comprising: at least one processing unit; at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions causing the electronic device to perform an action when executed by the at least one processing unit, the action comprising: generating a third image based on a first portion of a first image and a second portion of a second image, the first image having a first label and the second image having a second label; obtaining random parameters by random sampling from a continuous probability distribution; determining a third label of the third image based on the first label, the second label and the random parameters; and adding the third image having the third label to a training set for training a network model.
[0007] In a third aspect of this disclosure, a data augmentation apparatus is provided, comprising: an image generation module configured to generate a third image based on a first portion of a first image and a second portion of a second image, the first image having a first label and the second image having a second label; a parameter determination module configured to obtain random parameters by random sampling from a continuous probability distribution; a label determination module configured to determine a third label of the third image based on the first label, the second label, and the random parameters; and an image addition module configured to add the third image having the third label to a training set for training a network model.
[0008] In a fourth aspect of this disclosure, a computer-readable storage medium is provided having machine-executable instructions stored thereon, which, when executed by a device, cause the device to perform the method described in the first aspect of this disclosure.
[0009] A fifth aspect of this disclosure provides a computer program product including computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, implement the method described in the first aspect of this disclosure.
[0010] A sixth aspect of this disclosure provides an electronic device including: a processing circuit configured to perform the method described in the first aspect of this disclosure.
[0011] The summary section is provided to introduce a series of concepts in a simplified form, which will be further described in the detailed description below. The summary section is not intended to identify key or essential features of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0012] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. In the drawings, the same or similar reference numerals denote the same or similar elements, wherein:
[0013] Figure 1 A schematic diagram of the mixed images is shown;
[0014] Figure 2 A flowchart illustrating an example process according to some embodiments of this disclosure is shown;
[0015] Figures 3A-3B A schematic diagram illustrating a comparison of the first precise probabilities according to some embodiments of the present disclosure is shown;
[0016] Figure 4 A block diagram of an example apparatus according to an embodiment of the present disclosure is shown; and
[0017] Figure 5 A block diagram of an example device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0018] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0019] In embodiments of this disclosure, the term "network model" may also be referred to as a neural network model, neural network, machine learning (ML) model, deep learning (DL) model, deep network, etc., and this disclosure does not limit it.
[0020] To train network models more effectively, data augmentation mechanisms have been proposed. Data augmentation expands the training space and prevents overfitting. Existing data augmentation schemes include mixup and cutmix. In mixup, a new image is obtained by blending two given images, and the category of the new image is a weighted sum of the categories of the initial two images. Cutmix further proposes to blend two images by cropping and pasting, and the weight of each image in determining its category is the area ratio.
[0021] However, the current plan is not accurate enough. Figure 1 For example, if images 110 and 120 are blended to obtain blended images 132 to 138, even with manual annotation, it's impossible to accurately determine the ratio between the dog in image 110 and the cat in image 120. In this case, determining the weight based on area ratio is clearly inappropriate. For instance, in blended image 134, even though image 110 has a larger area ratio, the foreground area of image 110 is almost entirely covered. Assigning a large weight to "dog" in this case would result in an incorrect label. Similarly, in blended image 138, although it's a blend of images 110 and 120, it contains neither a cat nor a dog. Determining the label based solely on "dog" and "cat" would be inaccurate.
[0022] To at least partially address the deficiencies in the aforementioned technical solutions, embodiments of this disclosure provide a data augmentation scheme that determines the label of a synthetic image by considering random parameters in a continuous probability distribution. This simulates the uncertainty of human labeling, resulting in more accurate labels. Consequently, the synthetic image can be added to the training set to achieve data augmentation.
[0023] Figure 2 A flowchart of an example process 200 according to some embodiments of the present disclosure is shown. It should be understood that process 200 may also include additional boxes not shown and / or certain boxes shown may be omitted. The scope of the present disclosure is not limited in this respect.
[0024] In box 210, a third image is generated based on a first portion of the first image and a second portion of the second image, the first image having a first label and the second image having a second label. In box 220, random parameters are obtained by random sampling from a continuous probability distribution. In box 230, a third label for the third image is determined based on the first label, the second label, and the random parameters. In box 240, the third image with the third label is added to the training set used to train the network model.
[0025] In this way, when generating a third image based on the first and second images in the embodiments of this disclosure, the third label of the third image can be determined based on random parameters. This can simulate the uncertainty of human labeling, thereby making the obtained labels more accurate and enabling the third image to be used for data augmentation of the training set. As an example, the data augmentation scheme in the embodiments of this disclosure can be called the RandMix scheme.
[0026] In some embodiments, the first image can be represented as x A The second image is represented as x B The third image is represented as The third image can then be obtained using the following equation (1).
[0027]
[0028] For example, the first image, the second image, and the third image have the same size (or dimension), for example, represented as H×W. In equation (1), M∈{0,1} HW The first image is a binary mask indicating the position where it is filled into the third image; "1" represents a tensor with all elements equal to 1 and the same size as M; ⊙ represents element-wise multiplication. For example, the third image may be a composite image, a mixed image, or other names, etc., and this disclosure is not limited thereto.
[0029] For example, we can assume that the number of categories included in the image labels is C. Assuming the first label of the first image indicates that the first category of the first image is A, then the first label can be represented as a C-dimensional vector (called the first vector), where the element corresponding to category A is 1, and all other elements are 0. For example, the first vector can be represented as y A Let the second label of the second image indicate its second category as B. Then the second label can be represented as a C-dimensional vector (called the second vector), where the element corresponding to category B is 1, and all other elements are 0. For example, the second vector can be represented as y. B .
[0030] In embodiments of this disclosure, the third label of the third image can be determined based on the first label and the second label. Assume the third vector corresponding to the third label is represented as... The third vector can then be determined based on the weighted sum of the first and second vectors, as shown in equation (2) below.
[0031]
[0032] For example, λ can be called the first weight, and 1-λ can be called the second weight, with the sum of the two equal to 1.
[0033] In some embodiments of this disclosure, the first weight and the second weight may be determined based on at least one of a random parameter and a category parameter.
[0034] In some embodiments, the random parameter can be represented as λ. r Optionally, the random parameter can be determined by random sampling from a continuous probability distribution. For example, the random parameter can be randomly sampled from a beta distribution, as shown in equation (3) below:
[0035] λ r ~Beta(α,α) (3)
[0036] In equation (3), α represents the parameter of the beta distribution. For example, the beta distribution can be simply referred to as the B distribution, and can be expressed as the density function of the conjugate prior distribution of the Bernoulli distribution and the binomial distribution.
[0037] Alternatively, in other embodiments, random parameters can be sampled from a uniform distribution.
[0038] In some embodiments, the category parameter can be represented as λ. sFor example, based on the prediction results of the network model, a first probability corresponding to a first category indicated by a first label and a second probability corresponding to a second category indicated by a second label can be determined, and a category parameter can be determined based on the first probability and the second probability.
[0039] In some examples, multiple natural constant values can be determined based on multiple network scores for multiple categories indicated by the prediction results. A first probability is then determined based on the ratio of a first natural constant value to the sum of the multiple natural constant values, and a second probability is determined based on the ratio of a second natural constant value to the sum of the multiple natural constant values. The first natural constant value is the natural constant value among the multiple natural constant values corresponding to the first category, and the second natural constant value is the natural constant value among the multiple natural constant values corresponding to the second category.
[0040] Optionally, the third image can be input into the network model to obtain the network score predicted by the network model, which is represented as a probability space. in Let i represent the real number space. For example, the first probability and the second probability can be obtained by limiting i to A and B respectively using the following equation (4).
[0041]
[0042] In equation (4), e is the natural constant, and p j Let p represent the j-th dimension in the probability space p. j This represents the network score corresponding to the j-th category in class C. Represents the value of the first natural constant. This represents the value of the second natural constant.
[0043] For example, the first probability can be expressed as The second probability is expressed as The category parameters are obtained through equation (5).
[0044]
[0045] It is understood that, since the prediction results of the network model can indicate the category of the foreground object to some extent, the embodiments of this disclosure can, to a certain extent, achieve loss pruning only for specific target categories by introducing category parameters. Furthermore, it is understood that when performing data augmentation, if the third image does not contain a valid object (such as a foreground object) from the first image, then the category parameters can have a relatively small impact on the network model.
[0046] In some examples, the first weight can be determined based on the initial weight, the random parameter, and the class parameter, and then the second weight can be determined. Alternatively, the first weight can be equal to the weighted sum of the initial weight, the random parameter, and the class parameter, for example, as expressed in equation (6).
[0047] λ=(1-r1-r2)λ0+r1λ r +r2λ s (6)
[0048] In equation (6), r1 and r2 are predetermined hyperparameters between 0 and 1, and λ0 represents the initial weights. It can be understood that if r1 = 1, then λ = λ0. r This means that the first weight is completely random, and consequently the target confidence of the third image is also completely random.
[0049] Optionally, the initial weight λ0 can represent the proportion of the area of the first portion in the first image to that in the third image. In some examples, the initial weight can be the weight of the first image determined based on the cropping blending scheme, which will not be detailed in this disclosure.
[0050] In this way, combined with the aforementioned equation (2), the third label of the third image obtained by mixing a portion of the first image and a portion of the second image can be determined. It can be understood that this scheme is applicable to various situations, even for cases such as... Figure 1 The mixed images 134 or 138 shown can clearly obtain relatively accurate labels.
[0051] In some embodiments of this disclosure, the first image and the second image may be derived from a training set used to train the network model. Optionally, a third image with a third label may be added to the training set used to train the network model. This expands the training set. Furthermore, the network model can be trained based on the expanded training set to obtain an updated network model. In some embodiments, the loss function (expressed as) as shown in equation (7) can be used. Train the network model.
[0052]
[0053] In equation (7), This represents the loss value calculated using either the softmax function or binary cross-entropy with a softened label. Let represent the regularization term, and η represent the hyperparameter used to control the effect of the regularization term.
[0054] In this way, the embodiments of this disclosure, by adding a regularization term to the loss function, can address the problem of insufficient network confidence caused by random sampling based on the beta distribution, thereby making the network's predictions more confident. Optionally, the regularization term can be similar to a hinge loss that penalizes only the positive class. In some examples, the regularization term can be determined by equation (8).
[0055]
[0056] In equation (8), max represents taking the maximum value, and b k Let b represent an element in the binary vector space b, where b = y A ∧y B And b∈{0,1} C , where ∧ represents the bitwise XOR logical operator.
[0057] Based on this, the embodiments of this disclosure can obtain a third image with a third label through data augmentation, and because random parameters in the continuous probability distribution are considered, the third label can be made more consistent with the characteristics of human annotation. Furthermore, this third image can be added to the training set, thereby expanding the training set and updating the network model.
[0058] It should be noted that the data augmentation schemes of the embodiments of this disclosure can be applied to various network models, including but not limited to network models with various architectures such as vision transformers and convolutional neural networks. Furthermore, the schemes of the embodiments of this disclosure are simple, have low computational cost, and can be implemented with just a few lines of code. For example, the following shows pseudo-code for implementing Algorithm 1 of the embodiments of this disclosure:
[0059]
[0060]
[0061] The above combination Figure 2 In this embodiment, the present disclosure provides a data augmentation scheme (called RandMix) that, compared with existing schemes, can improve the accuracy of tags and enhance network capacity and performance.
[0062] Table 1 below shows a comparison of various approaches across multiple dimensions for the open-source image dataset (ImageNet). The network models shown in Table 1 include convolutional networks and transform networks, such as ConNeXt for convolutional networks and Swin, DeiT, and Cross-Covariance Image Transformer (XCiT) for transform networks.
[0063] In Table 1, the number of parameters (#Params) represents the number of parameters in the corresponding network model. Floating-point operations (FLOPs) can be used to measure the model's complexity. An epoch represents the number of operations performed across the entire training dataset. Top-1 accuracy indicates the answer with the highest probability. It should be noted that the baseline in this column (second to last column) of Table 1 is an adjusted baseline obtained through extensive tuning and regularization of existing mixtures, pruned mixtures, etc. The last column represents the probability of the first accuracy after applying this scheme.
[0064] Table 1
[0065]
[0066]
[0067] As can be seen from Table 1 above, the scheme disclosed herein can improve the probability of the first accurate result for each network model.
[0068] Furthermore, the randomization of the label space, achieved through the scheme disclosed herein, can lead to overall improvements. For example... Figure 3A The comparison results for the DeiT-S network model are shown, and it can be seen that the first exact probability is compared with the parameter λ in this disclosure. s , λ r and The relationship between them.
[0069] In addition, such as Figure 3B As shown, the ablation effect of the random ratio on the first exact probability is illustrated for the DeiT-S network model, where r1 = 1 indicates that the target confidence is completely random.
[0070] Furthermore, by evaluating the proposed solution on existing open-source datasets, it demonstrates improved robustness.
[0071] It should be understood that in the embodiments of this disclosure, "first," "second," "third," etc., are only used to indicate that multiple objects may be different, but at the same time, it does not exclude that two objects are the same, and should not be interpreted as any limitation on the embodiments of this disclosure.
[0072] It should also be understood that the manner, situation, category, and division of embodiments in the present disclosure are for the convenience of description only and should not constitute a special limitation. Various manners, categories, situations, and features in the embodiments can be combined with each other where logically consistent.
[0073] It should also be understood that the foregoing is merely to help those skilled in the art better understand the embodiments of this disclosure, and is not intended to limit the scope of the embodiments of this disclosure. Those skilled in the art can make various modifications, variations, or combinations based on the foregoing. Such modifications, variations, or combinations are also within the scope of the embodiments of this disclosure.
[0074] It should also be understood that the above description focuses on highlighting the differences between the various embodiments. Similarities or commonalities can be referenced or learned from each other, and for the sake of brevity, they will not be repeated here.
[0075] Figure 4 The schematic block diagram illustrating an example device 400 according to some embodiments of the present disclosure shows that the device 400 can be implemented by software, hardware, or a combination of both. In some embodiments, the device 400 can be implemented as a terminal device. In embodiments of the present disclosure, the terminal device can be a desktop computer, tablet computer, smartphone, etc., and the present disclosure is not limited thereto.
[0076] like Figure 4 As shown, the apparatus 400 includes an image generation module 410, a parameter determination module 420, a label determination module 430, and an image addition module 440. The image generation module 410 is configured to generate a third image based on a first portion of a first image and a second portion of a second image, wherein the first image has a first label and the second image has a second label. The parameter determination module 420 is configured to obtain random parameters by random sampling from a continuous probability distribution. The label determination module 430 is configured to determine a third label for the third image based on the first label, the second label, and the random parameters. The image addition module 440 is configured to add the third image with the third label to a training set used for training a network model.
[0077] In some embodiments, the parameter determination module 420 may also be configured to: determine a first probability corresponding to a first category indicated by a first label and a second probability corresponding to a second category indicated by a second label based on the prediction results of the network model; and determine category parameters based on the first probability and the second probability.
[0078] In some examples, the label determination module 430 can be configured to determine the third label based on the first label, the second label, a random parameter, and a category parameter.
[0079] In some examples, the label determination module 430 can be configured to determine a first weight and a second weight based on random parameters and category parameters; and to obtain a third label by determining the weighted sum of a first vector corresponding to the first label and a second vector corresponding to the second label, wherein the first vector has a first weight and the second vector has a second weight.
[0080] For example, determining the first weight includes determining the first weight based on a weighted sum of an initial weight, a random parameter, and a category parameter. Optionally, the initial weight represents the proportion of the area of the first portion in the third image.
[0081] In some embodiments, the parameter determination module 420 may be configured to determine a first probability and a second probability by: determining a plurality of natural constant values corresponding to a plurality of network scores for a plurality of categories indicated by the prediction results; determining a first probability based on the proportion of the first natural constant value corresponding to the first category in the sum of the plurality of natural constant values; and determining a second probability based on the proportion of the second natural constant value corresponding to the second category in the sum of the plurality of natural constant values.
[0082] Optionally, the continuous probability distribution is a beta distribution. Optionally, the first, second, and third images have the same size.
[0083] Figure 4 The device 400 can be used to achieve the above-mentioned combination. Figure 2 For the sake of brevity, the process 200 will not be described in detail here.
[0084] The division of modules or units in the embodiments of this disclosure is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods. Furthermore, the functional units in the disclosed embodiments may be integrated into one unit, exist as separate physical entities, or two or more units may be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional unit.
[0085] Figure 5 A block diagram of an example device 500 that can be used to implement embodiments of the present disclosure is shown. It should be understood that... Figure 5 The device 500 shown is merely exemplary and should not be construed as limiting the functionality and scope of the implementation described herein. For example, device 500 can be used to perform the process 200 described above.
[0086] like Figure 5 As shown, device 500 is in the form of a general-purpose computing device. Components of computing device 500 may include, but are not limited to, one or more processors or processing units 510, memory 520, storage devices 530, one or more communication units 540, one or more input devices 550, and one or more output devices 560. Processing unit 510 may be a physical or virtual processor and is capable of performing various processes according to programs stored in memory 520. In a multiprocessor system, multiple processing units execute computer-executable instructions in parallel to improve the parallel processing capability of computing device 500.
[0087] Computing device 500 typically includes multiple computer storage media. Such media can be any available media accessible to computing device 500, including but not limited to volatile and non-volatile media, removable and non-removable media. Memory 520 can be volatile memory (e.g., registers, cache, random access memory (RAM)), non-volatile memory (e.g., read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof). Storage device 530 can be removable or non-removable media and may include machine-readable media, such as flash drives, disks, or any other media capable of storing information and / or data (e.g., training data for training) and accessible within computing device 500.
[0088] The computing device 500 may further include additional removable / non-removable, volatile / non-volatile storage media. Although not explicitly stated... Figure 5 As shown, disk drives for reading from or writing to removable, non-volatile disks (e.g., "floppy disks") and optical disk drives for reading from or writing to removable, non-volatile optical disks can be provided. In these cases, each drive can be connected to a bus (not shown) via one or more data media interfaces. Memory 520 may include computer program product 525 having one or more program modules configured to perform various methods or actions of various implementations of this disclosure.
[0089] The communication unit 540 enables communication with other computing devices via a communication medium. Additionally, the components of the computing device 500 can function as a single computing cluster or multiple computing machines capable of communicating via communication connections. Therefore, the computing device 500 can operate in a networked environment using logical connections to one or more other servers, network personal computers (PCs), or another network node.
[0090] Input device 550 can be one or more input devices, such as a mouse, keyboard, trackball, etc. Output device 560 can be one or more output devices, such as a monitor, speaker, printer, etc. Computing device 500 can also communicate as needed with one or more external devices (not shown) via communication unit 540. These external devices, such as storage devices, display devices, etc., can communicate with one or more devices that enable user interaction with computing device 500, or with any device that enables computing device 500 to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication can be performed via an input / output (I / O) interface (not shown).
[0091] According to an exemplary implementation of this disclosure, a computer-readable storage medium is provided that stores computer-executable instructions thereon, wherein the computer-executable instructions are executed by a processor to implement the methods described above. According to an exemplary implementation of this disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, which are executed by a processor to implement the methods described above. According to an exemplary implementation of this disclosure, a computer program product is provided that stores a computer program thereon, which, when executed by a processor, implements the methods described above.
[0092] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, devices, and computer program products implemented according to this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0093] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0094] Computer-readable program instructions can be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions that execute on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0095] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0096] Various implementations of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed implementations. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described implementations. The terminology used herein is chosen to best explain the principles, practical applications, or improvements to technology in the market, or to enable others skilled in the art to understand the various implementations disclosed herein.
Claims
1. A method for data augmentation, comprising: generating a third image based on a first portion of a first image and a second portion of a second image, the first image having a first label, the second image having a second label; obtaining a random parameter by randomly sampling from a continuous probability distribution; determining a third label of the third image based on the first label, the second label, a class parameter, and the random parameter; adding the third image with the third label to a training set for training a network model; further comprising: determining a first probability corresponding to a first class indicated by the first label and a second probability corresponding to a second class indicated by the second label based on a prediction result of the network model; and determining the class parameter based on the first probability and the second probability, wherein the class parameter is a ratio of the first probability to a sum of the first probability and the second probability.
2. The method of claim 1, wherein determining the third label comprises: determining a first weight and a second weight based on the random parameter and the class parameter; and obtaining the third label by determining a weighted sum of a first vector corresponding to the first label and a second vector corresponding to the second label, wherein the first vector has the first weight and the second vector has the second weight.
3. The method of claim 2, wherein determining the first weight comprises: determining the first weight based on a weighted sum of an initial weight, the random parameter, and the class parameter, wherein the initial weight represents a proportion of an area of the first portion in the third image.
4. The method of claim 1, further comprising determining the first probability and the second probability by: determining a plurality of natural constant values corresponding to a plurality of classes indicated by the prediction result based on a plurality of network scores of the plurality of classes; determining the first probability based on a proportion of a first natural constant value corresponding to the first class in a sum of the plurality of natural constant values; and determining the second probability based on a proportion of a second natural constant value corresponding to the second class in the sum of the plurality of natural constant values.
5. The method of claim 1, wherein the continuous probability distribution is a Beta distribution.
6. The method of any one of claims 1-5, wherein the first image, the second image, and the third image have a same size.
7. An electronic device, comprising: at least one processing unit; at least one memory coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions when executed by the at least one processing unit cause the electronic device to perform acts comprising: generating a third image based on a first portion of a first image and a second portion of a second image, the first image having a first label, the second image having a second label; obtaining a random parameter by randomly sampling from a continuous probability distribution; determine a third label of the third image based on the first label, the second label, a category parameter, and the random parameter; add the third image with the third label to a training set for training a network model; the actions further include: determine a first probability corresponding to a first category indicated by the first label and a second probability corresponding to a second category indicated by the second label based on a prediction result of the network model; and determine the category parameter based on the first probability and the second probability, wherein the category parameter is a ratio of the first probability to a sum of the first probability and the second probability.
8. An apparatus for data augmentation, comprising: an image generation module configured to generate a third image based on a first portion of a first image and a second portion of a second image, the first image having a first label, the second image having a second label; a parameter determination module configured to obtain a random parameter by randomly sampling from a continuous probability distribution; a label determination module configured to determine a third label of the third image based on the first label, the second label, a category parameter, and the random parameter; and an image addition module configured to add the third image with the third label to a training set for training a network model; the parameter determination module is further configured to determine a first probability corresponding to a first category indicated by the first label and a second probability corresponding to a second category indicated by the second label based on a prediction result of the network model; and determine the category parameter based on the first probability and the second probability, wherein the category parameter is a ratio of the first probability to a sum of the first probability and the second probability.
9. A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.
10. A computer program product having stored thereon a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data enhancement method, model training method and analysis method based on face image
CN114387482A