Pornographic image recognition method and device, electronic equipment and storage medium

By extracting attention feature vectors from images and combining channel and spatial attention mechanisms, the problem of poor pornographic image recognition performance in existing technologies is solved, achieving more efficient pornographic image recognition.

CN114091551BActive Publication Date: 2025-12-16BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111235686.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-22
Publication Date
2025-12-16
Estimated Expiration
2041-10-22

AI Technical Summary

Technical Problem

In existing technologies, when identifying pornographic images by detecting the geometric characteristics of skin color regions in an image, the recognition effect is poor, especially when local pornographic content occupies a small part of the entire image, it is easy to miss detection.

Method used

The initial image feature vector of the target image is extracted, and attention feature vectors are generated through channel and spatial attention mechanisms to characterize the eroticism of different channels and spatial regions in the image. The image is then classified in combination with a pre-trained classification model.

Benefits of technology

It improves the accuracy of pornographic image recognition, enabling more accurate determination of the importance of pornographic areas and channels in images, and reducing missed detections.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114091551B_ABST
    Figure CN114091551B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a kind of pornographic image recognition method, device, electronic equipment and storage medium, applied to image processing technical field, wherein method includes: obtaining target image to be identified;Extract the initial image feature vector in the target image;According to the initial image feature vector, extract attention feature vector, the attention feature vector can represent the pornography degree of different channels in the target image and the pornography degree of different spatial regions in the target image;The target image is classified based on the attention feature vector, determines the identification result of the target image.To solve the problem that the identification effect is poor in related art when the image or video is audited pornographic content, only simple image features are identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method, apparatus, electronic device, and storage medium for pornographic image recognition. Background Technology

[0002] Human society has entered the information age, and the rapid spread of information has changed people's work, study, and lifestyles. Information takes many forms (text, images, audio, etc.); its content is also diversified. While promoting the progress of human society, a large amount of harmful information has a very negative impact on society. For example, pornographic images and videos are among the most widespread and difficult-to-control types of information.

[0003] Internet pornography is increasingly affecting people's normal lives. The proliferation of online pornography has led to many social and moral problems. Therefore, identifying or detecting online pornography is of great significance for the healthy development of internet resources and culture.

[0004] In related technologies, when reviewing images or videos for pornographic content, the method often involves detecting whether the image contains areas with large skin tones and using the geometric characteristics of these skin-toned areas (area, proportion of the area in the current image, aspect ratio of the bounding rectangle, etc.) to determine whether the current image is pornographic. This method can only review regular pornographic images. It may exhibit weak pornographic feature vectors locally or overall, or contain interference from normal images (e.g., pornographic images spliced ​​into a normal image). Since the pornographic content only occupies a part of the entire image, the recognition effect is poor and it is easy to miss detections. Summary of the Invention

[0005] The purpose of this invention is to provide a method, apparatus, electronic device, and storage medium for pornographic image recognition, in order to solve the problem in related technologies where the recognition effect is poor when reviewing pornographic content in images or videos by relying solely on simple image features.

[0006] In a first aspect of the present invention, a method for identifying pornographic images is provided, the method comprising:

[0007] Acquire the target image to be identified;

[0008] Extract the initial image feature vector from the target image;

[0009] Based on the initial image feature vector, an attention feature vector is extracted, which can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image;

[0010] The target image is classified based on the attention feature vector to determine the recognition result of the target image.

[0011] Optionally, extracting the attention feature vector based on the initial image feature vector includes:

[0012] Extract the features of the initial image feature vector in the channel dimension to obtain the channel feature vector;

[0013] Extract the features of the channel feature vector in the spatial dimension to obtain the attention feature vector; or,

[0014] Extract the features of the initial image feature vector in the spatial dimension to obtain the spatial feature vector;

[0015] The spatial feature vector is extracted along the channel dimension to obtain the attention feature vector.

[0016] Optionally, extracting the features of the initial image feature vector in the channel dimension to obtain the channel feature vector includes:

[0017] Determine the first maximum value and the first average value of the initial image feature vector in the spatial dimension, respectively;

[0018] The first maximum value and the first average value are fused to obtain the first intermediate vector;

[0019] The first intermediate vector is processed using a preset first objective function to obtain the channel weight coefficients;

[0020] The channel feature vector is obtained by weighting and summing the channel weight coefficients with the initial image feature vector.

[0021] Optionally, determining the first maximum value and the first average value of the initial image feature vector in the spatial dimension includes:

