A method for image recognition

The identification of images in social products through sensitive area detection, classification and feature extraction models solves the problem of identifying sensitive images, improves identification accuracy and network security, and ensures the healthy dissemination of data.

CN112001282BActive Publication Date: 2024-10-29TENCENT MUSIC ENTERTAINMENT TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010816472.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-12
Publication Date
2024-10-29
Estimated Expiration
2040-08-12

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively identify and classify images that are pornographic and vulgar or contain sensitive flags in social products, affecting network security and user experience.

Method used

The sensitive area detection model, classification model and feature extraction model are used to detect, classify and extract features of the image to be identified, determine the image category through similarity calculation with the preset database, and provide more detailed detection information to improve recognition accuracy.

Benefits of technology

It achieves accurate identification and classification of sensitive images, improves the security of social product data, reduces the spread of sensitive content, and enhances the health of the network environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112001282B_ABST
    Figure CN112001282B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention proposes an image recognition method, device, electronic device and storage medium. Among them, the image recognition method is specifically: detecting the image to be recognized through a sensitive area detection model, if it is determined that the image to be recognized is a sensitive image, then obtaining the sensitive area of ​​the image to be recognized; classifying the sensitive area through a classification model to obtain a feature extraction category of the sensitive area; extracting features of the feature extraction category of the sensitive area through a feature extraction model to obtain feature information of the sensitive area; calculating the similarity between the feature information and each feature information in a preset database, and determining the category corresponding to the feature information with the greatest similarity in the preset database as the category of the sensitive area. Through the embodiment of the present invention, more detailed detection information can be provided for the image to be recognized, and the category of the sensitive image can be recognized, so as to improve the accuracy of the recognition of the image to be recognized and ensure the security of the data in the social products.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet technology, and in particular to an image recognition method, an image recognition device, an electronic device and a storage medium. Background Art

[0002] With the continuous development of Internet technology, social products play an increasingly important role in people's daily lives. Social products such as Kugou, QQ Music, WeSing, etc. are emerging one after another. Therefore, the massive amount of pictures, videos, live broadcasts and other data in social products have become the focus of people's attention. Therefore, how to identify the category of sensitive images with pornographic and vulgar nature and containing sensitive flags has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The embodiments of the present invention propose an image recognition method, an image recognition device, an electronic device and a storage medium, which can provide more detailed detection information, realize the recognition of the category of sensitive images, so as to improve the accuracy of the recognition of the images to be recognized and ensure the security of the data in the social products.

[0004] An embodiment of the present invention provides an image recognition method, which includes:

[0005] The image to be identified is detected by using a sensitive area detection model, and if it is determined that the image to be identified is a sensitive image, the sensitive area of ​​the image to be identified is obtained;

[0006] Classifying the sensitive area through a classification model to obtain a feature extraction category of the sensitive area;

[0007] Performing feature extraction of the feature extraction category on the sensitive area through a feature extraction model to obtain feature information of the sensitive area;

[0008] The similarity between the feature information and each piece of feature information in a preset database is calculated, and the category corresponding to the feature information with the greatest similarity in the preset database is determined as the category of the sensitive area.

[0009] The embodiment of the present invention provides an image recognition device, which has the function of implementing the above-mentioned image recognition method. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes:

[0010] A detection module, used to detect the image to be identified by using a sensitive area detection model, and if it is determined that the image to be identified is a sensitive image, obtain the sensitive area of ​​the image to be identified;

[0011] A classification module, used to classify the sensitive area through a classification model to obtain a feature extraction category of the sensitive area;

[0012] A feature extraction module, used for performing feature extraction of the feature extraction category on the sensitive area through a feature extraction model to obtain feature information of the sensitive area;

[0013] The processing module is used to calculate the similarity between the feature information and each feature information in the preset database, and determine the category corresponding to the feature information with the greatest similarity in the preset database as the category of the sensitive area.

[0014] An embodiment of the present invention provides an electronic device, which includes a processor, an input device, an output device and a memory, wherein the processor, input device, output device and memory are interconnected, wherein the memory is used to store a computer program, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute the operations involved in the above-mentioned image recognition method.

[0015] An embodiment of the present invention provides a computer-readable storage medium for storing computer program instructions for use in an electronic device, which includes a program for executing the above-mentioned image recognition method.

[0016] By implementing the embodiments of the present invention, more detailed detection information can be provided for the image to be identified, and the category of sensitive images can be identified, so as to improve the accuracy of the image to be identified and ensure the security of data in social products. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0018] Figure 1 is a schematic diagram of the architecture of an image recognition system provided by an embodiment of the present invention;

[0019] Figure 2 is a network schematic diagram of a flag and banner detection model provided by an embodiment of the present invention;

[0020] Figure 3 is a flowchart of an image recognition method provided by an embodiment of the present invention;

[0021] Figure 4 is a schematic diagram of an image to be recognized provided by an embodiment of the present invention;

[0022] Figure 5 It is a schematic diagram of the architecture of a pornography and vulgarity scoring model provided by an embodiment of the present invention;

[0023] Figure 6 It is a flowchart of a method for obtaining a target evaluation value provided by an embodiment of the present invention;

[0024] Figure 7 is a structural schematic diagram of an image recognition device provided by an embodiment of the present invention;

[0025] Figure 8 It is a structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] With the development of Internet technology, the speed of information dissemination is getting faster and faster. Images, videos and other data are one of the most important components of Internet data. However, while the massive amount of data and information on the Internet brings convenience to people, it also brings many negative effects. The widespread dissemination of some images or videos containing sensitive content on the Internet seriously threatens network security and endangers the network security of Internet users. In order to ensure the health of the network environment, it is necessary to filter out these images containing sensitive content from the massive data and identify the categories of images containing sensitive content.

[0028] Based on this, the embodiment of the present invention proposes an image recognition method, an image recognition device, an electronic device and a storage medium. The image recognition method specifically comprises: detecting the image to be recognized through a sensitive area detection model, and if it is determined that the image to be recognized is a sensitive image, obtaining the sensitive area of ​​the image to be recognized; classifying the sensitive area through a classification model to obtain a feature extraction category of the sensitive area; extracting features of the feature extraction category of the sensitive area through a feature extraction model to obtain feature information of the sensitive area; calculating the similarity between the feature information and each feature information in a preset database, and determining the category corresponding to the feature information with the greatest similarity in the preset database as the category of the sensitive area. Through the image recognition method provided by the embodiment of the present invention, the electronic device can perform sensitive area detection, classification and feature extraction of feature extraction categories on the image to be recognized through the trained sensitive area detection model, classification model and feature extraction model, so as to obtain more detailed detection information and realize the recognition of the category of the sensitive image, so as to improve the accuracy of the recognition of the image to be recognized and ensure the security of the data in the social product.

[0029] See also Figure 1 , Figure 1 FIG. 1 is a schematic diagram of the architecture of an image recognition system provided by an embodiment of the present invention. Figure 1 As shown, the image recognition system mainly includes a sensitive area detection model, a classification model and a feature extraction model.

[0030] In one implementation, the sensitive area detection model is obtained by sensitive area detection model design, sensitive area detection data set preparation and creation, and then model training.

[0031] Specifically, the preparation and creation of sensitive area detection datasets can be carried out through data collection in the following ways: 1) Through web crawlers, such as websites with public images such as Google, Baidu, Yahoo, etc., crawl sensitive image data through various keywords related to vulgarity, pornography, flags, banners, etc.; 2) Use some large image classification datasets for subset analysis and crawling, such as Google's large open source dataset OpenImage, to filter out data related to flags, banners, and pornographic images.

