Violation detection model construction method, violation detection method and related device
By decoupling the recall and accuracy of the violation detection model into two independent models, and combining the construction of the violation detection model, the problem of difficulty in taking into account the accuracy and recall of the violation detection model in the existing technology is solved, and high accuracy is achieved and recall rates and reduce resource consumption and costs.
Patent Information
- Application Number
- CN202411417048.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2024-12-24
AI Technical Summary
The existing violation detection model is difficult to take into account both accuracy and recall in high-demand scenarios, resulting in missed and missed detection. The model parameters are large and complex, resulting in high resource consumption and high cost.
By decoupling the recall and accuracy of the violation detection model into two independent models, the first model focuses on the recall and the second model focuses on the accuracy. Combined with the construction of the violation detection model to reduce missed detection and false detection, And reduce model deployment and inference computing power overhead.
It realizes the high accuracy and recall rate of illegal detection models in massive data scenarios, reduces the missed detection and false detection rates, reduces the overhead of model deployment and inference computing power, and is suitable for risk control scenarios for massive live video screens.
Smart Images

Figure CN119180992A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image technology, and in particular to a violation detection model construction method, a violation detection method and related devices. Background Art
[0002] With the rise of the Internet live broadcast and short video industry, in order to maintain a healthy and orderly network environment, it is necessary to effectively supervise the illegal sensitive content in live broadcast and short video data, including but not limited to images or text content related to bad guidance, as well as copyright icons, etc. Since the live broadcast and short video data are growing explosively, it is impossible to supervise these massive data through manual review one by one. Therefore, a violation detection method based on deep learning big data drive is proposed to realize the automated review of massive video data.
[0003] However, the above-mentioned violation detection methods generally use end-to-end detection algorithms and conduct customized training and deployment in the scene field. Although they have the advantages of mature and simple solutions, their accuracy and recall rates are difficult to meet high-demand scenarios, which can easily lead to missed detections and false detections; moreover, if a higher accuracy is required, the models involved often have a large number of parameters and complex calculations, resulting in high resource consumption and high costs during inference deployment. Summary of the invention
[0004] In view of this, in order to at least take into account the accuracy and recall rate of the violation detection model, so as to reduce missed detections and false detections to a certain extent, and at the same time solve the technical problem of high model deployment cost in large-scale data scenarios, the purpose of the present invention is to provide a violation detection model construction method, a violation detection method and related devices.
[0005] In order to achieve the above purpose, the technical solution adopted by the embodiment of the present invention is as follows:
[0006] A first aspect of an embodiment of the present invention provides a method for constructing a violation detection model, comprising:
[0007] The first model is trained by a first sample set until the first model converges to obtain a first target model; the first sample set includes illegal images and compliant images, and the first target model is used to detect suspicious illegal areas in the image;
[0008] The second model is trained by the second sample set until the second model converges to obtain a second target model; the second sample set includes a captured image of the violation area, and the second target model is used to process the suspected violation area output by the first target model to obtain a classification result indicating whether the suspected violation area is in violation;
[0009] A violation detection model is constructed based on the first target model and the second target model.
[0010] A second aspect of an embodiment of the present invention provides a violation detection method, comprising:
[0011] The source image is processed by the violation detection model to obtain a classification result indicating whether the source image violates the rules; wherein the violation detection model is constructed by the violation detection model construction method provided in the first aspect above.
[0012] A third aspect of an embodiment of the present invention provides a violation detection model construction device, including:
[0013] A first training module is configured to: train a first model through a first sample set until the first model converges to obtain a first target model; the first sample set includes illegal images and compliant images, and the first target model is used to detect suspicious illegal areas in the image;
[0014] A second training module is configured to: train the second model through a second sample set until the second model converges to obtain a second target model; the second sample set includes a captured image of the violation area, and the second target model is used to process the suspected violation area output by the first target model to obtain a classification result indicating whether the suspected violation area is in violation;
[0015] The construction module is configured to construct a violation detection model according to the first target model and the second target model.
[0016] A fourth aspect of an embodiment of the present invention provides a violation detection device, including:
[0017] The detection module is configured to: process the source image through a violation detection model to obtain a classification result indicating whether the source image is in violation; wherein the violation detection model is constructed by the violation detection model construction device provided by the second aspect above.
[0018] The violation detection model construction method, violation detection method and related device provided by the embodiment of the present invention are realized separately by decoupling the recall rate and accuracy rate of the violation detection model into two relatively independent models, that is, by training the first model with a first sample set formed by violation images and compliance images, the first model is controlled to focus on the recall rate, and then when the first model converges, a first target model with a good recall rate can be obtained; and by training the second model with a second sample set formed by intercepting images of the violation area, the second model is controlled to focus on the accuracy rate, and then when the second model converges, a second target model with a good accuracy rate can be obtained. Then, the first target model and the second target model can be combined to construct a violation detection model. Since the violation detection model includes a first target model with a good recall rate and a second target model with a good accuracy rate, the violation detection model can have a good accuracy rate and recall rate, thereby reducing missed detection and false detection to a certain extent.
[0019] It can be seen that the violation detection model construction method, violation detection method and related devices provided by the embodiments of the present invention divide the recall rate related tasks and accuracy rate related tasks into two parts. It is not necessary to require the model capacity to be large enough and the parameters to be sufficient. The violation detection model can also take into account both accuracy and recall rate, which greatly reduces the inference computing power overhead in the training of the violation detection model and subsequent applications, thereby reducing the model deployment and computing power costs in large-scale data scenarios, and can be well applied to the risk control scenarios of massive live video images. In addition, since the second target model only needs to focus on the illegal areas in the source image, it can avoid the interference of irrelevant areas in the source image on the work of the second target model, thereby making the feature extraction and classification recognition tasks of the target objects in the illegal areas simpler, thereby better reducing the model deployment and computing power costs in large-scale data scenarios.
[0020] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A structural block diagram of an electronic device provided by an embodiment of the present invention is shown;
[0023] Figure 2A flow chart of a violation detection model construction method provided by an embodiment of the present invention is shown;
[0024] Figure 3 A network structure block diagram of a violation detection model provided by an embodiment of the present invention is shown;
[0025] Figure 4 A network structure block diagram of another violation detection model provided by an embodiment of the present invention is shown;
[0026] Figure 5 A flow chart of a violation detection method provided by an embodiment of the present invention is shown;
[0027] Figure 6 A functional module diagram of a violation detection model building device provided by an embodiment of the present invention is shown;
[0028] Figure 7 A functional module diagram of a violation detection device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0029] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0030] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.
[0031] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device 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, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0032] In order to solve the technical problem that the accuracy and recall rate of the violation detection model cannot be taken into account in the traditional technology, which leads to a large number of missed detections and false detections, the present invention provides a method for constructing a violation detection model, which is realized by decoupling the recall rate and accuracy rate of the violation detection model into two relatively independent models, that is, by training the first model with a first sample set formed by the violation image and the compliance image, the first model is controlled to focus on the recall rate, and then when the first model converges, a first target model with a good recall rate can be obtained; and by training the second model with a second sample set formed by the images intercepted from the violation area, the second model is controlled to focus on the accuracy rate, and then when the second model converges, a second target model with a good accuracy rate can be obtained. Then, the first target model and the second target model can be combined to construct a violation detection model. Since the violation detection model includes the first target model with a good recall rate and the second target model with a good accuracy rate, the violation detection model can have a good accuracy rate and recall rate, thereby reducing missed detections and false detections to a certain extent.
[0033] The violation detection model construction method provided by the present invention can be applied to electronic devices, please refer to Figure 1 , is a block diagram of the structure of an electronic device. The electronic device 100 includes a memory 110, a processor 120 and a communication module 130. The memory 110, the processor 120 and the communication module 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0034] The memory is used to store programs or data. The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0035] The processor is used to read / write data or programs stored in the memory and execute corresponding functions.
[0036] The communication module is used to establish a communication connection between the electronic device and other communication terminals through a network, and is used to send and receive data through the network.
[0037] It should be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device, and the electronic device may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0038] The following combination Figure 2 The violation detection model construction method provided by the embodiment of the present invention is described. Figure 2 : is a flow chart of a violation detection model construction method provided by an embodiment of the present invention, the violation detection model construction method comprising:
[0039] In step S100, a first model is trained by a first sample set until the first model converges to obtain a first target model; the first sample set includes illegal images and compliant images, and the first target model is used to detect suspicious illegal areas in the image;
[0040] In step S200, the second model is trained by the second sample set until the second model converges to obtain a second target model; the second sample set includes a captured image of the violation area, and the second target model is used to process the suspected violation area output by the first target model to obtain a classification result indicating whether the suspected violation area is in violation;
[0041] In step S300, a violation detection model is constructed according to the first target model and the second target model.
[0042] In order to obtain a violation detection model that can take into account both recall rate and accuracy, and to use the violation detection model to accurately identify the illegal content of the source image input by the user through the client device in the live broadcast field or the short video field, and then realize the effective supervision of the network environment, the violation detection model construction method provided by the embodiment of the present invention can be adopted, and the technical solution recorded in the above steps S100 to S300 can be used to obtain the violation detection model. The following is combined with steps S100 to S300 to illustrate the construction principle of the violation detection model in the embodiment of the present invention:
[0043] First, the technical principle of obtaining training samples in the relevant technology can be used to obtain a first sample set containing labeled violation images and compliance images, wherein the compliance images are included to ensure the recall rate of the first model, but since the first model still needs to focus on the identification of violation areas, the proportion of violation images in the first sample set can be greater than that of compliance images. Based on a similar principle, an image of a suspected violation area can be captured from a source image to obtain a captured image of the violation area that does not contain other information in the source image except the suspected violation area, and the captured image of the violation area is labeled to form a second sample set. Thus, steps S100 and S200 can be executed to train the first model using the first sample set and train the second model using the second sample set based on the training principle of the neural network model in the relevant technology, and the first target model can be obtained when the first model converges, and the second target model can be obtained when the second model converges.
[0044] It should be noted that step S100 and step S200 are independent training processes that do not interfere with each other. In addition, step S100 and step S200 can be executed in parallel. Of course, the two can also be executed serially without limiting the order.
[0045] In some embodiments, the first target model can be a small detection model for a single scene class (Recall-First Single-Class Detection model, RFSCD). During the application process, the first target model is used to locate all possible violation areas in the source image. It can be understood that the violation area indicated by the detection box information output by the first target model is not necessarily the violation area, and there may be redundancy, so as to ensure the recall rate through redundant suspected violation areas. Therefore, in the process of training the first model, there is no need to consider the accuracy of the first model, which greatly reduces the difficulty of building the first model, and thus reduces the difficulty of building the violation detection model.
[0046] In addition, in order to reduce the computing power overhead during the training of the first model and enable the violation detection model constructed based on the first target model to be widely promoted and applied at low cost in the risk control of massive live video images, the first model can use a lightweight network as the backbone neural network of the model to expand and construct it, following the simple principles of lightweight and few parameters, and the output of the first model can be set to only one category.
[0047] In some embodiments, in order to ensure that the first target model gives priority to the recall rate, the violation detection model construction method provided in the embodiment of the present invention further optimizes the loss function used in training the first model, that is, in the loss function L recall_firstIn addition to the conventional loss term, a weight factor α is also configured to control the loss calculation. Based on this, the loss function L recall_first The expression is:
[0048] L recall_first =αL FN +(1-α)L FP Formula (1)
[0049] In formula (1), L FN Indicates missed detection loss, L FP Represents the false detection loss, and the weight factor α is used to adjust the penalty ratio of missed detection and false detection. In order to prioritize the recall rate, the value range of the weight factor α is: 0.75<α<1. As an example, α can be 0.9, but is not limited to this.
[0050] In some embodiments, the second target model may be a small recognition model for constructing a salient object feature extraction model (SOFE). During the application process, the first target model is used to receive the coordinate information of the detection frame output by the first target model for surrounding the suspected violation area in the source image, and then perform feature extraction and classification recognition on the image features in the suspected violation area based on the detection frame coordinate information.
[0051] Similarly, in order to reduce the computing power overhead in the training process of the second model and enable the violation detection model constructed based on the second target model to be widely promoted and applied at low cost in the risk control of massive live video images, the backbone network of the second model can adopt a classic general feature model, such as a deep learning model (Residual Network18, ResNet18) that has been trained in an open source dataset. For example, assuming that f represents the general feature model ResNet18 and the suspected violation area corresponding to a detection box is x∈R H×W×C , and the output feature of the final average pooling layer is F, then F = f(x), and the output of the fully connected layer is Z = W c F+b c , where H×W×C represents the resolution of the suspected violation area, H is the image height, W is the image width, C is the number of image channels, and W c ∈R K×d , is the parameter of the fully connected layer in the second target model, b c ∈R K , is the bias term of the fully connected layer, where K is the number of categories (number of classification results) and d is the feature dimension. The predicted classification results of the suspicious violation area corresponding to the detection box generally need to be normalized using the softmax function, which can be expressed as P = softmax (Wc F+b c Based on this, the final output of the second model can be expressed as: (P, F) = (softmax (W c F+b c ), f(x)). The formulas and functions involved can be found in the relevant technology and will not be described in detail here.
[0052] It can be seen that the violation detection model construction method provided by the embodiment of the present invention divides the recall rate-related tasks and the accuracy rate-related tasks into two parts. It does not require the model capacity to be large enough and the parameters to be sufficient. It can also achieve that the violation detection model can take into account both the accuracy rate and the recall rate, greatly reducing the inference computing power overhead in the training of the violation detection model and subsequent applications, thereby reducing the model deployment and computing power costs in large-scale data scenarios, and can be well applied to the risk control scenarios of massive live video images. In addition, since the second target model only needs to focus on the illegal areas in the source image, it can avoid the interference of irrelevant areas in the source image on the work of the second target model, thereby making the feature extraction and classification recognition tasks of the target objects in the illegal areas simpler, thereby better reducing the model deployment and computing power costs in large-scale data scenarios.
[0053] Therefore, the violation detection model constructed based on the first target model and the second target model with low computing power overhead and low cost must also have the characteristics of low computing power overhead and low cost.
[0054] After obtaining the first target model and the second target model, step S300 can be executed to construct a violation detection model based on the first target model and the second target model. In some examples, the first target model can be connected to the input end of the second target model to obtain the violation detection model.
[0055] Although the above embodiment can obtain a violation detection model suitable for the risk control scenario of massive live video images, since the first target model and the second target model in the violation detection model are connected, this will inevitably lead to the second target model having to wait for the first target model to output the detection frame information before executing the corresponding classification and recognition task, that is, the second target model must go through a waiting process, and its computing power resources are obviously not fully utilized. Similarly, whether it is the first target model or the second target model, in a detection process, it contains sub-links with different functions. For example, the first target model contains sub-links such as data preprocessing, model reasoning and result processing, while the second target model contains sub-links such as data preprocessing and model reasoning. The operation characteristics involved in different sub-links are different, and the "barrel short board" effect is prone to occur, which makes some links in a waiting state and cannot fully utilize computing power resources. For ease of understanding, as an example, the deep learning model can efficiently calculate reasoning on the GPU, but the GPU needs to wait for the data on the CPU to be prepared and copied to the GPU before the GPU can perform reasoning, so it is easy to cause the model on the GPU to be in a "hungry" state, thereby causing a waste of computing power. To solve this technical problem, in some embodiments, the violation detection model construction method provided in the embodiments of the present invention further provides another solution for constructing a violation detection model based on the first target model and the second target model, that is, in step S300, the step of constructing a violation detection model according to the first target model and the second target model includes:
[0056] In step S311, the first target model is decoupled into a first preprocessing module, a first reasoning module and a first result processing module;
[0057] In step S312, the second target model is decoupled into a second preprocessing module and a second reasoning module;
[0058] In step S313, a scheduling module is constructed, and the first preprocessing module, the first reasoning module, the first result processing module, the second preprocessing module and the second reasoning module are respectively connected to the scheduling module to form a violation detection model.
[0059] See also Figure 3 , Figure 3 is a network structure diagram of a violation detection model provided by an embodiment of the present invention; after decoupling the first target model and the second target model through steps S311 to S313, and adding a scheduling module to realize the communication between the decoupled models, the network structure of the violation detection model formed is Figure 3It can be seen that in the violation detection model formed based on this, each functional module in the first target model and the second target model is decoupled, each forming a separate module, and each functional module can be asynchronously and concurrently called through the scheduling module.
[0060] Therefore, when the violation detection model is applied to the detection of illegal content in live video or short video, the scheduling module can be used to receive image data sent by the client device in addition to asynchronously and concurrently calling each functional module, and then send the image data to the corresponding module for processing, wherein the scheduling module can send images to the corresponding module one by one, or send batches of images to the corresponding module at one time. In order to improve the efficiency of image processing and improve the utilization rate of computing resources of each functional module, in this embodiment, the scheduling module can send batches of images to the corresponding module after receiving a sufficient number of image data, wherein the sufficient number can be reasonably set according to the computing resources of the corresponding functional module, for example, for the first preprocessing module, the corresponding sufficient number can be set to the first preset number, for the first reasoning module, the corresponding sufficient number can be set to the second preset number, for the first result processing module, the corresponding sufficient number can be set to the third preset number, for the second preprocessing module, the corresponding sufficient number can be set to the fourth preset number, and for the second reasoning module, the corresponding sufficient number can be set to the fifth preset number. The first preset number, the second preset number, the third preset number, the fourth preset number and the fifth preset number can be calculated according to the computing resources of the corresponding module, and the calculation principle thereof can be referred to the relevant technology. However, in some embodiments, if there is a need to simplify quantity calculation, the first preset quantity, the second preset quantity, the third preset quantity, the fourth preset quantity and the fifth preset quantity may be set to the same value.
[0061] based on Figure 3 The violation detection model shown in the figure, the collaborative workflow of each module in the violation detection model is described below:
[0062] After the scheduling module receives a sufficient number of source images, the batch of source images is sent to the first preprocessing module, which decodes, scales, normalizes and performs other operations on the received batch of source images in sequence, and returns the batch of preprocessed images obtained by preprocessing to the scheduling module.
[0063] After receiving a sufficient number of pre-processed images, the scheduling module will send the batch of pre-processed images to the first reasoning module, which will perform reasoning on the batch of pre-processed images and return the processed batch image features to the scheduling module.
[0064] After receiving a sufficient number of image features, the scheduling module will send the batches of image features to the first result processing module, which will decode and perform non-maximum suppression on the batches of image features, and return the processed detection box coordinate information and prediction score to the scheduling module, where the detection box coordinate information represents the coordinate information of the suspicious violation area in the source image, and the prediction score represents the confidence level of the detection of the suspicious violation area.
[0065] After receiving a sufficient amount of detection frame coordinate information, the scheduling module will send batches of detection frame coordinate information and the source images corresponding to these detection frame coordinate information to the second preprocessing module, which will decode the source images in sequence, crop the illegal areas of the source images according to the detection frame coordinate information, scale and normalize the cropped images in sequence, and return the processed illegal area screenshots to the scheduling module.
[0066] After receiving a sufficient number of illegal area screenshots, the scheduling module will send the batches of illegal area screenshots to the second reasoning module, which will infer the batches of illegal area screenshots and return the processed classification results and feature information corresponding to the illegal areas to the scheduling module.
[0067] After receiving the classification result and feature information returned by the second reasoning module, the scheduling module can save the classification result and feature information into a database to facilitate further review or backtracking by the reviewer of the illegal content.
[0068] Therefore, by utilizing the above-mentioned architecture, the functional modules in the first target model and the second target model are decoupled and used for actual deployment. This not only increases the resource overhead required for a certain computing operation, but also allows the scheduling module to make asynchronous calls to each functional module, which can greatly improve the throughput of the entire violation detection model, thereby ensuring that data can be efficiently executed from the first preprocessing module to the second reasoning module.
[0069] Based on the construction principle of the violation detection model of the above-mentioned decoupled architecture, for the situation that the first target model and the second target model are constructed by different developers in actual construction, in order to realize the decoupling of each functional module in the first target model and the second target model, it is convenient for relevant personnel to develop or maintain the first target model and the second target model. In other embodiments, the violation detection model construction method provided by the embodiments of the present invention also provides another construction scheme of the decoupled violation detection model, that is, in step S300, the step of constructing the violation detection model according to the first target model and the second target model includes:
[0070] In step S321, the first target model is decoupled into a first preprocessing module, a first reasoning module and a first result processing module;
[0071] In step S322, the second target model is decoupled into a second preprocessing module and a second reasoning module;
[0072] In step S323, a first scheduling module and a second scheduling module connected to each other are constructed;
[0073] In step S324, the first preprocessing module, the first reasoning module and the first result processing module are respectively connected to the first scheduling module, and the second preprocessing module and the second reasoning module are respectively connected to the second scheduling module to form a violation detection model.
[0074] See also Figure 4 , Figure 4 is a network structure diagram of another violation detection model provided by an embodiment of the present invention; after decoupling the first target model and the second target model through steps S321 to S324, and adding the first scheduling module and the second scheduling module to realize the communication between the decoupled models, the network structure of the violation detection model formed is Figure 4 It can be seen that in the violation detection model formed based on this, each functional module in the first target model and the second target model is decoupled, each forming a separate module, and each functional module in the first target model is called through the first scheduling module, and each functional module in the second target model is called through the second scheduling module, and the data exchange between the first target model and the second target model is realized by the first scheduling module and the second scheduling module.
[0075] For each functional module in steps S321 to S324, its function and working principle can be found in the relevant records of steps S311 to S313, which will not be elaborated here. The difference between the violation detection model formed by S321 to S324 and the violation detection model formed by steps S311 to S313 is that: a scheduling module is added to achieve better isolation between the first target model and the second target model, so as to facilitate the development or maintenance of the first target model and the second target model by different developers.
[0076] After obtaining the violation detection model through any of the above embodiments, in order to further reduce the occurrence of missed recognition and misrecognition of the violation detection model, in some embodiments, the embodiments of the present invention also add a feature library to the violation detection model, so as to use the feature library to store the feature information output by the second target model in the application and the real label corresponding to the feature information, so as to achieve that the feature information in the feature library can be used in subsequent applications to further determine the predicted classification result output by the second target model. For the specific determination scheme, please refer to the relevant content below, so as to further improve the recognition accuracy of the violation detection model and reduce the probability of missed recognition of the violation detection model. That is, in step S300, the step of constructing the violation detection model according to the first target model and the second target model may include:
[0077] In step S310, a feature library is constructed; the feature library is used to store feature information output by the second target model and real labels corresponding to the feature information, wherein the real labels include compliance labels and violation labels;
[0078] In step S320, a violation detection model is constructed according to the first target model, the second target model and the feature library.
[0079] The feature library constructed by step S310 mainly records two types of feature information, one of which is compliance features with compliance labels, which means that there is no illegal content in the suspected illegal area, and the other is illegal features with illegal labels, which means that there is illegal content in the suspected illegal area. In addition, in order to facilitate the distinction of different categories of data in the feature library, the storage area of the feature library can be divided into two sub-areas, one of which is used to store compliance features, and the other is used to store illegal features. In this way, in the subsequent search for illegal features or compliance features, you can search from the corresponding sub-area. If you can't find it in the corresponding sub-area, you can search from another sub-area. The efficiency of feature information search can be improved to a certain extent. In addition, the real label can be obtained by manually further checking the illegal area image corresponding to the feature information in the feature library and marking it.
[0080] After the feature library is constructed, the feature library can be connected to the output end of the second target model in step S320 to obtain the output of the second target model. The implementation scheme of how the first target model and the second target model cooperate to further obtain the violation detection model can adopt any of the above three related embodiments, so it will not be repeated here.
[0081] After obtaining the violation detection model through the violation detection model construction method in any of the above embodiments, the violation detection model can be loaded into an electronic device to detect the illegal content in live video, short video or other images using the violation detection model. In this regard, an embodiment of the present invention also provides a violation detection method based on the violation detection model, and the violation detection method includes:
[0082] In step S1000, the source image is processed by a violation detection model to obtain a classification result indicating whether the source image violates a rule; wherein the violation detection model is constructed by the violation detection model construction method in any of the above embodiments.
[0083] For the technical principle of using the violation detection model to process and obtain the classification result of whether the source image is in violation in step S1000, please refer to the relevant records in the embodiment of the violation detection model construction method, which will not be elaborated here.
[0084] In the violation detection model, Figure 3 When the violation detection model is shown, see Figure 5 , Figure 5 is a flow chart of a violation detection method provided by an embodiment of the present invention. In step S1000 of the violation detection method provided by an embodiment of the present invention, the step of processing the source image by the violation detection model to obtain a classification result indicating whether the source image is in violation may include:
[0085] In step S1100, when the scheduling module receives a first preset number of source images, the batch source images are sent to the first pre-processing module through the scheduling module;
[0086] In step S1200, when the scheduling module receives a second preset number of pre-processed images, the scheduling module sends a batch of pre-processed images to the first reasoning module; wherein the pre-processed images are obtained by the first pre-processing module based on the source images;
[0087] In step S1300, when the scheduling module receives a third preset number of image features, the batch image features are sent to the first result processing module through the scheduling module; wherein the image features are obtained by the first reasoning module based on the pre-processed image processing;
[0088] In step S1400, when the scheduling module receives a fourth preset number of detection frame coordinate information, the scheduling module sends batch detection frame coordinate information and batch source images corresponding to the batch detection frame coordinate information to the second pre-processing module; wherein the detection frame coordinate information is obtained by the first result processing module based on the image feature processing;
[0089] In step S1500, when the scheduling module receives the fifth preset number of illegal area intercepted images, the scheduling module sends batch illegal area intercepted images to the second reasoning module; wherein the illegal area intercepted images are obtained by the second preprocessing module based on the batch detection box coordinate information and the batch source images;
[0090] In step S1600, when the scheduling module receives the classification result sent by the second reasoning module, the classification result is sent to the server or the client through the scheduling module; wherein the classification result is obtained by the second reasoning module based on the image captured from the illegal area.
[0091] The technical principles of the above steps S1100 to S1600 can be found in the method for building a violation detection model. Figure 3 The relevant descriptions of the illustrated embodiments are not repeated here.
[0092] In the violation detection model, Figure 4 When the violation detection model is shown, in step S1000 of the violation detection method provided by the embodiment of the present invention, the step of processing the source image by the violation detection model to obtain a classification result indicating whether the source image violates the rule may include:
[0093] In step S1010, when a source image is received, the source image is processed by the first target model to obtain a violation detection result; the violation detection result includes a first determination result for characterizing that the source image is compliant, or a second determination result for characterizing that the source image is in violation; the second determination result includes detection frame coordinate information for indicating a suspected violation area in the source image;
[0094] In step S1020, when the detection frame coordinate information is received, the corresponding source image is processed based on the detection frame coordinate information by the second target model to obtain the predicted classification result and feature information of the suspected violation area in the source image;
[0095] In step S1030, a classification result of the suspected violation area is obtained according to the feature library, the predicted classification result and the feature information.
[0096] In the above, the relevant processing flow of the image in step S1010 and step S1020 can refer to the processing flow recorded in steps S1100 to S1600, and the technical principle can refer to the method for building a violation detection model. Figure 3 The relevant descriptions of the illustrated embodiments are not repeated here.
[0097] In addition, in step S1030, a specific implementation scheme of obtaining the classification result of the suspected violation area by using the feature library, the predicted classification result and the feature information, the violation detection method provided by the embodiment of the present invention provides different schemes for different scenarios, as follows:
[0098] The classification results and feature information corresponding to the same suspected violation area of the same source image are grouped together. It can be understood that for a source image, after being processed by the first target model and the second target model, one or more suspected violation areas (wherein "multiple" means more than one) may be identified in the source image, and the second target model outputs the predicted classification results and feature information corresponding to these suspected violation areas. Among them, one suspected violation area corresponds to one predicted classification result and one feature information, and this associated predicted classification result and one feature information is a group of outputs. Based on this, multiple suspected violation areas correspond to multiple groups of outputs.
[0099] The first option:
[0100] In the case that there is only one set of classification results and feature information output by the second target model, in step S1030, the step of obtaining the classification result of the suspected violation area according to the feature library, the predicted classification result and the feature information includes:
[0101] In step S103A, a real label of the target feature information having the highest similarity to the feature information is obtained from the feature library;
[0102] In step S103B, when the similarity between the target feature information and the feature information is greater than or equal to a first set threshold, the true label is used as the classification result of the suspected violation area;
[0103] In step S103C, when the similarity between the target feature information and the feature information is less than the first set threshold, the predicted classification result is used as the classification result of the suspected violation area.
[0104] For step S103A, the similarity between the feature information and all the feature information in the feature library can be calculated one by one, and then the feature information with the highest similarity to the feature information can be selected from the feature library as the target feature information. Since the real label of the target feature information is stored in the feature library, the real label of the target feature information can be obtained from the feature library.
[0105] In addition, if there is a need to improve the efficiency of similar feature searches, in some embodiments, some similar feature screening schemes in related technologies can be used to first screen out candidate feature information with higher similarity from the feature library, and then calculate the similarity between the feature information output by the second target model and each candidate feature information, thereby obtaining the target feature information with the highest similarity from all candidate feature information.
[0106] In addition, the first set threshold value can be obtained based on experience or experiments, and the embodiment of the present invention does not limit this.
[0107] Second option:
[0108] In the case where the second target model outputs more than one set of predicted classification results and feature information, in step S1030, the step of obtaining the classification result of the suspected violation area according to the feature library, the predicted classification results and the feature information includes:
[0109] In step S103a, for each feature information, target feature information with the highest similarity to the feature information is determined from the feature library, and the real label and similarity value corresponding to the target feature information are obtained to obtain an initial search item set;
[0110] In step S103b, from the initial search term set, search terms whose similarity values are greater than or equal to a first set threshold and whose corresponding true labels are violation labels are obtained to obtain a candidate search term set; wherein the search terms include true labels and their corresponding similarity values;
[0111] In step S103c, when the candidate search item set is not an empty set, the search item with the largest similarity value in the candidate search item set is taken as the classification result.
[0112] It should be understood that the above-mentioned prediction classification result includes a prediction category and a prediction score, wherein the prediction category is used to indicate whether the suspected violation area is a violation, and the prediction score is used to indicate the confidence of the prediction category.
[0113] The above steps S103a to S103d can be understood as a feature search priority stage, wherein the process of step S103b can be expressed by the following formula:
[0114]
[0115] In formula (2), labels s [i] represents the true label of the target feature information with the highest similarity among the n feature information output by the second target model for a source image, and scores s[i] represents the similarity between the above i-th feature information and its corresponding target feature information, (labels s [i], scores s [i]) represents the search item corresponding to the i-th feature information, labels d represents the set of violation labels containing all violation labels, represents a set of candidate search items, and threshold1 represents the first set threshold.
[0116] Therefore, through formula (2) expressed by step S103a and step S103b, the target feature information with the highest similarity to each feature information can be determined from the feature library, and the real label and similarity value corresponding to the target feature information can be obtained to obtain the search item corresponding to each feature information, thereby forming an initial search item set; then, from the initial search item set, the search item whose similarity value is greater than or equal to the first set threshold and whose real label is a violation label is obtained, thereby obtaining a candidate search item set.
[0117] After obtaining the candidate search item set, when the candidate search item set is not an empty set, step S103d is executed to take the search item with the largest similarity value in the candidate search item set as the classification result. It can be seen that the classification result output at this time is a representation of the existence of illegal content in the source image, because the real labels corresponding to the search items included in the candidate search item set are all illegal labels. Up to this point, the illegal detection model has completed the detection of this round of illegal content.
[0118] Similarly, the process of taking the search term with the largest similarity value in the candidate search term set as the classification result in step S103c can also be expressed by the formula:
[0119]
[0120] In formula (3), (res_label s_d , res_score s_d ) represents the classification result, where res_label s_d Represents the true label of the classification result, res_score s_d Represents the similarity value of the classification results, represents a set of candidate search terms, Represents a function for obtaining the search term with the largest similarity value from a set of candidate search terms.
[0121] However, when the candidate search item set is an empty set, the category aggregation stage will be entered. At this time, in order to aggregate the results output by the second target model to obtain a more accurate classification result, the predicted category can also be used to indicate the violation level of the suspected violation area. It can be understood that the predicted category can be represented by different numbers, for example, 0, 1, 2, 3, 4, etc. are used to represent four categories and violation levels. If the value of the predicted category is 0, it indicates compliance, and if the value of the predicted category is not 0, it indicates violation. In the case of violation, the violation level corresponding to the value of the predicted category can be determined from the pre-stored violation level mapping relationship based on the value of the predicted category. For example, if the value of the predicted category is 1, if the violation level corresponding to the value is a high violation level based on the violation level mapping relationship, it is considered that the corresponding feature information is the feature information of the high violation level. Among them, the violation level may include but is not limited to: a high violation level, a medium-high violation level, a medium violation level, a medium-low violation level and a low violation level; the higher the level, the more severe the violation. A violation level may correspond to a numerical value, for example, the predicted category value corresponding to the high violation level is 1, the predicted category value corresponding to the medium-high violation level is 2, and so on; in addition, a violation level may also correspond to a range of numerical values, for example, the predicted category value corresponding to the high level is [1, 3), the predicted category value corresponding to the medium-high violation level is [3, 5), and so on.
[0122] Based on this, the violation detection method provided by the embodiment of the present invention may further include:
[0123] In step S103e, when the candidate search item set is an empty set, a prediction classification result whose prediction category is a violation category and whose prediction score is greater than or equal to a first score threshold is obtained to obtain a candidate classification result set;
[0124] In step S103f, the violation level corresponding to the predicted category in the candidate classification result set is determined from the pre-stored violation level mapping relationship, and the predicted classification results whose violation level belongs to the set level and whose predicted score is less than the second score threshold are obtained to obtain a subset of candidate classification results;
[0125] In step S103g, the prediction classification results whose prediction categories are compliance categories are obtained to obtain a compliance result set;
[0126] In step S103h, the classification result of the suspected violation area in the source image is determined according to the candidate classification result set, the candidate classification result subset and the compliance result set.
[0127] Similarly, the process of step S103e can also be expressed by the formula:
[0128] candidates cls_d={(labels cls [i], scores cls [i]) | labels cls [i] ∈
[0129] labels d ∧ scores cls [i] ≥ threshold1} Equation (4)
[0130] In Equation (4), candidates cls_d represents the set of candidate classification results, labels cls [i] represents the predicted class corresponding to the i-th feature information among the n feature information outputs by the second target model, scores cls [i] represents the predicted score corresponding to the above-mentioned i-th feature information, (labels cls [i], scores cls [i]) represents the predicted classification result corresponding to the i-th feature information, labels d represents the set of violation labels containing all violation labels, and threshold1 represents the first score threshold.
[0131] Similarly, the process of step S103f can also be expressed by a formula:
[0132] candidates cls_low_d ={(labels cls [i], scores cls [i]) | labels cls [i] ∈
[0133] labels d ∧ scores cls [i] < threshold2} Equation (5)
[0134] In Equation (5), candidates cls_low_d represents the subset of candidate classification results, threshold2 represents the second score threshold, and the meanings of other letters are the same as those of the corresponding letters in Equation (4), so they will not be elaborated here. Based on this, a subset of candidate classification results with a violation level belonging to the low violation level can be obtained from the set of candidate classification results. It can be seen that in step S103f, the set level refers to the low violation level. As for how to determine the violation level corresponding to the classification result, reference can be made to the relevant records above and will not be elaborated here.
[0135] Similarly, the process of step S103g can also be expressed by a formula:
[0136] candidatescls_normal ={(labels cls [i],scores cls [i])|labels cls [i]∈
[0137] labels normal Formula (6)
[0138] In formula (6), candidates cls_normal Represents a set of compliance results, labels normal The prediction classification results whose prediction category is the compliance category are represented by the set of prediction classification results, and the meanings of other letters are the same as those of the corresponding letters in formula (4), so they are not repeated here. Thus, through step S103g or formula (6), the prediction classification results whose prediction category is the compliance category can be obtained to obtain the compliance result set.
[0139] After obtaining the candidate classification result set, the candidate classification result subset and the compliance result set, the three sets can be used to determine the classification result of the suspected violation area in the source image. In this regard, the embodiment of the present invention provides a corresponding implementation scheme, that is, in step S103h, the step of determining the classification result of the suspected violation area in the source image according to the candidate classification result set, the candidate classification result subset and the compliance result set may include:
[0140] In step S103h1, when the candidate classification result set is not an empty set, the predicted classification result with the largest prediction score in the candidate classification result set is used as the classification result;
[0141] In step S103h2, when the candidate classification result set is an empty set and the candidate classification result subset is not an empty set, the predicted classification result with the largest prediction score in the candidate classification result subset is taken as the classification result;
[0142] In step S103h3, when the candidate classification result set is an empty set and the classification result subset is an empty set, the predicted classification result with the smallest prediction score in the compliance result set is used as the classification result.
[0143] Similarly, the process of taking the predicted classification result with the largest prediction score in the candidate classification result set as the classification result in step S103h1 can be expressed by the formula:
[0144]
[0145] In formula (7), (res label_cls_d ,res score_cls_d ) represents the classification result, where res label_cls_dIndicates the category of the classification result, res score_cls_d Indicates the score of the classification result, candidates cls_d represents the candidate classification result set, A function representing the prediction classification result with the largest prediction score from the candidate classification result set. Based on this, since the prediction categories of the prediction classification results included in the candidate classification result set are all violation categories, the classification result obtained by step S103h1 must represent the presence of violation content. Up to this point, the violation detection model has completed the detection of this round of violation content.
[0146] Similarly, the process of taking the predicted classification result with the largest prediction score in the candidate classification result subset as the classification result in step S103h2 can also be expressed by the formula:
[0147]
[0148] In formula (8), (res_label cls_low_d ,res_score cls_low_d ) represents the classification result, candidates cls_low_d represents a subset of candidate classification results, and the function The relevant meaning of can be found in the above related records, which will not be repeated here. Based on this, since the predicted categories of the predicted classification results included in the candidate classification result subset are all violation categories, the classification results obtained by step S103h2 must represent the presence of illegal content. As of this point, the violation detection model has completed the detection of this round of illegal content.
[0149] Similarly, the process of taking the predicted classification result with the smallest prediction score in the compliance result set as the classification result in step S103h3 can also be expressed by the formula:
[0150]
[0151] In formula (9), (res_label cls_normal ,res_score cls_normal ) represents the classification result, candidates cls_normal Represents a set of compliant results, and for functions The understanding of can be understood based on the relevant explanation of the above-mentioned max function, and the min function is to take the minimum value. Based on this, since the predicted categories of the predicted classification results contained in the compliance result set are all compliance categories, the classification results obtained by step S103h3 must represent that there is no illegal content. Up to this point, the violation detection model has completed the detection of this round of illegal content. Here, the predicted classification result with the smallest prediction score is selected as the classification result. When displaying, the reviewer can be reminded to focus on the predicted classification results with the smallest prediction scores to further determine whether the corresponding source image does not contain illegal content.
[0152] As can be seen from the above, when the predicted classification results output by the second target model are further verified using the feature library, the feature search priority stage is first performed. When the candidate search item set is an empty set, the category aggregation stage is performed. In the feature search priority stage, the classification results are output mainly based on the real labels and similarities corresponding to the feature information in the feature library. Since the real labels are manually labeled, when the target feature information whose similarity with the feature information output by the second target model is greater than the corresponding set threshold can be found in the feature library, the real labels and similarities corresponding to the target feature information can be used as classification results, thereby solving the problem of missed identification and misidentification of illegal content. When the second target model outputs multiple sets of prediction results and feature information for the source image, the multiple sets of prediction results can be aggregated through the search priority stage or the category aggregation stage, and a unique and representative classification result can be output, thereby solving the problem in the related technology that the violation detection conclusion is not unique due to the violation detection model having multiple sets of output results, and the relevant personnel cannot accurately know the final qualitative results, resulting in invalid model output.
[0153] In addition, by further proposing the category aggregation stage, it is possible to use the multiple groups of prediction results output by the second target model for aggregation processing when the feature information constructed by the feature library is limited and it is difficult to fully cover the characteristics of unknown categories and violation risks, thereby enhancing the recognition ability of the violation detection model.
[0154] In some embodiments, when the classification result cannot be obtained through the feature search priority stage, that is, when the candidate search item set is an empty set, in order to maintain the processing advantage of the feature search priority stage, before entering the category aggregation stage, that is, before executing step S103e, the prediction results corresponding to the feature information whose true label is determined to be a compliance label in the feature search priority stage can be deleted from the multiple sets of prediction results output by the second target model to avoid affecting the accuracy of the classification results finally outputted in the subsequent category aggregation stage. Based on this, the violation detection method provided by the embodiment of the present invention can also include, before the step of obtaining the prediction classification result whose prediction category is a violation category and whose prediction score is greater than or equal to the first score threshold, the following steps:
[0155] In step S103d1, obtaining, from the initial search item set, compliant search items whose real labels are compliant labels and whose similarity values are greater than a second set threshold;
[0156] In step S103d2, the predicted classification results corresponding to the compliant search terms are deleted to obtain a set of predicted classification results.
[0157] Therefore, through step S103d1 and step S103d2, the prediction results whose corresponding search item's true label is a compliance label can be deleted from all the prediction results output by the second target model before the category aggregation stage. Based on this, in step S103e, the obtained candidate classification result set is a subset of the predicted classification result set, that is, in step S103e, the predicted classification results whose predicted category is a violation category and whose prediction score is greater than or equal to the first score threshold are obtained from the predicted classification result set, and the deleted predicted classification results will not be included. This can not only avoid the predicted classification results that have been determined to be compliant from continuing to retain the original predicted classification results, for example, the original predicted classification results represent a violation, which affects the judgment of the category aggregation stage, but also causes the accuracy of the classification results output in the end to be adversely affected.
[0158] In the above, the process of steps S103e01 and S103e02 can also be expressed by the formula:
[0159] (labels clc , scores cls )←
[0160] (labels cls0 , scores cls0 )-{(labels cls [i], scores cls [i])|labels s [i]
[0161] ∈labels normal ∧scores s [i]≥threshold2} Formula (10)
[0162] In formula (10), (labels cls , scores cls ) represents the predicted classification result set, (labels cls0 , scores cls0 ) represents the set of all predicted classification results output by the second target model, labels s[i] represents the true label of the search item corresponding to the i-th feature information among the n feature information output by the second target model, labels normal Represents a tag set containing all compliant tags, scores s [i] represents the similarity value corresponding to the i-th feature information, that is, the similarity value in the search item corresponding to the i-th feature information, and threshold2 represents the second set threshold.
[0163] It should be noted that any set threshold or any score threshold involved in the embodiments of the present invention can be obtained based on experience or experiments, and the present invention is not limited to this.
[0164] It is worth noting that the technical features or technical solutions in any of the above embodiments of the present invention can be combined with each other as long as there is no combination contradiction.
[0165] In order to execute the corresponding steps in the above-mentioned embodiments and various possible methods of the violation detection model construction method, a method for implementing a violation detection model construction device is given below. Optionally, the violation detection model construction device can adopt the above-mentioned Figure 1 For further information, please refer to Figure 6 , Figure 6 A functional module diagram of a violation detection model construction device provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the violation detection model construction device provided in this embodiment are the same as those of the above-mentioned violation detection model construction method embodiment. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above-mentioned violation detection model construction method embodiment. The violation detection model construction device 600 includes:
[0166] The first training module 610 is configured to: train the first model through the first sample set until the first model converges to obtain a first target model; the first sample set includes illegal images and compliant images, and the first target model is used to detect suspicious illegal areas in the image;
[0167] The second training module 620 is configured to: train the second model through the second sample set until the second model converges to obtain a second target model; the second sample set includes a captured image of the violation area, and the second target model is used to process the suspected violation area output by the first target model to obtain a classification result indicating whether the suspected violation area is a violation;
[0168] The construction module 630 is configured to construct a violation detection model according to the first target model and the second target model.
[0169] In some embodiments, the process of constructing the violation detection model by the construction module 630 according to the first target model and the second target model is configured as follows:
[0170] Decoupling the first target model into a first preprocessing module, a first reasoning module and a first result processing module;
[0171] Decoupling the second target model into a second preprocessing module and a second reasoning module;
[0172] A scheduling module is constructed, and the first preprocessing module, the first reasoning module, the first result processing module, the second preprocessing module and the second reasoning module are respectively connected to the scheduling module to form a violation detection model.
[0173] In some other embodiments, the process of constructing the violation detection model by the construction module 630 according to the first target model and the second target model is adjusted and configured as follows:
[0174] Decoupling the first target model into a first preprocessing module, a first reasoning module and a first result processing module;
[0175] Decoupling the second target model into a second preprocessing module and a second reasoning module;
[0176] Constructing a first scheduling module and a second scheduling module connected to each other;
[0177] The first preprocessing module, the first reasoning module and the first result processing module are respectively connected to the first scheduling module, and the second preprocessing module and the second reasoning module are respectively connected to the second scheduling module to form a violation detection model.
[0178] In some other embodiments, the process of constructing the violation detection model by the construction module 630 according to the first target model and the second target model is adjusted and configured as follows:
[0179] Constructing a feature library; the feature library is used to store feature information output by the second target model and real labels corresponding to the feature information, wherein the real labels include compliance labels and violation labels;
[0180] A violation detection model is constructed based on the first target model, the second target model and the feature library.
[0181] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown in the figure or solidified in the operating system (OS) of the electronic device, and can be Figure 1Meanwhile, the data and program codes required for executing the above modules can be stored in the memory.
[0182] In order to execute the corresponding steps in the above-mentioned embodiments of the violation detection method and various possible methods, a method for implementing a violation detection device is given below. Optionally, the violation detection device can adopt the above-mentioned Figure 1 For further information, please refer to Figure 7 , Figure 7 This is a functional module diagram of a violation detection device provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the violation detection device provided in this embodiment are the same as those of the above-mentioned violation detection method embodiment. For the sake of brief description, for the parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above-mentioned violation detection method embodiment. The violation detection device 700 includes:
[0183] The detection module 710 is configured to: process the source image through a violation detection model to obtain a classification result indicating whether the source image violates the rules; wherein the violation detection model is constructed by the violation detection model construction device 600.
[0184] In some embodiments, the process in which the detection module 710 processes the source image through the violation detection model to obtain a classification result indicating whether the source image violates the rule is configured as follows:
[0185] When the scheduling module receives a first preset number of source images, sending a batch of source images to the first preprocessing module through the scheduling module;
[0186] When the scheduling module receives a second preset number of pre-processed images, the scheduling module sends a batch of pre-processed images to the first reasoning module; wherein the pre-processed images are obtained by the first pre-processing module based on the source images;
[0187] When the scheduling module receives a third preset number of image features, the batch image features are sent to the first result processing module through the scheduling module; wherein the image features are obtained by the first reasoning module based on the pre-processed image processing;
[0188] When the scheduling module receives a fourth preset number of detection frame coordinate information, the scheduling module sends batch detection frame coordinate information and batch source images corresponding to the batch detection frame coordinate information to the second preprocessing module; wherein the detection frame coordinate information is obtained by the first result processing module based on the image feature processing;
[0189] When the scheduling module receives a fifth preset number of illegal area intercepted images, the scheduling module sends a batch of illegal area intercepted images to the second reasoning module; wherein the illegal area intercepted images are obtained by the second preprocessing module based on the batch detection frame coordinate information and the batch source images;
[0190] When the scheduling module receives the classification result sent by the second reasoning module, the classification result is sent to the server or the client through the scheduling module; wherein the classification result is obtained by the second reasoning module based on the image captured from the illegal area.
[0191] In some other embodiments, the process in which the detection module 710 processes the source image through the violation detection model to obtain a classification result indicating whether the source image violates the rule is adjusted and configured as follows:
[0192] The step of processing the source image by the violation detection model to obtain a classification result indicating whether the source image violates the rules comprises:
[0193] When a source image is received, the source image is processed by the first target model to obtain a violation detection result; the violation detection result includes a first determination result for characterizing that the source image is compliant, or a second determination result for characterizing that the source image is in violation; the second determination result includes detection frame coordinate information for indicating a suspected violation area in the source image;
[0194] When the detection frame coordinate information is received, the corresponding source image is processed based on the detection frame coordinate information by the second target model to obtain a predicted classification result and feature information of a suspected violation area in the source image;
[0195] A classification result of the suspected violation area is obtained according to the feature library, the predicted classification result and the feature information.
[0196] In some embodiments, the predicted classification result and feature information corresponding to the same suspected violation area of the same source image are grouped together. When there is only one group of predicted classification result and feature information output by the second target model, the process of the detection module 710 obtaining the classification result of the suspected violation area according to the feature library, the predicted classification result and the feature information is configured as follows:
[0197] Obtaining, from the feature library, a true label of the target feature information having the highest similarity to the feature information;
[0198] When the similarity between the target feature information and the feature information is greater than or equal to a first set threshold, taking the true label as the classification result of the suspected violation area;
[0199] When the similarity between the target feature information and the feature information is less than the first set threshold, the predicted classification result is used as the classification result of the suspected violation area.
[0200] In some embodiments, the predicted classification results and feature information corresponding to the same suspected violation area of the same source image are grouped together. When the second target model outputs more than one group of predicted classification results and feature information, the detection module 710 obtains the classification result of the suspected violation area according to the feature library, the predicted classification results and the feature information, and is configured as follows:
[0201] For each feature information, determine the target feature information with the highest similarity to the feature information from the feature library, and obtain the real label and similarity value corresponding to the target feature information to obtain an initial search item set;
[0202] From the initial search item set, obtain search items whose similarity values are greater than or equal to a first set threshold and whose corresponding true labels are compliant labels, so as to obtain a candidate search item set; wherein the search items include true labels and their corresponding similarity values;
[0203] When the candidate search item set is not an empty set, the search item with the largest similarity value in the candidate search item set is used as the classification result.
[0204] In some embodiments, the predicted classification result includes a predicted category and a predicted score, the predicted category is used to indicate whether the suspected violation area is in violation and the violation level, and the predicted score is used to indicate the confidence of the predicted category; the process in which the detection module 710 obtains the classification result of the suspected violation area according to the feature library, the predicted classification result and the feature information is further configured as follows:
[0205] When the candidate search item set is an empty set, obtaining a prediction classification result whose prediction category is a violation category and whose prediction score is greater than or equal to a first score threshold, to obtain a candidate classification result set;
[0206] Determine the violation level corresponding to the predicted category in the candidate classification result set from the pre-stored violation level mapping relationship, and obtain the predicted classification results whose violation level belongs to the set level and whose predicted score is less than the second score threshold, so as to obtain a subset of candidate classification results;
[0207] Obtain prediction classification results whose prediction categories are compliance categories to obtain a compliance result set;
[0208] A classification result of a suspected violation area in the source image is determined according to the candidate classification result set, the candidate classification result subset and the compliance result set.
[0209] In some embodiments, the process of the detection module 710 determining the classification result of the suspected violation area in the source image according to the candidate classification result set, the candidate classification result subset and the compliance result set is configured as follows:
[0210] When the candidate classification result set is not an empty set, taking the predicted classification result with the largest prediction score in the candidate classification result set as the classification result;
[0211] When the candidate classification result set is an empty set and the candidate classification result subset is not an empty set, taking the predicted classification result with the largest prediction score in the candidate classification result subset as the classification result;
[0212] When the candidate classification result set is an empty set and the classification result subset is an empty set, the predicted classification result with the smallest prediction score in the compliance result set is used as the classification result.
[0213] In some embodiments, the detection module 710 is further configured to:
[0214] Before obtaining a prediction classification result whose prediction category is a violation category and whose prediction score is greater than or equal to a first score threshold, obtaining a compliance search item whose real label is a compliance label and whose similarity value is greater than a second set threshold from the initial search item set;
[0215] Deleting the predicted classification results corresponding to the compliant search terms to obtain a set of predicted classification results;
[0216] Correspondingly, the candidate classification result set is a subset of the predicted classification result set.
[0217] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown in the figure or solidified in the operating system (OS) of the electronic device, and can be Figure 1 Meanwhile, the data and program codes required for executing the above modules can be stored in the memory.
[0218] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0219] In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0220] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0221] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for constructing a violation detection model, characterized in that: include: The first model is trained by a first sample set until the first model converges to obtain a first target model; the first sample set includes illegal images and compliant images, and the first target model is used to detect suspicious illegal areas in the image; The second model is trained by the second sample set until the second model converges to obtain a second target model; the second sample set includes a captured image of the violation area, and the second target model is used to process the suspected violation area output by the first target model to obtain a classification result indicating whether the suspected violation area is in violation; A violation detection model is constructed based on the first target model and the second target model.
2. The method according to claim 1, characterized in that The step of constructing a violation detection model according to the first target model and the second target model comprises: Decoupling the first target model into a first preprocessing module, a first reasoning module and a first result processing module; Decoupling the second target model into a second preprocessing module and a second reasoning module; A scheduling module is constructed, and the first preprocessing module, the first reasoning module, the first result processing module, the second preprocessing module and the second reasoning module are respectively connected to the scheduling module to form a violation detection model.
3. The method according to claim 1, characterized in that The step of constructing a violation detection model according to the first target model and the second target model comprises: Decoupling the first target model into a first preprocessing module, a first reasoning module and a first result processing module; Decoupling the second target model into a second preprocessing module and a second reasoning module; Constructing a first scheduling module and a second scheduling module connected to each other; The first preprocessing module, the first reasoning module and the first result processing module are respectively connected to the first scheduling module, and the second preprocessing module and the second reasoning module are respectively connected to the second scheduling module to form a violation detection model.
4. The method according to any one of claims 1 to 3, characterized in that The step of constructing a violation detection model according to the first target model and the second target model comprises: Constructing a feature library; the feature library is used to store feature information output by the second target model and real labels corresponding to the feature information, wherein the real labels include compliance labels and violation labels; A violation detection model is constructed based on the first target model, the second target model and the feature library.
5. A violation detection method, characterized in that: include: The source image is processed by a violation detection model to obtain a classification result indicating whether the source image violates a rule; wherein the violation detection model is constructed by the violation detection model construction method described in any one of claims 1 to 4.
6. The method according to claim 5, characterized in that The violation detection model is constructed by the violation detection model construction method according to claim 2; The step of processing the source image by the violation detection model to obtain a classification result indicating whether the source image violates the rules comprises: When the scheduling module receives a first preset number of source images, sending a batch of source images to the first preprocessing module through the scheduling module; When the scheduling module receives a second preset number of pre-processed images, the scheduling module sends a batch of pre-processed images to the first reasoning module; wherein the pre-processed images are obtained by the first pre-processing module based on the source images; When the scheduling module receives a third preset number of image features, the batch image features are sent to the first result processing module through the scheduling module; wherein the image features are obtained by the first reasoning module based on the pre-processed image processing; When the scheduling module receives a fourth preset number of detection frame coordinate information, the scheduling module sends batch detection frame coordinate information and batch source images corresponding to the batch detection frame coordinate information to the second preprocessing module; wherein the detection frame coordinate information is obtained by the first result processing module based on the image feature processing; When the scheduling module receives a fifth preset number of illegal area intercepted images, the scheduling module sends a batch of illegal area intercepted images to the second reasoning module; wherein the illegal area intercepted images are obtained by the second preprocessing module based on the batch detection frame coordinate information and the batch source images; When the scheduling module receives the classification result sent by the second reasoning module, the classification result is sent to the server or the client through the scheduling module; wherein the classification result is obtained by the second reasoning module based on the image captured from the illegal area.
7. The method according to claim 5 or 6, characterized in that: The violation detection model is constructed by the violation detection model construction method according to claim 4; The step of processing the source image by the violation detection model to obtain a classification result indicating whether the source image violates the rules comprises: When a source image is received, the source image is processed by the first target model to obtain a violation detection result; the violation detection result includes a first determination result for characterizing that the source image is compliant, or a second determination result for characterizing that the source image is in violation; the second determination result includes detection frame coordinate information for indicating a suspected violation area in the source image; When the detection frame coordinate information is received, the corresponding source image is processed based on the detection frame coordinate information by the second target model to obtain a predicted classification result and feature information of a suspected violation area in the source image; A classification result of the suspected violation area is obtained according to the feature library, the predicted classification result and the feature information.
8. The method according to claim 7, characterized in that Taking the predicted classification results and feature information corresponding to the same suspected violation area of the same source image as one group, when there is only one group of predicted classification results and feature information output by the second target model, the step of obtaining the classification result of the suspected violation area according to the feature library, the predicted classification results and the feature information includes: Obtaining, from the feature library, a true label of target feature information having the highest similarity to the feature information; When the similarity between the target feature information and the feature information is greater than or equal to a first set threshold, taking the true label as the classification result of the suspected violation area; When the similarity between the target feature information and the feature information is less than the first set threshold, the predicted classification result is used as the classification result of the suspected violation area.
9. The method according to claim 7, characterized in that: Taking the predicted classification results and feature information corresponding to the same suspected violation area of the same source image as one group, when the second target model outputs more than one group of predicted classification results and feature information, the step of obtaining the classification result of the suspected violation area according to the feature library, the predicted classification results and the feature information includes: For each feature information, determine the target feature information with the highest similarity to the feature information from the feature library, and obtain the real label and similarity value corresponding to the target feature information to obtain an initial search item set; From the initial search item set, obtain search items whose similarity values are greater than or equal to a first set threshold and whose corresponding true labels are violation labels, so as to obtain a candidate search item set; wherein the search items include true labels and their corresponding similarity values; When the candidate search item set is not an empty set, the search item with the largest similarity value in the candidate search item set is taken as the classification result.
10. The method according to claim 9, characterized in that The prediction classification result includes a prediction category and a prediction score, wherein the prediction category is used to indicate whether the suspected violation area is a violation and the violation level, and the prediction score is used to indicate the confidence of the prediction category; the method further includes: When the candidate search item set is an empty set, obtaining a prediction classification result whose prediction category is a violation category and whose prediction score is greater than or equal to a first score threshold, to obtain a candidate classification result set; Determine the violation level corresponding to the predicted category in the candidate classification result set from the pre-stored violation level mapping relationship, and obtain the predicted classification results whose violation level belongs to the set level and whose predicted score is less than the second score threshold, so as to obtain a subset of candidate classification results; Obtain prediction classification results whose prediction categories are compliance categories to obtain a compliance result set; A classification result of a suspected violation area in the source image is determined according to the candidate classification result set, the candidate classification result subset and the compliance result set.
11. The method according to claim 10, characterized in that The step of determining the classification result of the suspected violation area in the source image according to the candidate classification result set, the candidate classification result subset and the compliance result set comprises: When the candidate classification result set is not an empty set, taking the predicted classification result with the largest prediction score in the candidate classification result set as the classification result; When the candidate classification result set is an empty set and the candidate classification result subset is not an empty set, taking the predicted classification result with the largest prediction score in the candidate classification result subset as the classification result; When the candidate classification result set is an empty set and the candidate classification result subset is an empty set, the predicted classification result with the smallest prediction score in the compliance result set is used as the classification result.
12. The method according to claim 10, characterized in that Before the step of obtaining a prediction classification result in which the prediction category is a violation category and the prediction score is greater than or equal to a first score threshold, the method further includes: From the initial search item set, obtain a compliant search item whose real label is a compliant label and whose similarity value is greater than a second set threshold; Deleting the predicted classification results corresponding to the compliant search terms to obtain a set of predicted classification results; Correspondingly, the candidate classification result set is a subset of the predicted classification result set.
13. A violation detection model building device, characterized in that: include: A first training module is configured to: train a first model through a first sample set until the first model converges to obtain a first target model; the first sample set includes illegal images and compliant images, and the first target model is used to detect suspicious illegal areas in the image; A second training module is configured to: train the second model through a second sample set until the second model converges to obtain a second target model; the second sample set includes a captured image of the violation area, and the second target model is used to process the suspected violation area output by the first target model to obtain a classification result indicating whether the suspected violation area is in violation; The construction module is configured to construct a violation detection model according to the first target model and the second target model.
Citation Information
Patent Citations
Video auditing method, video auditing device, equipment and storage medium
CN111225234A