[0022] Perform global max pooling on the initial image feature vector in the spatial dimension to obtain the first maximum value;

[0023] The initial image feature vector is subjected to global average pooling in the spatial dimension to obtain the first average value.

[0024] Optionally, extracting the features of the channel feature vector in the spatial dimension to obtain the attention feature vector includes:

[0025] Determine the second maximum value and the second average value of the channel feature vector in the channel dimension, respectively;

[0026] The second maximum value and the second average value are fused to obtain the second intermediate vector;

[0027] The second intermediate vector is processed using a preset second objective function to obtain spatial weight coefficients;

[0028] The attention feature vector is obtained by weighting and summing the spatial weight coefficients with the channel feature vectors.

[0029] Optionally, classifying the target image based on the attention feature vector to determine the recognition result of the target image includes:

[0030] The attention feature vector is input into a pre-trained classification model;

[0031] The main classification result and the sub-classification result of the target image are determined according to the pre-trained classification model. The main classification result and the sub-classification result are used as the recognition result. The main classification result is obtained by optimizing the classification model based on the softmax loss function, and the sub-classification result is obtained by optimizing the classification model based on the center loss function.

[0032] Optionally, extracting the initial image feature vector from the target image includes:

[0033] Based on the residual network, the deep channel feature vector and the shallow channel feature vector are extracted from the target image;

[0034] The deep channel feature vector and the shallow channel feature vector are fused to obtain the initial image feature vector.

[0035] Optionally, acquiring the target image to be identified includes:

[0036] Obtain the original image;

[0037] The original image is augmented to obtain an augmented image;

[0038] The augmented image is scaled to obtain the target image.

[0039] Optionally, the data augmentation of the original image includes:

[0040] Perform at least one of the following operations on the original image: image flipping, image cropping, Gaussian blurring, and affine transformation.

[0041] In a second aspect of the present invention, a pornographic image recognition device is also provided, comprising:

[0042] The acquisition module is used to acquire the target image to be identified;

[0043] The first extraction module is used to extract the initial image feature vector from the target image;

[0044] The second extraction module is used to extract an attention feature vector based on the initial image feature vector. The attention feature vector can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image.

[0045] The classification module is used to classify the target image based on the attention feature vector and determine the recognition result of the target image.

[0046] In a third aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.

[0047] Memory, used to store computer programs;

[0048] When a processor executes a program stored in memory, it implements any of the pornographic image recognition methods described in the first aspect above.

[0049] In a fourth aspect of the present invention, a storage medium is also provided, the storage medium storing instructions that, when run on a computer, cause the computer to execute any of the pornographic image recognition methods described in the first aspect above.

[0050] In a fifth aspect of the present invention, a computer program product comprising instructions is also provided, which, when run on a computer, causes the computer to perform any of the pornographic image recognition methods described in the first aspect above.

[0051] The technical solution provided by this invention involves: acquiring a target image to be identified; extracting an initial image feature vector from the target image; extracting an attention feature vector based on the initial image feature vector, whereby the attention feature vector can characterize the pornographic intensity of different channels and different spatial regions within the target image; and classifying the target image based on the attention feature vector to determine the identification result. Thus, after extracting the initial image feature vector, further processing it yields an attention feature vector that characterizes both the pornographic intensity of different channels and different spatial regions within the target image. Therefore, by using the attention feature vector, it is possible to determine which regions and channels within the target image are more important for the identification of the target image. Consequently, classification based on the obtained attention feature vector can accurately determine whether the target image is pornographic. Attached Figure Description

[0052] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0053] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0054] Figure 1 This is a schematic diagram of the scenario structure for implementing a pornographic image recognition method according to an embodiment of the present invention;

[0055] Figure 2 This is a flowchart illustrating a pornographic image recognition method in an embodiment of the present invention;

[0056] Figure 3 This is a flowchart illustrating another pornographic image recognition method in an embodiment of the present invention;

[0057] Figure 4 This is a schematic diagram of the structure of a pornographic image recognition device shown in an embodiment of the present invention;

[0058] Figure 5 This is a schematic diagram of the structure of an electronic device shown in an embodiment of the present invention. Detailed Implementation