[0032] In one implementation, after sensitive image data is collected through web crawlers or other means, it is then labeled and cleaned, and screened to construct a medium-sized detection data set.

[0033] Specifically, it can be done by iterative data annotation. The specific steps are as follows:

[0034] 1) First, a small amount of image data is annotated in the early stage for training the preliminary sensitive area detection model;

[0035] 2) Then, the unlabeled data is machine-detected and labeled using the trained preliminary sensitive region detection model;

[0036] 3) Manual review and correction of the machine’s annotations are then performed to obtain more annotation data;

[0037] 4) Use more data to continue training a better model;

[0038] 5) Then go back to step 2) to iterate the data labeling and cleaning.

[0039] Through this model, a medium-sized detection dataset can be obtained.

[0040] In one implementation, taking the scene of detecting sensitive flags and banners as an example, the sensitive area detection model can be a flag and banner detection model. The flag and banner detection model in the embodiment of the present application is improved based on the YOLOV3 solution. The specific network architecture diagram is as follows: Figure 2 shown.

[0041] The improvements of the flag detection model in this solution are mainly in the following aspects:

[0042] (1) The multi-category target detection is changed to single-category target detection (i.e., only detecting flags and banners), and the corresponding detection parameters (mainly the number of categories and filters in the detection layer) are modified to a certain extent.

[0043] (2) The original head neural network of YOLOV3 was darknet53. In order to reduce model parameters and speed up model processing, it was changed to a more lightweight head neural network.

[0044] (3) Since the flag and banner detection task is a single-category detection task, and the shapes, colors, and sizes of various annotated flags are very different, there will be a lot of false detections in the training results. In order to solve this false detection problem, a lot of false detection data is added as negative samples for model training, which greatly reduces the false detection situation. The flag and banner detection model finally trained can effectively detect flag and banner targets of various angles, lighting, sizes, occlusions, and slight blurs.

[0045] In one implementation, after obtaining the sensitive area detection model, the sensitive area is intercepted and classified to obtain a sensitive image classification data set. The classification model is obtained by creating and cleaning the sensitive image classification data set, designing a classification model, and training the model.

[0046] Specifically, first, the embodiments of the present invention can intercept sensitive areas in two ways: using a labeled sensitive area detection data set to directly intercept the labeled area; for a large amount of unlabeled data, using a trained sensitive area detection model to detect sensitive areas, and automatically intercept the detected sensitive areas. Then, all the intercepted sensitive data are classified and cleaned according to the category of the sensitive data. For example, if the sensitive data is flag data, the flag data can be divided into the American flag, the Chinese flag, the Japanese flag, the French flag, sensitive flags, etc., a total of dozens of different types of flags. Finally, in order to make the training data set data more balanced, a small number of images can be enhanced through various data enhancement methods, and finally a flag classification data set with dozens of different types of flags and a balanced number of categories is constructed.

[0047] In one implementation, the classification model of this solution adopts the MobilenetV2 solution, and the present invention mainly makes the following modifications and optimizations based on the MobilenetV2 solution:

[0048] (1) The original 1000-category classification task is changed to a multi-category classification task. The dataset created by the present invention contains dozens of different sensitive image types, so the classification task is a classification task of dozens of categories;

[0049] (2) To reduce the processing volume, appropriately reduce the number of channels and network layers in the network layer;

[0050] (3) In order to better distinguish sensitive image features of different categories and cluster sensitive image features of the same category, the softmax loss function in the original classification model is replaced with Arc Faceloss, which has achieved good results in face recognition feature extraction. This makes the extracted fingerprint features have better characteristics of maximizing inter-class differences and minimizing intra-class differences.

[0051] In one implementation, the classification model and feature extraction model designed by the present invention achieve a classification recognition accuracy of more than 99% under a test data set. Finally, the last classification layer of the trained classification model is removed to obtain a feature extraction model.

[0052] It can be understood that the image recognition system described in the embodiment of the present invention is for the purpose of more clearly illustrating the technical solution of the embodiment of the present invention, and does not constitute a limitation on the technical solution provided by the embodiment of the present invention. A person skilled in the art can know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided by the embodiment of the present invention is also applicable to similar technical problems.

[0053] based on Figure 1 For a schematic diagram of the architecture of the image recognition system, see Figure 3 , Figure 3 : is a flowchart of an image recognition method provided by an embodiment of the present invention. The method can be executed by an electronic device, and the electronic device can be a client running a social product or a server. The image recognition method described in this embodiment includes the following steps S310 to S340:

[0054] Step S310: Detect the image to be identified by using a sensitive area detection model. If it is determined that the image to be identified is a sensitive image, obtain the sensitive area of ​​the image to be identified.

[0055] The image to be identified may be an image uploaded or downloaded by a user, or an image uploaded or downloaded involved in a certain business applied for by an enterprise, etc., and the present invention is not limited thereto.

[0056] In one implementation, the method for obtaining the image to be identified can be to directly obtain the image in social products such as Kugou, QQ Music, WeSing, etc., or to obtain video data in social products such as Kugou, QQ Music, WeSing, etc., and the electronic device takes screenshots and analyzes the video data at fixed time intervals to obtain multiple frames of images to be identified.

[0057] In one implementation, before acquiring the image to be identified, the electronic device may verify the user's identity information. Specifically, when the electronic device receives a login request sent by the user, the login request includes a user account and a password, and the electronic device verifies the user account and password in the login request. For example, the user account is the user's ID number, and the electronic device obtains the credibility value of the ID number through the public security authority. If the credibility value is greater than a preset quantity threshold, it triggers the execution of the electronic device to detect the image to be identified through a sensitive area detection model to obtain the sensitive area of ​​the image to be identified. By verifying the user's identity information to obtain the image to be identified, the safety factor of the electronic device in identifying the image to be identified can be improved.

[0058] In one implementation, before the electronic device detects the image to be identified through the sensitive area detection model, first, the electronic device obtains a preset detection model and performs sparse training on the preset detection model to obtain a sparsely trained detection model, wherein the sparsely trained detection model includes at least one parameter and the weights corresponding to each parameter; secondly, the electronic device deletes the parameters whose weights are less than a second preset threshold in the sparsely trained detection model through a pruning algorithm to obtain a pruned detection model; then, the electronic device optimizes and trains the pruned detection model to obtain an optimized detection model; finally, the electronic device tests the optimized detection model, and if the optimized detection model meets the preset test requirements, the optimized detection model is used as the sensitive area detection model.

[0059] In one implementation, the electronic device obtains a position identifier of a sensitive area through a sensitive area detection model, where the position identifier is used to indicate the position of the sensitive area in the image to be identified; the electronic device intercepts the sensitive area according to the position of the sensitive area in the image to be identified to obtain the sensitive area of ​​the image to be identified.

[0060] like Figure 4 As shown, the electronic device obtains the position identification of at least one sensitive area in the image to be identified through the sensitive area detection model, such as the position identification of sensitive area 1, which can be that the position of sensitive area 1 is located in the upper left corner of the image to be identified, and the size is 1 / 12 of the area of ​​the image to be identified; the position identification of sensitive area 2, which can be that the position of sensitive area 2 is located in the upper right corner of the image to be identified, and the size is 1 / 12 of the area of ​​the image to be identified; the position identification of sensitive area 3, which can be that the position of sensitive area 3 is located in the lower left corner of the image to be identified, and the size is 1 / 12 of the area of ​​the image to be identified; the position identification of sensitive area 4, which can be that the position of sensitive area 4 is located in the lower right corner of the image to be identified, and the size is 1 / 12 of the area of ​​the image to be identified.

