Pornographic image recognition method and system, storage medium and electronic equipment
An image recognition and pornographic technology, applied in the field of image recognition, can solve the problems of multiple elements that do not conform to pornographic images, missed recognition of pornographic images, and inability to recognize pornographic content.
Pending Publication Date: 2021-10-22
北京数美时代科技有限公司
5 Cites 1 Cited by
AI-Extracted Technical Summary
Problems solved by technology
The algorithm design does not conform to the multi-element characteristics of pornographic images, resulting in the final recognition result only having the most obvious pornographic elements,...
Method used
Wherein, the feature of softmax function is that output value summation is 1, extremely meets the requirement of the output single pornog...
Abstract
The invention relates to a pornographic image recognition method and system, a storage medium and electronic equipment, and the method comprises the steps: inputting a to-be-recognized image into a double-branch trained pornographic image recognition model, and obtaining a result corresponding to each branch, the result corresponding to the first branch comprising at least one first pornographic label, the result of the second branch only comprising one second pornographic label; and judging whether the to-be-recognized image is a pornographic image or not according to a result corresponding to the first branch and a result corresponding to the second branch. After the to-be-recognized image is input into the pornographic image recognition model of double-branch training, the result corresponding to the first branch and the result corresponding to the second branch can be obtained, the two results can be compared and verified, and the probability of missed recognition of the pornographic image is greatly reduced.
Application Domain
Character and pattern recognitionNeural architectures +1
Technology Topic
EngineeringImage identification +2
Image
Examples
- Experimental program(1)
Example Embodiment
[0038] like figure 1 As shown, a kind of pornographic image recognition method of the embodiment of the present invention comprises the following steps:
[0039] S1. Input the image to be recognized into a dual-branch training pornographic image recognition model to obtain a result corresponding to each branch, wherein the result corresponding to the first branch includes at least one first pornographic label, and the result of the second branch only includes a second Pornographic tags, wherein the double branch refers to the first branch and the second branch;
[0040] S2. Determine whether the to-be-identified image is a pornographic image according to the result corresponding to the first branch and the result corresponding to the second branch. specifically:
[0041] 1) For example, the first image to be recognized is input into the pornographic image recognition model, the corresponding result of the first branch obtained includes two first pornographic labels such as "nudity" and "art", and the result of the second branch obtained only includes a For example, the second pornographic label is "art", then it can be determined that the first image to be identified is not a pornographic image;
[0042] 2) for example, the second to-be-recognized image is input into the pornographic image recognition model, the corresponding result of the first branch obtained includes two first pornographic labels such as "nudity" and "sex", and the result of the second branch obtained only includes a For example, the second pornographic label is "sex", then it can be determined that the second to-be-identified image is a pornographic image;
[0043] 3) For example, the 3rd image to be recognized is input into the pornographic image recognition model, the corresponding result of the first branch obtained includes two first pornographic labels such as "nudity" and "sex", and the result of the second branch obtained only includes a For example, the second pornographic label is "art", then it can be determined that the third image to be identified is pornographic; but in the prior art, if the pornographic label of "art" is obtained, due to the lack of other results for verification, it is likely to appear Missing recognition of pornographic images.
[0044] Wherein, a frame image can be obtained from the video as the image to be recognized.
[0045] That is to say, in this application, after the image to be recognized is input into the pornographic image recognition model trained by dual branches, the result corresponding to the first branch and the result corresponding to the second branch can be obtained, and the two results can be compared and verified with each other, which greatly reduces the Probability of missing recognition of pornographic images.
[0046] Preferably, in the above technical solution, it also includes:
[0047] S010, mark at least one first pornographic label to any preset image, and mark only one second pornographic label to any preset image, until at least one first pornographic label corresponding to each preset image is obtained, and , a second pornographic label corresponding to each preset image;
[0048] S011, build an improved inception v3 model including a feature extractor and a classifier, wherein the classifier includes the first branch and the second branch, wherein the feature extractor will be based on each preset image, At least one first pornographic tag corresponding to each preset image, and a feature vector obtained from a second pornographic tag corresponding to each preset image are respectively input into the first branch and the second branch;
[0049]Among them, the network structure of the feature extractor part is the same as that of the existing inception v3, and the classifier includes a first branch and a second branch. The first preset image is used as an example to illustrate, specifically:
[0050] The feature extractor obtains a feature map according to the first preset image, at least one first pornographic tag corresponding to the first preset image, and a second pornographic tag corresponding to the first preset image, and then performs average pooling on the feature map, The feature vector corresponding to the first preset image is obtained, and then the feature vector is input into the first branch and the second branch respectively.
[0051] S012, based on at least one first pornographic label corresponding to each preset image, and the second pornographic label corresponding to each preset image, utilize the improved inception v3 model and train in conjunction with the Adam algorithm to obtain the pornographic Image recognition model.
[0052] Among them, the number of preset images can be confirmed according to the actual situation, such as 1000 and 5000 preset images. In general, the more preset images, the higher the accuracy of the trained pornographic image recognition model, but the training takes time. will increase, and the accuracy and training time can be balanced according to the actual situation. Generally, multiple preset images are divided into training sets and validation sets according to preset ratios such as 9:1 or 8:2, and then use the improved inception v3 model. , and combined with Adam algorithm for training to obtain the pornographic image recognition model. The training process is known to those skilled in the art and will not be repeated here.
[0053] Among them, small batches of input are used for training in the training process, and the model does not improve on the validation set after several batches, then the training is stopped, and the pornographic image recognition model is obtained, or when the accuracy reaches the preset accuracy, the training is stopped. Get a pornographic image recognition model.
[0054] Among them, the Adam algorithm can make it reach the convergence state stably and smoothly in the training phase.
[0055] Before training, each preset image is flipped, rotated, contrasted, etc., to enrich the dataset samples. The size of each preset image is unified and normalized to facilitate training.
[0056] Preferably, in the above technical solution, in S011, building the improved inception v3 model further includes:
[0057] S0110. Introduce a binary-cross-entropy loss function to the first branch, and introduce a cross-entropy loss function to the second branch.
[0058] Preferably, in the above technical solution, the first branch includes two fully connected layers of different dimensions, and the activation function corresponding to the first branch is a sigmoid function;
[0059] The second branch includes two fully connected layers with different dimensions, and the activation function corresponding to the second branch is a softmax function.
[0060] Among them, using the Cross-entropy loss function has a smoother descent, and the model can fit the sample features that are more difficult to learn during the training process. The correlation between the output categories of the second branch is weakened, and Binary-cross-entropy is used to ensure a certain degree of independence of the output categories.
[0061] Among them, the characteristic of the softmax function is that the sum of the output values is 1, which is very in line with the requirement of outputting a single pornographic label of the second branch. sigmoid calculates the activation value separately for each category to ensure category independence.
[0062] The first branch includes two fully connected layers of different dimensions, such as a 2048-dimensional fully connected layer and a 65-dimensional fully connected layer, and the second branch includes two fully connected layers of different dimensions, such as a 2048-dimensional fully connected layer , 31-dimensional fully connected layer, etc.
[0063] In the above embodiments, although the steps are numbered S1, S2, etc., they are only specific embodiments given in this application. Those skilled in the art can adjust the execution order of S1, S2, etc. according to the actual situation. Within the protection scope of the present invention, it can be understood that in some embodiments, some or all of the above-mentioned embodiments may be included.
[0064] like figure 2 As shown, a pornographic image recognition system 200 according to an embodiment of the present invention includes an input module 210 and a judgment module 220;
[0065] The input module 210 is used to input the image to be recognized into the pornographic image recognition model trained by the dual branches, and obtain a result corresponding to each branch, wherein the corresponding result of the first branch includes at least one first pornographic label, and the result of the second branch. Include only one secondary pornographic tag;
[0066] The judging module 220 is configured to judge whether the to-be-identified image is a pornographic image according to the result corresponding to the first branch and the result corresponding to the second branch.
[0067] After the image to be recognized is input into the dual-branch training pornographic image recognition model, the result corresponding to the first branch and the result corresponding to the second branch can be obtained, and the two results can be compared and verified with each other, which greatly reduces the probability of missing pornographic images.
[0068] Preferably, in the above technical solution, a labeling module, a model building module and a model training module are also included;
[0069] The labeling module is used to label at least one first pornographic label to any preset image, and to label only one second pornographic label to any preset image, until at least one first pornographic label corresponding to each preset image is obtained. pornographic tags, and a second pornographic tag corresponding to each preset image;
[0070] The model building module is used to build an improved inception v3 model including a feature extractor and a classifier, wherein the classifier includes the first branch and the second branch, wherein the feature extractor will A feature vector obtained from a preset image, at least one first pornographic tag corresponding to each preset image, and a second pornographic tag corresponding to each preset image are respectively input to the first branch and the second branch;
[0071] The model training module is used for training based on the at least one first pornographic label corresponding to each preset image, and the second pornographic label corresponding to each preset image, using the improved inception v3 model and in combination with the Adam algorithm. , to obtain the pornographic image recognition model.
[0072] Preferably, in the above technical solution, the model building module is also used for:
[0073] A binary-cross-entropy loss function is introduced into the first branch, and a cross-entropy loss function is introduced into the second branch.
[0074] Preferably, in the above technical solution, the first branch includes two fully connected layers of different dimensions, and the activation function corresponding to the first branch is a sigmoid function;
[0075] The second branch includes two fully connected layers with different dimensions, and the activation function corresponding to the second branch is a softmax function.
[0076] Above-mentioned about each parameter in a kind of pornographic image recognition system 200 of the present invention and the step that each unit module realizes corresponding function, can refer to each parameter and step in the embodiment of a kind of pornographic image recognition method above, do not here. Do repeat.
[0077] An embodiment of the present invention is a storage medium, where instructions are stored in the storage medium, and when a computer reads the instructions, the computer is made to execute any one of the above-mentioned methods for recognizing pornographic images.
[0078] An electronic device according to an embodiment of the present invention includes a memory, a processor, and a program stored in the memory and running on the processor, and the processor implements any one of the above-mentioned programs when the processor executes the program. Steps of a pornographic image recognition method.
[0079] Among them, the electronic device can be selected from a computer, a mobile phone, etc., correspondingly, its program is a computer software or a mobile phone APP, etc., and the above-mentioned parameters and steps in an electronic device of the present invention can refer to the above-mentioned pornographic image The parameters and steps in the embodiments of the identification method will not be repeated here.
[0080] As will be appreciated by one skilled in the art, the present invention may be implemented as a system, method or computer program product.
[0081] Therefore, the present disclosure can be embodied in the following forms, that is: it can be complete hardware, it can also be complete software (including firmware, resident software, microcode, etc.), or it can be a combination of hardware and software. Called a "circuit," "module," or "system." Furthermore, in some embodiments, the present invention may also be implemented in the form of a computer program product on one or more computer-readable media having computer-readable program code embodied thereon.
[0082] Any combination of one or more computer-readable media may be employed. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or a combination of any of the above. More specific examples (non-exhaustive list) of computer readable storage media include: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM), Erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0083] Although the embodiments of the present invention have been shown and described above, it should be understood that the above-mentioned embodiments are exemplary and should not be construed as limiting the present invention. Embodiments are subject to variations, modifications, substitutions and variations.
PUM


Description & Claims & Application Information
We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.