[0059] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0060] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0061] According to one embodiment of this application, a method for identifying pornographic images is provided. Optionally, in this embodiment, the above-described method for identifying pornographic images can be applied to, for example... Figure 1 The hardware environment shown consists of terminal 101 and server 102. For example... Figure 1 As shown, server 102 is connected to terminal 101 via a network and can be used to provide services (such as video services, application services, etc.) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 102. The network mentioned above includes, but is not limited to, wide area network, metropolitan area network or local area network. Terminal 101 is not limited to PC, mobile phone, tablet computer, etc.

[0062] The pornographic image recognition method of this application embodiment can be executed by server 102 or by terminal 101. Specifically, the pornographic image recognition method of this application embodiment is executed by a client installed on the terminal 101.

[0063] Taking the pornographic image recognition method of this application as an example, the pornographic image recognition method of this application can be implemented by a pre-trained neural network model. This pre-trained neural network model is applied to the terminal to achieve accurate image recognition. Specifically, the pre-trained neural network model can be an SE-ResNext-50 model with a channel attention mechanism module and a spatial attention mechanism module inserted. After the SE-ResNext-50 model extracts the initial image feature vector, this vector is input into the channel attention mechanism module and the spatial attention mechanism module respectively to obtain channel feature vectors and spatial feature vectors. These two feature vectors are then fused, and the resulting attention feature vector is input into the SE-ResNext-50 model for further classification to obtain the recognition result.

[0064] Figure 2This is a flowchart illustrating an optional pornographic image recognition method according to an embodiment of this application, such as... Figure 2 As shown, the process of this method may include the following steps:

[0065] Step 201: Obtain the target image to be identified.

[0066] In some embodiments, the target image to be identified can be the original input image or an image obtained after a series of processing steps on the original image.

[0067] In one optional embodiment, the specific process of obtaining the target image to be identified can be obtained in the following manner:

[0068] Acquire the original image; perform data augmentation on the original image to obtain the augmented image; scale the augmented image to obtain the target image.

[0069] In some embodiments, the original image may be input by the user, obtained by the terminal from a preset image data source, or extracted from the video to be identified.

[0070] After obtaining the original image, in order to improve the accuracy of image recognition, the original image is augmented to obtain multiple augmented images based on the original image, thereby enabling recognition of the original image from multiple angles and improving the accuracy of original image recognition.

[0071] Furthermore, during the model training phase, data augmentation can be used to increase the training dataset, making it as diverse as possible and enhancing the model's generalization ability. Data augmentation methods can include, but are not limited to, at least one of the following: horizontal flipping, vertical flipping, rotation, scaling, cropping, shearing, translation, contrast adjustment, color dithering, Gaussian blur, and affine transformation. Gaussian blur, in particular, can blur and smooth images, reducing image noise and detail.

[0072] Furthermore, during the experiment, it was found that unifying the target images in the input model to a suitable size can improve the recognition accuracy. In this embodiment, the augmented images can be uniformly scaled to 299×299 pixels.

[0073] Step 202: Extract the initial image feature vector from the target image.

[0074] In some embodiments, the initial image feature vector can be obtained by using a residual network to extract deep channel feature vectors and shallow channel feature vectors from the target image. Using SE-ResNext-50 as the backbone network, global average pooling is used to fuse the deep and shallow channel features, ultimately yielding a feature vector of a preset dimension, i.e., the initial image feature vector. The preset dimension can be, but is not limited to, 2048 dimensions.

[0075] Among them, the residual network is used to extract the initial image feature vector. The residual network can improve the accuracy by increasing the depth considerably. In addition, the residual blocks in the residual network use skip connections, which alleviates the gradient vanishing problem caused by increasing the depth in deep neural networks.

[0076] The deep channel feature vectors mentioned above are extracted through the deep layers of the residual network, while the shallow channel feature vectors are extracted through the shallow layers of the residual network. The deep and shallow networks have different numbers of layers, with the deep network having more layers than the shallow network. The number of layers in both the deep and shallow networks can be set according to specific requirements.

[0077] Step 203: Extract attention feature vectors based on the initial image feature vectors. Attention feature vectors can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image.

[0078] In some embodiments, after obtaining the initial image feature vector of the target image, the initial image feature vector can be further extracted and input into the attention module for attention feature vector extraction. The attention module includes a channel attention module and a spatial attention module, so that the attention feature vector obtained after inputting the initial image feature vector into the attention module can characterize both the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image.

[0079] Specifically, there are multiple ways to extract attention feature vectors based on the initial image feature vectors.