[0061] For example, the electronic device determines, based on the position identifier, that the sensitive areas in the image to be identified are 1 / 12 of the upper left corner, 1 / 12 of the lower left corner, 1 / 12 of the upper right corner, and 1 / 12 of the lower right corner of the image to be identified. Then, the electronic device performs a capture operation on area 1, area 2, area 3, and area 4. The method for capturing specific areas in the image to be identified includes but is not limited to capturing through Pillow and OpenCV to obtain the sensitive areas of the image to be identified, specifically sensitive area 1, sensitive area 2, sensitive area 3, and sensitive area 4.

[0062] In one implementation, the electronic device classifies the sensitive areas according to preset classification categories to obtain an initial sensitive area detection model (ie, a preset detection model), and the electronic device performs an iterative cleaning operation on the initial sensitive area detection model to obtain a sensitive area detection model.

[0063] In a specific implementation, the electronic device obtains first image data, and annotates the first image data according to a preset classification category to obtain first sensitive annotation data; the electronic device trains an initial sensitive area detection model according to the first sensitive annotation data; the electronic device obtains second image data, and annotates the second image data through the initial sensitive area detection model to obtain second sensitive annotation data; the category of the electronic device is modified through manual review, and the electronic device trains the initial sensitive area detection model according to the first sensitive annotation data and the second sensitive annotation data; the electronic device obtains third image data, and annotates the third image data through the initial sensitive area detection model to obtain third sensitive annotation data; the electronic device obtains a sensitive area detection model through the first sensitive annotation data, the second sensitive annotation data, and the third sensitive annotation data.

[0064] Among them, since the initial sensitive area detection model has the ability to recognize common images of different categories, by manually modifying the category of electronic equipment on the basis of the initial sensitive area detection model and adding the initial sensitive area detection model to learn more image data, the learning speed can be accelerated and the efficiency and accuracy of the sensitive area detection model can be improved.

[0065] In one implementation, before detecting an image to be identified through a sensitive area detection model and obtaining the sensitive area of ​​the image to be identified, the electronic device collects sample data, the sample data including multiple sensitive images and the category of each sensitive image, and the electronic device trains the sample data through a neural network model to obtain a classification model.

[0066] Among them, electronic devices can collect sample data in the following three ways: (1) collect some small amount of labeled data from open source networks; (2) collect a large amount of uncleaned data from foreign public adult websites through web crawlers, where web crawler methods include but are not limited to writing crawlers based on socket communication, writing crawlers based on Http URL Connection class, writing crawlers based on Apache's Http Client package, based on headless (no interface) browsers such as phantomjs, and based on headless (with interface) browsers such as Selenium or Web Driver; (3) other data crawling, mainly for business scenarios, specifically for bars, hotels, KTVs and other entertainment venues such as video surveillance data.

[0067] For example, first, the electronic device collects sample data, which may include pornographic and vulgar data, sensitive flags, etc. Pornographic and vulgar data may specifically include data of categories such as pornographic and vulgar, sexy, and normal, and sensitive flags may specifically include flags or banners such as sensitive flag 1, sensitive flag 2, and sensitive flag 3.

[0068] In order to ensure the data distinction between different categories, the electronic device can define the scope of each category of data in advance. For pornographic and vulgar data, pornographic and vulgar categories may include: direct exposure of sensitive areas (female breasts, genitals, etc.); large areas of skin exposed; strong sexually suggestive pictures; close-ups of various sensitive organs; sexual behavior scenes; full-body photos of men wearing only underwear or vulgar scene photos; others, etc. Sexy categories may include: normal bikini photos; beautiful women wearing cool but not revealing clothes; normal fitness photos; men with only naked upper body; normal intimate photos; others, etc. Normal categories include: all images except the above two categories belong to the normal category.

[0069] Then, for sensitive flags, the electronic equipment classifies and cleans all the captured flag data according to the flag category, such as the American flag, Chinese flag, Japanese flag, French flag, sensitive flag, etc., a total of dozens of different types of flags. Since the amount of data that can be found for different flags is different, in order to make the training sample data more balanced, various data enhancement methods can be used, specifically: multi-scale, translation, rotation, scaling, cropping a relatively small part of the image to be identified, and various input data preprocessing methods. In this way, a small number of images are enhanced, and finally a flag classification sample data with a balanced number of categories of dozens of different types of flags is constructed.

[0070] In one implementation, the sample data may be updated periodically. The specific process is as follows: based on a preset period, a specified number of image data are randomly selected from images recognized by the electronic device, and the images are submitted for manual review to obtain the manually annotated categories of each image data, and the manually annotated categories of each image data are compared with the categories recognized by the electronic device. If the manually annotated categories of each image data are different from the categories recognized by the electronic device, the manually annotated categories are added to the image data corresponding to the categories recognized by the electronic device, and the sample data are updated based on the image data after the manually annotated categories are added.

[0071] Step S320: classifying the sensitive area through a classification model to obtain a feature extraction category of the sensitive area.

[0072] In one implementation, the electronic device classifies the sample data according to preset data categories to obtain an initial classification model, and the electronic device performs an iterative cleaning operation on the initial classification model to obtain a classification model.

[0073] In specific implementation, the electronic device obtains the first sample data, and performs an annotation operation on the first sample data according to the preset data category to obtain the first sample annotation data; the electronic device performs a training operation on the initial classification model according to the first sample annotation data; the electronic device obtains the second sample data, and performs an annotation operation on the second sample data through the initial classification model to obtain the second sample annotation data; the category of the electronic device is modified through manual review, and the initial classification model is trained according to the first sample annotation data and the second sample annotation data; the electronic device obtains the third sample data, and performs an annotation operation on the third sample data through the initial classification model to obtain the third sample annotation data; the electronic device obtains the classification model through the first sample annotation data, the second sample annotation data and the third sample annotation data. In this way, the classification model obtained by the classification training method has the ability to extract the distinguishing deep features of different flag categories.

[0074] For example, the electronic device classifies sensitive area 1, sensitive area 2, sensitive area 3, and sensitive area 4 in the image to be identified through a classification model, and obtains that the feature extraction category of sensitive area 1 is feature extraction category 1, the feature extraction category of sensitive area 2 is feature extraction category 2, the feature extraction category of sensitive area 3 is feature extraction category 3, and the feature extraction category of sensitive area 4 is feature extraction category 4. Specifically, feature extraction category 1 may be the category corresponding to sensitive flag 1, and feature extraction category 2 may be the category corresponding to sensitive flag 2.

[0075] In one implementation, the electronic device classifies the sensitive sub-image through the classification model to obtain the feature extraction category of the sensitive sub-image. For example, the electronic device classifies sensitive sub-image 1 through the classification model to obtain the feature extraction category of sensitive sub-image 1 as feature extraction category 1, the electronic device classifies sensitive sub-image 2 through the classification model to obtain the feature extraction category of sensitive sub-image 2 as feature extraction category 2, the electronic device classifies sensitive sub-image 3 through the classification model to obtain the feature extraction category of sensitive sub-image 3 as feature extraction category 3, and the electronic device classifies sensitive sub-image 4 through the classification model to obtain the feature extraction category of sensitive sub-image 4 as feature extraction category 4.

[0076] Step S330: extracting features of the feature extraction category from the sensitive area using a feature extraction model to obtain feature information of the sensitive area.

[0077] In a specific implementation, after the electronic device determines the feature extraction category corresponding to at least one sensitive area, the electronic device performs feature extraction of the feature extraction category on the sensitive area through a feature extraction model to obtain feature information of the sensitive area. The feature information may include fingerprint features of the sensitive area. For example, the electronic device extracts fingerprint feature 1 of feature extraction category 1 of sensitive area 1 through a feature extraction model, extracts fingerprint feature 2 of feature extraction category 2 of sensitive area 2 through a feature extraction model, extracts fingerprint feature 3 of feature extraction category 3 of sensitive area 3 through a feature extraction model, and so on.

