AI image recognition method and device, electronic equipment and medium
By extracting and fusing the global and local features of the image, and using deep learning models to identify AI images, the problem of low accuracy in AI image recognition in the prior art is solved, and higher recognition accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411351495.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-31
AI Technical Summary
The existing image recognition technology has low accuracy when recognizing AI images, making it difficult to effectively distinguish between images generated by AI models and ordinary images captured.
By extracting the global and local features of the image and fusing them, using pre-trained deep learning models and local self-similarity processing, we predict whether the image is an AI image.
It improves the accuracy of AI image recognition, can effectively distinguish AI images from ordinary images, and is suitable for media review, content creation and information security.
Smart Images

Figure CN119229201A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image recognition technology, and in particular to an AI image recognition method, device, electronic device and medium. Background Art
[0002] With the rapid development of artificial intelligence technology, AI (Artificial Intelligence) models such as Generative Adversarial Networks (GAN) have been widely used in the field of image generation. These technologies can generate highly realistic images and are widely used in industries such as entertainment, advertising, and design. However, the images generated by AI models may be maliciously used to create false information and have a negative social impact. Therefore, it has become crucial to identify AI images.
[0003] Most existing image recognition technologies focus on identifying objects and scenes in ordinary captured images. When the object and scene recognition method of the captured images is used to identify whether the image is generated by the AI model, the accuracy is relatively low. Summary of the invention
[0004] The present invention provides an AI image recognition method, device, electronic device and medium, which identify whether an image to be recognized is an AI image by fusing global features and local features, thereby improving the recognition accuracy.
[0005] In a first aspect, an embodiment of the present invention provides an AI image recognition method, comprising:
[0006] Extracting global features from the image to be identified by a feature extractor;
[0007] Dividing the image to be identified into a plurality of image blocks, performing local self-similarity processing on each of the image blocks to obtain a similarity matrix, and performing feature extraction on the similarity matrix to obtain local features;
[0008] The image to be identified is identified according to the global features and the local features, and it is predicted whether the image to be identified is an AI image.
[0009] The above method can extract the global features of the image through a feature extractor, and divide the image into multiple image blocks, obtain local features by determining the local self-similarity of the image blocks themselves, and fuse the global features and local features to identify whether the image to be identified is an AI image. Since the local similarity of AI images is higher than that of ordinary images, global features are added to local features when identifying AI images, which improves the recognition accuracy.
[0010] In one possible implementation, the feature extractor is a pre-trained deep learning model.
[0011] In one possible implementation, the feature extractor is a deep learning model established using a small convolution kernel and / or a deep learning model established using a residual structure.
[0012] In a possible implementation, identifying the image to be identified according to the global features and the local features, and predicting whether the image to be identified is an AI image, includes:
[0013] weighting the global feature using a first weight, and weighting the local feature using a second weight;
[0014] Combining the weighted global features and the weighted local features into a fusion matrix;
[0015] The fusion matrix is input into the classification model, and outputs whether the image to be identified is an AI image.
[0016] In a possible implementation, the step of forming a fusion matrix from the weighted global features and the weighted local features includes:
[0017] taking the sum of the weighted global features and the weighted local features as a fusion matrix; or
[0018] The weighted local features are concatenated after the weighted global features to form a fusion matrix.
[0019] In one possible implementation, the method further includes:
[0020] The classification model is trained multiple times using a training set; wherein the training set includes multiple fusion matrices used for training and information on whether an image corresponding to the fusion matrix used for marking training is an AI image;
[0021] For each training, the fusion matrix in the training set is input into the classification model, and the predicted classification corresponding to the fusion matrix in the training set is output;
[0022] The classification model is adjusted according to the predicted classification corresponding to the fusion matrix in the training set and the labeling information of the fusion matrix in the training set.
[0023] In a possible implementation, after identifying the image to be identified according to the global features and the local features and predicting whether the image to be identified is an AI image, the method further includes:
[0024] Determining an actual classification result of the image to be identified;
[0025] If the actual classification result of the image to be identified is different from the predicted result, adjusting the first weight and the second weight according to the prediction strategy; wherein the prediction strategy includes a first strategy and a second strategy; the first strategy and the second strategy have different adjustment directions for the first weight and the second weight, and the first strategy and the second strategy have the same adjustment step length for the first weight and the second weight;
[0026] Re-predicting the image to be identified using the first weight and the second weight adjusted by the first strategy to obtain a first result, and re-predicting the image to be identified using the first weight and the second weight adjusted by the second strategy to obtain a second result;
[0027] If the first result is the same as the actual classification result of the image to be identified, continue prediction according to the first weight and the second weight adjusted by the first strategy;
[0028] If the second result is the same as the actual classification result of the image to be identified, the prediction is continued according to the first weight and the second weight adjusted by the second strategy.
[0029] In a second aspect, an embodiment of the present invention provides an AI image recognition method and device, including:
[0030] A first extraction module, used for extracting global features from the image to be identified by a feature extractor;
[0031] A second extraction module is used to divide the image to be identified into a plurality of image blocks, perform local self-similarity processing on each of the image blocks to obtain a similarity matrix, and perform feature extraction on the similarity matrix to obtain local features;
[0032] A prediction module is used to identify the image to be identified based on the global features and the local features, and predict whether the image to be identified is an AI image.
[0033] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0034] processor;
[0035] A processor is used to execute the computer program or instructions in the memory so that the AI image recognition method as described in any one of the first aspects is executed.
[0036] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor, the processor is enabled to execute the AI image recognition method as described in any one of the first aspects.
[0037] In a fifth aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the AI image recognition method as described in any one of the first aspects.
[0038] In addition, the technical effects brought about by any implementation method in the second to fifth aspects can refer to the technical effects brought about by different implementation methods in the first aspect, and will not be repeated here.
[0039] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A flowchart of an AI image recognition method provided by an embodiment of the present invention;
[0041] Figure 2 A schematic diagram of a terminal verification image provided by an embodiment of the present invention;
[0042] Figure 3 A schematic diagram of dividing an image block from an image to be recognized provided by an embodiment of the present invention;
[0043] Figure 4 A flowchart of a method for predicting whether an image is an AI image by using two global features provided by an embodiment of the present invention;
[0044] Figure 5 A flowchart of a method for identifying whether an image is an AI image using multiple features provided by an embodiment of the present invention;
[0045] Figure 6 A flowchart of a method for adjusting a first weight and a second weight provided by an embodiment of the present invention;
[0046] Figure 7 A schematic diagram of the structure of an AI image recognition device provided by an embodiment of the present invention;
[0047] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all 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.
[0049] In the description of the embodiments of the present application, unless otherwise specified, in the description of the embodiments of the present application, "plurality" refers to two or more than two.
[0050] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0051] At present, AI models are widely used in the field of image generation. The images generated by AI models may be maliciously used to create false information and have a negative social impact. Therefore, it is necessary to distinguish between AI images and ordinary images.
[0052] Based on this, the embodiments of the present invention provide an AI image recognition method, device, electronic device and medium for solving the problem of whether an image is an AI image or a captured ordinary image.
[0053] The present invention is described in detail below with reference to the accompanying drawings:
[0054] Combination Figure 1 As shown, an embodiment of the present invention provides an AI image recognition method, including:
[0055] S100: extracting global features from the image to be identified by a feature extractor;
[0056] The image to be identified can be directly obtained from the Internet or sent from other devices.
[0057] S101: Divide the image to be identified into multiple image blocks, perform local self-similarity processing on each image block to obtain a similarity matrix, perform feature extraction on the similarity matrix to obtain local features;
[0058] In detail, the image to be identified can be converted into a grayscale image, and then the grayscale image can be divided into multiple image blocks. The image similarity algorithm is used to perform local self-similarity processing on each image block to obtain a similarity matrix, and features are extracted from the similarity matrix to obtain local features.
[0059] S102: Identify the image to be identified based on the global features and the local features, and predict whether the image to be identified is an AI image.
[0060] right Figure 1 The recognition method mainly uses the following differences between AI images and ordinary images: AI images generally have smaller local color changes and higher local similarities, while ordinary images are natural pictures, so both local and global color changes are relatively large, and local similarities are relatively low.
[0061] The embodiment of the present invention extracts the global features of an image through a feature extractor, divides the image into multiple image blocks, obtains local features by determining the local self-similarity of the image blocks themselves, and fuses the global features and local features to identify whether the image to be identified is an AI image. In this way, the local features that are integrated with the characteristics of the AI image are identified, thereby improving the recognition accuracy.
[0062] For example, users can identify whether the pictures stored in their terminals are AI images. Figure 2 As shown, the user clicks on the program icon, and the terminal responds to the program icon clicked by the user. The terminal displays the recognition interface, which includes a picture adding area P1 and a confirmation button P2. The user clicks on the picture adding area P1, and the terminal receives the user's click on the picture adding area P1 and jumps to the photo application. After the user selects the complete photo, the photo is the image to be identified. The user clicks on the confirmation button P2. After the terminal receives the user's click on the button P2, the terminal can execute the solution of the embodiment of the present invention by itself to predict whether the image to be identified is an AI image. The terminal can also upload the image to be identified to other devices, and the other devices execute the solution provided by the embodiment of the present invention to predict whether the image to be identified is an AI image. Finally, the prediction result is displayed to the user. For example, if the prediction result is that the image to be identified is an AI image, then text and pictures can be displayed directly, just like Figure 2 As shown, the upper part of the display page is the image to be identified, and the lower part of the display page is the prediction result, which is verified to be an AI image. Similarly, when the image to be identified is predicted not to be an AI image, the lower part of the display page is: Verified not to be an AI image.
[0063] Alternatively, the embodiment of the present invention can also be used for big data recognition, that is, the database includes a large number of images, and these large number of images are predicted to determine whether the above-mentioned large number of images are AI images, so as to display them.
[0064] Of course, the scenarios of the embodiments of the present invention are not limited to the above examples.
[0065] In some embodiments, the method of dividing the image to be recognized into multiple image blocks is implemented by a sliding window.
[0066] Sliding window is an efficient data processing technology, which is mainly used to deal with array and string related problems. It reduces the time complexity of the algorithm by reducing the nesting depth of the loop.
[0067] In actual processing, the RGB image to be identified is converted into a grayscale image, and the grayscale value is used to represent the image to be identified. Then, a sliding window is used to intercept the grayscale value, and the intercepted multiple grayscale values are combined into an image block, and so on, multiple image blocks are formed.
[0068] Combination Figure 3 As shown, with a window size of 3×3, the image to be identified contains pixels p11~p16, p21~p26, p31~p36, p41~p46, p51~p56, p61~p66; pixels p11~p13, p21~p23, p31~p33 form image block C1, pixels p12~p14, p22~p24, p32~p34 form image block C2, and so on, to obtain multiple image blocks.
[0069] In some embodiments, local self-similarity processing is performed on each image block to obtain a similarity matrix by comparing the number of pixels with relatively small difference values in the image block.
[0070] For example, find the ratio between the number of pixels with relatively small differences and the total number of pixels in the image block, and use the ratio as the similarity value of the image block;
[0071] The similarity values of each image block are concatenated into a matrix, which is the similarity matrix.
[0072] Of course, the method of performing local self-similarity processing on each image block in the embodiment of the present invention may also include other methods of calculating the similarity of pictures, and the embodiment of the present invention does not impose any specific limitation on this.
[0073] In some embodiments, the similarity matrix is subjected to feature extraction to obtain local features, and the implementation method includes:
[0074] The similarity matrix is extracted through deep convolutional neural network (CNN) to obtain local features F CNN .
[0075] Before extracting features, CNN needs to be trained multiple times using a training set; the training set includes multiple similarity matrices and information that indicates whether the image corresponding to each similarity matrix is an AI image; for each training, the similarity matrix in the training set is input into CNN, and the predicted classification corresponding to the similarity matrix in the training set is output; the parameters within CNN are adjusted based on the predicted classification corresponding to the similarity matrix in the training set and the labeled information of the similarity matrix in the training set.
[0076] Take a training as an example. Select a similarity matrix from the training set, and then input the similarity matrix into CNN. CNN outputs the classification result. For example, if the classification result output by CNN is not an AI image, if the image from the selected similarity matrix is not an AI image, then there is no need to adjust the parameters in CNN. If the image from the selected similarity matrix is an AI image, then since the CNN classification result is different from the actual result, the parameters in CNN need to be adjusted according to the result. Similarly, when the classification result output by CNN is an AI image, if the image from the selected similarity matrix is an AI image, then there is no need to adjust the parameters in CNN. If the image from the selected similarity matrix is not an AI image, then since the CNN classification result is different from the actual result, the parameters in CNN need to be adjusted according to the result.
[0077] Among them, the feature extractor is a pre-trained deep learning model.
[0078] In step 100 of the embodiment of the present invention, a pre-trained deep learning model is used to extract global features from the image to be identified. In this way, the pre-trained deep learning model is used to extract global features when extracting features, which can reduce the training process and reduce costs.
[0079] Among them, the feature extractor is a deep learning model established using a small convolution kernel and / or a deep learning model established using a residual structure.
[0080] In detail, the deep learning model established using small convolution kernels can be composed of a 3×3 convolution kernel and a 2×2 maximum pooling layer, such as the VGG model.
[0081] The embodiment of the present invention adopts a deep learning model established by a small convolution kernel, which can enhance nonlinearity and reduce parameters.
[0082] Deep learning models built using residual structures, such as the ResNet model, extract the difference between the original high-resolution image and the low-resolution image to form a residual image. This residual image represents the difference or missing details between the low-resolution image and the target high-resolution image. This residual image is then added to the low-resolution image to obtain a new image that combines the low-resolution information and the residual details. This new image serves as the input to the next neural network layer, allowing the network to use both the original low-resolution information and the residual detail information for more accurate learning. In this way, information is gradually extracted from the low-resolution image, and the missing details are added back through the addition operation of the residual image. This enables the network to perform image restoration or other tasks more efficiently, improving the performance and accuracy of the model.
[0083] Exemplary, combined Figure 4As shown, an embodiment of the present invention provides an AI image recognition method, including:
[0084] S400: Extract global features F from the image to be recognized through the pre-trained VGG model VGG ;
[0085] S401: Extract global features F from the image to be identified through the pre-trained resnet model resnet ;
[0086] S402: Divide the image to be identified into multiple image blocks, perform local self-similarity processing on each image block to obtain a similarity matrix, and use CNN to extract features from the similarity matrix to obtain local features F CNN ;
[0087] S403: Based on the global feature F VGG , global feature F resnet and local features F CNN Identify the image to be identified and predict whether it is an AI image.
[0088] Of course, step 400 can also be performed separately to extract the global feature F VGG In step 403, according to the global feature F VGG and local features F CNN The image to be identified is identified to predict whether the image to be identified is an AI image. Alternatively, step 401 may be performed separately to extract the global feature F resnet In step 403, according to the global feature F resnet and local features F CNN Identify the image to be identified and predict whether it is an AI image.
[0089] In this way, the embodiment of the present invention utilizes pre-trained deep learning models (such as VGG, ResNet) to extract high-level features of the image to improve recognition accuracy, and adopts a CNN network to extract local features with local similarities. In this way, a feature extraction algorithm based on local self-similarity of the image is introduced to further improve recognition accuracy and robustness.
[0090] Since the embodiment of the present invention introduces multiple types of features, the multiple types of features need to be fused before prediction.
[0091] In some embodiments, the image to be identified is identified based on the global features and the local features, and it is predicted whether the image to be identified is an AI image. Figure 5 As shown, including:
[0092] S500: weighting the global feature using the first weight, and weighting the local feature using the second weight;
[0093] Exemplarily, the global features include the global features F VGG and the global feature F resnet ; The first weight includes weight w v and weight w r , global feature F VGG for:
[0094]
[0095] Weight w v for:
[0096]
[0097] Using weight w v Weighted global feature F VGG , and we get the following first matrix:
[0098] Global feature F resnet for:
[0099]
[0100] Weight w r for:
[0101]
[0102] Using weight w r Weighted global feature F resnet , and the following second matrix is obtained:
[0103] Local feature F CNN for:
[0104]
[0105] Weight w F for:
[0106]
[0107] Using weight w F Weighted local feature F CNN , and the following third matrix is obtained:
[0108]
[0109] S501: Combining the weighted global features and the weighted local features into a fusion matrix;
[0110] In the embodiment of the present invention, the fusion matrix is formed in the following two ways:
[0111] Method 1: The sum of the weighted global features and the weighted local features is used as the fusion matrix; illustratively, the first matrix, the second matrix and the third matrix are added by the following formula:
[0112]
[0113] The element of the first row and first column of the obtained fusion matrix is: the element a of the first row and first column of the first matrix 11 ·w v11 Add the element b in the first row and first column of the second matrix 11 ·w r11 Add the element c in the first row and first column of the third matrix 11 ·w F11 ;
[0114] The element in the first row and second column of the fused matrix is: the element a in the first row and second column of the first matrix 12 ·w v12 Add the element b in the first row and second column of the second matrix 12 ·w r12 Add the element c in the first row and second column of the third matrix 12 ·w F12 ;
[0115] The element in the first row and the mth column of the fused matrix is: the element a in the first row and the mth column of the first matrix 1m ·w v1m Add the element b in the first row and mth column of the second matrix 1m ·w r1m Add the element c in the first row and mth column of the third matrix 1m ·w F1m ;
[0116] And so on, calculate n rows and m columns of elements.
[0117] Method 2: concatenate the weighted local features onto the weighted global features to form a fusion matrix.
[0118] Exemplarily, the first matrix is concatenated with the second matrix, and the second matrix is concatenated with the third matrix, as follows:
[0119]
[0120] The elements of the first row of the fusion matrix are: a 11 ·w v11 a 12 ·w v12 …a 1m ·w v1m b 11 ·wr11 b 12 ·w r12 …b 1m ·w r1m c 11 ·w F11 c 12 ·w F12 …c 1m ·w F1m ;
[0121] By analogy, the elements of the nth row of the fusion matrix are: a n1 ·w vn1 a n2 ·w vn2 …a nm ·w vnm b n1 ·w rn1 b n2 ·w rn2 …b nm ·w rnm c n1 ·w Fn1 c n2 ·w Fn2 …c nm ·w Fnm .
[0122] S502: Input the fusion matrix into the classification model, and output whether the image to be identified is an AI image.
[0123] Exemplarily, the classification model may be a multi-layer perceptron or a convolutional neural network.
[0124] Before using the classification model for classification, the classification model needs to be trained. The training process is as follows:
[0125] The classification model is trained multiple times using the training set; wherein the training set includes multiple fusion matrices used in the training and information on whether the image corresponding to the fusion matrix used in the labeling training is an AI image;
[0126] For each training, the fusion matrix in the training set is input into the classification model, and the predicted classification corresponding to the fusion matrix in the training set is output;
[0127] Adjust the classification model according to the predicted classification corresponding to the fusion matrix in the training set and the annotation information of the fusion matrix in the training set.
[0128] Take a training as an example, select a fusion matrix from the training set, and then input the fusion matrix into the classification model, and the classification model outputs the classification result. For example, if the classification result output by the classification model is not an AI image, if the image from the selected fusion matrix is not an AI image, then there is no need to adjust the parameters in the classification model; if the image from the selected fusion matrix is an AI image, then since the classification result of the classification model is different from the actual result, the parameters in the classification model need to be adjusted according to the result. Similarly, when the classification result output by the classification model is an AI image, if the image from the selected fusion matrix is an AI image, then there is no need to adjust the parameters in the classification model; if the image from the selected fusion matrix is not an AI image, then since the classification result of the classification model is different from the actual result, the parameters in the classification model need to be adjusted according to the result.
[0129] For the CNN training process, during the classification model training process, it is first necessary to obtain a large number of images used in the training process. A large number of images can be extracted from the database, and then the images extracted from the database are preprocessed, and the preprocessed images are subjected to local similarity processing to obtain a similarity matrix. The similarity matrix is used to train the CNN. After the training is completed, the trained CNN can be used to extract the local matrix, and the extracted local matrix and the global matrix are fused to obtain a fused matrix. These fused matrices are combined into a training set, and this training set is used to train the classification model.
[0130] The database can store and manage image data, and the images in the database can be obtained by using web crawlers, user uploads, public data sets, etc., and the present invention does not make specific limitations on this.
[0131] The images in the database include AI images and ordinary images.
[0132] The process of preprocessing the image is: normalizing, denoising and enhancing the image.
[0133] Among them, image enhancement is performed through geometric transformation, brightness adjustment and other methods.
[0134] In some embodiments, the image to be identified is identified based on the global features and the local features, and after predicting whether the image to be identified is an AI image, the Figure 6 As shown, the method also includes:
[0135] S600: Determine the actual classification result of the image to be identified;
[0136] S601: If the actual classification result of the image to be identified is different from the predicted result, adjusting the first weight and the second weight according to the prediction strategy; wherein the prediction strategy includes the first strategy and the second strategy; the first strategy and the second strategy have different adjustment directions for the first weight and the second weight, and the first strategy and the second strategy have the same adjustment step length for the first weight and the second weight;
[0137] S602: re-predicting the image to be recognized by using the first weight and the second weight adjusted by the first strategy to obtain a first result, and re-predicting the image to be recognized by using the first weight and the second weight adjusted by the second strategy to obtain a second result;
[0138] S603: If the first result is the same as the actual classification result of the image to be identified, continue prediction according to the first weight and the second weight adjusted by the first strategy;
[0139] S604: If the second result is the same as the actual classification result of the image to be identified, continue prediction according to the first weight and the second weight adjusted by the second strategy.
[0140] In detail, the first strategy is to add a preset step length to the first weight and subtract the preset step length from the second weight; the second strategy is to subtract the preset step length from the first weight and add the preset step length to the second weight.
[0141] For the AI image recognition solution provided by the embodiment of the present invention, a pre-trained deep learning model (such as VGG, ResNet) is used to extract high-level features of the image to improve recognition accuracy. A feature extraction algorithm based on local self-similarity of the image is introduced to further improve recognition accuracy and robustness. An efficient classification model is trained based on the fused high-level features to achieve real-time recognition. In this way, through a variety of data enhancement technologies, the generalization ability of the model is improved, so that it performs well when processing different types of AI-generated pictures. An efficient, accurate and real-time AI image recognition tool is implemented, which is suitable for a wide range of application scenarios, including media review, content creation, and information security.
[0142] like Figure 7 As shown, the present invention also provides an AI image recognition device, comprising:
[0143] A first extraction module 700, configured to extract global features from the image to be identified by means of a feature extractor;
[0144] The second extraction module 701 is used to divide the image to be identified into multiple image blocks, perform local self-similarity processing on each image block to obtain a similarity matrix, and perform feature extraction on the similarity matrix to obtain local features;
[0145] The prediction module 702 is used to identify the image to be identified according to the global features and the local features, and predict whether the image to be identified is an AI image.
[0146] Optionally, the feature extractor is a pre-trained deep learning model.
[0147] Optionally, the feature extractor is a deep learning model established using a small convolution kernel and / or a deep learning model established using a residual structure.
[0148] Optionally, the prediction module 702 is specifically configured to:
[0149] weighting the global feature using a first weight, and weighting the local feature using a second weight;
[0150] Combining the weighted global features and the weighted local features into a fusion matrix;
[0151] The fusion matrix is input into the classification model, and outputs whether the image to be identified is an AI image.
[0152] Optionally, the prediction module 702 is further configured to:
[0153] taking the sum of the weighted global features and the weighted local features as a fusion matrix; or
[0154] The weighted local features are concatenated after the weighted global features to form a fusion matrix.
[0155] Optionally, the device further comprises: a training module;
[0156] Training modules for:
[0157] The classification model is trained multiple times using a training set; wherein the training set includes multiple fusion matrices used for training and information on whether an image corresponding to the fusion matrix used for marking training is an AI image;
[0158] For each training, the fusion matrix in the training set is input into the classification model, and the predicted classification corresponding to the fusion matrix in the training set is output;
[0159] The classification model is adjusted according to the predicted classification corresponding to the fusion matrix in the training set and the labeling information of the fusion matrix in the training set.
[0160] Optionally, the device further comprises: an adjustment module;
[0161] Adjustment modules for:
[0162] Determining an actual classification result of the image to be identified;
[0163] If the actual classification result of the image to be identified is different from the predicted result, adjusting the first weight and the second weight according to the prediction strategy; wherein the prediction strategy includes a first strategy and a second strategy; the first strategy and the second strategy have different adjustment directions for the first weight and the second weight, and the first strategy and the second strategy have the same adjustment step length for the first weight and the second weight;
[0164] Re-predicting the image to be identified using the first weight and the second weight adjusted by the first strategy to obtain a first result, and re-predicting the image to be identified using the first weight and the second weight adjusted by the second strategy to obtain a second result;
[0165] If the first result is the same as the actual classification result of the image to be identified, continue prediction according to the first weight and the second weight adjusted by the first strategy;
[0166] If the second result is the same as the actual classification result of the image to be identified, the prediction is continued according to the first weight and the second weight adjusted by the second strategy.
[0167] In addition, combined Figure 1-Figure 7 The AI image recognition method and system described in the embodiments of the present invention may be implemented by an electronic device.
[0168] Electronic devices, including: processors;
[0169] a memory for storing instructions executable by the processor;
[0170] Among them, the processor is configured to execute the instructions to implement the AI image recognition method as described in any one of the above introductions.
[0171] Based on the above introduction, an exemplary Figure 8 electronic equipment structure.
[0172] The electronic device may include a processor 810 and a memory 820 storing computer program instructions.
[0173] Specifically, the processor 810 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present invention.
[0174] The memory 820 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 820 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 820 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 820 may be inside or outside a data processing device. In a specific embodiment, the memory 820 is a non-volatile solid-state memory. In a specific embodiment, the memory 820 includes a read-only memory (ROM). In appropriate cases, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these.
[0175] The processor 810 implements any one of the methods for performing tasks in the above embodiments by reading and executing computer program instructions stored in the memory 820 .
[0176] In one example, the electronic device may further include a communication interface 830 and a bus 840. Figure 8 As shown, the processor 810, the memory 820, and the communication interface 830 are connected via a bus 840 and communicate with each other.
[0177] The communication interface 830 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiment of the present invention.
[0178] Bus 840 includes hardware, software or both, and the parts of electronic equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 840 may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection.
[0179] The electronic device can execute the AI image recognition method in the embodiment of the present invention based on the received task, thereby realizing the combination Figure 1-Figure 8 Described AI image recognition method and system.
[0180] In addition, in combination with the electronic device in the above embodiments, an embodiment of the present invention may provide a storage medium, and when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the AI image recognition method as described in any one of the above items.
[0181] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0182] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0183] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0184] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0185] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. An AI image recognition method, characterized in that: include: Extracting global features from the image to be identified by a feature extractor; Dividing the image to be identified into a plurality of image blocks, performing local self-similarity processing on each of the image blocks to obtain a similarity matrix, and performing feature extraction on the similarity matrix to obtain local features; The image to be identified is identified according to the global features and the local features, and it is predicted whether the image to be identified is an AI image.
2. The AI image recognition method according to claim 1, characterized in that: in, The feature extractor is a pre-trained deep learning model.
3. The AI image recognition method according to claim 1, characterized in that: in, The feature extractor is a deep learning model established using a small convolution kernel and / or a deep learning model established using a residual structure.
4. The AI image recognition method according to claim 1, characterized in that: The identifying the image to be identified according to the global features and the local features, and predicting whether the image to be identified is an AI image, includes: weighting the global feature using a first weight, and weighting the local feature using a second weight; Combining the weighted global features and the weighted local features into a fusion matrix; The fusion matrix is input into the classification model, and outputs whether the image to be identified is an AI image.
5. The AI image recognition method according to claim 4, characterized in that: The step of forming a fusion matrix from the weighted global features and the weighted local features comprises: taking the sum of the weighted global features and the weighted local features as a fusion matrix; or The weighted local features are concatenated after the weighted global features to form a fusion matrix.
6. The AI image recognition method according to claim 4, characterized in that: The method further comprises: The classification model is trained multiple times using a training set; wherein the training set includes multiple fusion matrices used for training and information on whether an image corresponding to the fusion matrix used for marking training is an AI image; For each training, the fusion matrix in the training set is input into the classification model, and the predicted classification corresponding to the fusion matrix in the training set is output; The classification model is adjusted according to the predicted classification corresponding to the fusion matrix in the training set and the labeling information of the fusion matrix in the training set.
7. The AI image recognition method according to claim 4, characterized in that: After identifying the image to be identified according to the global features and the local features and predicting whether the image to be identified is an AI image, the method further includes: Determining an actual classification result of the image to be identified; If the actual classification result of the image to be identified is different from the predicted result, adjusting the first weight and the second weight according to the prediction strategy; wherein the prediction strategy includes a first strategy and a second strategy; the first strategy and the second strategy have different adjustment directions for the first weight and the second weight, and the first strategy and the second strategy have the same adjustment step length for the first weight and the second weight; Re-predicting the image to be identified using the first weight and the second weight adjusted by the first strategy to obtain a first result, and re-predicting the image to be identified using the first weight and the second weight adjusted by the second strategy to obtain a second result; If the first result is the same as the actual classification result of the image to be identified, continue prediction according to the first weight and the second weight adjusted by the first strategy; If the second result is the same as the actual classification result of the image to be identified, the prediction is continued according to the first weight and the second weight adjusted by the second strategy.
8. An AI image recognition method and device, characterized in that: include: A first extraction module, used for extracting global features from the image to be identified by a feature extractor; A second extraction module is used to divide the image to be identified into a plurality of image blocks, perform local self-similarity processing on each of the image blocks to obtain a similarity matrix, and perform feature extraction on the similarity matrix to obtain local features; A prediction module is used to identify the image to be identified based on the global features and the local features, and predict whether the image to be identified is an AI image.
9. An electronic device, characterized in that: include: Memory, used to store computer programs or instructions; A processor, configured to execute a computer program or instruction in the memory so that the AI image recognition method as described in any one of claims 1 to 7 is executed.
10. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor, the processor is enabled to execute the AI image recognition method as described in any one of claims 1-7.