[0080] Specifically, the first approach is to extract the features of the initial image feature vector in the channel dimension to obtain the channel feature vector; and then extract the features of the channel feature vector in the spatial dimension to obtain the attention feature vector.

[0081] Alternatively, the second approach can be used: extract the features of the initial image feature vector in the spatial dimension to obtain the spatial feature vector; extract the features of the spatial feature vector in the channel dimension to obtain the attention feature vector.

[0082] In practical applications, any of the above methods can be used to extract attention feature vectors.

[0083] Taking the first method above as an example, the initial image feature vector is input into the channel attention module, and the channel feature vector is extracted by the channel attention module. The channel feature vector is then input into the spatial attention module, and the attention feature vector is extracted by the spatial attention module.

[0084] Furthermore, to efficiently compute channel attention, the spatial dimension of the input channel attention map is compressed; that is, an initial image feature vector of 2048 dimensions is input into the channel attention module. Within the channel attention module, the channel attention map is generated using the inter-channel relationships of the features. Each channel of this channel attention map is used as a feature detector, and channel attention focuses on "what" is meaningful in the input image; that is, the channel attention module determines which channels are important for identifying the image as pornographic. To focus on spatial information, both average pooling and max pooling are used simultaneously, which significantly improves the network's representational power.

[0085] The channels mentioned above refer to different color channels in the target image. The corresponding channels differ depending on the target image format. Specifically, for RGB images, the channels include RGB, R, G, and B channels; for CMYK images, they include CMYK, C, M, Y, and K channels; and for Lab images, they include Lab, L, a, and b channels.

[0086] Taking an RGB image as an example, different values ​​in each channel will result in different colors in the image. For example, when the R, G, and B channels take certain values, the RGB channels will appear flesh-colored. Since human skin is usually flesh-colored when it is naked, it is important to determine the RGB channels when the R, G, and B channels take certain values ​​to determine if the image is pornographic.

[0087] In an optional embodiment, the features of the initial image feature vector in the channel dimension are extracted to obtain the channel feature vector, specifically including:

[0088] The first maximum value and the first average value of the initial image feature vector in the spatial dimension are determined respectively; the first maximum value and the first average value are fused to obtain the first intermediate vector; the first intermediate vector is processed using a preset first objective function to obtain the channel weight coefficients; the channel weight coefficients are weighted and summed with the initial image feature vector to obtain the channel feature vector.

[0089] The first maximum value can be obtained by performing a global max pooling operation on the initial image feature vector in the spatial dimension; the first average value can be obtained by performing a global average pooling operation on the initial image feature vector in the spatial dimension.

[0090] By using global average pooling and global max pooling operations, the spatial information of the feature map is aggregated to generate two different spatial context descriptors: a first maximum value and a first average value. Global average pooling focuses more on the overall information of the image, while global max pooling focuses more on certain extreme values ​​in the image. Using both in parallel allows for the synergistic effect of their respective strengths, resulting in a better and more comprehensive feature representation. Therefore, after obtaining the first maximum value and the first average value, they are fused to obtain a first intermediate vector, which better represents the channel features of the target image.

[0091] There are several ways to merge the first maximum value and the first average value. For example, the "ADD()" function can be used to merge them.

[0092] Furthermore, after obtaining the first intermediate vector after fusion, the sigmoid activation function (i.e., the first objective function) can be used for activation. Since the sigmoid activation function will turn each number in the first intermediate vector into a probability value between [0,1], the response coefficient of each channel dimension of the target image can be obtained, i.e., the channel weight coefficient.

[0093] Furthermore, after obtaining the channel weight coefficients, the channel weight coefficients are multiplied by the initial image feature vector to obtain the channel feature vector.

[0094] In this embodiment, the original features are weighted, and channel attention is introduced into the original features, making the model pay more attention to the feature regions with higher scores.

[0095] In an optional embodiment, the features of the channel feature vector in the spatial dimension are extracted to obtain the attention feature vector, including:

[0096] The second maximum value and the second average value of the initial image feature vector in the channel dimension are determined respectively; the second maximum value and the second average value are fused to obtain the second intermediate vector; the second intermediate vector is processed using a preset second objective function to obtain the spatial weight coefficients; the spatial weight coefficients are weighted and summed with the initial image feature vector to obtain the spatial feature vector.

[0097] The second maximum value can be obtained by performing global max pooling on the initial image feature vector along the channel dimension; the second average value can be obtained by performing global average pooling on the initial image feature vector along the channel dimension.