[0078] In one implementation, the feature extraction model includes an attention mechanism module, and the attention mechanism module includes a channel attention submodule and a spatial attention submodule. The electronic device performs pooling and compression processing on the sensitive area through the channel attention submodule to obtain a channel feature vector of the sensitive area; performs pooling processing on the sensitive area through the spatial attention submodule to obtain a two-dimensional feature vector of the sensitive area, and performs convolution operation on the two-dimensional feature vector to obtain a spatial feature vector of the sensitive area; extracts the channel feature vector and the spatial feature vector through the broadcast mechanism to obtain feature information of the sensitive area.

[0079] In one implementation, the channel attention submodule performs average pooling processing on the sensitive area to obtain a first vector of the sensitive area, and performs maximum pooling processing on the sensitive area to obtain a second vector of the sensitive area; the first vector and the second vector are input into a preset shared network for compression processing to obtain a channel feature vector of the sensitive area. The preset network may be composed of a hidden layer and a multilayer perceptron (MLP).

[0080] Step S340: Calculate the similarity between the feature information and each feature information in the preset database, and determine the category corresponding to the feature information with the greatest similarity in the preset database as the category of the sensitive area.

[0081] In one implementation, after calculating the similarity between the feature information and each feature information in the preset database, the electronic device compares the similarity with a first preset threshold, and if the similarity is greater than or equal to the first preset threshold, the electronic device is triggered to determine the category corresponding to the feature information with the greatest similarity in the preset database as the category of the sensitive area. The preset database may contain feature information storing at least one feature extraction category.

[0082] For example, the electronic device calculates through similarity matching that the similarity between the fingerprint feature 1 corresponding to the sensitive area 1 and the preset fingerprint feature 1 in the preset database is 80%, the similarity between the fingerprint feature 2 corresponding to the sensitive area 2 and the preset fingerprint feature 2 in the preset database is 85%, the similarity between the fingerprint feature 3 corresponding to the sensitive area 3 and the preset fingerprint feature 3 in the preset database is 90%, and the similarity between the fingerprint feature 4 corresponding to the sensitive area 4 and the preset fingerprint feature 4 in the preset database is 95%. Assuming that the first preset threshold is 90%, the electronic device determines the category corresponding to the feature information with the greatest similarity between fingerprint feature 3 and fingerprint feature 4 and the preset database as the category of the sensitive area, that is, determines the feature category 4 corresponding to fingerprint feature 4 as the category of the sensitive area. For another example, the electronic device calculates through similarity matching that the similarity between fingerprint feature 1 corresponding to sensitive area 1 and the preset fingerprint feature 1 in the preset database is 50%, the similarity between fingerprint feature 2 corresponding to sensitive area 2 and the preset fingerprint feature 2 in the preset database is 45%, the similarity between fingerprint feature 3 corresponding to sensitive area 3 and the preset fingerprint feature 3 in the preset database is 60%, and the similarity between fingerprint feature 4 corresponding to sensitive area 4 and the preset fingerprint feature 4 in the preset database is 55%. Assuming that the first preset threshold is 90%, because the similarity between each sensitive area and the corresponding preset fingerprint feature in the preset database is less than the first preset threshold, the electronic device judges the sensitive area as a new feature extraction category and updates the new feature extraction category to the preset database.

[0083] It should be noted that the image recognition method provided by the embodiment of the present invention can be specifically applied to the identification scenario of sensitive flags. For example, in the user albums, uploaded avatars, work covers and other images of Kugou and QQ Music, the electronic device automatically identifies the pictures containing specific flags through the sensitive area detection model designed by the embodiment of the present invention, and matches the identified specific flags with the flags in the preset flag database to obtain the flag type similarity information related to the specific flag, and then manually reviews and confirms, and deletes, warns or bans the flags that violate the rules according to the situation. Through the embodiment of the present invention, for the image data uploaded by users in social products such as Kugou and QQ Music, for example, if there are sensitive flags in the image, the machine recognition judgment of the image recognition method provided by this solution determines that there are specific sensitive flags. At this time, the sensitive flags are marked and identified to obtain the sensitive information results of the judgment, which may specifically include the type, similarity, and quantity of sensitive flags, thereby preventing the possibility of the spread of specific sensitive flags and improving the security of data in social products.

[0084] See also Figure 5 , Figure 5 It is a schematic diagram of the architecture of a pornography and vulgarity scoring model provided by an embodiment of the present invention.

[0085] In one implementation, the pornography and vulgarity scoring model is obtained by designing the pornography and vulgarity scoring model, preparing and creating a pornography and vulgarity classification data set, and then training and testing the model.

[0086] Specifically, the pornographic and vulgar classification data set can collect relevant data through the following channels: some small amount of labeled data open source on the Internet; web crawlers, such as foreign public adult websites, which can obtain a large amount of uncleaned data; other data crawling, which is mainly collected for business scenarios.

[0087] In one implementation, for the design of pornography and vulgarity scoring model, the present invention divides pornography and vulgarity data in all sensitive data into three categories: pornography and vulgarity, sexy, and normal. In order to ensure the data distinction between different categories, the scope of each category needs to be defined in advance.

[0088] Pornographic and vulgar content includes: 1) direct exposure of sensitive areas (female breasts, genitals, etc.); 2) large areas of skin exposed; 3) strong sexually suggestive images; 4) close-ups of various sensitive organs; 5) sexual behavior scenes; 6) full-body photos of men wearing only underwear or photos of vulgar scenes; 7) others.

[0089] Sexy: 1) Normal bikini photos; 2) Beautiful women wearing cool but not revealing clothes; 3) Normal fitness photos; 4) Men with only naked upper body; 5) Normal intimate photos; 6) Others, etc.

[0090] Normal: All images other than the above two types are considered normal.

[0091] In one implementation, after collecting pornographic and vulgar image data through web crawlers and other means, the data is labeled and cleaned, and then screened to construct a medium-sized pornographic and vulgar scoring data set.

[0092] Specifically, it can be done by iterative data annotation. The specific steps are as follows:

[0093] 1) First, a small amount of image data is annotated in the early stage for the training of the preliminary pornography scoring model;

[0094] 2) Then, the unlabeled data is machine-detected and labeled using the trained preliminary pornography scoring model;

[0095] 3) Correct the machine’s category through manual review to obtain more labeled data;

[0096] 4) Use more data to continue training a better model;

[0097] 5) Then go back to step 2) to iterate the data labeling and cleaning.

[0098] In this way, a medium-sized pornographic and vulgarity rating classification dataset can be constructed in the fastest and lowest cost.

[0099] In one implementation, the pornographic and vulgar scoring model of this solution mainly develops two models of different complexity, which are improved based on mobilenetV2 and inceptionV3 solutions and can be applied to different scenarios. MobilenetV2 is a lightweight deep neural network with smaller calculation amount and parameter amount, which is more suitable for occasions where calculation cost and processing time need to be considered.

[0100] The improvements of the pornographic and vulgar scoring model of this scheme are mainly in the following aspects:

[0101] 1) Based on the original network, the original 1000-category classification layer is removed and a new classification layer is added, changing the number of classification task categories to 3;

[0102] 2) Add some new modules to the original network, such as the attention module, so that the model can pay more attention to the learning of characteristic content when learning channels and spatial regions during training;

[0103] 3) The pornographic and vulgar scoring model finally trained can achieve a classification accuracy of nearly 99% on 300,000 data, which can accurately identify and score data in most scenarios.

