Image segmentation method, device, equipment and storage medium based on artificial intelligence
By adopting a loss function based on prediction uncertainty weighting in the training process of the image segmentation model, the problem of inaccurate image prediction results outside the distribution is solved, and the accuracy and reliability of the model are improved.
Patent Information
- Application Number
- CN202210635568.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-06
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2042-06-06
AI Technical Summary
The existing image segmentation model has inaccurate prediction results when encountering out-of-distribution images and has an excessive confidence in the prediction results, resulting in unreliable model predictions.
The image segmentation loss function based on predictive uncertainty weighting is used to train the image segmentation model, and the training process of the model is improved by using predictive uncertainty as the weighting weight.
This improves the accuracy of image segmentation results and the reliability of model prediction, and avoids the model from having too high confidence in the prediction results.
Smart Images

Figure CN114998588B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an image segmentation method, device, equipment and storage medium based on artificial intelligence. Background Art
[0002] Models trained using deep learning methods have a high probability of being unreliable in the presence of uncertainty, uncertain measurements, and interference. The uncertainty of the model's prediction results is called prediction uncertainty, and the sources of prediction uncertainty can be divided into model uncertainty (also known as epistemic uncertainty) and data uncertainty (also known as arbitrary uncertainty).
[0003] In the field of image segmentation, the loss functions commonly used in existing image segmentation tasks include pixel-by-pixel cross entropy (crossentropy loss), minimized loss function (soft dice loss), mean square error loss function (MSE loss), etc. However, these loss functions only calculate the difference between the predicted value and the true value of the image segmentation model, and do not consider the prediction uncertainty of image segmentation. The image segmentation model trained in this way is likely to be unrobust, which will lead to inaccurate segmentation results when the model encounters out-of-distribution images. Moreover, the current neural network structure is becoming deeper and wider, resulting in models trained with loss functions that only consider the gap between the predicted value and the true value often having too high confidence in the prediction results, which is not conducive to the model making reliable predictions. Summary of the invention
[0004] The main purpose of this application is to provide an image segmentation method, device, equipment and storage medium based on artificial intelligence, aiming to solve the technical problem that the model currently trained with a loss function that only considers the gap between the predicted value and the true value has inaccurate predicted segmentation results when encountering out-of-distribution images, and has too high confidence in the predicted results, which is not conducive to the model making reliable predictions.
[0005] In order to achieve the above-mentioned invention object, the present application proposes an image segmentation method based on artificial intelligence, the method comprising:
[0006] Get the target image;
[0007] Inputting the target image into a preset image segmentation model to perform image segmentation, and obtaining a target image segmentation result corresponding to the target image;
[0008] The image segmentation model is a model trained by using an image segmentation loss function weighted by prediction uncertainty.
[0009] Furthermore, before the step of inputting the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, the step further includes:
[0010] Acquire multiple training samples and initial models, wherein each training sample includes: an image sample set and an image segmentation label, and the image sample set is a set obtained based on the same image;
[0011] The initial model is trained using an image segmentation loss function weighted by prediction uncertainty and each of the training samples until a model training end condition is reached;
[0012] The initial model that meets the model training end condition is used as the image segmentation model.
[0013] Furthermore, before the step of obtaining a plurality of training samples and an initial model, the following steps are included:
[0014] Acquire an image to be analyzed;
[0015] Using each image transformation method combination in a preset image transformation method combination set to transform the image to be analyzed, so as to obtain a transformed image set, wherein the image transformation method combination includes at least one image transformation method;
[0016] Performing a collection process on the image to be analyzed and the transformed image set to obtain the image sample set of the training samples corresponding to the image to be analyzed;
[0017] An image segmentation calibration result corresponding to the image to be analyzed is obtained as the image segmentation label of the training sample corresponding to the image to be analyzed.
[0018] Furthermore, the step of using the image segmentation loss function weighted based on prediction uncertainty and each of the training samples to train the initial model until the model training end condition is reached includes:
[0019] Acquire any one of the training samples as a target sample;
[0020] Input each image sample in the image sample set of the target sample into the initial model for image segmentation to obtain an initial image segmentation result;
[0021] Generating a prediction uncertainty map for each of the initial image segmentation results;
[0022] According to the image source of the target sample in the image sample set being the original image sample, obtaining the initial image segmentation result from each of the initial image segmentation results as the original image segmentation result;
[0023] Calculating a target loss value according to an image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result, and the image segmentation label of the target sample;
[0024] Update the network parameters of the initial model according to the target loss value;
[0025] Repeat the step of obtaining any one of the training samples as a target sample until the model training end condition is reached.
[0026] Furthermore, the step of generating a prediction uncertainty map for each of the initial image segmentation results includes:
[0027] The image samples in the image sample set of the target sample are transformed from the image source as the candidate image set;
[0028] According to each position transformation method identifier in a preset position transformation method identifier set, searching for the image sample from the candidate image set to obtain a hit image set;
[0029] Performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set;
[0030] Searching the image samples that do not exist in the hit image set from the image sample set of the target sample to obtain an image set that does not need to be processed;
[0031] Combining the restored segmentation result set and the initial image segmentation results corresponding to the image set that does not need to be processed to obtain a segmentation result set to be analyzed;
[0032] Generating a variance map for the segmentation result set to be analyzed;
[0033] The variance map is normalized to obtain the prediction uncertainty map.
[0034] Furthermore, the step of performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set includes:
[0035] Taking any image sample in the hit image set as an image to be processed;
[0036] Based on the principle of spatial position restoration, a target inverse transformation method is determined according to a combination of image transformation methods corresponding to the image to be processed;
[0037] Using the target inverse transformation method, the initial image segmentation result corresponding to the image to be processed is subjected to inverse transformation processing in terms of spatial position, so as to obtain a restored segmentation result corresponding to the image to be processed;
[0038] The restored segmentation results are taken as the restored segmentation result set.
[0039] Furthermore, the step of calculating the target loss value according to the image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample includes:
[0040] The target loss value calculation formula L U for:
[0041]
[0042] Wherein, m is the total number of horizontal pixels of the image sample set of the target sample whose image source is the original image sample, k is the total number of vertical pixels of the image sample set of the target sample whose image source is the original image sample, and u ij is the prediction uncertainty in the i-th row and j-th column of the prediction uncertainty graph, l ij is the image segmentation loss value of the pixel point in the i-th row and j-th column calculated according to the original image segmentation result and the image segmentation label of the target sample.
[0043] The present application also proposes an image segmentation device based on artificial intelligence, the device comprising:
[0044] A data acquisition module, used for acquiring a target image;
[0045] The target image segmentation result determination module is used to input the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, wherein the image segmentation model is a model trained using an image segmentation loss function weighted by prediction uncertainty.
[0046] The present application also proposes a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the above methods when executing the computer program.
[0047] The present application also proposes a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.
[0048] The present application discloses an artificial intelligence-based image segmentation method, device, equipment and storage medium, wherein the method inputs the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image; wherein the image segmentation model is a model trained using an image segmentation loss function weighted by prediction uncertainty. By using a model trained using an image segmentation loss function weighted by prediction uncertainty for image segmentation, prediction uncertainty is used as a weighted weight, avoiding the use of a model trained using a loss function that only considers the gap between the predicted value and the true value for image segmentation, thereby improving the accuracy of the predicted segmentation result and the reliability of the model prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A flowchart of an image segmentation method based on artificial intelligence according to an embodiment of the present application;
[0050] Figure 2 This is a schematic block diagram of the structure of an image segmentation device based on artificial intelligence according to an embodiment of the present application;
[0051] Figure 3 A schematic block diagram of the structure of a computer device according to an embodiment of the present application.
[0052] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] Reference Figure 1 In an embodiment of the present application, an image segmentation method based on artificial intelligence is provided, the method comprising:
[0055] S1: Acquire target image;
[0056] S2: Inputting the target image into a preset image segmentation model to perform image segmentation, and obtaining a target image segmentation result corresponding to the target image;
[0057] The image segmentation model is a model trained by using an image segmentation loss function weighted by prediction uncertainty.
[0058] This embodiment uses a model trained by an image segmentation loss function weighted by prediction uncertainty to perform image segmentation, thereby using prediction uncertainty as a weighted weight, avoiding image segmentation using a model trained by a loss function that only considers the gap between the predicted value and the true value, thereby improving the accuracy of the predicted segmentation results and the reliability of the model prediction.
[0059] For S1, the target image may be obtained from a user input, a database, or a third-party application.
[0060] The target image is a digital image that needs to be segmented.
[0061] It is understandable that image segmentation can be to predict one category for each pixel, or to predict multiple categories for each pixel.
[0062] For S2, the target image is input into a preset image segmentation model for image segmentation, and the data obtained by the image segmentation is used as the target image segmentation result corresponding to the target image.
[0063] Among them, the image segmentation model is a model trained by an image segmentation loss function weighted by prediction uncertainty, that is, multiple training samples are used to perform classification prediction for each pixel point on the initial model, and the prediction uncertainty is used as a weighted weight based on the difference between the predicted value and the true value of each pixel point to calculate the target loss value, and the network parameters of the initial model are updated according to the calculated target loss value, thereby avoiding image segmentation using a model trained by a loss function that only considers the difference between the predicted value and the true value, improving the accuracy of the predicted segmentation result, and improving the reliability of the model prediction.
[0064] The initial model is a model obtained based on a neural network.
[0065] Forecast uncertainty is a measure of the uncertainty in a forecast.
[0066] In one embodiment, before the step of inputting the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, the step further includes:
[0067] S21: Acquire multiple training samples and an initial model, wherein each training sample includes: an image sample set and an image segmentation label, and the image sample set is a set obtained based on the same image;
[0068] S22: using the image segmentation loss function weighted based on prediction uncertainty and each of the training samples to train the initial model until a model training end condition is reached;
[0069] S23: Using the initial model that meets the model training end condition as the image segmentation model.
[0070] This embodiment performs model training based on an image segmentation loss function weighted by prediction uncertainty, thereby using prediction uncertainty as the weight of the loss function, allowing the model to learn information related to uncertainty during training, and making the model's prediction results more robust.
[0071] For S21, multiple training samples and initial models input by the user may be obtained, multiple training samples and initial models may be obtained from a database, and multiple training samples and initial models may be obtained from a third-party application.
[0072] Each training sample includes: an image sample set and an image segmentation label. The image sample set includes multiple image samples, and each image sample in the image sample set is a set of images obtained based on the same image. The image segmentation label is the accurate classification result of the original image corresponding to the image sample set.
[0073] For S22, the initial model is trained using each of the training samples. During the training process, a target loss value is calculated using an image segmentation loss function weighted by prediction uncertainty, and the network parameters of the initial model are updated using the calculated target loss value.
[0074] Optionally, the model training end condition refers to the target loss value converging to a preset value.
[0075] For S23, when the model training end condition is reached, it means that the performance of the initial model has met the expected requirements. Therefore, the initial model that meets the model training end condition is directly used as the image segmentation model.
[0076] In one embodiment, before the step of obtaining a plurality of training samples and an initial model, the following steps are included:
[0077] S211: Acquire the image to be analyzed;
[0078] S212: using each image transformation method combination in a preset image transformation method combination set to perform image transformation on the image to be analyzed to obtain a transformed image set, wherein the image transformation method combination includes at least one image transformation method;
[0079] S213: performing a collection process on the image to be analyzed and the transformed image set to obtain the image sample set of the training samples corresponding to the image to be analyzed;
[0080] S214: Obtain an image segmentation calibration result corresponding to the image to be analyzed as the image segmentation label of the training sample corresponding to the image to be analyzed.
[0081] This embodiment uses the image to be analyzed and the transformed image set obtained by image transformation according to the image to be analyzed as the image sample set, thereby enriching the images in the image sample set and providing a basis for calculating the prediction uncertainty; and the image transformation method combination includes at least one image transformation method, which is conducive to further enriching the images in the image sample set and further making the prediction results of the model more robust; it provides a basis for calculating the prediction uncertainty of the model only through the forward propagation of the image segmentation network and image transformation, without adding additional network modules to calculate the uncertainty, and will not increase the number of parameters of the model to make the model bulky.
[0082] For S211 , the image to be analyzed may be obtained from a user input, may be obtained from a database, or may be obtained from a third-party application.
[0083] The image to be analyzed is a digital image.
[0084] For S212, each image transformation method combination in the preset image transformation method combination set is used to perform image transformation on the image to be analyzed, and each image obtained by the transformation is used as a transformed image, and each transformed image is used as a transformed image set. It can be understood that the transformed images correspond to the image transformation method combinations in the image transformation method combination set one by one.
[0085] Among them, the image transformation method combination includes at least one image transformation method, and the value range of the image transformation method includes but is not limited to: mirroring, histogram equalization, Gaussian blur, grayscale, color dithering (randomly adjusting the brightness, contrast, saturation, and hue of the image), illumination transformation, color inversion, sharpness adjustment, and tone separation.
[0086] For S213, the image to be analyzed and the transformed image set are combined, and a set obtained by the combination process is used as the image sample set of the training samples corresponding to the image to be analyzed.
[0087] For S214, the image segmentation calibration result corresponding to the image to be analyzed input by the user is obtained, and the obtained image segmentation calibration result is used as the image segmentation label of the training sample corresponding to the image to be analyzed.
[0088] In one embodiment, the step of using the image segmentation loss function weighted based on prediction uncertainty and each of the training samples to train the initial model until the model training end condition is reached includes:
[0089] S221: Acquire any one of the training samples as a target sample;
[0090] S222: Input each image sample in the image sample set of the target sample into the initial model for image segmentation to obtain an initial image segmentation result;
[0091] S223: generating a prediction uncertainty map for each of the initial image segmentation results;
[0092] S224: According to the image source of the target sample in the image sample set being the original image sample, obtaining the initial image segmentation result from each of the initial image segmentation results as the original image segmentation result;
[0093] S225: Calculating a target loss value according to the image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result, and the image segmentation label of the target sample;
[0094] S226: Update the network parameters of the initial model according to the target loss value;
[0095] S227: Repeat the step of obtaining any one of the training samples as a target sample until the model training end condition is reached.
[0096] This embodiment generates a prediction uncertainty map for each of the initial image segmentation results. The prediction uncertainty of the model can be calculated only through the forward propagation of the image segmentation network and image transformation. There is no need to add additional network modules to calculate the uncertainty, and the number of model parameters will not be increased to make the model bulky. The target loss value is calculated by using an image segmentation loss function weighted by the prediction uncertainty, so that the model can learn information related to uncertainty during the training process, so that the prediction results of the model have higher robustness.
[0097] For S222, each image sample in the image sample set of the target sample is input into the initial model for image segmentation, and the data obtained from the segmentation of each image sample is used as an initial image segmentation result, that is, the initial image segmentation result corresponds one-to-one to the image samples in the image sample set of the target sample.
[0098] For S223, the prediction uncertainty of each pixel point is calculated for each of the initial image segmentation results, and the prediction uncertainties obtained by calculation are combined into a prediction uncertainty map.
[0099] That is, the value of each pixel in the prediction uncertainty map is the prediction uncertainty.
[0100] For S224, according to the image source of the image sample set of the target sample being the original image sample, the initial image segmentation result is obtained from each of the initial image segmentation results, and the obtained initial image segmentation result is used as the original image segmentation result.
[0101] That is to say, the original image segmentation result is the initial image segmentation result corresponding to the image sample that has not been transformed in the image sample set of the target sample.
[0102] For S225, the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample are input into an image segmentation loss function weighted based on prediction uncertainty to calculate a target loss value.
[0103] For S226, the step of updating the network parameters of the initial model according to the target loss value is not described in detail here.
[0104] The updated initial model is used for calculating the prediction uncertainty map and the original image segmentation result next time.
[0105] For S227, the step of obtaining any one of the training samples as the target sample is repeated, that is, steps S221 to S227 are repeated until the model training end condition is met. When the model training end condition is met, the repetition of steps S221 to S227 is stopped, and the performance of the initial model at this time meets the expected requirements.
[0106] In one embodiment, the step of generating a prediction uncertainty map for each of the initial image segmentation results includes:
[0107] S2231: selecting each of the image samples whose image sources are transformed from the image sample set of the target sample as a candidate image set;
[0108] S2232: searching for the image sample from the candidate image set according to each position transformation method identifier in a preset position transformation method identifier set to obtain a hit image set;
[0109] S2233: performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set;
[0110] S2243: searching the image sample set of the target sample for the image sample that does not exist in the hit image set to obtain an image set that does not need to be processed;
[0111] S2235: combining the restored segmentation result set and the initial image segmentation results corresponding to the image set that does not need to be processed to obtain a segmentation result set to be analyzed;
[0112] S2236: generating a variance map for the segmentation result set to be analyzed;
[0113] S2237: Normalize the variance map to obtain the prediction uncertainty map.
[0114] This embodiment first performs an inverse transformation of the spatial position of the initial image segmentation results corresponding to the image samples that have undergone spatial position transformation, then generates a variance map for the restored segmentation result set and the initial image segmentation results corresponding to the image set that does not need to be processed, and finally normalizes the variance map to obtain a prediction uncertainty map. There is no need to add additional network modules to calculate the uncertainty, and the number of model parameters will not be increased to make the model bulky. Moreover, the calculation of the uncertainty does not undergo back propagation, and the training time of the image segmentation model will not be increased.
[0115] For S2231, each of the image samples in the image sample set carries an image source. There is only one value of the image source, and the value range of the image source includes: original and transformed. The original is an image that has not been transformed. The transformed is an image obtained by using a combination of image transformation methods to transform the image.
[0116] Among them, each of the image samples whose image sources are transformed in the image sample set of the target sample is used as a candidate image set, thereby finding all the image samples in the image sample set of the target sample that are obtained based on image transformation.
[0117] For S2232, each of the image samples in the image sample set carries a method identifier, which may be data such as a method name, a method ID, etc. that uniquely identifies an image transformation method combination.
[0118] Among them, according to each position transformation method identifier in a preset position transformation method identifier set, the method identifier is searched from the candidate image set, and each image sample corresponding to the found method identifier in the candidate image set is taken as a hit image, and each hit image is taken as a hit image set.
[0119] The position transformation method identification set includes one or more position transformation method identifications. The position transformation method identification is a method identification of a combination of image transformation methods in which the spatial position is transformed.
[0120] For S2233, an inverse transformation process of the spatial position is performed on each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result, and each restored segmentation result is used as a restored segmentation result set.
[0121] It can be understood that the restored segmentation result and the data at the same position in the image sample set of the target sample whose image source is the original image sample correspond to the same pixel point. For example, the pixel value in the tth row and pth column in the restored segmentation result and the pixel value in the tth row and pth column in the image sample set of the target sample whose image source is the original image sample correspond to the same pixel point.
[0122] For S2243, the image samples that do not exist in the hit image set are searched from the image sample set of the target sample to obtain an image set that does not need to be processed, thereby finding each of the image samples that do not need to be inversely transformed in spatial position.
[0123] For S2235, the restored segmentation result set and each of the initial image segmentation results corresponding to the image set that does not need to be processed are combined, and the set obtained by the combined processing is used as the segmentation result set to be analyzed.
[0124] For S2236, the variance of each pixel point of the segmentation result set to be analyzed is calculated, and the calculated variances are combined into a variance map.
[0125] It can be understood that the variance map and the data at the same position of the image sample whose image source is the original image sample in the image sample set of the target sample correspond to the same pixel point. For example, the pixel value of the t-th row and p-th column in the variance map and the pixel value of the t-th row and p-th column in the image sample set of the target sample whose image source is the original image sample correspond to the same pixel point.
[0126] For S2237, the values of each pixel point in the variance map are normalized, and the data obtained after the normalization process is used as the prediction uncertainty map.
[0127] In one embodiment, the step of performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set includes:
[0128] S22331: taking any image sample in the hit image set as an image to be processed;
[0129] S22332: Based on the principle of spatial position restoration, determine a target inverse transformation method according to a combination of image transformation methods corresponding to the image to be processed;
[0130] S22333: using the target inverse transformation method to perform inverse transformation processing on the spatial position of the initial image segmentation result corresponding to the image to be processed, so as to obtain a restored segmentation result corresponding to the image to be processed;
[0131] S22334: taking each of the restored segmentation results as the restored segmentation result set.
[0132] This embodiment uses an inverse transformation method corresponding to the image transformation to perform inverse transformation processing on the spatial position, so that the restored segmentation result has the same meaning as the pixel points at the same position of the original image sample in the image sample set of the target sample, which provides a basis for the subsequent generation of a prediction uncertainty map.
[0133] For S22332, the principle of spatial position restoration is to transform the image after image transformation into the image before image transformation in terms of spatial position. In other words, the principle of spatial position restoration is to make the image after image transformation correspond to the same pixel point at the same position as the image before image transformation.
[0134] According to each method for spatial position transformation in the image transformation method combination corresponding to the image to be processed, an inverse transformation method is determined, and the determined inverse transformation method is used as a target inverse transformation method. That is, the target inverse transformation method transforms the initial image segmentation result corresponding to the image to be processed into the image before transformation in terms of spatial position.
[0135] For S22333, the target inverse transformation method is used to perform inverse transformation processing on the spatial position of the initial image segmentation result corresponding to the image to be processed, and the data obtained by the inverse transformation processing is used as the restored segmentation result corresponding to the image to be processed.
[0136] It can be understood that by repeatedly executing steps S22331 to S22333, the restored segmentation result corresponding to each image sample in the hit image set can be determined.
[0137] For S22334, each of the restored segmentation results is used as the restored segmentation result set, that is, data at the same position in the restored segmentation result set corresponds to the same pixel point.
[0138] In one embodiment, the step of calculating the target loss value based on the image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample includes:
[0139] The target loss value calculation formula L U for:
[0140]
[0141] Wherein, m is the total number of horizontal pixels of the image sample set of the target sample whose image source is the original image sample, k is the total number of vertical pixels of the image sample set of the target sample whose image source is the original image sample, and u ij is the prediction uncertainty in the i-th row and j-th column of the prediction uncertainty graph, l ij is the image segmentation loss value of the pixel point in the i-th row and j-th column calculated according to the original image segmentation result and the image segmentation label of the target sample.
[0142] This embodiment uses the prediction uncertainty in the prediction uncertainty graph as a weighted weight, so that the model can learn information related to uncertainty during the training process and the prediction results of the model have higher robustness.
[0143] It can be understood that the data at the same position of the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample correspond to the same pixel point.
[0144] Optional, l ij The mean square error loss function is used. In other words, y ij is the value of the pixel at the i-th row and j-th column in the original image segmentation result, is the value of the pixel in the i-th row and j-th column in the image segmentation label of the target sample.
[0145] It is understandable that l ij Other loss functions that calculate loss values pixel by pixel may also be used.
[0146] Reference Figure 2 , the present application also proposes an image segmentation device based on artificial intelligence, the device comprising:
[0147] The data acquisition module 100 is used to acquire a target image;
[0148] The target image segmentation result determination module 200 is used to input the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, wherein the image segmentation model is a model trained using an image segmentation loss function weighted by prediction uncertainty.
[0149] This embodiment uses a model trained by an image segmentation loss function weighted by prediction uncertainty to perform image segmentation, thereby using prediction uncertainty as a weighted weight, avoiding image segmentation using a model trained by a loss function that only considers the gap between the predicted value and the true value, thereby improving the accuracy of the predicted segmentation results and the reliability of the model prediction.
[0150] In one embodiment, the above-mentioned device further includes: a model training module;
[0151] The model training module is used to obtain multiple training samples and an initial model, wherein each training sample includes: an image sample set and an image segmentation label, and the image sample set is a set obtained based on the same image; the initial model is trained using an image segmentation loss function weighted by prediction uncertainty and each training sample until a model training termination condition is met; and the initial model that meets the model training termination condition is used as the image segmentation model.
[0152] In one embodiment, the above-mentioned apparatus includes: a training sample generation module;
[0153] The training sample generation module is used to obtain an image to be analyzed; use each image transformation method combination in a preset image transformation method combination set to perform image transformation on the image to be analyzed to obtain a transformed image set, wherein the image transformation method combination includes at least one image transformation method; perform collection processing on the image to be analyzed and the transformed image set to obtain the image sample set of the training samples corresponding to the image to be analyzed; obtain an image segmentation calibration result corresponding to the image to be analyzed as the image segmentation label of the training sample corresponding to the image to be analyzed.
[0154] In one embodiment, the above-mentioned model training module includes: a training submodule;
[0155] The training submodule is used to obtain any one of the training samples as a target sample; input each image sample in the image sample set of the target sample into the initial model for image segmentation to obtain an initial image segmentation result; generate a prediction uncertainty map for each of the initial image segmentation results; obtain the initial image segmentation result from each of the initial image segmentation results as the original image segmentation result based on the image source of the image in the image sample set of the target sample being the original image sample; calculate the target loss value based on the image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample; update the network parameters of the initial model according to the target loss value; and repeat the step of obtaining any one of the training samples as the target sample until the model training end condition is reached.
[0156] In one embodiment, the training submodule includes: a prediction uncertainty map generation unit;
[0157] The prediction uncertainty map generating unit is used to select each of the image samples whose image sources are transformed from the image sample set of the target sample as a candidate image set; search the image samples from the candidate image set according to each position transformation method identifier in a preset position transformation method identifier set to obtain a hit image set; perform inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set; search the image samples that do not exist in the hit image set from the image sample set of the target sample to obtain an image set that does not require processing; combine the restored segmentation result set and each of the initial image segmentation results corresponding to the image set that does not require processing to obtain a segmentation result set to be analyzed; generate a variance map for the segmentation result set to be analyzed; and normalize the variance map to obtain the prediction uncertainty map.
[0158] In one embodiment, the prediction uncertainty map generating unit comprises: a restored segmentation result set determining subunit;
[0159] The restored segmentation result set determination subunit uses any image sample in the hit image set as the image to be processed; based on the principle of spatial position restoration, determines the target inverse transformation method according to the image transformation method combination corresponding to the image to be processed; uses the target inverse transformation method to perform inverse transformation processing on the spatial position of the initial image segmentation result corresponding to the image to be processed, so as to obtain the restored segmentation result corresponding to the image to be processed; and uses each of the restored segmentation results as the restored segmentation result set.
[0160] In one embodiment, the step of calculating the target loss value based on the image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample includes:
[0161] The target loss value calculation formula L U for:
[0162]
[0163] Wherein, m is the total number of horizontal pixels of the image sample set of the target sample whose image source is the original image sample, k is the total number of vertical pixels of the image sample set of the target sample whose image source is the original image sample, and u ij is the prediction uncertainty in the i-th row and j-th column of the prediction uncertainty graph, l ij is the image segmentation loss value of the pixel point in the i-th row and j-th column calculated according to the original image segmentation result and the image segmentation label of the target sample.
[0164] Reference Figure 3 In an embodiment of the present application, a computer device is also provided. The computer device may be a server, and its internal structure may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor designed by the computer is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as an image segmentation method based on artificial intelligence. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an image segmentation method based on artificial intelligence is implemented. The image segmentation method based on artificial intelligence includes: acquiring a target image; inputting the target image into a preset image segmentation model for image segmentation, and obtaining a target image segmentation result corresponding to the target image; wherein the image segmentation model is a model trained using an image segmentation loss function weighted based on prediction uncertainty.
[0165] This embodiment uses a model trained by an image segmentation loss function weighted by prediction uncertainty to perform image segmentation, thereby using prediction uncertainty as a weighted weight, avoiding image segmentation using a model trained by a loss function that only considers the gap between the predicted value and the true value, thereby improving the accuracy of the predicted segmentation results and the reliability of the model prediction.
[0166] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, an artificial intelligence-based image segmentation method is implemented, comprising the steps of: acquiring a target image; inputting the target image into a preset image segmentation model for image segmentation, and obtaining a target image segmentation result corresponding to the target image; wherein the image segmentation model is a model trained using an image segmentation loss function weighted by prediction uncertainty.
[0167] The above-mentioned artificial intelligence-based image segmentation method performs image segmentation by adopting a model trained by an image segmentation loss function weighted by prediction uncertainty, thereby realizing the use of prediction uncertainty as a weighted weight, avoiding the use of a model trained by a loss function that only considers the gap between the predicted value and the true value for image segmentation, thereby improving the accuracy of the predicted segmentation results and the reliability of the model prediction.
[0168] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0169] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, device, article or method including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, device, article or method. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, device, article or method including the element.
[0170] The above description is only a preferred embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. An image segmentation method based on artificial intelligence, characterized in that: The method comprises: Get the target image; Inputting the target image into a preset image segmentation model to perform image segmentation, and obtaining a target image segmentation result corresponding to the target image; Wherein, the image segmentation model is a model trained by using an image segmentation loss function weighted based on prediction uncertainty; Before the step of inputting the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, the step further includes: Acquire multiple training samples and initial models, wherein each training sample includes: an image sample set and an image segmentation label, and the image sample set is a set obtained based on the same image; The initial model is trained using an image segmentation loss function weighted by prediction uncertainty and each of the training samples until a model training end condition is reached; Using the initial model that meets the model training end condition as the image segmentation model; The step of using the image segmentation loss function weighted based on prediction uncertainty and each of the training samples to train the initial model until the model training end condition is reached includes: Acquire any one of the training samples as a target sample; Input each image sample in the image sample set of the target sample into the initial model for image segmentation to obtain an initial image segmentation result; Generating a prediction uncertainty map for each of the initial image segmentation results; According to the image source of the target sample in the image sample set being the original image sample, obtaining the initial image segmentation result from each of the initial image segmentation results as the original image segmentation result; Calculating a target loss value according to an image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result, and the image segmentation label of the target sample; Update the network parameters of the initial model according to the target loss value; Repeat the step of obtaining any one of the training samples as a target sample until the model training end condition is met; The step of generating a prediction uncertainty map for each of the initial image segmentation results comprises: The image samples in the image sample set of the target sample are transformed from the image source as the candidate image set; According to each position transformation method identifier in a preset position transformation method identifier set, searching for the image sample from the candidate image set to obtain a hit image set; Performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set; Searching the image samples that do not exist in the hit image set from the image sample set of the target sample to obtain an image set that does not need to be processed; Combining the restored segmentation result set and the initial image segmentation results corresponding to the image set that does not need to be processed to obtain a segmentation result set to be analyzed; Generating a variance map for the segmentation result set to be analyzed; The variance map is normalized to obtain the prediction uncertainty map.
2. The image segmentation method based on artificial intelligence according to claim 1, characterized in that: Before the step of obtaining a plurality of training samples and an initial model, the method includes: Acquire an image to be analyzed; Using each image transformation method combination in a preset image transformation method combination set to transform the image to be analyzed, so as to obtain a transformed image set, wherein the image transformation method combination includes at least one image transformation method; Performing a collection process on the image to be analyzed and the transformed image set to obtain the image sample set of the training samples corresponding to the image to be analyzed; An image segmentation calibration result corresponding to the image to be analyzed is obtained as the image segmentation label of the training sample corresponding to the image to be analyzed.
3. The image segmentation method based on artificial intelligence according to claim 1, characterized in that: The step of performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set includes: Taking any image sample in the hit image set as an image to be processed; Based on the principle of spatial position restoration, a target inverse transformation method is determined according to a combination of image transformation methods corresponding to the image to be processed; Using the target inverse transformation method, the initial image segmentation result corresponding to the image to be processed is subjected to inverse transformation processing in terms of spatial position, so as to obtain a restored segmentation result corresponding to the image to be processed; The restored segmentation results are taken as the restored segmentation result set.
4. The image segmentation method based on artificial intelligence according to claim 1, characterized in that: The step of calculating the target loss value according to the image segmentation loss function weighted based on prediction uncertainty, the prediction uncertainty map, the original image segmentation result and the image segmentation label of the target sample comprises: The target loss value calculation formula L U for: Wherein, m is the total number of horizontal pixels of the image sample set of the target sample whose image source is the original image sample, k is the total number of vertical pixels of the image sample set of the target sample whose image source is the original image sample, and u ij is the prediction uncertainty in the i-th row and j-th column of the prediction uncertainty graph, l ij is the image segmentation loss value of the pixel point in the i-th row and j-th column calculated according to the original image segmentation result and the image segmentation label of the target sample.
5. An image segmentation device based on artificial intelligence, characterized in that: The device comprises: A data acquisition module, used for acquiring a target image; A target image segmentation result determination module is used to input the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, wherein the image segmentation model is a model trained by using an image segmentation loss function weighted by prediction uncertainty; Before the step of inputting the target image into a preset image segmentation model for image segmentation to obtain a target image segmentation result corresponding to the target image, the step further includes: Acquire multiple training samples and initial models, wherein each training sample includes: an image sample set and an image segmentation label, and the image sample set is a set obtained based on the same image; The initial model is trained using an image segmentation loss function weighted by prediction uncertainty and each of the training samples until a model training end condition is reached; Using the initial model that meets the model training end condition as the image segmentation model; The step of using the image segmentation loss function weighted based on prediction uncertainty and each of the training samples to train the initial model until the model training end condition is reached includes: Acquire any one of the training samples as a target sample; Input each image sample in the image sample set of the target sample into the initial model for image segmentation to obtain an initial image segmentation result; Generating a prediction uncertainty map for each of the initial image segmentation results; According to the image source of the target sample in the image sample set being the original image sample, obtaining the initial image segmentation result from each of the initial image segmentation results as the original image segmentation result; Calculating a target loss value according to an image segmentation loss function weighted by prediction uncertainty, the prediction uncertainty map, the original image segmentation result, and the image segmentation label of the target sample; Update the network parameters of the initial model according to the target loss value; Repeat the step of obtaining any one of the training samples as a target sample until the model training end condition is met; The step of generating a prediction uncertainty map for each of the initial image segmentation results comprises: The image samples in the image sample set of the target sample are transformed from the image source as the candidate image set; According to each position transformation method identifier in a preset position transformation method identifier set, searching for the image sample from the candidate image set to obtain a hit image set; Performing inverse transformation processing on the spatial position of each of the initial image segmentation results corresponding to the hit image set to obtain a restored segmentation result set; Searching the image samples that do not exist in the hit image set from the image sample set of the target sample to obtain an image set that does not need to be processed; Combining the restored segmentation result set and the initial image segmentation results corresponding to the image set that does not need to be processed to obtain a segmentation result set to be analyzed; Generating a variance map for the segmentation result set to be analyzed; The variance map is normalized to obtain the prediction uncertainty map.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Image classification method and device and readable storage medium
CN111651626A
Model training method and device and image segmentation method and device
CN113256651A