[0098] Furthermore, in the spatial attention module, a spatial attention map is generated by utilizing the spatial relationships between features. Unlike channel attention, spatial attention focuses on "where" the input image is meaningful; that is, the spatial attention module determines which regions are important for identifying an image as pornographic. To compute the spatial feature vector, average pooling and max pooling operations are first applied along the channel dimension, and they are concatenated to generate a valid feature descriptor, namely the second intermediate vector.

[0099] In an optional embodiment, the second intermediate vector is processed using a preset second objective function to obtain spatial weight coefficients, including:

[0100] The second intermediate vector is convolved with a preset convolution kernel to obtain the convolution result; the convolution result is activated based on the activation function to obtain the spatial weight coefficients.

[0101] The preset convolution kernel can be, but is not limited to, a 7×7 convolution kernel, and the activation function can be, but is not limited to, a sigmoid activation function. The specific settings can be made according to the actual situation and are not limited here.

[0102] The convolution result is activated using the sigmoid activation function. By using the sigmoid activation function, each number in the second intermediate vector is transformed into a probability value between [0,1]. This allows us to obtain the response coefficient of each spatial dimension of the feature map, i.e., the spatial weight coefficient.

[0103] Furthermore, the spatial feature vector can be obtained by multiplying the spatial weight coefficients by the initial image feature vector.

[0104] Understandably, the global max pooling and global average pooling operations used in obtaining the channel feature vectors and spatial feature vectors are identical in process—both preserve overall information and highlight extreme values. However, their application differs. Applying both pooling operations to the channel dimension preserves spatial information, allowing the model to understand which regions are important (where); applying them to the spatial dimension preserves channel information, allowing the model to understand which channels are important (what).

[0105] For example, taking the initial image feature vector as a 2048-dimensional feature vector (10×10×2048) as an example, since the pooling in the two steps is applied at different positions, the channel attention module pools the original 10×10×2048 features to 1×1×2048, preserving channel information; the spatial attention module pools the 10×10×2048 features to 10×10×1, preserving spatial information.

[0106] In some embodiments, the extracted attention feature vectors are combined with the channel and spatial features, achieving significant performance improvements while maintaining low overhead. For separate attention to the channel and spatial features, max pooling and average pooling are used, enabling the pre-trained neural network model to learn how to effectively emphasize or compress extracted intermediate features.

[0107] Step 204: Classify the target image based on the attention feature vector to determine the recognition result of the target image.

[0108] In some embodiments, after obtaining the attention feature vector, it can be input into the global pooling layer and fully connected layer of the SE-ResNext-50 model to achieve the final classification of the target image.

[0109] In an alternative embodiment, the classification of the target image based on the attention feature vector can also be performed using a separately trained classification model.

[0110] Specifically, this includes: inputting attention feature vectors into a pre-trained classification model; determining the main classification result of the target image and the sub-classification results within the main classification result based on the pre-trained classification model; using the main classification result and the sub-classification results as recognition results, wherein the main classification result is obtained after optimizing the classification model based on the softmax loss function, and the sub-classification results are obtained after optimizing the classification model based on the center loss function.

[0111] In some implementations, different loss functions are used for the primary and secondary classifications. This allows the primary classification to retain its softmax loss function while using a center loss function (e.g., center loss or focal loss) for the secondary classifications. This enables the model to increase the distance between secondary classification classes while simultaneously reducing the distance within each class. Since the network feature layers share weights, this approach improves the accuracy of the secondary classifications while simultaneously enhancing the accuracy of the primary classification.

[0112] Furthermore, weighted processing can be applied to different categories, as the risk of misclassification varies across different business scenarios. For example, misclassifying "sexy" as "normal" is clearly more serious than misclassifying "pornography" as "normal." Therefore, during model training, weighted processing can be applied to misclassify different categories, increasing the penalty for misclassifying "pornography" as "normal," further widening the gap between the "normal" and "pornography" classes, thus making the trained model more accurate in its classification.

[0113] In one alternative embodiment, when training a pre-trained neural network model, each input training sample includes a training target image and an identifier for the training target image, wherein the identifier for the training target image is used to label the classification category of the training target image.

[0114] In an optional embodiment, when training a pre-trained classification model, each input training sample includes a training attention feature vector and an identifier of the training target image corresponding to the training attention feature vector, wherein the identifier of the training target image corresponding to the training attention feature vector is used to mark the classification category of the training target image.