[0104] based on Figure 5 For a schematic diagram of the architecture of the pornography and vulgarity scoring model, see Figure 6 , Figure 6 1 is a flow chart of a method for obtaining a target evaluation value provided by an embodiment of the present invention. The method can be executed by an electronic device. The image recognition method described in this embodiment includes the following steps S610 to S640:

[0105] Step S610: Analyze the image to be identified and obtain a first evaluation value of the image to be identified.

[0106] In one implementation, the electronic device obtains the probability that the category of the image to be identified is each category in the preset categories, and performs a weighted operation on each probability to obtain a first evaluation value.

[0107] Among them, for the pornographic and vulgar recognition and scoring model, the probabilities of three categories will be output, assuming they are P(porn), P(sexy), and P(normal). The calculation formula for obtaining the first evaluation value of the image to be identified is:

[0108] Score = 100*(β porn *P(porn)+β sexy *P(sexy)+0*P(normal))

[0109] It should be noted that Score refers to the first evaluation value, βporn and βsexy are weighting coefficients, and the value of βporn is greater than βsexy. For the normal category, this coefficient is directly set to 0, that is, the normal content probability score is weighted to 0.

[0110] For example, suppose the preset categories are pornographic and vulgar categories, sexy categories, and normal categories. The probability that the electronic device obtains the category of the image to be identified as pornographic and vulgar categories is 80%, the probability that the image to be identified as sexy categories is 20%, and the probability that the image to be identified as normal categories is 0%. The electronic device can define the weights of each category in advance. If the weight corresponding to the pornographic and vulgar category is 90%, the weight corresponding to the sexy category is 10%, and the weight corresponding to the normal category is 0%, then the electronic device obtains a first evaluation value of 74 by weighting the probability of the pornographic and vulgar category, the probability of the sexy category, and the probability of the normal category with the weight corresponding to the pornographic and vulgar category, the weight corresponding to the sexy category, and the weight corresponding to the normal category.

[0111] For example, assuming that the preset categories are sensitive flag category and normal category. The electronic device obtains the category of the image to be identified as sensitive flag category or normal category. The electronic device scores the image to be identified through the sensitive area detection model. If the category of the image to be identified is the sensitive flag category, the first evaluation value is 100. If the category of the image to be identified is the normal category, the first evaluation value is 0.

[0112] Step S620: If the first evaluation value is greater than the first preset threshold, it is determined that the category of the image to be identified is a sensitive image.

[0113] In one implementation, the electronic device compares the first evaluation value with a first preset threshold value. If the first evaluation value is greater than the first preset threshold value, the electronic device determines that the category of the image to be identified is a sensitive image.

[0114] For example, the electronic device may predefine the interval score for each category, such as the interval score for pornographic and vulgar categories is [60, 100], the interval score for sexy categories is [20, 60), and the interval score for normal categories is [0, 20). Assuming that the second preset threshold is 50, the electronic device compares the first evaluation value 74 of the image to be identified with the second preset threshold. If the electronic device determines that the first evaluation value of the image to be identified is greater than the second preset threshold, the electronic device further determines which category the image to be identified belongs to based on the preset interval scores of each category. Since the first evaluation value 74 falls between [60, 100], the electronic device determines that the image to be identified belongs to the pornographic and vulgar category, that is, a sensitive image.

[0115] Step S630: Acquire a sensitive area of ​​the image to be identified, where the sensitive area includes at least one sensitive sub-area.

[0116] In one implementation, the image to be identified includes a human image, and the electronic device determines the skin area in the human image through an image segmentation algorithm; the electronic device calculates the area of ​​the skin area and the position of the skin area in the human image; the electronic device obtains a first evaluation value of the image to be identified based on the area of ​​the skin area and the position of the skin area in the human image. It should be noted that the area of ​​the skin area is the uncovered area of ​​the skin area, that is, the exposed skin area. Among them, the image segmentation algorithm can specifically be a sensitive target segmentation algorithm based on a deep neural network, and the image segmentation algorithm can also be a traditional image segmentation algorithm, such as a GrabCut algorithm, a watershed algorithm, etc., which is not limited in the present invention.

[0117] For example, the electronic device obtains the skin area in the human body image through a deep segmentation algorithm based on a deep neural network model, the electronic device calculates the area of ​​the uncovered skin area, and the electronic device obtains the position of the skin area in the human body image, assuming that it is the chest, buttocks, waist, abdomen, etc. The electronic device determines the first evaluation value of the image to be identified based on the position of the exposed skin area in the human body image and the area of ​​the skin area. Assuming that the position of the exposed skin area in the human body image is the chest, and the exposed area of ​​the chest is greater than the third preset threshold, the electronic device can determine that the image to be identified is a sensitive image. Among them, the third preset threshold can be changed accordingly according to the different positions of the exposed skin area in the human body image. For example, when the position of the exposed skin area in the human body image is the private part, the third threshold is X1, when the position of the exposed skin area in the human body image is the chest, the third threshold can be X2, when the position of the exposed skin area in the human body image is the buttocks, the third threshold can be X3, when the position of the exposed skin area in the human body image is the abdomen, the third threshold can be X4, where X1>X2>X3>X4.

[0118] In one implementation, the electronic device obtains a first evaluation value of 100 for the image to be identified, then the electronic device can determine that the image to be identified is a sensitive flag category image, and then the electronic device can analyze the sensitive area of ​​the image to be identified, and the sensitive area may include at least one sensitive sub-area, such as Figure 4 As shown, the electronic device analyzes at least one sensitive sub-region of the sensitive flag.

[0119] Step S640: Analyze each sensitive sub-region to obtain a second evaluation value of the sensitive region, where the second evaluation value is used to indicate the sensitivity of the sensitive region.

[0120] In one implementation, an electronic device acquires a sensitive sub-region in an image to be identified by detecting the number, position, size, confidence and other information of the sensitive sub-region in the image to be identified through a target detection model based on a deep neural network model, and then the electronic device analyzes each sensitive sub-region to obtain a third evaluation value of each sensitive sub-region; the electronic device performs a weighted operation on each third evaluation value to obtain a second evaluation value. The second evaluation value is used to indicate the sensitivity of the sensitive region.

[0121] The calculation formula for obtaining the second evaluation value of the sensitive area is:

[0122]

[0123] It should be noted that Score detect Refers to the second evaluation value of the sensitive area, β 女胸refers to the weight corresponding to female breasts, β 男胸 refers to the weight corresponding to male breasts, β 女生殖 refers to the weight corresponding to the female genitalia, β 男生殖 refers to the weight corresponding to the male genitals, β 臀部 Refers to the weight corresponding to the female buttocks or male buttocks. In addition, the weights of female breasts, female genitals and male genitals are the highest, the weight of buttocks is the second, and the weight of male breasts is the lowest.

[0124] For example, if Figure 4 As shown, first, the electronic device analyzes sensitive sub-area 1, sensitive sub-area 2, sensitive sub-area 3, and sensitive sub-area 4, and obtains third evaluation values ​​Y1, Y2, Y3, and Y4 corresponding to sensitive sub-area 1, sensitive sub-area 2, sensitive sub-area 3, and sensitive sub-area 4, respectively; then, the electronic device performs weighted operation on each third evaluation value and the weight corresponding to each sensitive sub-area, specifically, the electronic device performs weighted operation on the weight corresponding to Y1 and sensitive sub-area 1, the weight corresponding to Y2 and sensitive sub-area 2, the weight corresponding to Y3 and sensitive sub-area 3, and the weight corresponding to Y4 and sensitive sub-area 4, to obtain a second evaluation value. Among them, the weight of female breast is β1, the weight of female genitals is β2, the weight of male genitals is β3, the weight of buttocks is β4, and the weight of male breast is β5. It should be noted that β1>β2>β3>β4>β5 or β1=β2=β3>β4>β5 or β1>β2=β3>β4>β5 or β1=β2>β3>β4>β5.

