Method, apparatus and server for detecting rule violation pictures
By segmenting images into multiple regions and using a predictive model for detection, the problem of low accuracy in detecting illegal picture-in-picture images is solved, achieving more efficient identification and location of illegal images.
Patent Information
- Application Number
- CN202210294028.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-23
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-03-23
AI Technical Summary
Existing technologies have low accuracy in detecting illegal picture-in-picture images and cannot effectively identify small illegal images embedded in background images.
By dividing the image to be detected into multiple second images, a prediction model is used to predict the category of each second image, and the location of the violation area is calculated by regression through the predicted offset information. The prediction model is then optimized to improve the detection accuracy.
It improves the detection accuracy of illegal images, reduces the amount of data processed by the prediction model each time, saves computational resources, and improves detection efficiency.
Smart Images

Figure CN114663792B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, and in particular to a method and device for detecting illegal pictures and a server. BACKGROUND
[0002] With the development of network technology, network has become an important way for people to obtain information. In order to provide a healthy network environment for users, administrators usually need to detect the information uploaded by users. Among them, illegal picture detection is one of the commonly used detection methods.
[0003] In the process of illegal picture detection, the server will obtain a first picture to be detected, and determine whether the first picture to be detected belongs to an illegal picture. At present, the commonly used illegal picture detection method usually detects the entire picture. When the entire first picture to be detected is an illegal picture, the illegal picture detection method can accurately determine that the first picture to be detected is an illegal picture.
[0004] However, there is a new type of attack method, in which the attacker will embed a small illegal picture in a normal background picture to form a picture-in-picture. When the picture-in-picture is used as the first picture to be detected, the illegal picture detection method in the prior art usually cannot accurately identify the illegal picture in the picture-in-picture, and there is a problem of low detection accuracy. SUMMARY
[0005] The present application provides an illegal picture detection method, device and server to solve the problem of low detection efficiency in the prior art.
[0006] In a first aspect, the present application provides an illegal picture detection method, comprising:
[0007] obtaining a first picture to be detected;
[0008] dividing the first picture into a plurality of second pictures using a preset window;
[0009] predicting each second picture using a prediction model to obtain a prediction category of each second picture, the prediction category including two categories of belonging to an illegal picture and not belonging to an illegal picture;
[0010] when there is at least one second picture corresponding to a prediction category of belonging to an illegal picture, determining that the first picture is an illegal picture.
[0011] Optionally, the step of dividing the first picture into a plurality of second pictures using a preset window comprises:
[0012] using the preset window to slide and obtain a plurality of second pictures in the picture to be detected.
[0013] Optionally, the prediction model is used to predict each of the second pictures to obtain a prediction category of each of the second pictures, including:
[0014] The prediction model is used to convolve each of the second pictures in the first picture to obtain a plurality of feature points;
[0015] The plurality of feature points are input into the prediction model to predict a prediction category of each of the second pictures.
[0016] Optionally, the method further comprises:
[0017] The plurality of feature points are input into the prediction model to predict a prediction offset information of each of the second pictures, the prediction offset information including a center point coordinate of the second picture and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a prediction center point coordinate of a violation region in the first picture;
[0018] According to the prediction offset information of each of the second pictures in the first picture, a prediction position information of the violation region in the first picture is calculated by regression, the prediction position information including a prediction center point coordinate, a prediction width and a prediction height of the violation region in the first picture.
[0019] Optionally, the method further comprises:
[0020] A training set is obtained, the training set including a training picture containing a violation region and a picture label indicating actual position information of the violation region in the training picture;
[0021] Each of the training pictures in the training set is divided into a plurality of second pictures using a preset window;
[0022] Each of the second pictures in each of the training pictures is predicted using the prediction model to obtain a prediction category of each of the second pictures, the prediction category including two categories of belonging to a violation picture and not belonging to a violation picture;
[0023] According to position information of each of the second pictures in each of the training pictures and actual position information of the violation region in each of the training pictures, an actual category of the second picture is determined, the actual category including two categories of belonging to a violation picture and not belonging to a violation picture;
[0024] According to the prediction category and the actual category of each of the second pictures in each of the training pictures in the training set, a label loss of the prediction model is determined, and the prediction model is optimized according to the label loss.
[0025] Optionally, the determining the actual category of each of the second pictures according to the position information of each of the second pictures of each of the training pictures in the training set and the actual position information of the violation region in each of the training pictures comprises:
[0026] calculating the overlap degree of each of the second pictures and the violation region according to the position information of each of the second pictures of each of the training pictures in the training set and the actual position information of the violation region in the training picture;
[0027] when the overlap degree of the second picture is greater than or equal to a preset threshold, the actual category of the second picture is that the second picture belongs to a violation picture; otherwise, the actual category of the second picture is that the second picture does not belong to a violation picture.
[0028] Optionally, the method further comprises:
[0029] predicting each of the second pictures in each of the training pictures using the prediction model, to obtain prediction offset information of each of the second pictures, the prediction offset information comprising a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a predicted center point coordinate of the violation region in the training picture;
[0030] regression calculating, according to the prediction offset information of each of the second pictures of each of the training pictures, to obtain prediction position information of the violation region in each of the training pictures, the prediction position information comprising a predicted center point coordinate, a predicted width and a predicted height;
[0031] determining a position loss of the prediction model according to the prediction position information of each of the training pictures in the training set and the actual position information in the picture label;
[0032] optimizing the prediction model according to the label loss and the position loss.
[0033] In a second aspect, the present application provides a violation picture detection device, comprising:
[0034] an acquisition module configured to acquire a first picture to be detected;
[0035] a processing module configured to divide the first picture into a plurality of second pictures using a preset window, predict each of the second pictures using a prediction model, to obtain a prediction category of each of the second pictures, the prediction category comprising two categories of belonging to a violation picture and not belonging to a violation picture, and determine that the first picture is a violation picture when there is at least one second picture corresponding to a prediction category of belonging to a violation picture.
[0036] Optionally, the processing module is specifically configured to:
[0037] The preset window is used to obtain a plurality of second pictures by sliding in the picture to be detected.
[0038] Optionally, the processing module is specifically configured to:
[0039] The first picture is convolved using the prediction model to obtain a plurality of feature points.
[0040] The plurality of feature points are input into the prediction model to predict a prediction category of each second picture.
[0041] Optionally, the processing module is further configured to:
[0042] The plurality of feature points are input into the prediction model to predict prediction offset information of each second picture, wherein the prediction offset information includes a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a prediction center point coordinate of a rule violation region in the first picture.
[0043] According to the prediction offset information of each second picture in the first picture, prediction position information of the rule violation region in the first picture is calculated by regression, wherein the prediction position information includes a prediction center point coordinate, a prediction width and a prediction height of the rule violation region in the first picture.
[0044] Optionally, the device further comprises:
[0045] A model generation module is configured to obtain a training set, wherein the training set includes a training picture containing a rule violation region and a picture label indicating actual position information of the rule violation region in the training picture; a preset window is used to divide each training picture in the training set into a plurality of second pictures; the prediction model is used to predict each second picture in each training picture to obtain a prediction category of each second picture, wherein the prediction category includes two categories of a rule violation picture and a non-rule violation picture; according to position information of each second picture of each training picture in the training set and actual position information of the rule violation region in each training picture, an actual category of the second picture is determined, wherein the actual category includes two categories of a rule violation picture and a non-rule violation picture; according to the prediction category and the actual category of each second picture in each training picture in the training set, a label loss of the prediction model is determined, and the prediction model is optimized according to the label loss.
[0046] Optionally, the model generation module is specifically configured to:
[0047] According to the position information of each of the second pictures of each of the training pictures in the training set and the actual position information of the violation region in the training picture, an overlap degree of the second picture and the violation region is calculated;
[0048] When the overlap degree of the second picture is greater than or equal to a preset threshold, an actual category of the second picture is that the second picture belongs to a violation picture; otherwise, the actual category of the second picture is that the second picture does not belong to a violation picture.
[0049] Optionally, the model generation module is further configured to:
[0050] predict, by using the prediction model, each of the second pictures in each of the training pictures, to obtain prediction offset information of each of the second pictures, the prediction offset information including a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a predicted center point coordinate of a violation region in the training picture;
[0051] According to the prediction offset information of each of the second pictures of each of the training pictures, regression calculation is performed to obtain prediction position information of the violation region in each of the training pictures, the prediction position information including a predicted center point coordinate, a predicted width and a predicted height;
[0052] According to the prediction position information of each of the training pictures in the training set and the actual position information in the picture label, a position loss of the prediction model is determined;
[0053] According to the label loss and the position loss, the prediction model is optimized.
[0054] In a third aspect, a server is provided, including a memory and a processor.
[0055] The memory is configured to store a computer program, and the processor is configured to execute the violation picture detection method in the first aspect and any possible design of the first aspect according to the computer program stored in the memory.
[0056] In a fourth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. When at least one processor of a server executes the computer program, the server executes the violation picture detection method in the first aspect and any possible design of the first aspect.
[0057] In a fifth aspect, the present application provides a computer program product, which comprises a computer program, when at least one processor of a server executes the computer program, the server executes the rule violation picture detection method in the first aspect and any possible design of the first aspect.
[0058] The rule violation picture detection method provided by the present application comprises the following steps: obtaining a picture uploaded to a cloud end and taking the picture as a first picture to be detected; using a preset window to slide in the first picture to be detected to obtain a plurality of second pictures; using a prediction model to down-sample each second picture to obtain a feature point corresponding to each second picture, and the feature points of the plurality of second pictures of the first picture can form a feature picture; inputting the feature picture into the prediction model to predict a prediction category of each second picture, thereby improving the detection accuracy of rule violation pictures. Moreover, the present application divides a larger first picture into a plurality of second pictures for detection, thereby reducing the data amount processed by the prediction model each time for prediction and improving the picture detection efficiency. When the prediction model detects the second picture, once it is detected that the second picture belongs to a rule violation picture, the prediction model will not need to detect other second pictures, thereby saving calculation resources. BRIEF DESCRIPTION OF DRAWINGS
[0059] In order to more clearly illustrate the technical solutions of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without any creative effort.
[0060] Figure 1 A picture-in-picture schematic diagram provided by an embodiment of the present application;
[0061] Figure 2 A first picture processing scene schematic diagram provided by an embodiment of the present application;
[0062] Figure 3 A flowchart of a rule violation picture detection method provided by an embodiment of the present application;
[0063] Figure 4 A flowchart of another rule violation picture detection method provided by an embodiment of the present application;
[0064] Figure 5 A flowchart of still another rule violation picture detection method provided by an embodiment of the present application;
[0065] Figure 6 A flowchart of yet another rule violation picture detection method provided by an embodiment of the present application;
[0066] Figure 7 A structural schematic diagram of a device for detecting illegal pictures provided by an embodiment of the present application is shown in FIG. 1.
[0067] Figure 8 A hardware structural schematic diagram of a server provided by an embodiment of the present application is shown in FIG. 2. DETAILED DESCRIPTION
[0068] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described in detail below with the drawings in the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0069] The terms "first", "second", "third", "fourth" and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances. For example, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information, without departing from the scope of the present application.
[0070] Depending on the context, the word "if" as used herein can be interpreted to mean "when" or "in response to determining".
[0071] Furthermore, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context indicates otherwise.
[0072] It should be further understood that the terms "comprise", "comprising", "include", "including", "contain", "containing", "have", "having", "consist", "consisting", "consisting essentially of" indicate the presence of the features, steps, operations, elements, components, items, kinds, and / or groups but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups.
[0073] The terms "or" and "and / or" as used herein are to be interpreted as inclusive, or meaning either or any combination thereof. Therefore, "A, B or C" or "A, B and / or C" means "any of the following: A; B; C; A and B; A and C; B and C; A, B and C". An exception to this definition will occur only when a combination of elements, functions, steps or acts are in some way inherently mutually exclusive.
[0074] With the development of internet technology, the internet has become an important channel for people to obtain information. To provide users with a healthy online environment, administrators typically need to monitor user-uploaded information. One common method is detecting inappropriate images. Inappropriate images can include those containing content that violates national laws and regulations, those that violate public order and morals, or those that are unsuitable for public dissemination. For example, inappropriate images can include private images without permission, pirated images, and pornographic images. During the inappropriate image detection process, the server obtains the first image to be detected and determines whether it is inappropriate. Currently, commonly used inappropriate image detection methods typically detect the entire image. When the entire first image to be detected is inappropriate, the method can accurately determine that the first image is indeed inappropriate.
[0075] However, a new type of attack has emerged where the attacker embeds a small, intrusive image within a normal background image, creating a picture-in-picture. The area containing the intrusive image within this picture-in-picture is the intrusive area. This picture-in-picture can be used as follows: Figure 1 As shown, the prohibited images can be as follows: Figure 1 The image is shown within the solid white box. This solid white box may also include a dashed white box, which is a rectangle that has not been rotated or distorted. The area indicated by this dashed white box is the violation area. Figure 1 In this example, the white solid border is used to more clearly show the location of the offending image. In the actual embedding process, the offending image can use a border of any color, or no border at all. Figure 1 The white dashed box in the image is only used to indicate the violation area; it is usually not included in the actual first image. When the first image to be detected is a picture-in-picture, the violation area occupies a very small proportion of the first image. Therefore, existing violation image classification algorithms cannot effectively prevent this type of attack, resulting in low recognition accuracy and poor detection performance. In existing technologies, considering that the violation area in a picture-in-picture is usually rectangular and may have relatively obvious contour features, Hough transform line detection can be used to locate the violation image to some extent. However, this line detection method mainly relies on the gradient transformation of the image. False detection is prone to occur if there are obvious lines in the background image of the first image to be detected. Furthermore, this line detection method can only detect whether a picture-in-picture exists in the first image to be detected, but cannot determine whether the picture-in-picture is a violation image.
[0076] To solve the above problems, the application provides a method for detecting illegal pictures. In the application, the server can use a CNN convolutional neural network to convolve the entire first picture to be detected. The server can down-sample to obtain a feature picture. For example, the size of the feature picture can be 8*8 pixels. The size of the feature picture can be determined according to a preset window (anchor) of a fixed size. One anchor can correspond to one feature point in the feature picture. One anchor can correspond to a second picture in the first picture to be detected. The second picture is the position where the illegal region in the first picture to be detected may appear. The server can predict each feature point in the feature picture through a prediction model. The prediction result can include a prediction category. The prediction category can include two categories: belonging to an illegal picture and not belonging to an illegal picture. The prediction result can also include prediction offset information. The prediction offset information can include the center point coordinates of the second picture corresponding to the feature point in the first picture to be detected, and the horizontal and vertical offset amounts between the center point coordinates of the second picture and the predicted center point coordinates of the illegal region in the first picture to be detected. The server can regress and calculate the predicted position information of the illegal region in the first picture to be detected according to the predicted offset information. The prediction position information can include the predicted center point coordinates, the predicted width and the predicted height.
[0077] Before performing the above prediction operation using the prediction model, the server also needs to train the prediction model using training pictures. In the training process, the server can determine the overlap rate of each second picture and the illegal region according to the actual position information of the illegal region in each training picture and the position information of each second picture. When the overlap rate is greater than a preset threshold, it can be determined that the actual category of the second picture is an illegal picture. The server can calculate the label loss of the prediction model according to the predicted category and the actual category of each second picture predicted by the prediction model. The server can also regress and calculate the predicted position information of the illegal region in each training picture according to the prediction offset information of each second picture. The server can determine the position loss of the prediction model according to the actual position information and the predicted position information of the illegal region in each training picture. The server can optimize the prediction model in reverse according to the position loss and the label loss, and train the prediction model.
[0078] The application can not only more accurately predict whether each to-be-detected first picture belongs to a rule violation picture, but also accurately detect the specific position of the rule violation region in the to-be-detected first picture, so as to facilitate processing of the rule violation region in the to-be-detected first picture. The use of the rule violation picture prediction method effectively improves the prevention ability of rule violation pictures and improves the safety of products. Moreover, the application divides a larger first picture into multiple second pictures for detection, thereby reducing the amount of data processed by the prediction model each time the prediction model predicts, and improving the picture detection efficiency. When the prediction model detects the second picture, if it is detected that the second picture belongs to a rule violation picture, the prediction model will not need to detect other second pictures, thereby saving calculation resources.
[0079] The technical solutions of the application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in some embodiments.
[0080] Figure 2 A scene schematic diagram of first picture processing provided by an embodiment of the application is shown. The first picture can be as shown in Figure 2 (a). When the server obtains the first picture as shown in Figure 2 (a), the server can input the first picture into a prediction model for prediction. The server can obtain a prediction result as shown in Figure 2 (b) through prediction. As shown in Figure 2 (b), the prediction result can include the prediction result of each feature point in a feature picture. The size of the feature picture can be 8*8. Each feature point can correspond to a second picture obtained by dividing the first picture. The prediction result of each feature point can include six dimensions. The area shown by the black small box in the feature picture can correspond to the rule violation region in the first picture as shown in Figure 2 (c). The Figure 2 black point in Figure 2 (b) can be the center point of the rule violation region. The server can perform regression calculation on the six-dimensional prediction result of each feature point. The server can obtain the prediction position information of the rule violation region in the first picture through regression calculation. The prediction position information in the first picture can be as shown by the dashed box in (c).
[0081] In the application, a server is taken as an execution subject to execute the rule violation picture detection method of the following embodiments. Specifically, the execution subject can be a hardware device of the server, or a software application for implementing the following embodiments in the server, or a computer readable storage medium installed with the software application for implementing the following embodiments, or a code of the software application for implementing the following embodiments.
[0082] Figure 3 A flowchart of a method for detecting a rule violation picture is shown. In Figure 1 and Figure 2 Based on the embodiments shown in Figure 3 As shown in the server as the execution subject, the method of the present embodiment can include the following steps:
[0083] S101, obtaining a first picture to be detected.
[0084] In the present embodiment, when the rule violation picture detection method is applied to cloud service risk control management, the server can obtain pictures uploaded to the cloud in real time. In order to ensure the security of the cloud data, the server needs to detect the rule violation pictures of these pictures to ensure the security of the pictures. After obtaining the pictures uploaded to the cloud, the server can take the picture as the first picture to be detected.
[0085] In an example, in order to facilitate subsequent processing, the server can perform scaling, grayscale processing, etc. on the first picture to be detected after obtaining the first picture to be detected, so as to facilitate the uniform processing and calculation of the first picture to be detected in the subsequent prediction model. Wherein, scaling can be used to scale the first picture to be detected to a fixed length and width. Wherein, grayscale can be used to convert the first picture to be detected from RGB, HVS, etc. color model to grayscale picture.
[0086] S102, using a preset window to divide the first picture into a plurality of second pictures.
[0087] In the present embodiment, a plurality of preset windows with different aspect ratios can be set in the server. The server can use the preset window to slide and obtain a plurality of second pictures in the picture to be detected. For example, when the preset size of the first picture to be detected is 128*128, the size of the preset window can be 16*16. The server can obtain 8 rows of non-overlapping second pictures on the first picture to be detected according to the preset window size of 16*16, each row including 8 non-overlapping second pictures. The server obtains 64 second pictures in total.
[0088] S103, using a prediction model to predict each second picture, and obtaining a prediction category of each second picture, the prediction category including two categories of belonging to a rule violation picture and not belonging to a rule violation picture.
[0089] In this embodiment, the server can use the prediction model to down-sample each of the second pictures to obtain a feature point corresponding to each of the second pictures. The feature points of the plurality of second pictures of the first picture can form a feature picture. For example, when the preset size of the first picture to be detected is 128*128 and the size of the preset window is 16*16, 8 rows of non-overlapping second pictures are obtained on the first picture to be detected, and each row includes 8 non-overlapping second pictures. The feature points corresponding to the 8*8 second pictures can form an 8*8 feature picture. The server can input the feature picture into the prediction model to predict the prediction category of each feature point in the feature picture. The prediction category can include two categories of being a violation picture and not being a violation picture.
[0090] In an implementation manner, the prediction model can directly convolve the first picture. In the convolution process, the prediction model can complete the down-sampling of the first picture to obtain a feature picture of the first picture to be detected. For example, when the preset size of the first picture to be detected is 128*128 and the size of the preset window is 16*16, the size of the feature picture can be 8*8. Each feature point in the feature picture can correspond to a second picture of a preset window size. The prediction model can be a neural network model such as a CNN. The server can realize the convolution and down-sampling of the first picture through the convolution layer and the pooling layer of the neural network model. The setting of the pooling layer can be determined according to the size of the preset window and the size of the first picture.
[0091] In an example, the prediction process can include the following steps:
[0092] Step 1, convolve each of the second pictures in the first picture using the prediction model to obtain a plurality of feature points.
[0093] In this step, the server can input each second picture into the prediction model. The prediction model can complete the down-sampling of the second picture in the convolution calculation process. Each second picture can be down-sampled to a feature point.
[0094] Step 2, input the plurality of feature points into the prediction model to predict the prediction category of each of the second pictures.
[0095] In this step, the server can determine the arrangement of each feature point of the first picture to be detected according to the positions of each second picture in the first picture to be detected and the feature points corresponding to each second picture, and obtain a feature picture of the first picture to be detected. For example, when the server obtains 8 rows and 8 columns of second pictures, the server can correspondingly obtain an 8*8 feature picture. The server can input the feature picture into the prediction model to realize the prediction of each feature point in the feature picture. The server can obtain the prediction category of each feature point through prediction. For example, when the size of the feature picture is 8*8, the server can obtain the prediction categories of the 64 "sub-pictures" through the prediction model. The prediction category can include two categories of belonging to a violation picture and not belonging to a violation picture. The prediction category can be represented using two dimensions. For example, when the two dimensions are (1, 0), it means that the prediction category is belonging to a violation picture. When the two dimensions are (0, 1), it means that the prediction category is not belonging to a violation picture.
[0096] S104, when there is at least one second picture corresponding to the prediction category belonging to a violation picture, determining that the first picture is a violation picture.
[0097] In this embodiment, the server can determine the second picture corresponding to each feature point according to the feature points in the feature picture and a preset window. The prediction category of the feature point is the prediction category of the second picture corresponding to the feature point. When there is at least one second picture whose prediction category is belonging to a violation picture in a first picture to be detected, it means that the first picture to be detected is a violation picture.
[0098] In an example, when the server detects that a first picture is a violation picture, the server can store the first picture in a violation picture set.
[0099] In an example, when the server detects that a first picture is a violation picture, the server can also generate an abnormality reminder according to the upload information of the first picture. The server can send the abnormality reminder of the first picture to the management terminal of the administrator and / or the user terminal of the user to remind the administrator and / or the user to process the first picture.
[0100] The method for detecting a rule violation picture provided in the application can obtain a picture uploaded to the cloud and take the picture as a first picture to be detected. The server can slide the preset window in the picture to be detected to obtain a plurality of second pictures. The server can use a prediction model to down-sample each second picture to obtain a feature point corresponding to each second picture. The feature points of the plurality of second pictures of the first picture can form a feature picture. The server can input the feature picture into the prediction model to predict a prediction category of each second picture. When the prediction category of at least one second picture in the first picture to be detected is a rule violation picture, it is determined that the first picture to be detected is a rule violation picture. In the application, the prediction category of each second picture is predicted to detect the rule violation picture of the first picture to be detected, thereby improving the detection accuracy of the rule violation picture.
[0101] Figure 4 A flowchart of another method for detecting a rule violation picture provided in an embodiment of the application is shown. In the Figure 1 to Figure 3 based on the embodiment shown, the embodiment can also predict the position of a rule violation area in the first picture to be detected. As Figure 4 The method of the embodiment can include the following steps with the server as the execution subject.
[0102] S201, obtaining a first picture to be detected.
[0103] S202, dividing the first picture into a plurality of second pictures using a preset window.
[0104] S203, using a prediction model to predict each second picture to obtain a prediction category of each second picture, the prediction category including two categories of belonging to a rule violation picture and not belonging to a rule violation picture.
[0105] S204, when there is at least one second picture corresponding to a prediction category of belonging to a rule violation picture, determining that the first picture is a rule violation picture.
[0106] The steps S201 to S204 in the embodiment are similar to the implementation of the steps S101 to S104 in the Figure 3 The implementation of the steps S101 to S104 in the embodiment is similar, and the embodiment will not be described here.
[0107] S205, inputting a plurality of feature points into a prediction model to predict prediction offset information of each second picture, the prediction offset information including a center point coordinate of the second picture and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a prediction center point coordinate of a rule violation area in the first picture.
[0108] In the embodiment, when the server inputs the feature picture obtained by convolving the plurality of second pictures of the first picture into the prediction model, the server can also obtain the prediction offset information of each second picture. The prediction offset information is used to indicate the offset between the center point coordinate of the second picture and the predicted center point coordinate of the violation region in the first picture.
[0109] In an example, the prediction offset information can be represented using two dimensions. One dimension is used to indicate the horizontal offset between the center point coordinate of the second picture and the predicted center point coordinate of the violation picture, and the other dimension is used to indicate the vertical offset between the center point coordinate of the second picture and the center point coordinate of the violation picture. The center point coordinate of the second picture is the coordinate of the center point of the second picture in the coordinate system of the first picture. The predicted center point coordinate of the violation picture is also the coordinate in the coordinate system of the first picture.
[0110] In an example, the prediction offset information can be represented using four dimensions. The first dimension and the second dimension are used to represent the center point coordinate of the second picture. The third dimension and the fourth dimension are used to indicate the horizontal offset and the vertical offset between the center point coordinate of the second picture and the predicted center point coordinate of the violation picture. When the prediction offset information includes four dimensions and the prediction category includes two dimensions, the prediction result of each feature point with six dimensions can be as shown in Figure 2 (b).
[0111] S206, according to the prediction offset information of each second picture in the first picture, the server regresses to calculate the prediction position information of the violation region in the first picture. The prediction position information includes the predicted center point coordinate, the predicted width and the predicted height of the violation region in the first picture.
[0112] In the embodiment, the server can regress to calculate according to the prediction result as shown in Figure 2 (b). The server can calculate the first center point coordinate of a violation region according to the center point coordinate, the horizontal offset and the vertical offset of a second picture. Since the first center point coordinate calculated according to each second picture can not be the same. Therefore, the server can estimate a coordinate with the smallest variance of the first center point coordinates as the predicted center point coordinate. The server can also predict the predicted width and the predicted height of the violation region according to the prediction category of each second picture and the predicted center point coordinate.
[0113] The method for detecting a rule violation picture provided in the application includes the following steps: a server acquires a first picture to be detected. The server divides the first picture into a plurality of second pictures using a preset window. The server uses a prediction model to predict each second picture to obtain a prediction category of each second picture. When the prediction category of at least one second picture in the first picture is a rule violation picture, it is determined that the first picture is a rule violation picture. When the server inputs the feature picture into the prediction model, the server can also obtain prediction offset information of each second picture. The prediction offset information is used to indicate the offset condition of the second picture corresponding to the feature point and the rule violation region in the first picture to be detected. The server can estimate the prediction center point coordinates of the rule violation region in the first picture according to the center point coordinates and the horizontal offset and the vertical offset of each second picture. The server can also predict the prediction width and the prediction height of the rule violation region according to the prediction category of each second picture and the prediction center point coordinates. In the application, the prediction offset information of each window is used to locate the rule violation region in the first picture, thereby improving the detection accuracy and the detection effect of the rule violation picture.
[0114] Figure 5 A flow chart of another method for detecting a rule violation picture provided in an embodiment of the application is shown. In the method, a server is used as an execution subject. Figure 1 to Figure 4 Based on the embodiment shown, the method provided in the embodiment needs to train a prediction model before the above-mentioned rule violation picture detection is performed. As shown in the embodiment, the method provided in the embodiment can include the following steps: Figure 5 Based on the embodiment shown, the method provided in the embodiment needs to train a prediction model before the above-mentioned rule violation picture detection is performed. As shown in the embodiment, the method provided in the embodiment can include the following steps:
[0115] S301, acquire a training set, the training set including a training picture containing a rule violation region and a picture label used to indicate the actual position information of the rule violation region in the training picture.
[0116] In this embodiment, the server can obtain a training set. The training set can include a large number of training pictures. The training pictures can include violation pictures and normal pictures. The violation region in the violation picture and the normal picture are both in-picture-in-picture. Among them, the violation picture can include a real violation picture encountered in the violation picture detection process, and a simulated violation picture generated according to the real violation picture. The training set can also include a picture label. The picture label can include actual category and actual position information. Among them, the actual category is used to indicate whether the training picture belongs to a violation picture. Among them, the actual position information is used to indicate the position information of the violation region in the training picture. For example, the picture label can be (0, 1, x, y, w, h). Among them, the first dimension and the second dimension are used to indicate the actual category of the training picture. When the values of the two dimensions are (1, 0), it means that the training picture is a violation picture. When the values of the two dimensions are (0, 1), it means that the training picture is a normal picture. The values of x and y of the third dimension and the fourth dimension are used to represent the center point coordinates of the violation region. The values of w and h of the fifth dimension and the sixth dimension are used to represent the width and height of the violation region.
[0117] S302, using a preset window to divide each training picture in the training set into a plurality of second pictures.
[0118] In this embodiment, in each training period, the server can randomly obtain a certain number of training pictures from the training set according to the preset parameters. The proportion of violation pictures and normal pictures in the training pictures can be determined according to the preset proportion. The server can divide these training pictures randomly obtained from the training set. Each training picture will be divided into a plurality of second pictures. For example, when the preset size of the first picture to be detected is 128*128 and the size of the preset window is 16*16, 8 rows of non-overlapping second pictures are obtained on the first picture to be detected, and each row includes 8 non-overlapping second pictures.
[0119] S303, using a prediction model to predict each second picture in each training picture, and obtaining a prediction category of each second picture, the prediction category including two categories of belonging to a violation picture and not belonging to a violation picture.
[0120] In this embodiment, in the first training period, the server can set the prediction model using the initial value to obtain the prediction model in the first training period. In the subsequent training period, the server can use the prediction model obtained by training in the last period for prediction. The server can add the training pictures obtained in S302 one by one to the prediction model for prediction, and obtain a prediction result. The prediction result includes the prediction category of each second picture of each training picture. The prediction category includes two categories of belonging to a violation picture and not belonging to a violation picture.
[0121] In an example, the prediction process can include the following steps with respect to a training picture:
[0122] Step 1, the server can input the training picture into the prediction model, and perform convolution calculation and down-sampling to obtain a feature picture of the training picture. Each feature point in the feature picture can correspond to a second picture. For example, the feature picture can have a size of 8*8. The prediction model can be a neural network model such as CNN.
[0123] Step 2, the server can input the feature picture of the training picture into the prediction model to obtain a predicted category of each feature point in the feature picture. The predicted category of each feature point is the predicted category of the second picture corresponding to the feature point.
[0124] S304, according to the position information of each second picture in each training picture in the training set and the actual position information of the violation region in each training picture, determine the actual category of the second picture, which includes two categories of belonging to the violation picture and not belonging to the violation picture.
[0125] In this embodiment, the server can obtain the picture label of the training picture used in the period from the training set. The picture label includes whether the training picture belongs to the violation picture and the actual position information of the violation region in the training picture. When a training picture belongs to a violation picture, the server can calculate the overlap degree of the violation region and each second picture according to the actual position information of the violation region in the training picture and the position information of each second picture. The server can determine the actual category of each second picture according to the overlap degree of each second picture. The actual category can include two categories of belonging to the violation picture and not belonging to the violation picture.
[0126] In an example, the server can determine the actual category of the second picture by calculating the overlap degree of the second picture and the violation region. The specific steps can include:
[0127] Step 1, the server can obtain the position information of each second picture in the training picture. The server can also obtain the actual position information of the violation region in the training picture. The server can calculate the overlap degree of each second picture and the violation picture according to the position information of each second picture and the actual position information of the violation picture. The overlap degree can be the ratio of the overlapping area to the area of the second picture.
[0128] Step 2, when the overlap degree of the second picture is greater than or equal to a preset threshold, the server can determine the actual category of the second picture as belonging to the violation picture. Otherwise, the server can determine the actual category of the second picture as not belonging to the violation picture. The preset threshold can be determined according to an empirical value. For example, the preset threshold can be 0.7.
[0129] S305, determine a label loss of the prediction model according to the predicted category and the actual category of each second picture in each training picture in the training set, and optimize the prediction model according to the label loss.
[0130] In the embodiment, the server can determine whether the prediction of the prediction model for the second picture is accurate by comparing the predicted category and the actual category of the second picture. The server can also calculate the label loss of the prediction model according to the prediction result and a calculation formula of a preset loss function. The preset loss function can be an existing loss function or an improved loss function. The server can also use the label loss to perform backward optimization on the parameters in the prediction model, thereby realizing the training of the prediction model.
[0131] The method for detecting a rule violation picture provided in the application can be used to obtain a training set. The training set can include a large number of training pictures. In each training period, the server can randomly obtain a certain number of training pictures from the training set according to a preset parameter. The server can divide the training pictures randomly obtained from the training set. Each training picture can be divided into a plurality of second pictures. The server can use a prediction model to predict each second picture in each training picture, and obtain a predicted category of each second picture. The server can calculate the overlap degree between the rule violation region and each second picture according to the actual position information of the rule violation region in the training picture and the position information of each second picture. The server can determine the actual category of each second picture according to the overlap degree of each second picture. The server can determine a label loss of the prediction model according to the predicted category and the actual category of each second picture in each training picture in the training set. The server can also use the loss function to optimize the parameters in the prediction model, thereby realizing the training of the prediction model. In the application, the classification accuracy of the prediction model is improved by using the label loss function to optimize the prediction model.
[0132] Figure 6 A flowchart of another method for detecting a rule violation picture provided in an embodiment of the application is shown. In the embodiment, the method for detecting a rule violation picture provided in the embodiment shown in the above can be used as a basis. Figure 1 to Figure 5 On the basis of the embodiment shown, the embodiment needs to train a prediction model before performing the above-mentioned method for detecting a rule violation picture. As shown in the above, Figure 6 As shown in the above, the method of the embodiment can include the following steps:
[0133] S401, obtain a training set, the training set including training pictures containing rule violation regions and picture labels indicating the actual position information of the rule violation regions in the training pictures.
[0134] S402, divide each training picture in the training set into a plurality of second pictures using a preset window.
[0135] S403, predict each second picture in each training picture using the prediction model, to obtain a predicted category of each second picture, the predicted category including two categories of being a violation picture and not being a violation picture.
[0136] S404, determine an actual category of each second picture in each training picture according to position information of each second picture in each training picture and actual position information of a violation region in each training picture, the actual category including two categories of being a violation picture and not being a violation picture.
[0137] S405, determine a label loss of the prediction model according to the predicted category and the actual category of each second picture in each training picture.
[0138] The steps S401 to S405 are similar to the steps S301 to S305 in the embodiment, and will not be described here. Figure 5 The steps S301 to S305 in the embodiment are similar to the implementation manner, and will not be described here.
[0139] S406, predict each second picture in each training picture using the prediction model, to obtain predicted offset information of each second picture, the predicted offset information including a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a predicted center point coordinate of a violation region in the training picture.
[0140] In the embodiment, the server can also predict the predicted offset information of each second picture in the training picture after inputting each training picture into the prediction model. The predicted offset information can include the center point coordinate of each second picture, the horizontal offset and the vertical offset between the center point coordinate of the second picture and the predicted center point coordinate of the violation region.
[0141] S407, regressively calculate predicted position information of the violation region in each training picture according to the predicted offset information of each second picture in each training picture, the predicted position information including a predicted center point coordinate, a predicted width and a predicted height.
[0142] In the embodiment, the server can estimate the predicted position information of the violation region in the training picture according to the center point coordinate, the horizontal offset and the vertical offset of each second picture in the training picture. The predicted position information can include the predicted center point coordinate, the predicted width and the predicted height of the violation region in the training picture. The server can visualize the predicted position information of the violation region in the training picture according to the predicted position information. For example, the visualization of the predicted position information can be as shown in FIG. 6. Figure 2(c) is shown by the dashed box.
[0143] S408, according to the prediction position information of each training picture in the training set and the actual position information in the picture label, determine the position loss of the prediction model.
[0144] In this embodiment, the server can obtain the picture label of each training picture used in the training period from the training set. The picture label includes the actual position information of the violation region in the training picture. The server can calculate the prediction deviation according to the prediction position information and the actual position information of the violation region in each training picture. The server can calculate the label loss of the prediction model according to the prediction deviation of each training picture used in the training period and the calculation formula of the preset loss function. The preset loss function can be an existing loss function or an improved loss function.
[0145] S409, according to the label loss and the position loss, optimize the prediction model.
[0146] In this embodiment, the server can determine the total loss of the prediction model according to the sum of the label loss and the position loss. The server can also use the total loss to perform backward optimization on the parameters in the prediction model, thereby realizing the training of the prediction model. The server can continuously obtain the iterative optimization of the prediction model according to the training data.
[0147] In an example, the server can also obtain a test set. The test set can include a large number of test pictures and the picture label of each test picture. The pictures in the test set are different from the pictures in the training set. The test pictures can include violation pictures and normal pictures. The violation pictures can be real violation pictures encountered in the violation picture detection process. After the server completes the optimization of the prediction model once, the server can obtain part of the test pictures from the test set. The server can use the optimized prediction model to predict the part of the test pictures, and obtain the prediction result of each test picture. The prediction result includes the prediction category and the prediction offset information. The server can determine the test total loss of the test pictures in the test period according to the prediction result and the picture label of each test picture. The server can be preset with a total iteration number and / or a test loss threshold. The server can end the optimization iteration of the prediction model when the iteration number reaches the total iteration number, and / or the test total loss is less than the test loss threshold.
[0148] The application provides a method for detecting illegal pictures. A server can obtain a training set. In each training cycle, the server can randomly obtain a certain number of training pictures from the training set according to preset parameters. The server can divide each training picture into a plurality of second pictures. The server can use a prediction model to predict each second picture in each training picture, and obtain a predicted category of each second picture. The server can calculate the overlap degree between the illegal area and each second picture according to the actual position information of the illegal area in the training picture and the position information of each second picture, and determine the actual category of each second picture. The server can determine the label loss of the prediction model according to the predicted category and the actual category of each second picture in each training picture in the training set. The server can use the prediction model to predict each second picture in each training picture, and obtain the predicted offset information of each second picture. The server can regress and calculate the predicted position information of the illegal area in each training picture according to the predicted offset information of each second picture in each training picture. The server can determine the position loss of the prediction model according to the predicted position information of each training picture in the training set and the actual position information in the picture label. The server can determine the total loss of the prediction model according to the sum of the label loss and the position loss. The server can also optimize the parameters in the prediction model using the total loss, thereby realizing the training of the prediction model. In the application, the prediction model is optimized by using the total loss function, and the classification accuracy of the prediction model is improved.
[0149] Figure 7 The structure of the illegal picture detection device provided by an embodiment of the application is shown in a structural schematic diagram, as shown in Figure 7 The illegal picture detection device 10 of the embodiment is used to realize the operation of the server in any of the method embodiments described above. The illegal picture detection device 10 of the embodiment comprises:
[0150] The acquisition module 11 is configured to acquire a first picture to be detected.
[0151] The processing module 12 is configured to divide the first picture into a plurality of second pictures using a preset window, predict each second picture using a prediction model, and obtain a predicted category of each second picture. The predicted category includes two categories of belonging to an illegal picture and not belonging to an illegal picture. When the predicted category of at least one second picture is the category of belonging to an illegal picture, the first picture is determined to be an illegal picture.
[0152] In an example, the processing module 12 is specifically configured to:
[0153] The preset window is used to slide in the picture to be detected to obtain a plurality of second pictures.
[0154] In an example, the processing module 12 is specifically configured to:
[0155] convolve each second picture in the first picture using the prediction model to obtain a plurality of feature points;
[0156] input the plurality of feature points into the prediction model to obtain a predicted category of each second picture.
[0157] In an example, the processing module 12 is further configured to:
[0158] input the plurality of feature points into the prediction model to obtain predicted offset information of each second picture, the predicted offset information comprising a center point coordinate of the second picture and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a predicted center point coordinate of the violation region in the first picture;
[0159] regressively calculate predicted position information of the violation region in the first picture according to the predicted offset information of each second picture in the first picture, the predicted position information comprising a predicted center point coordinate, a predicted width and a predicted height of the violation region in the first picture.
[0160] In an example, the apparatus further comprises:
[0161] a model generation module configured to obtain a training set, the training set comprising training pictures containing a violation region and picture labels indicating actual position information of the violation region in the training pictures; divide each training picture in the training set into a plurality of second pictures using a preset window; predict each second picture in each training picture using a prediction model to obtain a predicted category of each second picture, the predicted category comprising two categories of belonging to a violation picture and not belonging to a violation picture; determine an actual category of each second picture according to position information of each second picture in each training picture and actual position information of the violation region in each training picture, the actual category comprising two categories of belonging to a violation picture and not belonging to a violation picture; determine a label loss of the prediction model according to the predicted category and the actual category of each second picture in each training picture in the training set, and optimize the prediction model according to the label loss.
[0162] In an example, the model generation module is specifically configured to:
[0163] calculate an overlap degree of each second picture with the violation region according to position information of each second picture in each training picture in the training set and actual position information of the violation region in the training picture;
[0164] when the overlap degree of the second picture is greater than or equal to a preset threshold, the actual category of the second picture is that the second picture belongs to a violation picture; otherwise, the actual category of the second picture is that the second picture does not belong to a violation picture.
[0165] In an example, the model generating module is further configured to:
[0166] predict each second picture in each training picture using the prediction model to obtain prediction offset information of each second picture, the prediction offset information including a center point coordinate of the second picture and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a predicted center point coordinate of the violation region in the training picture;
[0167] regress to obtain prediction location information of the violation region in each training picture according to the prediction offset information of each second picture of each training picture, the prediction location information including the predicted center point coordinate, a predicted width and a predicted height;
[0168] determine a location loss of the prediction model according to the prediction location information of each training picture in the training set and the actual location information in the picture label;
[0169] optimize the prediction model according to the label loss and the location loss.
[0170] The violation picture detection device 10 provided by the embodiments of the present application can execute the above method embodiments, and the specific implementation principles and technical effects can be referred to the above method embodiments, which will not be described here again.
[0171] Figure 8 A hardware structure schematic diagram of a server provided by the embodiments of the present application is shown. As shown in the figure, Figure 8 The server 20 is used to implement the operations corresponding to the server in any of the above method embodiments. The server 20 of the present embodiment can include a memory 21, a processor 22 and a communication interface 24.
[0172] The memory 21 is used to store a computer program. The memory 21 can include a random access memory (RAM) and can also include a non-volatile memory (NVM), such as at least one disk memory, and can also be a U disk, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0173] The processor 22 is configured to execute the computer program stored in the memory to implement the method for detecting the rule violation picture in the above embodiments. Details can be referred to the description of the method embodiments. The processor 22 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly embodied as hardware processor execution, or executed by a combination of hardware and software modules in the processor.
[0174] Optionally, the memory 21 can be independent or integrated with the processor 22.
[0175] When the memory 21 is a device independent of the processor 22, the server 20 can further include a bus 23. The bus 23 is configured to connect the memory 21 and the processor 22. The bus 23 can be an industry standard architecture (ISA) bus, a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, the bus in the drawings of the present application does not limit to only one bus or one type of bus.
[0176] The communication interface 24 can be connected with the processor 21 through the bus 23. The communication interface 24 is configured to obtain the first picture to be detected, and send the identification result of the first picture to be detected to other terminal devices.
[0177] The server provided in the embodiment can be used to execute the method for detecting the rule violation picture, and the implementation manner and technical effects are similar, which will not be described here.
[0178] The present application also provides a computer readable storage medium, and the computer readable storage medium stores a computer program. The computer program is executed by the processor to implement the method provided in the various embodiments.
[0179] The computer readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates transfer of a computer program from one place to another. A storage medium can be any available medium that can be accessed by a general purpose or special purpose computer. By way of example, and not limitation, computer readable storage media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired computer program code means in the form of computer readable instructions or data structures and that can be accessed by a general-purpose or special-purpose computer, or a combination thereof. It should be understood that computer readable storage media and data storage media do not include carrier waves and / or other propagating / transitory
[0180] In particular, the computer readable storage medium can be realized by any type of volatile or non-volatile storage devices, or a combination thereof, such as static random access memory (SRAM), electrically-erasable programmable read-only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage devices, flash memory, magnetic disks, or optical disks. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0181] The present application also provides a computer program product including a computer program stored in a computer readable storage medium. At least one processor of a device can read the computer program from the computer readable storage medium, and the at least one processor executes the computer program to enable the device to implement the method provided in the various embodiments described above.
[0182] The embodiments of the present application also provide a chip including a memory and a processor. The memory is configured to store a computer program, and the processor is configured to call and run the computer program from the memory, so that a device installed with the chip executes the method in the various possible embodiments described above.
[0183] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and actual implementation can have another division manner, for example, a plurality of modules can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed modules can be indirect coupling or communication connection through some interfaces, apparatuses or modules, and can be electrical, mechanical or other forms.
[0184] Each module can be physically separated, for example, installed in different positions of one device, or installed on different devices, or distributed on a plurality of network elements, or distributed on a plurality of processors. Each module can also be integrated together, for example, installed in the same device, or integrated in a set of codes. Each module can exist in the form of hardware, or can exist in the form of software, or can be realized in the form of software plus hardware. The present application can select some or all modules to achieve the purpose of the embodiment scheme according to actual needs.
[0185] When each module is realized in the form of an integrated module of a software function module, the integrated module can be stored in a computer readable storage medium. The software function module stored in the storage medium includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute part of the steps of the method of each embodiment of the present application.
[0186] It should be understood that although each step in the flowchart in the above embodiment is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise stated herein, the execution of these steps has no strict sequence limitation, and they can be executed in other orders. Moreover, at least part of the steps in the figure can include a plurality of sub-steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or sub-steps or stages of other steps.
[0187] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for part or all of the technical features. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method of detecting a rule violation picture, characterized by, The method comprises: obtaining a first picture to be detected; dividing the first picture into a plurality of second pictures using a preset window; predicting each of the second pictures using a prediction model to obtain a prediction category of each of the second pictures, the prediction category including two categories of belonging to a rule violation picture and not belonging to a rule violation picture; when there is at least one second picture corresponding to a prediction category of belonging to a rule violation picture, determining that the first picture is a rule violation picture; The method further comprises: inputting a plurality of feature points into the prediction model to predict prediction offset information of each of the second pictures, the prediction offset information including a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a prediction center point coordinate of a rule violation region in the first picture; wherein the feature points are obtained by convolving the second image in the detection image; According to the prediction offset information of each of the second pictures in the first picture, the prediction position information of the rule violation region in the first picture is calculated by regression, and the prediction position information includes the prediction center point coordinate, the prediction width and the prediction height of the rule violation region in the first picture.
2. The method of claim 1, wherein, The use of a preset window to divide the first picture into a plurality of second pictures comprises: using the preset window to slide and obtain a plurality of second pictures in the picture to be detected.
3. The method of claim 2, wherein, The use of a prediction model to predict each of the second pictures to obtain a prediction category of each of the second pictures comprises: convolving each of the second pictures in the first picture using the prediction model to obtain a plurality of feature points; inputting the plurality of feature points into the prediction model to predict the prediction category of each of the second pictures.
4. The method according to any one of claims 1-3, characterized in that, The method further comprises: obtaining a training set, the training set including a training picture containing a rule violation region and a picture label indicating the actual position information of the rule violation region in the training picture; dividing each of the training pictures in the training set into a plurality of second pictures using a preset window; predicting each of the second pictures in each of the training pictures using the prediction model to obtain a prediction category of each of the second pictures, the prediction category including two categories of belonging to a rule violation picture and not belonging to a rule violation picture; determining the actual category of each of the second pictures according to the position information of each of the second pictures of each of the training pictures in the training set and the actual position information of the rule violation region in each of the training pictures, the actual category including two categories of belonging to a rule violation picture and not belonging to a rule violation picture; determining a label loss of the prediction model according to the prediction category and the actual category of each of the second pictures in each of the training pictures in the training set, and optimizing the prediction model according to the label loss.
5. The method of claim 4, wherein, The determination of the actual category of each of the second pictures according to the position information of each of the second pictures of each of the training pictures in the training set and the actual position information of the rule violation region in each of the training pictures comprises: According to position information of each of the second pictures in each of the training pictures in the training set and actual position information of the rule violation region in the training picture, an overlap degree of the second picture and the rule violation region is calculated; When the overlap degree of the second picture is greater than or equal to a preset threshold, an actual category of the second picture is that the second picture belongs to a rule violation picture; otherwise, the actual category of the second picture is that the second picture does not belong to a rule violation picture.
6. The method of claim 4, wherein, The method further comprises: Using the prediction model to predict each of the second pictures in each of the training pictures, to obtain prediction offset information of each of the second pictures, wherein the prediction offset information comprises a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a prediction center point coordinate of the rule violation region in the training picture; According to the prediction offset information of each of the second pictures in each of the training pictures, regression calculation is performed to obtain prediction position information of the rule violation region in each of the training pictures, wherein the prediction position information comprises a prediction center point coordinate, a prediction width and a prediction height; According to the prediction position information of each of the training pictures in the training set and the actual position information in the picture label, a position loss of the prediction model is determined; According to the label loss and the position loss, the prediction model is optimized.
7. A violation picture detection apparatus characterized by comprising: The device comprises: An acquisition module is configured to acquire a first picture to be detected; A processing module is configured to divide the first picture into a plurality of second pictures using a preset window, and to use a prediction model to predict each of the second pictures to obtain a prediction category of each of the second pictures, wherein the prediction category comprises two categories of belonging to a rule violation picture and not belonging to a rule violation picture; when there is at least one second picture corresponding to a prediction category of belonging to a rule violation picture, the first picture is determined to be a rule violation picture; The processing module is further configured to input a plurality of feature points into the prediction model to obtain prediction offset information of each of the second pictures, wherein the prediction offset information comprises a center point coordinate of the second picture, and a horizontal offset and a vertical offset between the center point coordinate of the second picture and a prediction center point coordinate of a rule violation region in the first picture; wherein the feature points are obtained by convolution on the second picture in the detection image; According to the prediction offset information of each of the second pictures in the first picture, regression calculation is performed to obtain prediction position information of the rule violation region in the first picture, wherein the prediction position information comprises a prediction center point coordinate, a prediction width and a prediction height of the rule violation region in the first picture.
8. A server, characterized by The server comprises a memory and a processor; The memory is configured to store a computer program; and the processor is configured to implement the rule violation picture detection method according to the computer program stored in the memory.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is used for realizing the method for detecting the rule violation picture according to any one of claims 1-6 when being executed by the processor.
10. A computer program product, characterised in that, The computer program product comprises a computer program, and the computer program is used for realizing the method for detecting the rule violation picture according to any one of claims 1-6 when being executed by the processor.
Citation Information
Patent Citations
Guide board detection method based on adaptive sliding window and convolutional neural network
CN107016366A