[0115] A specific embodiment of the pornographic image recognition method provided in this application is described in [reference]. Figure 3 ,include:

[0116] Step 301: Obtain the original image.

[0117] Step 302: Scale the original image to obtain the target image.

[0118] Step 303: Extract features from the target image to obtain a 2048-dimensional feature vector.

[0119] Step 304: Obtain the channel feature vector based on the channel attention mechanism.

[0120] Step 305: Obtain the attention feature vector based on the spatial attention mechanism.

[0121] Step 306: Input the attention feature vector into the hierarchical classification module.

[0122] Step 307: Output the classification results of the main category and the secondary categories.

[0123] In this embodiment, by combining the channel attention module and the spatial attention module and integrating these two modules with the SE-ResNeXt-50 model, the model's ability to represent image features is improved. Furthermore, these two modules can be flexibly inserted into any stage of the network, enhancing their usability. Additionally, a two-layer classification structure is used during model training to simultaneously complete both primary and secondary classification tasks. In subsequent use, the results of primary and secondary classifications can be integrated, improving the model's recognition performance.

[0124] The main category can include categories such as pornography, normal, and sexy. Subcategories are the subcategories derived from each main category. After fusing features to obtain the attention feature vector, two fully connected layers are used to map the attention feature vector to the dimensions of the main and subcategories, respectively, and then softmax is used to achieve classification.

[0125] This invention can be applied to image and video classification tasks containing pornographic content, especially for difficult cases where images contain interfering elements or whose features are not obvious. It can effectively improve the recognition ability of the algorithm and further improve the accuracy of the algorithm without increasing the algorithm complexity and maintaining the algorithm's inference speed. It has great application potential in image and video review.

[0126] Corresponding to the above method embodiments, this invention also provides a pornographic image recognition device, such as... Figure 4 As shown, the device may include:

[0127] The acquisition module 401 is used to acquire the target image to be identified;

[0128] The first extraction module 402 is used to extract the initial image feature vector from the target image;

[0129] The second extraction module 403 extracts attention feature vectors based on the initial image feature vectors. The attention feature vectors can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image.

[0130] The classification module 404 is used to classify the target image based on the attention feature vector and determine the recognition result of the target image.

[0131] Based on the same concept, this application also provides an electronic device, such as... Figure 5 As shown, the electronic device mainly includes a processor 501, a memory 502, and a communication bus 503. The processor 501 and the memory 502 communicate with each other via the communication bus 503. The memory 502 stores programs that can be executed by the processor 501. The processor 501 executes the programs stored in the memory 502 to perform the following steps:

[0132] Acquire the target image to be identified;

[0133] Extract the initial image feature vector from the target image;

[0134] Based on the initial image feature vector, an attention feature vector is extracted. The attention feature vector can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image.

[0135] The target image is classified based on the attention feature vector to determine the recognition result of the target image.

[0136] The communication bus 503 mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus 503 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0137] The memory 502 may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor 501.

[0138] The processor 501 mentioned above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc., or a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0139] In another embodiment of the present invention, a storage medium is also provided, which stores instructions that, when run on a computer, cause the computer to execute any of the pornographic image recognition methods described in the above embodiments.

[0140] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the pornographic image recognition methods described in the above embodiments.

[0141] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a storage medium or transmitted from one storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0142] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0143] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0144] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A method for identifying pornographic images, characterized in that, include: Acquire the target image to be identified; Extract the initial image feature vector from the target image; Based on the initial image feature vector, an attention feature vector is extracted, which can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image; The target image is classified based on the attention feature vector to determine the recognition result of the target image; The step of extracting the attention feature vector based on the initial image feature vector includes: Extract the features of the initial image feature vector in the channel dimension to obtain the channel feature vector; Extract the features of the channel feature vector in the spatial dimension to obtain the attention feature vector; The step of extracting the features of the initial image feature vector in the channel dimension to obtain the channel feature vector includes: The first maximum value and the first average value of the initial image feature vector in the spatial dimension are determined respectively; wherein, the first maximum value is obtained by performing a global max pooling operation on the initial image feature vector in the spatial dimension, and the first average value is obtained by performing a global average pooling operation on the initial image feature vector in the spatial dimension. The first maximum value and the first average value are fused to obtain the first intermediate vector; The first intermediate vector is processed using a preset first objective function to obtain the channel weight coefficients; The channel weight coefficients are weighted and summed with the initial image feature vector to obtain the channel feature vector; The step of extracting the spatial features of the channel feature vector to obtain the attention feature vector includes: The second maximum value and the second average value of the channel feature vector in the channel dimension are determined respectively; wherein, the second maximum value is obtained by performing a global max pooling operation on the channel feature vector in the channel dimension, and the second average value is obtained by performing a global average pooling operation on the channel feature vector in the channel dimension. The second maximum value and the second average value are fused to obtain the second intermediate vector; The second intermediate vector is processed using a preset second objective function to obtain spatial weight coefficients; The attention feature vector is obtained by weighting and summing the spatial weight coefficients with the channel feature vectors.