[0125] For example, if Figure 4 As shown, first, the electronic device performs similarity matching calculations on sensitive sub-region 1, sensitive sub-region 2, sensitive sub-region 3, and sensitive sub-region 4 with the sensitive flags in the preset database, and obtains the similarities corresponding to sensitive sub-region 1, sensitive sub-region 2, sensitive sub-region 3, and sensitive sub-region 4, respectively, a1, a2, a3, and a4, wherein a1 may refer to the similarity between sensitive region 1 and sensitive flag 1, a2 may refer to the similarity between sensitive region 2 and sensitive flag 2, a3 may refer to the similarity between sensitive region 3 and sensitive flag 3, and a4 may refer to the similarity between sensitive region 4 and sensitive flag 4, wherein the electronic device may define the weights of sensitive flag 1, sensitive flag 2, sensitive flag 3, and sensitive flag 4 in advance, assuming that they are 30%, 30%, 30%, and 10%, respectively. Then, the electronic device performs weighted calculations on the similarities a1, a2, a3, and a4 to obtain a second evaluation value.

[0126] Step S650: Obtain a target evaluation value of the image to be identified based on the first evaluation value and the second evaluation value, where the target evaluation value is used to indicate the sensitivity of the image to be identified.

[0127] In one implementation, the electronic device performs a weighted operation on the first evaluation value and the second evaluation value to obtain a target evaluation value of the image to be identified, wherein the first evaluation value is used to determine whether the image to be identified is a sensitive image, the second evaluation value is used to determine the sensitivity of the sensitive area, and the target evaluation value is used to determine the sensitivity of the image to be identified.

[0128] The calculation formula of the target evaluation value is:

[0129] Score total =β1*Score+β2*Score detect

[0130] It should be noted that Score total It refers to the target evaluation value, and β1 and β2 refer to the weighting coefficients.

[0131] In one implementation, after the electronic device obtains a target evaluation value of the image to be identified based on the first evaluation value and the second evaluation value, it obtains image attribute information of the image to be identified; the electronic device determines a first image category set corresponding to the evaluation value interval to which the target evaluation value belongs, and a second image category set corresponding to the image attribute information; the electronic device takes the image category that exists in both the first image category set and the second image category set as the category of the image to be identified, and obtains label information of the image to be identified, and the label information includes image attribute information corresponding to the category of the image to be identified.

[0132] For example, assuming that the target evaluation value of the image to be identified is 90, and the sensitive area contained in the image to be identified is a female breast, the label information of the image to be identified is marked as: 90 points, female breast.

[0133] In one implementation, the background reviewer can screen the images to be identified based on the condition that the target evaluation value is greater than or equal to 90 points and there are sensitive areas of the genitals or female chest areas, obtain high-risk images, and then warn or block the accounts corresponding to the high-risk images. For another example, the user can screen based on the target evaluation value being greater than or equal to 90 points and the similarity with sensitive flags in the preset database being greater than or equal to 90%, and delete, warn or block the flags that violate the rules according to the situation. In this way, sensitive images can be processed more specifically, improving the security of data in social products.

[0134] In one implementation, the electronic device can set screening conditions and automatically process the images that meet the screening conditions in the to-be-recognized images. The specific screening conditions can be: in bars, hotels and other entertainment venues, the target evaluation value is greater than or equal to 95 points, and there are sensitive genital areas or female chest areas. For the to-be-recognized images that meet the screening conditions, there is no need to submit them to manual review. The electronic device can obtain the account of the image that meets the screening conditions and automatically block the account. In this way, sensitive images in specific scenes can be automatically processed, which improves the efficiency of reviewing data in social products.

[0135] In one implementation, after the electronic device obtains the tag information of the image to be identified, it receives an image acquisition request, which includes an image identifier and user identity information; the electronic device obtains the tag information of the image corresponding to the image identifier; if the user identity information and the tag information match, the image corresponding to the image identifier is output.

[0136] For example, if the image to be identified is a human body image, the background reviewer receives the image acquisition request sent by the user, and the background reviewer determines that the sensitive area contained in the image to be identified is a female chest based on the label information of the image to be identified. The background reviewer obtains the user's gender, and if the user's gender is female, the image to be identified can be output. In this way, the opposite sex can be prohibited from viewing sensitive images, maintaining a good network atmosphere on social networks.

[0137] It should be noted that the image recognition method provided by the embodiment of the present invention can be specifically applied to the recognition scenario of pornographic and vulgar images. For example, a user uploads an image or video on a social product such as Kugou, QQ Music or WeSing, where a fixed interval screenshot analysis is generally used for the video, and the electronic device recognizes and analyzes the image data uploaded by the user through a pornographic and vulgar scoring model. First, the electronic device scores the image for pornography and vulgarity, and obtains a basic pornographic and vulgar score, a sexy score and a normal score. The electronic device initially performs a weighted calculation on the score. If the score is low, it can be directly judged as a normal image. If the score is greater than the threshold, the image is further subjected to sensitive area detection and analysis. The five main sensitive areas, namely, the number, position, size and confidence of male exposed chest, female exposed chest, exposed buttocks, male genitals, and female genitals, are analyzed by the sensitive area detection model, and the analysis results and the scoring results are subjected to secondary weighted calculation and result marking.

[0138] Then, image data with problematic scores can be sent to manual review and disposal. Manual review can be conducted based on scores, sensitive area types, quantities and other information to quickly process the most dangerous content and improve disposal efficiency. It should be noted that in some high-risk scenarios, such as bars, KTVs and other occasions, image data with high scores and highly sensitive areas, such as exposed breasts of women, male and female genitals, etc., can be automatically processed according to specific scenarios. For example, operations such as automatic deletion of data, automatic push of warnings, and automatic restriction of user behavior can be selected. The image recognition method provided by the embodiment of the present invention can provide more detailed scoring information for sensitive images, ensure an extremely low probability of mishandling, and improve the timeliness and diversity of disposal methods.

[0139] See also Figure 7 , Figure 7 is a schematic diagram of the structure of an image recognition device provided by an embodiment of the present invention. The image recognition device is used to perform Figure 3 to Figure 6 In the steps performed by the electronic device in the corresponding method embodiment, the image recognition device may include:

[0140] The detection module 710 is used to detect the image to be identified by using a sensitive area detection model, and if it is determined that the image to be identified is a sensitive image, obtain the sensitive area of ​​the image to be identified;

[0141] A classification module 720, configured to classify the sensitive area through a classification model to obtain a feature extraction category of the sensitive area;

[0142] A feature extraction module 730, configured to extract features of the feature extraction category from the sensitive area through a feature extraction model to obtain feature information of the sensitive area;

[0143] The processing module 740 is used to calculate the similarity between the feature information and each feature information in the preset database, and determine the category corresponding to the feature information with the greatest similarity in the preset database as the category of the sensitive area.

[0144] In one implementation, the image recognition device provided by the embodiment of the present invention may further include: an analysis module 750 , an acquisition module 760 , and a determination module 770 .

[0145] The analysis module 750 is used to analyze the image to be identified;

[0146] The acquisition module 760 is used to acquire the first evaluation value of the image to be identified;

[0147] A determination module 770, configured to determine that the category of the image to be identified is a sensitive image if the first evaluation value is greater than a first preset threshold;

[0148] The acquisition module 760 acquires a sensitive area of ​​the image to be identified, where the sensitive area includes at least one sensitive sub-area;

