An image risk control method, device, medium and electronic equipment
By uniformly extracting multi-dimensional features from image data and using a comprehensive loss function to train the image risk control model, the problems of high training cost and conflicting outputs of the image risk control model are solved, and a more accurate image risk control effect is achieved.
Patent Information
- Application Number
- CN202411273219.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-09-11
AI Technical Summary
In existing technologies, image risk control models have high training costs and are prone to conflicting outputs from different tasks, resulting in poor risk control performance. This is especially true when it comes to overall image risk classification and target detection, where they are difficult to perform simultaneously and accurately.
By uniformly extracting multi-dimensional size features from image data, combining object detection and image classification layers, and using a comprehensive loss function to train the image risk control model, the loss of different model branch layers is fused to avoid conflicting task results. Pseudo-labeled samples and self-supervised learning are used to improve the model training efficiency and accuracy.
It significantly improves the accuracy of image risk control and the effectiveness of content risk prevention, avoids output conflicts between different tasks, and enhances the robustness and generalization ability of the model.
Smart Images

Figure CN119516239B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and particularly relates to an image risk control method and device, a medium and an electronic equipment. BACKGROUND
[0002] At present, with the rapid development of the Internet, the number of user-generated content has increased dramatically, which includes but is not limited to images, videos, audios and texts. In order to ensure the security and compliance of the network environment, it is particularly important to control the risks of these contents.
[0003] In the prior art, there are various risks, and these risks need to be accurately classified and accurately detected. For example, when controlling the risks of images, it is necessary to classify the risks of images and to identify the risks of targets in images. Because there are various risk control requirements, different models are usually trained to meet the various risk control requirements when controlling the risks.
[0004] However, due to the high cost of manual annotation, and even the labeled data may have noise, the cost of training different models alone is high, and the output results of the models may contradict each other, resulting in poor risk control effect. For example, the target detection shows that there is a dangerous object, but the image classification result shows that the user behavior in the image is risky.
[0005] In order to solve the above problems, the present application provides an image risk control method which can significantly improve the effect of content risk control.
[0006] Due to the drawbacks of manual annotation, most of the data that can be used for training is unlabeled data, and even the labeled data may have noise. This brings challenges to model training, because traditional supervised learning methods cannot effectively utilize unlabeled data, and the noise in labeled data will affect the accuracy of the model. SUMMARY
[0007] The embodiment of the present application provides an image risk control method, which extracts image features of multiple dimensions of a sample, so that the image overall classification prediction and the target detection in the image can be performed simultaneously through different model branch layers. During the training, the losses of different model branch layers are fused into a comprehensive loss, so that the results of target detection and image overall classification can be referenced to each other during the training of the model, and the situation that the results of different tasks contradict each other is avoided. Therefore, the image risk control model trained based on the above process can give more accurate risk control results, and the effect of content risk control can be significantly improved. The method comprises the following steps:
[0008] determine a training sample constructed based on image data and an image risk control model to be trained, the image risk control model comprising a feature extraction layer, a target detection layer, and an image classification layer;
[0009] input the training sample into the image risk control model to be trained, and determine image features of multiple dimensions of the image data through the feature extraction layer of the image risk control model;
[0010] input the image features of multiple dimensions into the target detection layer and the image classification layer respectively, determine a predicted bounding box and a bounding box classification output by the target detection layer, and determine an image classification result output by the image classification layer;
[0011] determine a comprehensive loss according to the output of the target detection layer, the output of the image classification layer, and the annotation of the training sample, train the image risk control model based on the comprehensive loss, and use the trained image risk control model to perform an image risk control task, input an image to be controlled into the image risk control model, and determine a risk target object and an image risk type of the image to be controlled according to a bounding box, a bounding box classification, and an image classification result output by the image risk control model, so as to perform risk control.
[0012] Further, in some embodiments,
[0013] the target detection layer comprises a feature fusion subnetwork, a bounding box prediction subnetwork, and a bounding box classification subnetwork;
[0014] input the image features of multiple dimensions into the target detection layer, and determine a predicted bounding box and a bounding box classification output by the target detection layer, specifically including:
[0015] input the image features of multiple dimensions into the target detection layer, and determine each fused image feature through the feature fusion subnetwork of the target detection layer;
[0016] input each fused image feature into the bounding box prediction subnetwork of the target detection layer to determine a predicted bounding box of each target of the training sample, and input each fused image feature into the bounding box classification subnetwork of the target detection layer to determine a risk classification result of each predicted bounding box as a bounding box classification.
[0017] Further, in some embodiments,
[0018] determine a comprehensive loss according to the output of the target detection layer, the output of the image classification layer, and the annotation of the training sample, specifically including:
[0019] determine an image risk classification of the training sample according to the annotation of the training sample;
[0020] determine an image classification loss according to the image classification result output by the image classification layer and a difference between the risk classification of the image of the training sample;
[0021] determine a bounding box of a risk target in the training sample and a risk classification of the risk target according to the label of the training sample;
[0022] determine a target classification loss according to a difference between the prediction bounding box output by the target detection layer and the bounding box of the risk target in the training sample, and a difference between the bounding box classification output by the target detection layer and the risk classification of the risk target in the training sample;
[0023] determine a comprehensive loss according to the image classification loss and the target classification loss.
[0024] Further, in some embodiments,
[0025] determine the training sample constructed based on the image data, specifically comprising:
[0026] obtain labeled image data as labeled samples and obtain unlabeled image data as unlabeled samples;
[0027] determine a comprehensive loss according to the output of the target detection layer, the output of the image classification layer and the label of the training sample, specifically comprising:
[0028] train the image risk control model in an iterative manner, and for each iteration process, determine the output of the image risk control model for the unlabeled samples in the last iteration process of the iteration process, and a confidence degree of the output;
[0029] determine a pseudo-labeled sample from the unlabeled samples according to the confidence degree and a confidence degree expected threshold of the iteration process, and take the output of the pseudo-labeled sample in the last iteration process as a label;
[0030] in the iteration process, determine a comprehensive loss according to the output of the target detection layer, the output of the image classification layer and the corresponding label based on the determined pseudo-labeled sample and the labeled sample.
[0031] Further, in some embodiments,
[0032] Before determining a pseudo-labeled sample from the unlabeled samples according to the confidence degree and a confidence degree expected threshold of the iteration process, the method further comprises:
[0033] determine the number of unlabeled samples of the image risk control model used for training in the last iteration process of the iteration process.
[0034] According to the confidence of the output of the image risk control model for the unannotated sample in the last iteration process, a confidence reference value is determined;
[0035] According to the number and the confidence reference value, a confidence expectation threshold of the iteration process is determined.
[0036] Further, in some embodiments,
[0037] Based on the determined pseudo-annotated sample and the annotated sample, a comprehensive loss is determined according to the output of the target detection layer, the output of the image classification layer, and the corresponding annotation, specifically including:
[0038] Based on the determined pseudo-annotated sample, a function value of a cross-entropy loss function is determined according to the output of the target detection layer, the output of the image classification layer, and the annotation of the pseudo-annotated sample;
[0039] Based on the annotated sample, a function value of a symmetric cross-entropy loss function is determined according to the output of the target detection layer, the output of the image classification layer, and the annotation of the annotated sample;
[0040] According to the function value of the cross-entropy loss function and the function value of the symmetric cross-entropy loss function, a comprehensive loss function value is determined, and based on the comprehensive loss function value, the model parameters of the image risk control model are adjusted.
[0041] Further, in some embodiments,
[0042] Based on the annotated sample, a function value of a symmetric cross-entropy loss function is determined according to the output of the target detection layer, the output of the image classification layer, and the annotation of the annotated sample, specifically including:
[0043] Based on the annotation of the annotated sample, a positive sample and a negative sample corresponding to the annotated sample are determined;
[0044] According to a first difference between the output of the image risk control model for the positive sample and the annotation, a first function value is determined, and the first difference is positively correlated with the first function value;
[0045] According to a second difference between the output of the image risk control model for the positive sample and the output of the image risk control model for the negative sample, a second function value is determined, and the second difference is negatively correlated with the second function value;
[0046] According to the first function value and the second function value, a function value of a symmetric cross-entropy loss function is determined.
[0047] Further, in some embodiments,
[0048] The method further comprises:
[0049] For each training sample, according to the label of the training sample, determining other samples whose risk classification of the risk target is consistent with the training sample;
[0050] Taking the training sample as an anchor sample, determining a reference sample according to the determined other training samples, and combining to obtain at least one sample combination corresponding to the training sample;
[0051] Inputting the training sample into the image risk control model to be trained, and determining the image features of multiple dimensions of the image data through the feature extraction layer of the image risk control model, specifically comprising:
[0052] Inputting the sample combination into the image risk control model to be trained, and respectively determining the image features of multiple dimensions of the anchor sample and the reference sample in the sample combination through the feature extraction layer of the image risk control model;
[0053] Inputting the image features of multiple dimensions into the target detection layer to determine the predicted detection frame and the detection frame classification output by the target detection layer, specifically comprising:
[0054] Inputting the reference sample in the sample combination into the reference subnetwork of the target detection layer to determine the common features of the significant target in the reference sample;
[0055] Inputting the anchor sample in the sample combination and the common features into the segmentation subnetwork of the target detection layer to determine the predicted detection frame and the detection frame classification output as the predicted detection frame and the detection frame classification of the training sample.
[0056] The embodiments of the present specification also provide an image risk control device, and the device comprises:
[0057] The preparation module determines the training sample constructed based on the image data and the image risk control model to be trained, and the image risk control model is composed of a feature extraction layer, a target detection layer, and an image classification layer;
[0058] The feature extraction module inputs the training sample into the image risk control model to be trained, and determines the image features of multiple dimensions of the image data through the feature extraction layer of the image risk control model;
[0059] The classification module inputs the image features of multiple dimensions into the target detection layer and the image classification layer respectively, determines the predicted detection frame and the detection frame classification output by the target detection layer, and determines the image classification result output by the image classification layer;
[0060] The training and risk control module determines a comprehensive loss according to the output of the target detection layer, the output of the image classification layer, and the label of the training sample, and trains the image risk control model based on the comprehensive loss. The image risk control model obtained through the training is used to perform an image risk control task. A to-be-controlled image is input into the image risk control model, and a risk target object and an image risk type of the to-be-controlled image are determined according to a detection frame, a detection frame classification, and an image classification result output by the image risk control model, so as to perform risk control.
[0061] The embodiments of the present specification also provide a computer program product, which stores at least one instruction suitable for being loaded by a processor and executing the method steps described above.
[0062] The embodiments of the present specification also provide a storage medium, which stores a computer program suitable for being loaded by a processor and executing the steps of the method described above.
[0063] The embodiments of the present specification also provide an electronic device, comprising a processor and a memory; wherein the memory stores a computer program suitable for being loaded by the processor and executing the steps of the method described above.
[0064] In the embodiments of the present specification, by uniformly extracting image features of multiple dimensions of samples, the image overall classification prediction and the target object detection in the image can be simultaneously performed through different model branch layers. Since the losses of different model branch layers are fused into a comprehensive loss during training, the results of target object detection and image overall classification can be mutually referenced during the training model process, so that the situation that the results of different tasks conflict with each other during training of different models performing different tasks is avoided. Therefore, when the image risk control model trained based on the process performs risk control, the risk control result is more accurate, and the effect of content risk prevention and control can be significantly improved. BRIEF DESCRIPTION OF DRAWINGS
[0065] Figure 1 A flowchart of an image risk control method is provided for the embodiments of the present specification;
[0066] Figure 2 An image risk control model structure diagram is provided for the embodiments of the present specification;
[0067] Figure 3 A target detection layer structure diagram is provided for the embodiments of the present specification;
[0068] Figure 4 An image risk control device structure diagram is provided for the embodiments of the present specification;
[0069] Figure 5 A structural schematic diagram of an electronic device is provided for an embodiment of the present specification. DETAILED DESCRIPTION
[0070] For the purpose, technical solutions and advantages of the present specification to be clearer, the technical solutions of the present specification will be described clearly and completely below in combination with specific embodiments of the present specification and corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present specification, rather than all the embodiments. Based on the embodiments in the present specification, all other embodiments obtained by a person of ordinary skill in the art without creative labor shall fall within the scope of protection of the present specification.
[0071] Generally, in order to ensure the security and compliance of the network environment, in view of the current situation of the sharp increase in the quantity of user-generated content, the user-generated content needs to be controlled. As for the image control scene, since the image contains more content and is usually more complex, there is strong concealment. Therefore, whether the image as a whole is risky and whether there is a risky target in the image are both needed to be identified and controlled. For example, the image itself as a whole does not seem to have any problem, but it contains risky content in the corner of the image. If the image as a whole is controlled, this hidden risky content may be ignored.
[0072] Therefore, for different types of image control, it is usually necessary to establish a large number of training samples for each type of image control task to train the control model. However, due to the high cost of manual annotation, and even the labeled data may have noise, the cost of training different models separately is high, and the output results of the models may conflict, resulting in poor control effect.
[0073] Based on this, please refer to Figure 1 A flowchart of an image control method is provided for an embodiment of the present specification. The following will be described in detail with respect to the flowchart shown in Figure 1 The image control method can specifically include the following steps:
[0074] S100: Determine the training samples constructed based on image data and the image control model to be trained, the image control model being composed of a feature extraction layer, a target detection layer and an image classification layer.
[0075] In one or more embodiments of the present specification, for the convenience of description, the image control process of a single entity server is taken as an example for subsequent description. Of course, the server can be a device or a distributed system composed of multiple devices, and the present specification does not limit this.
[0076] In one or more embodiments of the present specification, the server can first determine a training sample constructed based on image data and an image risk control model to be trained. Moreover, in order to solve the problem of the risk control results contradicting each other when training multiple models in the prior art, the training sample needs to be annotated for different tasks in the embodiments of the present specification. In the embodiments of the present specification, the image risk control model to be trained is used for at least image classification and target detection, so as to determine the risk control result of the image based on the image risk classification obtained by image classification and the type of risk target in the image obtained by target detection.
[0077] Specifically, the server can first determine each training sample. For each training sample, the annotation of the training sample includes: image risk classification of the training sample, bounding box of a risk target in the training sample, and risk classification of the risk target.
[0078] The image risk classification of the training sample refers to which risk type the training sample corresponds to for a preset image risk type. The bounding box of the risk target in the training sample refers to the position of the risk target in the training sample. The risk classification of the risk target refers to the risk classification of the risk target. It should be noted that, in general, the image risk classification of the image matches the risk classification of the risk target in the image. For example, the image risk classification includes A, B, and C. In the A-type image risk classification, it is generally considered that the corresponding target exists, and the image as a whole belongs to the A-type image risk classification. However, in some cases, the image can also include a target corresponding to other image risk classifications, and therefore, the image risk classification and the target detection result need to be considered comprehensively to determine the final risk control result.
[0079] In addition, the server can also determine an image risk control model to be trained, which is composed of a feature extraction layer, a target detection layer, and an image classification layer.
[0080] S102: inputting the training sample into the image risk control model to be trained, and determining the image features of multiple dimensions of the image data through the feature extraction layer of the image risk control model.
[0081] In one or more embodiments of the present specification, after the server determines the training sample, the image features of multiple dimensions of the image data can be determined by inputting the training sample into the feature extraction layer of the image risk control model. The feature extraction layer is a network composed of a series of convolution layers and pooling layers, and is used to extract image features of an input image.
[0082] Specifically, the feature extraction layer is a pyramid structure, which is used to extract a feature pyramid of the input image. Therefore, for each training sample, the feature extraction layer can output image features of multiple dimensions corresponding to the training sample.
[0083] That is, a series of image features with different resolutions are extracted through each layer to capture multi-scale information in the image. Generally, the image features extracted by higher layers contain more abstract features. In some architectures, the features can also be refined from the top layer to the bottom layer, which helps to enhance the detection ability of small objects. Since different size targets may have different forms in the image, the feature pyramid can help the image risk control model better identify targets of different scales. And for targets of different sizes, the feature pyramid provides more context information, making the image risk control model more robust and less affected by changes in target size. Moreover, since different image processing tasks have different requirements for image features, in order to support the image risk control model to realize image risk classification and target detection at the same time, the image features of different dimensions extracted by the feature extraction layer make it more convenient for other layers of the image risk control model to realize different image processing tasks.
[0084] Figure 2 The structure diagram of the image risk control model provided by the embodiments of the present specification can be seen that the image risk control model is composed of a feature extraction layer, a target detection layer and an image classification layer, wherein the feature extraction layer is a pyramid structure, which extracts image features of different dimensions, and the target detection layer and the image classification layer are two parallel network structures, which are respectively used for image risk classification and target detection.
[0085] S104: input the image features of multiple dimensions into the target detection layer and the image classification layer respectively, determine the predicted detection box and the detection box classification output by the target detection layer, and determine the image classification result output by the image classification layer.
[0086] In one or more embodiments of the present specification, after the server obtains the image features of multiple dimensions of the training sample, the server can determine the target detection result and the image classification result through the target detection layer and the image classification layer of the image risk control model respectively. Among them, the target detection layer is used to determine the predicted detection box and the detection box classification of the training sample, that is, the position of the target object with risk predicted to exist in the image data and the risk type of the target object with risk. And the image classification layer is used to determine the image classification result of the training sample, that is, considering the image data as a whole, the risk type of the image data.
[0087] Specifically, in the embodiments of the present disclosure, the target detection layer can include a feature fusion subnetwork, a bounding box prediction subnetwork, and a bounding box classification subnetwork. The server can input image features of multiple dimensions into the target detection layer, determine each fused image feature through the feature fusion subnetwork of the target detection layer, input the each fused image feature into the bounding box prediction subnetwork of the target detection layer to determine a predicted bounding box of each target of the training sample, and input the each fused image feature into the bounding box classification subnetwork of the target detection layer to determine a risk classification result of the each predicted bounding box as a bounding box classification result.
[0088] Similarly, for the image classification layer, the image classification layer can also include a feature fusion subnetwork and a classifier. The server can input image features of multiple dimensions into the image classification layer, determine each fused image feature through the feature fusion subnetwork of the image classification layer, and input the each fused image feature into the classifier of the image classification layer to determine an image classification result of the training sample.
[0089] S106: According to the output of the target detection layer, the output of the image classification layer, and the label of the training sample, a comprehensive loss is determined, and the image risk control model is trained based on the comprehensive loss. The trained image risk control model is used to perform an image risk control task. A to-be-controlled image is input into the image risk control model, and according to the detection box, the detection box classification, and the image classification result output by the image risk control model, a risk target object and an image risk type of the to-be-controlled image are determined for risk control.
[0090] In one or more embodiments of the present disclosure, after the output of the target detection layer and the output of the image classification layer are determined, the server can determine a comprehensive loss according to the label of the training sample, and adjust the model parameters of the image risk control model with the minimum comprehensive loss as an optimization target to train the image risk control model. Since both the image classification task and the target detection task are based on the comprehensive loss determined by the two tasks to determine the gradient of the model parameters when training the image risk control model. Moreover, both tasks are based on image features extracted by the same feature extraction layer for prediction, thus avoiding the situation that the output results contradict each other. The image risk control model can be used to output matching target detection results and image classification results based on one input image data.
[0091] Specifically, the server can determine an image risk classification of the training sample according to the label of the training sample, and determine an image classification loss according to a difference between an image classification result output by the image classification layer and the image risk classification of the training sample. In addition, the server can also determine a bounding box of a risk target in the training sample and a risk classification of the risk target according to the label of the training sample, and determine a target classification loss according to a difference between a predicted bounding box output by the target detection layer and the bounding box of the risk target in the training sample, and a difference between a bounding box classification output by the target detection layer and the risk classification of the risk target in the training sample. Finally, the server can determine a comprehensive loss according to the image classification loss and the target classification loss.
[0092] The image classification loss and the target classification loss can be determined based on a cross-entropy loss function according to a model output result and a label of a training sample, and a comprehensive loss function value can be determined according to two function values. The model parameters of the image risk control model are adjusted based on the comprehensive loss function value. In general, the closer the model output is to the label, the more accurate the model output is. Therefore, the minimum comprehensive loss function value is usually used as an optimization target to determine the adjustment gradient of the model parameters.
[0093] Optionally, after the server trains the image risk control model, the image risk control model can be used to perform risk control on image data. Specifically, for image data in user production content, the business server can take the image data as a to-be-controlled image. Then the trained image risk control model is called to input the to-be-controlled image into the image risk control model. Then the detection box, the detection box classification and the image classification result output by the two layers of the image risk control model are received to determine the risk category of the target object in the to-be-controlled image and the image classification result of the to-be-controlled image. Finally, based on the risk target object and the image risk type of the to-be-controlled image, it is determined that the to-be-controlled image belongs to which risk type and is to be controlled in which way.
[0094] In the embodiments of the present specification, the specific way of performing risk control is not limited, but as mentioned above, the risk control result determined by the image risk control model is not contradictory, which is beneficial to accurately performing risk control. For example, when the to-be-controlled image is determined to belong to a low-risk category based on the image classification result, the identified risk target object can be covered so that the risk-free part of the to-be-controlled image can be displayed to other users. Or when the image classification result determines that the to-be-controlled image belongs to a high-risk category, the entire image is prohibited from being displayed, and the like.
[0095] Based on Figure 1The image risk control method shown can extract image features of multiple dimensions of samples uniformly, so that image overall classification prediction and target object detection in the image can be performed simultaneously through different model branch layers, and because the losses of different model branch layers are fused into a comprehensive loss during training, the results of target object detection and image overall classification can be referenced to each other during model training, so that the situation that the results of different tasks contradict each other during training of different models to perform different tasks is avoided. Therefore, when the image risk control model trained based on the process is used for risk control, the risk control result is more accurate, and the effect of content risk prevention and control can be significantly improved.
[0096] In addition, because the difficulty of manually labeling training samples for multiple tasks is higher than that of manually labeling training samples for a single task, and in order to ensure that the output results of the trained image risk control model do not contradict each other, the multi-task labeling of the training samples also needs to be non-contradictory, which leads to higher requirements for manual labeling and greater dependence on expert experience, so that the labeling accuracy is inevitably affected.
[0097] It can be seen that in the scenario provided in the specification, the labeling of training samples is more difficult than in common scenarios, so under the same labor cost and time cost, the number of training samples obtained by labeling is smaller. In order to avoid the problem of insufficient training caused by small samples, or falling into a local optimal solution, in one or more embodiments of the specification, in step S100, the server can also obtain labeled image data as labeled samples and obtain unlabeled image data as unlabeled samples. That is, in the training of the image risk control model in the specification, a self-supervised manner can be used.
[0098] Then, during the iterative training of the image risk control model, the server can determine the unlabeled samples that can be used for self-supervision from the unlabeled samples before each iteration process starts, and use them to train the image risk control model.
[0099] Specifically, the server can determine, for each iteration process, the output of the image risk control model for the unlabeled samples in the last iteration process of the iteration process, and determine the confidence of the output. That is, for each unlabeled sample, the server can also input the unlabeled sample into the image risk control model to be trained, and determine the output of the image risk control model. However, more importantly, the server can determine the confidence of the output of the image risk control model, that is, the confidence of the output of the image risk control model for each unlabeled sample. In order to subsequently determine, according to the confidence, which outputs of the unlabeled samples are accurate enough to be used as "labeled samples" for subsequent iterative training processes.
[0100] Afterwards, the server can determine pseudo-labeled samples from unlabeled samples according to the confidence and a confidence expectation threshold of the iteration process, and take the output of the pseudo-labeled samples in the last iteration process as labels.
[0101] As mentioned above, as long as the confidence is high enough, the output of the unlabeled sample in the last iteration process of the image risk control model can be considered to be accurate to a certain extent, and the output can be taken as a label, and the corresponding unlabeled sample can be taken as a pseudo-labeled sample.
[0102] Specifically, in one or more embodiments of the present specification, the server can screen out pseudo-labeled samples by using a preset confidence expectation threshold, but the accuracy of the model output is constantly changing with training, and in the embodiments of the present specification, pseudo-labeled samples are needed to be added to the training faster to avoid overfitting of the training. Because once the overfitting occurs, the confidence of the model output is also for the overfitting, and the label of the screened pseudo-labeled sample is not accurate enough.
[0103] Therefore, the server can use a dynamically adjusted confidence expectation threshold to determine the confidence expectation threshold once or every few rounds. The server can determine the number of unlabeled samples used to train the image risk control model in the last iteration process of the iteration process, and determine a confidence reference value according to the confidence of the output of the image risk control model for the unlabeled samples in the last iteration process, and determine the confidence expectation threshold of the iteration process according to the number and the confidence reference value.
[0104] For example, the confidence expectation threshold is determined in the following manner.
[0105]
[0106] wherein τ represents the confidence expectation threshold, t represents the iteration number. When t = 0, the confidence expectation threshold is 1 / C, and C represents the number of categories, i.e., the total number of different categories in the labels of the training samples. For example, on the CIFAR-10 dataset, C will be equal to 10 because the dataset contains 10 different categories. λ is a preset hyperparameter, which can specifically refer to the momentum decay coefficient of Exponential Moving Average (EMA), which is a value between 0 and 1. EMA is a method of calculating the weighted average of a sequence, in which newer observations have more weight than older observations. The value of λ determines the degree of influence of the previous state on the current state. If λ is close to 1, more historical information is retained; if λ is close to 0, more attention is paid to new information. μB is the total number of training samples, which is the total number of unlabeled samples in the embodiments of the present specification. max(q b) represents the maximum value of the prediction probability of the image risk control model for the b-th unlabeled sample. Specifically, q b is the probability distribution predicted by the image risk control model for the unlabeled sample ub, and max(q b ) is the maximum probability value selected from this probability distribution. In addition, q b is represented as pm(y|Ω(ub)), that is, the probability distribution output by the model on the strongly augmented unlabeled sample ub. max(qb) is used to determine whether the confidence of a sample is high enough to generate a pseudo-label. If max(qb) is greater than a set threshold τ, then this unlabeled sample will be assigned a pseudo-label for training. In short, max(q b ) is the prediction probability of the most likely class of the model for the unlabeled sample ub.
[0107] Finally, in this round of iteration, based on the determined pseudo-labeled samples and labeled samples, a comprehensive loss is determined according to the output of the target detection layer, the output of the image classification layer, and the corresponding labels. That is, the image risk control model is trained in a supervised training manner using pseudo-labeled samples and original labeled samples.
[0108] In addition, it should be noted that in one or more embodiments of the present specification, the pseudo-labeled sample can be used to determine both the image classification loss and the target classification loss, or only one of the two losses.
[0109] Further, in one or more embodiments of the present specification, the server can further fine-tune the confidence expectation threshold based on the local threshold. Specifically, the server can determine the fine-tuning value using the following method:
[0110]
[0111] where q b (C) represents the probability of the image risk control model predicting that the b-th unlabeled sample ub belongs to class c. qb itself is a vector, representing the probability distribution output by the image risk control model for the unlabeled sample ub, and q b (C) specifically refers to the probability value corresponding to class c in the distribution. The adjusted confidence expectation threshold is fine-tuned to represent:
[0112]
[0113] where [C] represents a set of classes, and C represents a specific class.
[0114] Through the above process, the confidence expectation threshold can be automatically adjusted, so that the determined pseudo-labeled samples are more accurate. Generally speaking, as the iteration process increases, the model parameter adjustment is more accurate, and the confidence expectation threshold is higher, so that the training effect is better. At the same time, since the number of training samples is increased flexibly, the small sample problem is also avoided.
[0115] In addition, for the labeled samples, the labeling is generally manually labeled according to expert experience as described above, and for multi-task and non-conflicting labeling requirements, it is difficult to avoid the inaccuracy of manual labeling, so that there are noise in the labeled samples, that is, there are labeled samples with labeling errors.
[0116] In order to further reduce the influence of noise on the training effect, in one or more embodiments of the present specification, the server can also determine the function value of the symmetric cross entropy loss function (Symmetric Cross Entropy, SCE) for the labeled samples for training the image risk control model. For pseudo-labeled samples, since the confidence of the labeling is adjusted in real time, because even if there is noise, it is not fixed, so the function value of the cross entropy loss function can be directly used to train the image risk control model.
[0117] Specifically, the server can determine the function value of the cross entropy loss function based on the output of the target detection layer, the output of the image classification layer, and the labeling of the pseudo-labeled sample.
[0118] And based on the labeled sample, the function value of the symmetric cross entropy loss function is determined based on the output of the target detection layer, the output of the image classification layer, and the labeling of the labeled sample.
[0119] Finally, according to the function value of the cross entropy loss function and the function value of the symmetric cross entropy loss function, a comprehensive loss function value is determined, and the model parameters of the image risk control model are adjusted based on the comprehensive loss function value.
[0120] The symmetric cross entropy loss function combines the cross entropy loss in two directions to improve the robustness and generalization ability of the model. Compared with the traditional cross entropy loss function, which is usually used in supervised learning, especially in classification problems. It measures the difference between the probability distribution predicted by the model and the probability distribution of the true label. For a given sample, if the true label is a one-hot encoding vector, then the cross entropy loss function can be defined as:
[0121] H(y, p) = -∑ylogp
[0122] where y is the true label, p is the probability distribution predicted by the model. To address the issue of noisy labels, the inverse cross-entropy is also introduced:
[0123] H(p, y) = -∑plogy
[0124] where y' represents the probability distribution obtained from the true label by some means, such as softening one-hot encoding, so that y' and p are both probability distributions. Combining the cross-entropy in both directions, we get the symmetric cross-entropy loss function:
[0125] SCE = H(y, p) + aH(p, y)
[0126] where a is a hyperparameter to balance the contributions of the two loss terms. By considering the relationship between the true label and the model prediction symmetrically, the model can not only fit the training data, but also better handle uncertainty and noise, thus improving the overall performance of the model.
[0127] Further, in order to further improve the intra-class compactness and inter-class discriminability of the features, the server can adjust the function value based on the inter-class difference and intra-class difference when determining the cross-entropy function in both directions of the symmetric cross-entropy loss function.
[0128] Specifically, the server can determine the positive samples and negative samples corresponding to the labeled samples based on the labels of the labeled samples. Wherein each labeled sample is taken as a standard sample, the positive sample refers to the sample belonging to the same class as the standard sample. For example, the positive sample refers to those samples aj belonging to the same class as the standard sample ai. And the negative sample refers to the sample not belonging to the same class as the standard sample. For example, the negative sample refers to those samples ak not belonging to the same class as the standard sample ai.
[0129] Then, the server can determine the first function value according to the first difference between the output of the image risk control model for the positive sample and the label of the positive sample. Wherein the first difference is positively correlated with the first function value. And determine the second function value according to the second difference between the output of the image risk control model for the positive sample and the output of the image risk control model for the negative sample. Wherein the second difference is negatively correlated with the second function value.
[0130] Finally, the function value of the symmetric cross-entropy loss function is determined according to the first function value and the second function value of each labeled sample. Then the function value of the symmetric cross-entropy loss function reflects the class structure in the dataset of labeled samples, that is, the labeled samples in the same class are close to each other, and the labeled samples in different classes are far away from each other.
[0131] In addition, in one or more embodiments of the present specification, the target detection layer of the image risk control model can also use images containing significant targets to assist in training the target detection layer.
[0132] Specifically, first, the server can determine, for each training sample, other samples whose risk categories of risk targets are consistent with the training sample according to the label of the training sample. Wherein, the server can only determine other samples consistent with the training sample for the labeled samples.
[0133] Second, the server can determine reference samples according to the determined other training samples, and combine to obtain at least one sample combination corresponding to the training sample, taking the training sample as an anchor sample. That is, for each labeled sample, a sample combination can be determined, which contains an anchor sample and multiple reference samples. Of course, there is at least one reference sample, but generally there is only one other sample of the same category.
[0134] Then, when extracting image features through the feature extraction layer of the image risk control model, the image features of multiple dimensions need to be extracted for each image in the sample combination. That is, the sample combination is input into the image risk control model to be trained, and the multi-dimensional image features of the anchor sample and the reference sample in the sample combination are determined through the feature extraction layer of the image risk control model.
[0135] After inputting the image features into the target detection layer, the server can input the reference sample in the sample combination into the reference subnetwork of the target detection layer to determine the common features of the significant target in the reference sample. Wherein, the task of the reference subnetwork is to extract the common features of the target object from the reference sample.
[0136] And input the anchor sample in the sample combination and the common features into the segmentation subnetwork of the target detection layer to determine the output prediction detection frame and detection frame classification as the prediction detection frame and detection frame classification of the training sample. The segmentation subnetwork belongs to a kind of image segmentation network, which is used to identify and segment the target object in the anchor sample under the guidance of the common features provided by the reference subnetwork.
[0137] Wherein, the reference subnetwork is used to input the image features of each dimension of a group of reference samples. The extracted image features and the label of the reference sample are subjected to masking and pooling operations to obtain the common features of the target object.
[0138] And the segmentation sub-network input multi-dimensional size of the image features of the anchor sample. Utilizing the common representation generated by the reference sub-network, a pixel-level prior mask is generated by a referring mask generation (RMG) module. Then the feature is enhanced by a referring feature enrichment (RFE) module to highlight the target object in the anchor sample. Finally, the segmentation mask of the target object is generated.
[0139] Figure 3 The structure diagram of the target detection layer provided in the specification can be seen that the image features of the reference sample and the anchor sample are input into the target detection layer, the reference sub-network extracts common features, the prior mask is obtained by inputting the RMG, and the segmentation mask of the target object is generated by the RFE according to the prior mask and the image features of the anchor sample.
[0140] See Figure 4 The structure diagram of an image risk control device provided in an embodiment of the specification is shown. As Figure 4 shown, the image risk control device can be realized by software, hardware or a combination of both to become all or part of an electronic device. According to some embodiments, the image risk control includes a preparation module 401, a feature extraction module 402, a classification module 403, a training and risk control module 404, and specifically includes:
[0141] The preparation module 401 determines the training sample constructed based on the image data and the image risk control model to be trained, and the image risk control model is composed of a feature extraction layer, a target detection layer and an image classification layer;
[0142] The feature extraction module 402 inputs the training sample into the image risk control model to be trained, and determines the image features of multi-dimensional size of the image data through the feature extraction layer of the image risk control model;
[0143] The classification module 403 inputs the image features of multi-dimensional size into the target detection layer and the image classification layer respectively, determines the predicted detection frame output by the target detection layer and the detection frame classification, and determines the image classification result output by the image classification layer;
[0144] The training and risk control module 404 determines the comprehensive loss according to the output of the target detection layer, the output of the image classification layer and the label of the training sample, and trains the image risk control model based on the comprehensive loss. The image risk control model obtained by training is used to perform an image risk control task. The image to be controlled is input into the image risk control model, and the risk target object and the image risk type of the image to be controlled are determined according to the detection frame, the detection frame classification and the image classification result output by the image risk control model, so as to perform risk control.
[0145] Optionally, the target detection layer comprises a feature fusion subnetwork, a bounding box prediction subnetwork, and a bounding box classification subnetwork, the classification module 403 inputs the image features of the multiple dimensions into the target detection layer, determines each fusion image feature through the feature fusion subnetwork of the target detection layer, inputs the each fusion image feature into the bounding box prediction subnetwork of the target detection layer to determine the predicted detection box of each target of the training sample, and inputs the each fusion image feature into the bounding box classification subnetwork of the target detection layer to determine the risk classification result of the each predicted detection box as the detection box classification.
[0146] Optionally, the training and risk control module 404 determines the image risk classification of the training sample according to the label of the training sample, determines the image classification loss according to the difference between the image classification result output by the image classification layer and the image risk classification of the training sample, determines the bounding box of the risk target in the training sample and the risk classification of the risk target according to the label of the training sample, determines the target classification loss according to the difference between the predicted detection box output by the target detection layer and the bounding box of the risk target in the training sample, and the difference between the detection box classification output by the target detection layer and the risk classification of the risk target in the training sample, and determines the comprehensive loss according to the image classification loss and the target classification loss.
[0147] Optionally, the preparation module 401 acquires image data with labels as labeled samples and acquires image data without labels as unlabeled samples, and the training and risk control module 404 trains the image risk control model in an iterative manner, for each iteration process, determines the output of the image risk control model for the unlabeled samples in the last iteration process of the iteration process, and a confidence of the output, determines pseudo-labeled samples from the unlabeled samples according to the confidence and a confidence expectation threshold of the iteration process, and takes the output of the pseudo-labeled samples in the last iteration process as labels in the iteration process, and determines the comprehensive loss according to the output of the target detection layer, the output of the image classification layer, and the corresponding labels based on the determined pseudo-labeled samples and the labeled samples in the iteration process.
[0148] Optionally, the training and risk control module 404 determines the number of unlabeled samples used for training the image risk control model in the last iteration process of the iteration process, determines a confidence reference value according to the confidence of the output of the image risk control model for the unlabeled samples in the last iteration process, and determines the confidence expectation threshold of the iteration process according to the number and the confidence reference value.
[0149] Optionally, the training and risk control module 404 determines, based on the determined pseudo-labeled sample, a function value of a cross-entropy loss function according to the output of the target detection layer, the output of the image classification layer and the label of the pseudo-labeled sample, determines, based on the labeled sample, a function value of a symmetric cross-entropy loss function according to the output of the target detection layer, the output of the image classification layer and the label of the labeled sample, determines a comprehensive loss function value according to the function value of the cross-entropy loss function and the function value of the symmetric cross-entropy loss function, and adjusts the model parameters of the image risk control model based on the comprehensive loss function value.
[0150] Optionally, the training and risk control module 404 determines, based on the label of the labeled sample, a positive sample and a negative sample corresponding to the labeled sample, determines a first function value according to a first difference between the output of the image risk control model on the positive sample and the label, the first difference being positively correlated with the first function value, determines a second function value according to a second difference between the output of the image risk control model on the positive sample and the output of the image risk control model on the negative sample, the second difference being negatively correlated with the second function value, and determines a function value of a symmetric cross-entropy loss function according to the first function value and the second function value.
[0151] Optionally, the preparation module 401 determines, for each training sample, other samples whose risk classification of a risk target is consistent with that of the training sample according to the label of the training sample, takes the training sample as an anchor sample, determines reference samples according to the determined other training samples, and combines to obtain at least one sample combination corresponding to the training sample.
[0152] Then the feature extraction module 402 inputs the sample combination into the image risk control model to be trained, and determines, through a feature extraction layer of the image risk control model, image features of multiple dimensions of the anchor sample and the reference sample in the sample combination.
[0153] Then the classification module 403 inputs the reference sample in the sample combination into a reference subnetwork of the target detection layer to determine common features of the significant target in the reference sample, and inputs the anchor sample in the sample combination and the common features into a segmentation subnetwork of the target detection layer to determine a predicted detection frame and a detection frame classification output as the predicted detection frame and the detection frame classification of the training sample.
[0154] The above device embodiments correspond to the method embodiments, and specific descriptions can be referred to the description of the method embodiments, which will not be repeated here. The device embodiments are based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. Specific descriptions can be referred to the corresponding method embodiments.
[0155] The embodiment of the present specification also provides a computer storage medium, which can store a plurality of instructions, and the instructions are suitable for being loaded and executed by a processor to implement the method of the above-mentioned Figure 1 The specific implementation process of the method of the embodiment shown in the above-mentioned Figure 1 The specific implementation process of the method of the embodiment shown in the above-mentioned
[0156] The present specification also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the method of the above-mentioned Figure 1 The specific implementation process of the method of the embodiment shown in the above-mentioned Figure 1 The specific implementation process of the method of the embodiment shown in the above-mentioned
[0157] The embodiment of the present specification also provides an electronic device as shown in the above-mentioned Figure 5 The structure diagram of the electronic device is shown in the above-mentioned Figure 5 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory and a non-volatile memory, and of course, other hardware required by the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs to implement the above-mentioned image risk control method.
[0158] Of course, in addition to the software implementation, the present specification does not exclude other implementation manners, such as logic devices or the combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but also can be hardware or logic device.
[0159] In the 1990s, it was quite obvious to distinguish whether an improvement in a technology was in hardware (e.g., improvement in circuit structures of diodes, transistors, switches, etc.) or in software (improvement in method flow). However, as technology has evolved, many improvements in method flow today can be considered as direct improvements in hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structures by programming the improved method flow into hardware circuits. Therefore, it cannot be said that an improvement in a method flow cannot be implemented by hardware entity modules. For example, a programmable logic device (PLD) (e.g., a field programmable gate array (FPGA)) is an integrated circuit whose logic function is determined by user programming of the device. A digital system is "integrated" on a PLD by the designer programming it, rather than by asking a chip manufacturer to design and fabricate a custom integrated circuit chip. Moreover, instead of manually fabricating integrated circuit chips, this programming is now mostly implemented by "logic compiler" software, which is similar to software compilers used in program development, and the original code to be compiled is written in a specific programming language, which is called a hardware description language (HDL), and there are many such languages, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., and the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should be aware that, as long as the method flow is logically programmed in the above-mentioned hardware description languages and programmed into an integrated circuit, a hardware circuit implementing the logical method flow can be easily obtained.
[0160] The controller can be implemented in any suitable way, for example, the controller can take the form of a microprocessor or processor and a computer readable medium storing computer readable program code, such as software or firmware, executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20 and Silicone Labs C8051F320, the memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also know that, in addition to being implemented in pure computer readable program code, the controller can equally well be implemented to perform the same functions using logic gates, switches, an application specific integrated circuit, a programmable logic controller and an embedded microcontroller, etc. by means of a logical programming of the method steps. The controller can thus be considered as a hardware component, and the means comprised therein for performing the various functions can be considered as structures within the hardware component. Alternatively, the means for performing the various functions can even be considered as both a software module implementing the method and a structure within the hardware component.
[0161] The systems, apparatuses, modules or units illustrated by the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0162] For the sake of description, the above apparatuses are described in various units by functions respectively. Of course, the functions of the units can be implemented in one or more software and / or hardware in the implementation of the present specification.
[0163] Those skilled in the art will understand that the embodiments of the present specification can be provided as a method, a system or a computer program product. Therefore, the present specification can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0164] The specification is presented with reference to flow diagrams and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the specification. It will be understood that each block of the flow diagrams and / or block diagrams, and combinations of blocks in the flow diagrams and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing element or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.
[0165] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.
[0166] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks. Figure 1 The flow diagrams and / or block diagrams in the specification can present a method, apparatus or computer program product according to embodiments of the specification. Flow diagrams and / or block diagrams can also present a method, apparatus or computer program product to achieve functions specified in flow diagrams and / or block diagrams block or blocks.
[0167] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0168] The memory can include non-persistent memory and / or storage mechanisms such as, for example, random access memory (RAM), non-volatile memory (NVM), and / or a persistent memory such as, for example, read-only memory (ROM) or flash memory. The memory is an example of computer-readable media.
[0169] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.
[0170] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, such that processes, methods, articles or devices that comprise a list of elements do not only include those elements, but also other elements not explicitly listed or inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0171] Those skilled in the art will appreciate that embodiments of the present specification can be provided as methods, systems or computer program products. Therefore, the present specification can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present specification can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) containing computer-usable program code.
[0172] The present specification can be described in the general context of computer-executable instructions, such as program modules, executed by computers. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The present specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including storage devices.
[0173] The various embodiments described in this specification are described using a numbering of embodiments approach: these are each individually integrated contributions pertaining to different aspects of the description. For each embodiment, the description focuses on the differences from the other embodiments. In particular, the description of the system embodiments is relatively brief, as the system embodiments are largely analogous to the method embodiments. The relevant parts of the description of the method embodiments are therefore referred to.
[0174] The above only describes the embodiments of the present specification and is not intended to limit the present specification. The present specification can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of claims of the present specification.
Claims
1. An image risk control method, the method comprising: determining a training sample constructed based on image data and an image risk control model to be trained, the image risk control model consisting of a feature extraction layer, a target detection layer and an image classification layer; inputting the training sample into the image risk control model to be trained, determining image features of multiple dimensions of the image data through the feature extraction layer of the image risk control model; inputting the image features of multiple dimensions into the target detection layer and the image classification layer respectively, determining a predicted bounding box output by the target detection layer and a bounding box classification, and determining an image classification result output by the image classification layer; determining a comprehensive loss according to the output of the target detection layer, the output of the image classification layer and the annotation of the training sample, and training the image risk control model based on the comprehensive loss, the trained image risk control model being used to perform an image risk control task, inputting a to-be-controlled image into the image risk control model, and determining a risk target and an image risk type of the to-be-controlled image according to the bounding box, the bounding box classification and the image classification result output by the image risk control model to perform risk control.
2. The method of claim 1, wherein the target detection layer comprises a feature fusion subnetwork, a bounding box prediction subnetwork and a bounding box classification subnetwork; inputting the image features of multiple dimensions into the target detection layer to determine the predicted bounding box and the bounding box classification output by the target detection layer, specifically comprising: inputting the image features of multiple dimensions into the target detection layer to determine each fusion image feature through the feature fusion subnetwork of the target detection layer; inputting each fusion image feature into the bounding box prediction subnetwork of the target detection layer to determine a predicted bounding box of each target of the training sample, and inputting each fusion image feature into the bounding box classification subnetwork of the target detection layer to determine a risk classification result of each predicted bounding box as a bounding box classification.
3. The method of claim 1, wherein the comprehensive loss is determined according to the output of the target detection layer, the output of the image classification layer and the annotation of the training sample, specifically comprising: determining an image risk classification of the training sample according to the annotation of the training sample; determining an image classification loss according to a difference between the image classification result output by the image classification layer and the image risk classification of the training sample; determining a bounding box of a risk target in the training sample and a risk classification of the risk target according to the annotation of the training sample; determining a target classification loss according to a difference between the predicted bounding box output by the target detection layer and the bounding box of the risk target in the training sample, and a difference between the bounding box classification output by the target detection layer and the risk classification of the risk target in the training sample; determining the comprehensive loss according to the image classification loss and the target classification loss.
4. The method of claim 1, wherein the training sample constructed based on image data is determined, specifically comprising: Obtaining labeled image data as labeled samples and unlabeled image data as unlabeled samples; According to the output of the target detection layer, the output of the image classification layer and the label of the training sample, determine the comprehensive loss, specifically including: Train the image risk control model in an iterative manner, for each iteration process, determine the output of the image risk control model for the unlabeled sample in the last iteration process of this iteration process, and the confidence of the output; According to the confidence and the confidence expectation threshold of this iteration process, determine the pseudo-labeled sample from the unlabeled sample, and take the output of the pseudo-labeled sample in the last iteration process as the label; In this iteration process, based on the determined pseudo-labeled sample and the labeled sample, according to the output of the target detection layer, the output of the image classification layer and the corresponding label, determine the comprehensive loss.
5. The method of claim 4, before determining the pseudo-labeled sample from the unlabeled sample according to the confidence and the confidence expectation threshold of this iteration process, the method further comprises: Determine the number of unlabeled samples of the image risk control model used in the last iteration process of this iteration process; According to the last iteration process, the confidence of the output of the image risk control model for the unlabeled sample, determine the confidence reference value; According to the number and the confidence reference value, determine the confidence expectation threshold of this iteration process.
6. The method of claim 4, based on the determined pseudo-labeled sample and the labeled sample, according to the output of the target detection layer, the output of the image classification layer and the corresponding label, determine the comprehensive loss, specifically including: Based on the determined pseudo-labeled sample, according to the output of the target detection layer, the output of the image classification layer and the label of the pseudo-labeled sample, determine the function value of the cross-entropy loss function; Based on the labeled sample, according to the output of the target detection layer, the output of the image classification layer and the label of the labeled sample, determine the function value of the symmetric cross-entropy loss function; According to the function value of the cross-entropy loss function and the function value of the symmetric cross-entropy loss function, determine the comprehensive loss function value, based on the comprehensive loss function value, adjust the model parameters of the image risk control model.
7. The method of claim 6, based on the labeled sample, according to the output of the target detection layer, the output of the image classification layer and the label of the labeled sample, determine the function value of the symmetric cross-entropy loss function, specifically including: Based on the label of the labeled sample, determine the positive sample and the negative sample corresponding to the labeled sample; According to the first difference between the output of the image risk control model to the positive sample and the label, determine the first function value, the first difference is positively correlated with the first function value; determining a second function value according to a second difference between the output of the image risk control model on the positive sample and the output of the image risk control model on the negative sample, the second difference being negatively correlated with the second function value; determining a function value of a symmetric cross-entropy loss function according to the first function value and the second function value. 8.The method of claim 1, further comprising: for each training sample, determining other samples in which a risk classification of a risk target is consistent with the training sample according to a label of the training sample; combining the training sample and the determined other training samples to obtain at least one sample combination corresponding to the training sample, wherein the training sample is an anchor sample and the other training samples are reference samples; inputting the training sample into the image risk control model to be trained, and determining image features of multiple dimensions of the image data by a feature extraction layer of the image risk control model, including: inputting the sample combination into the image risk control model to be trained, and respectively determining image features of multiple dimensions of the anchor sample and the reference samples in the sample combination by the feature extraction layer of the image risk control model; inputting the image features of multiple dimensions into the target detection layer to determine a predicted bounding box and a bounding box classification output by the target detection layer, including: inputting the reference sample in the sample combination into a reference subnetwork of the target detection layer to determine common features of the significant target in the reference sample; inputting the anchor sample in the sample combination and the common features into a segmentation subnetwork of the target detection layer to determine the predicted bounding box and the bounding box classification output by the target detection layer as the predicted bounding box and the bounding box classification of the training sample. 9.An image risk control device, comprising a preparation module configured to determine training samples constructed based on image data and an image risk control model to be trained, the image risk control model comprising a feature extraction layer, a target detection layer, and an image classification layer; a feature extraction module configured to input the training sample into the image risk control model to be trained, and determine image features of multiple dimensions of the image data by the feature extraction layer of the image risk control model; a classification module configured to input the image features of multiple dimensions into the target detection layer and the image classification layer respectively, determine a predicted bounding box and a bounding box classification output by the target detection layer, and determine an image classification result output by the image classification layer; a training and risk control module configured to determine a comprehensive loss according to the output of the target detection layer, the output of the image classification layer, and a label of the training sample, and train the image risk control model based on the comprehensive loss, wherein the trained image risk control model is used to perform an image risk control task, input a to-be-controlled image into the image risk control model, and determine a risk target and an image risk type of the to-be-controlled image according to a bounding box, a bounding box classification, and an image classification result output by the image risk control model to perform risk control.
10. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by a processor to implement the steps of the method of any one of claims 1-8.
11. An electronic device, comprising: including: a processor and a memory; wherein the memory stores a computer program adapted to be loaded and executed by the processor to perform the steps of the method according to any one of claims 1 to 8.
12. A computer program product having stored thereon at least one instruction, the computer program product comprising: The at least one instruction, when executed by the processor, implements the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Target detection method and device
CN116012811A
Abnormality detection model training method and device, equipment and storage medium
CN116152933A