2. The method according to claim 1, characterized in that, The step of extracting the attention feature vector based on the initial image feature vector includes: Extract the features of the initial image feature vector in the spatial dimension to obtain the spatial feature vector; The spatial feature vector is extracted along the channel dimension to obtain the attention feature vector.

3. The method according to claim 1, characterized in that, The step of determining the first maximum value and the first average value of the initial image feature vector in the spatial dimension includes: Perform global max pooling on the initial image feature vector in the spatial dimension to obtain the first maximum value; The initial image feature vector is subjected to global average pooling in the spatial dimension to obtain the first average value.

4. The method according to claim 1, characterized in that, The target image is classified based on the attention feature vector to determine the recognition result of the target image, including: The attention feature vector is input into a pre-trained classification model; The main classification result and the sub-classification result of the target image are determined according to the pre-trained classification model. The main classification result and the sub-classification result are used as the recognition result. The main classification result is obtained by optimizing the classification model based on the softmax loss function, and the sub-classification result is obtained by optimizing the classification model based on the center loss function.

5. The method according to claim 1, characterized in that, The step of extracting the initial image feature vector from the target image includes: Based on the residual network, the deep channel feature vector and the shallow channel feature vector are extracted from the target image; The deep channel feature vector and the shallow channel feature vector are fused to obtain the initial image feature vector.

6. A pornographic image recognition device, characterized in that, include: The acquisition module is used to acquire the target image to be identified; The first extraction module is used to extract the initial image feature vector from the target image; The second extraction module is used to extract an attention feature vector based on the initial image feature vector. The attention feature vector can characterize the eroticism of different channels in the target image and the eroticism of different spatial regions in the target image. The extraction of the attention feature vector based on the initial image feature vector includes: extracting features of the initial image feature vector in the channel dimension to obtain a channel feature vector; and extracting features of the channel feature vector in the spatial dimension to obtain the attention feature vector. The extraction of features of the initial image feature vector in the channel dimension to obtain a channel feature vector includes: determining a first maximum value and a first average value of the initial image feature vector in the spatial dimension; wherein the first maximum value is obtained by performing a global max pooling operation on the initial image feature vector in the spatial dimension, and the first average value is obtained by performing a global average pooling operation on the initial image feature vector in the spatial dimension; and then combining the first maximum value and the first average value... The first average value is fused to obtain a first intermediate vector; the first intermediate vector is processed using a preset first objective function to obtain channel weight coefficients; the channel weight coefficients are weighted and summed with the initial image feature vector to obtain the channel feature vector; wherein, the step of extracting the features of the channel feature vector in the spatial dimension to obtain the attention feature vector includes: determining the second maximum value and the second average value of the channel feature vector in the channel dimension respectively; wherein, the second maximum value is obtained by performing a global max pooling operation on the channel feature vector in the channel dimension, and the second average value is obtained by performing a global average pooling operation on the channel feature vector in the channel dimension; the second maximum value and the second average value are fused to obtain a second intermediate vector; the second intermediate vector is processed using a preset second objective function to obtain spatial weight coefficients; the spatial weight coefficients are weighted and summed with the channel feature vector to obtain the attention feature vector; The classification module is used to classify the target image based on the attention feature vector and determine the recognition result of the target image.

7. An electronic device, comprising: The system includes a processor, a memory, and a communication bus, wherein the processor and the memory communicate with each other via the communication bus; the memory is used to store computer programs; and the processor is used to execute the programs stored in the memory to implement the pornographic image recognition method according to any one of claims 1 to 5.

8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the pornographic image recognition method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Similar image determination method and device, electronic equipment and storage medium

    CN112949777A

  • Attention-based image recognition method and system, electronic equipment and storage medium

    CN113255821A