[0149] The analysis module 750 analyzes each of the sensitive sub-regions to obtain a second evaluation value of the sensitive region, where the second evaluation value is used to indicate the sensitivity of the sensitive region;

[0150] The processing module 740 obtains a target evaluation value of the image to be identified according to the first evaluation value and the second evaluation value, where the target evaluation value is used to indicate the sensitivity of the image to be identified.

[0151] In one implementation, after the processing module 740 obtains the target evaluation value of the image to be identified according to the first evaluation value and the second evaluation value, it further includes:

[0152] The acquisition module 760 acquires the image attribute information of the image to be identified;

[0153] The determination module 770 determines a first image category set corresponding to the evaluation value interval to which the target evaluation value belongs, and a second image category set corresponding to the image attribute information;

[0154] The processing module 740 takes the image category that exists in both the first image category set and the second image category set as the category of the image to be identified, and obtains label information of the image to be identified, wherein the label information includes image attribute information corresponding to the category of the image to be identified.

[0155] In one implementation, the image recognition device provided by the embodiment of the present invention may further include: a receiving module 780 .

[0156] The receiving module 780 is used to receive an image acquisition request after the processing module 740 obtains the tag information of the image to be identified, and the image acquisition request includes an image identifier and user identity information.

[0157] The acquisition module 760 acquires label information of the image corresponding to the image identifier;

[0158] If the user identity information matches the tag information, the processing module 740 outputs the image corresponding to the image identifier.

[0159] In one implementation, the analyzing module 750 analyzes the image to be identified, and the acquiring module 760 acquires the first evaluation value of the image to be identified, including:

[0160] Obtaining the probability that the category of the image to be identified is each category in the preset categories;

[0161] The first evaluation value is obtained by performing a weighted operation on each of the probabilities.

[0162] In one implementation, the image to be identified includes a human body image, the analysis module 750 analyzes the image to be identified, and the acquisition module 760 acquires a first evaluation value of the image to be identified, including:

[0163] The analysis module 750 determines the skin area in the human body image by using an image segmentation algorithm;

[0164] The analysis module 750 calculates the area of ​​the skin region and the position of the skin region in the human body image;

[0165] According to the area of ​​the skin region and the position of the skin region in the human body image, the acquisition module 760 acquires a first evaluation value of the image to be recognized.

[0166] In one implementation, the analysis module 750 analyzes each of the sensitive sub-regions to obtain a second evaluation value of the sensitive region, including:

[0167] Analyze each of the sensitive sub-regions to obtain a third evaluation value of each of the sensitive sub-regions;

[0168] A weighted operation is performed on each of the third evaluation values ​​to obtain the second evaluation value.

[0169] In one implementation, the acquisition module 760 acquires the sensitive area of ​​the image to be identified, including:

[0170] Acquire a position identifier of the sensitive area through the sensitive area detection model, where the position identifier is used to indicate a position of the sensitive area in the image to be identified;

[0171] According to the position of the sensitive area in the image to be identified, the sensitive area is intercepted to obtain the sensitive area of ​​the image to be identified.

[0172] In one implementation, the feature extraction model includes an attention mechanism module, and the attention mechanism module includes a channel attention submodule and a spatial attention submodule. The feature extraction module 730 performs feature extraction of the feature extraction category on the sensitive area through the feature extraction model to obtain feature information of the sensitive area, including:

[0173] Performing pooling and compression processing on the sensitive area through the channel attention submodule to obtain a channel feature vector of the sensitive area;

[0174] Performing pooling processing on the sensitive area through the spatial attention submodule to obtain a two-dimensional feature vector of the sensitive area, and performing a convolution operation on the two-dimensional feature vector to obtain a spatial feature vector of the sensitive area;

[0175] The channel feature vector and the space feature vector are extracted through a broadcast mechanism to obtain feature information of the sensitive area.

[0176] In one implementation, before the detection module 710 detects the image to be identified by using the sensitive area detection model, it also includes:

[0177] The acquisition module 760 acquires a preset detection model, and performs sparse training on the preset detection model to obtain a sparsely trained detection model, wherein the sparsely trained detection model includes at least one parameter and a weight corresponding to each parameter;

[0178] The processing module 740 deletes the parameters whose weights are less than the second preset threshold in the detection model after the sparse training through a pruning algorithm to obtain a pruned detection model;

[0179] The processing module 740 performs optimization training on the pruned detection model to obtain an optimized detection model;

[0180] The processing module 740 tests the optimized detection model. If the optimized detection model meets the preset test requirements, the optimized detection model is used as the sensitive area detection model.

[0181] See also Figure 8 , Figure 8 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, the electronic device is used to perform Figure 3 to Figure 6 The steps performed by the electronic device in the corresponding method embodiment include: one or more processors 810; one or more input devices 820, one or more output devices 830 and a memory 840. The processor 810, the input device 820, the output device 830 and the memory 840 are connected via a bus 850. The memory 820 is used to store a computer program, and the computer program includes program instructions. The processor 810 is used to execute the program instructions stored in the memory 840 to perform the following operations:

[0182] The image to be identified is detected by using a sensitive area detection model, and if it is determined that the image to be identified is a sensitive image, the sensitive area of ​​the image to be identified is obtained;

[0183] Classifying the sensitive area through a classification model to obtain a feature extraction category of the sensitive area;

[0184] Performing feature extraction of the feature extraction category on the sensitive area through a feature extraction model to obtain feature information of the sensitive area;

[0185] The similarity between the feature information and each piece of feature information in a preset database is calculated, and the category corresponding to the feature information with the greatest similarity in the preset database is determined as the category of the sensitive area.

[0186] In one implementation, the processor 810 is further configured to:

[0187] Analyzing the image to be identified to obtain a first evaluation value of the image to be identified;

[0188] If the first evaluation value is greater than a first preset threshold, determining that the category of the image to be identified is a sensitive image;

[0189] Acquire a sensitive area of ​​the image to be identified, wherein the sensitive area includes at least one sensitive sub-area;

[0190] Analyze each of the sensitive sub-regions to obtain a second evaluation value of the sensitive region;

[0191] A target evaluation value of the image to be recognized is obtained according to the first evaluation value and the second evaluation value.

[0192] In one implementation, after the processor 810 obtains the target evaluation value of the image to be recognized according to the first evaluation value and the second evaluation value, the processor 810 further includes:

[0193] Acquire image attribute information of the image to be identified;

[0194] Determine a first image category set corresponding to the evaluation value interval to which the target evaluation value belongs, and a second image category set corresponding to the image attribute information;

[0195] An image category that exists in both the first image category set and the second image category set is used as the category of the image to be identified, and label information of the image to be identified is obtained, where the label information includes image attribute information corresponding to the category of the image to be identified.

[0196] In one implementation, after the processor 810 obtains the label information of the image to be identified, the processor 810 further includes:

[0197] receiving an image acquisition request, wherein the image acquisition request includes an image identifier and user identity information;

[0198] Obtaining label information of the image corresponding to the image identifier;

[0199] If the user identity information matches the tag information, the image corresponding to the image identifier is output.

[0200] In one implementation, the processor 810 analyzes the image to be identified to obtain a first evaluation value of the image to be identified, including:

[0201] Obtaining the probability that the category of the image to be identified is each category in the preset categories;

[0202] The first evaluation value is obtained by performing a weighted operation on each of the probabilities.

[0203] In one implementation, the image to be recognized includes a human body image, and the processor 810 analyzes the image to be recognized to obtain a first evaluation value of the image to be recognized, including:

[0204] Determine the skin area in the human body image by using an image segmentation algorithm;

[0205] Calculating the area of ​​the skin region and the position of the skin region in the human body image;

[0206] A first evaluation value of the image to be recognized is obtained according to the area of ​​the skin region and the position of the skin region in the human body image.

[0207] In one implementation, the processor 810 analyzes each of the sensitive sub-regions to obtain a second evaluation value of the sensitive region, including:

[0208] Analyze each of the sensitive sub-regions to obtain a third evaluation value of each of the sensitive sub-regions;

[0209] A weighted operation is performed on each of the third evaluation values ​​to obtain the second evaluation value.

[0210] In one implementation, the processor 810 obtains the sensitive area of ​​the image to be identified, including:

[0211] Acquire a position identifier of the sensitive area through the sensitive area detection model, where the position identifier is used to indicate a position of the sensitive area in the image to be identified;

[0212] According to the position of the sensitive area in the image to be identified, the sensitive area is intercepted to obtain the sensitive area of ​​the image to be identified.

[0213] In one implementation, the feature extraction model includes an attention mechanism module, the attention mechanism module includes a channel attention submodule and a spatial attention submodule, and the processor 810 performs feature extraction of the feature extraction category on the sensitive area through the feature extraction model to obtain feature information of the sensitive area, including:

[0214] Performing pooling and compression processing on the sensitive area through the channel attention submodule to obtain a channel feature vector of the sensitive area;

[0215] Performing pooling processing on the sensitive area through the spatial attention submodule to obtain a two-dimensional feature vector of the sensitive area, and performing a convolution operation on the two-dimensional feature vector to obtain a spatial feature vector of the sensitive area;

[0216] The channel feature vector and the space feature vector are extracted through a broadcast mechanism to obtain feature information of the sensitive area.

[0217] In one implementation, before the processor 810 detects the image to be identified by using the sensitive area detection model, the process further includes:

[0218] Obtain a preset detection model, and perform sparse training on the preset detection model to obtain a sparsely trained detection model, wherein the sparsely trained detection model includes at least one parameter and a weight corresponding to each parameter;

[0219] Deleting parameters whose weights are less than a second preset threshold in the detection model after the sparse training by a pruning algorithm to obtain a pruned detection model;

[0220] Performing optimization training on the pruned detection model to obtain an optimized detection model;

[0221] The optimized detection model is tested, and if the optimized detection model meets the preset test requirements, the optimized detection model is used as the sensitive area detection model.

[0222] A computer-readable storage medium is also provided in an embodiment of the present invention. The computer-readable storage medium stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the steps performed by the electronic device in the above embodiment can be executed.

[0223] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0224] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiments and equivalent changes made according to the claims of the present invention are still within the scope of the invention.

Claims

1. An image recognition method, It is characterized in that The method comprises: Detecting the image to be identified by using a sensitive area detection model to analyze the image to be identified, and obtaining a first evaluation value of the image to be identified. If the first evaluation value is greater than a first preset threshold, determining that the category of the image to be identified is a sensitive image; Acquire a sensitive area of ​​the image to be identified, wherein the sensitive area includes at least one sensitive sub-area; Analyze each of the sensitive sub-regions to obtain a second evaluation value of the sensitive region, where the second evaluation value is used to indicate the sensitivity of the sensitive region; Obtaining a target evaluation value of the image to be identified according to the first evaluation value and the second evaluation value, wherein the target evaluation value is used to indicate a sensitivity of the image to be identified; Classifying the sensitive area through a classification model to obtain a feature extraction category of the sensitive area; Performing feature extraction of the feature extraction category on the sensitive area through a feature extraction model to obtain feature information of the sensitive area; The similarity between the feature information and each piece of feature information in a preset database is calculated, and the category corresponding to the feature information with the greatest similarity in the preset database is determined as the category of the sensitive area.

2. The method according to claim 1, It is characterized in that After obtaining the target evaluation value of the image to be identified according to the first evaluation value and the second evaluation value, the method further includes: Acquire image attribute information of the image to be identified; Determine a first image category set corresponding to the evaluation value interval to which the target evaluation value belongs, and a second image category set corresponding to the image attribute information; An image category that exists in both the first image category set and the second image category set is used as the category of the image to be identified, and label information of the image to be identified is obtained, where the label information includes image attribute information corresponding to the category of the image to be identified.

3. The method according to claim 2, It is characterized in that After obtaining the label information of the image to be identified, the method further includes: receiving an image acquisition request, wherein the image acquisition request includes an image identifier and user identity information; Obtaining label information of the image corresponding to the image identifier; If the user identity information matches the tag information, the image corresponding to the image identifier is output.

4. The method according to claim 1, It is characterized in that The step of analyzing the image to be identified to obtain a first evaluation value of the image to be identified includes: Obtaining the probability that the category of the image to be identified is each category in the preset categories; The first evaluation value is obtained by performing a weighted operation on each of the probabilities.

5. The method according to claim 1, It is characterized in that The image to be identified includes a human body image; The step of analyzing the image to be identified to obtain a first evaluation value of the image to be identified includes: Determine the skin area in the human body image by using an image segmentation algorithm; Calculating the area of ​​the skin region and the position of the skin region in the human body image; A first evaluation value of the image to be recognized is obtained according to the area of ​​the skin region and the position of the skin region in the human body image.

6. The method according to claim 1, It is characterized in that The step of analyzing each of the sensitive sub-regions to obtain a second evaluation value of the sensitive region includes: Analyze each of the sensitive sub-regions to obtain a third evaluation value of each of the sensitive sub-regions; A weighted operation is performed on each of the third evaluation values ​​to obtain the second evaluation value.

7. The method according to claim 1, It is characterized in that The step of obtaining the sensitive area of ​​the image to be identified includes: Acquire a position identifier of the sensitive area through the sensitive area detection model, where the position identifier is used to indicate a position of the sensitive area in the image to be identified; According to the position of the sensitive area in the image to be identified, the sensitive area is intercepted to obtain the sensitive area of ​​the image to be identified.

8. The method according to claim 1, It is characterized in that The feature extraction model includes an attention mechanism module, and the attention mechanism module includes a channel attention submodule and a spatial attention submodule; The extracting the features of the feature extraction category from the sensitive area by using the feature extraction model to obtain feature information of the sensitive area includes: Performing pooling and compression processing on the sensitive area through the channel attention submodule to obtain a channel feature vector of the sensitive area; Performing pooling processing on the sensitive area through the spatial attention submodule to obtain a two-dimensional feature vector of the sensitive area, and performing a convolution operation on the two-dimensional feature vector to obtain a spatial feature vector of the sensitive area; The channel feature vector and the space feature vector are extracted through a broadcast mechanism to obtain feature information of the sensitive area.

9. The method according to claim 1, It is characterized in that Before detecting the image to be identified by the sensitive area detection model, the method further includes: Obtain a preset detection model, and perform sparse training on the preset detection model to obtain a sparsely trained detection model, wherein the sparsely trained detection model includes at least one parameter and a weight corresponding to each parameter; Deleting parameters whose weights are less than a second preset threshold in the detection model after the sparse training by a pruning algorithm to obtain a pruned detection model; Performing optimization training on the pruned detection model to obtain an optimized detection model; The optimized detection model is tested, and if the optimized detection model meets the preset test requirements, the optimized detection model is used as the sensitive area detection model.

10. An electronic device, It is characterized in that include: Memory and processor; One or more computer programs are stored in the memory; A processor, used to load the one or more computer programs to implement the image recognition method as described in any one of claims 1 to 9.

11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image recognition method according to any one of claims 1 to 9 is executed.

Citation Information

Patent Citations

  • Violation picture identification method and device

    CN111178410A

  • Picture book identification method, terminal equipment and computer readable storage medium

    CN111191067A