Data processing method, device, electronic device and computer readable storage medium
By dividing and combining image samples, global and local features are extracted for model convergence, which solves the problem of low recognition accuracy caused by too small content areas in image recognition, and achieves higher recognition accuracy and recall.
Patent Information
- Application Number
- CN202210217384.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-07
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-03-07
AI Technical Summary
When existing technology identifies unhealthy or inappropriate content in images, the image scaling or cutting method often loses the screening area information, resulting in a reduction in recognition accuracy. Especially when the content area is too small, the data amplification method cannot be effective. Solve this problem.
By dividing the image sample to be recognized into a preset number of image subsamples and randomly combining them, a preset image recognition model is used to extract features of the target image sample and image subsamples to obtain global and local features. Based on these features, The model converges to form a trained image recognition model to improve recognition accuracy.
This method reduces the dependence on object structure information, considers image features from the granularity of the area to be screened, reduces the misjudgment rate of normal images, ensures the recall rate of target images, and thus improves the accuracy of image recognition.
Smart Images

Figure CN116778211B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a data processing method, device, electronic device and computer-readable storage medium. Background Art
[0002] In recent years, with the development of Internet technology, the speed of content dissemination on the Internet has become faster and faster, especially the content of the second dimension (ACG). In order to purify the network environment, some pictures may contain unhealthy or inappropriate content, which needs to be identified so that viewers can avoid these contents. However, these contents may have problems such as the area where the unhealthy or inappropriate content appears is too small. In the process of identifying images of this type of content, data amplification is often used to highlight such areas for identification, so as to achieve the purpose of screening out these areas.
[0003] In the process of research and practice of the prior art, the inventors of the present invention found that data augmentation cannot fundamentally solve the problem of the image area to be screened being too small, and the scaling or cutting of the image often loses the information of the image area to be screened, thereby reducing the accuracy of image recognition. Summary of the invention
[0004] The embodiments of the present invention provide a data processing method, device, electronic device and computer-readable storage medium, which can improve the accuracy of image recognition.
[0005] A data processing method, comprising:
[0006] Acquire a set of image samples to be identified, and divide each image sample to be identified in the set of image samples to be identified into a preset number of image subsamples;
[0007] Randomly combining the image subsamples to obtain a target image sample corresponding to the image sample to be identified;
[0008] Using a preset image recognition model to extract features of the target image sample to obtain global image features of the image sample to be recognized;
[0009] Using the preset image recognition model to extract features from the image subsample to obtain local image features of the image sample to be recognized;
[0010] The preset image recognition model is converged based on the global image features and the local image features to obtain a trained image recognition model.
[0011] Accordingly, an embodiment of the present invention provides a data processing device, including:
[0012] An acquisition unit, used for acquiring a set of image samples to be identified, and dividing each image sample to be identified in the set of image samples to be identified into a preset number of image subsamples;
[0013] A combining unit, used for randomly combining the image subsamples to obtain a target image sample corresponding to the image sample to be identified;
[0014] A first extraction unit, configured to extract features of the target image sample using a preset image recognition model to obtain global image features of the image sample to be recognized;
[0015] A second extraction unit, configured to extract features from the image subsample using the preset image recognition model to obtain local image features of the image sample to be recognized;
[0016] A convergence unit is used to converge the preset image recognition model based on the global image features and the local image features to obtain a trained image recognition model.
[0017] Optionally, in some embodiments, the first extraction unit can be specifically used to use a preset image recognition model to perform feature extraction on the target image sample to obtain sample image features; perform channel conversion on the sample image features to obtain multiple converted sample image features; and fuse the converted sample image features to obtain global image features of the image sample to be identified.
[0018] Optionally, in some embodiments, the first extraction unit can be specifically used to extract associated features from the converted sample image features, and determine the attention weights of the converted sample image features based on the associated features; weight the converted sample image features based on the attention weights to obtain weighted sample image features; identify the feature values of each pixel of the image sample to be identified in the weighted sample image features; filter out target feature values from the feature values, and fuse the target feature values of each pixel to obtain the global image features of the image sample to be identified.
[0019] Optionally, in some embodiments, the second extraction unit can be specifically used to perform feature extraction on the image subsamples using the preset image recognition model to obtain subsample image features of each of the image subsamples; determine the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type based on the subsample image features; and screen out the local image features of the image sample to be identified from the subsample image features based on the local prediction probability.
[0020] Optionally, in some embodiments, the recognition unit can be specifically used to determine the contrast loss information of the image sample to be recognized based on the global image features and the local image features; determine the image loss information of the image sample to be recognized based on the local prediction type corresponding to the global image features and the local image features; fuse the contrast loss information and the image loss information, and converge the preset image recognition model based on the fused loss information to obtain a trained image recognition model.
[0021] Optionally, in some embodiments, the recognition unit can be specifically used to compress the global image features and the local image features to the same dimension to obtain compressed global image features and compressed local image features; respectively extract feature values corresponding to the same pixel from the compressed global image features and the compressed local image features; based on the feature values, calculate pixel loss information corresponding to the pixel, and fuse the pixel loss information to obtain contrast loss information of the image sample to be identified.
[0022] Optionally, in some embodiments, the recognition unit can be specifically used to determine the global prediction type of the image sample to be recognized based on the global image features; calculate the global image loss information of the image sample to be recognized based on the global prediction type, and calculate the local image loss information of the image sample to be recognized based on the local prediction type; and fuse the global image loss information and the local loss information to obtain the image loss information of the image sample to be recognized.
[0023] In addition, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the data processing method provided by the embodiment of the present invention.
[0024] In addition, an embodiment of the present invention further provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any data processing method provided by the embodiment of the present invention.
[0025] After obtaining a set of image samples to be identified and dividing each image to be identified in the set of image samples to be identified into a preset number of image sub-samples, the embodiment of the present invention randomly combines the image sub-samples to obtain target image samples corresponding to the image samples to be identified, and then uses a preset image recognition model to extract features of the target image samples to obtain global image features of the image samples to be identified, and then uses the preset image recognition model to extract features of the image sub-samples to obtain local image features of the image samples to be identified, and converges the preset image recognition model based on the global image features and the local image features to obtain a trained image recognition model; since the scheme can randomly divide and combine the images to be identified, reducing the dependence on the object structure information, the image features can be considered from the granularity of the area to be screened, and in addition, by converging the preset image recognition model through the global image features and the local image features, the recall of the target image can be guaranteed under the premise of low misjudgment of normal images, thereby improving the accuracy of image recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 is a schematic diagram of a scenario of a data processing method provided by an embodiment of the present invention;
[0028] Figure 2 is a flow chart of a data processing method provided by an embodiment of the present invention;
[0029] Figure 3 is a schematic diagram of dividing an image sample to be identified into image subsamples provided by an embodiment of the present invention;
[0030] Figure 4 is a schematic diagram of the structure of an encoder provided by an embodiment of the present invention;
[0031] Figure 5 is a schematic diagram of the structure of a residual module provided by an embodiment of the present invention;
[0032] Figure 6 is a schematic diagram of training a preset image recognition model provided by an embodiment of the present invention;
[0033] Figure 7 is another flow chart of the data processing method provided by an embodiment of the present invention;
[0034] Figure 8is a schematic diagram of the structure of a data processing device provided by an embodiment of the present invention;
[0035] Fig. 9 is another structural schematic diagram of a data processing device provided by an embodiment of the present invention;
[0036] Fig.10 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0037] 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0038] The embodiment of the present invention provides a data processing method, device, electronic device and computer-readable storage medium. The data processing device can be integrated in an electronic device, and the electronic device can be a server or a terminal.
[0039] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The embodiments of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application is not limited here.
[0040] For example, see Figure 1Taking the data processing device integrated in an electronic device as an example, after the electronic device obtains a set of image samples to be identified and divides each image to be identified in the set of image samples to be identified into a preset number of image sub-samples, the image sub-samples are randomly combined to obtain target image samples corresponding to the image samples to be identified, and then, a preset image recognition model is used to extract features of the target image samples to obtain global image features of the image samples to be identified, and then, a preset image recognition model is used to extract features of the image sub-samples to obtain local image features of the image samples to be identified, and the preset image recognition model is converged based on the global image features and the local image features to obtain a trained image recognition model, thereby improving the accuracy of image recognition.
[0041] The data processing method provided in the embodiment of the present application relates to the computer vision direction in the field of artificial intelligence. The embodiment of the present application can extract image features from target image samples and image subsamples.
[0042] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. Among them, artificial intelligence software technology mainly includes computer vision technology, machine learning / deep learning and other directions.
[0043] Among them, Computer Vision (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision that uses computers to replace human eyes to identify and measure targets, and further processes images so that the images are processed by computers to become more suitable for human eye observation or transmission to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multidimensional data. Computer vision technology usually includes image processing, image recognition and other technologies.
[0044] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0045] This embodiment will be described from the perspective of a data processing device, which can be specifically integrated into an electronic device, which can be a server or a terminal. The terminal can include a tablet computer, a laptop computer, a personal computer (PC), a wearable device, a virtual reality device, or other smart devices that can perform image recognition.
[0046] A data processing method, comprising:
[0047] A set of image samples to be identified is obtained, and each image to be identified in the set of image samples to be identified is divided into a preset number of image sub-samples, the image sub-samples are randomly combined to obtain target image samples corresponding to the image samples to be identified, a preset image recognition model is used to perform feature extraction on the target image samples to obtain global image features of the image samples to be identified, a preset image recognition model is used to perform feature extraction on the image sub-samples to obtain local image features of the image samples to be identified, the preset image recognition model is converged based on the global image features and the local image features to obtain a trained image recognition model, and the trained image recognition model is used to identify the image to be identified.
[0048] like Figure 2 As shown, the specific process of the data processing method is as follows:
[0049] 101. Obtain a set of to-be-recognized image samples, and divide each to-be-recognized image sample in the set of to-be-recognized image samples into a preset number of image sub-samples.
[0050] Among them, the image samples to be identified can be image samples of the two-dimensional (ACG) content. Traditional two-dimensional (ACG) can be attributed to animation, comics, and games. In the process of content review or image recognition, the scope of ACG is wider, and can include simple drawings, color paintings, illustrations, page comics, strip comics, real-life CG, electronic games, anime characters, emoticons, and other styles of content. The corresponding non-ACG content images can be images corresponding to content other than the ACG range, for example, real-life images and real-object images.
[0051] The image subsample can be understood as an image segment obtained by segmenting the image sample to be identified.
[0052] There are many ways to obtain a set of image samples to be identified, which can be as follows:
[0053] For example, the image samples to be identified uploaded by the user through the terminal can be directly obtained to obtain a set of image samples to be identified, or ACG content can be obtained from the content database, and image samples can be extracted from the ACG content as image samples to be identified, thereby obtaining a set of image samples to be identified, or original images can be obtained on the Internet, ACG content images can be screened out from the original images, and the ACG content images can be sent to the review server for review, and the ACG content images can be annotated with the review results as image tags, and the ACG content images annotated with the image tags can be used as image samples to be identified, thereby obtaining a set of image samples to be identified, or, when the number of image samples to be identified in the set of image samples to be identified is large, an image recognition request can also be received, and the image recognition request carries the storage address of the image samples to be identified, and the image samples to be identified are obtained based on the storage address, thereby obtaining a set of image samples to be identified.
[0054] After obtaining the set of image samples to be identified, each image sample to be identified in the set of image samples to be identified can be divided into a preset number of image sub-samples. There are many ways to divide the image sub-samples. For example, the image sample to be identified can be divided into a preset number of image regions, each of which has the same area. Each image region in the image sample to be identified is divided to obtain a preset number of image sub-samples. For example, taking the preset number of 2*2 as an example, the image sample to be identified can be divided into 4 image sub-samples. Specifically, Figure 3 shown.
[0055] 102. Randomly combine the image subsamples to obtain a target image sample corresponding to the image sample to be identified.
[0056] The random combination can be understood as randomly splicing the image subsamples to form a complete target image sample.
[0057] There are many ways to randomly combine image subsamples, which can be as follows:
[0058] For example, the segmented image sub-samples can be directly randomly spliced together to obtain a target image sample corresponding to the image sample to be identified. Alternatively, the image sub-samples can be numbered, and based on the numbers, the image sub-samples can be randomly synthesized into an image sample, and the spliced image sample can be used as the target image sample.
[0059] The randomly combined target image samples may be different from or the same as the to-be-recognized image samples.
[0060] 103. Use a preset image recognition model to extract features of the target image sample to obtain the global image features of the image sample to be recognized.
[0061] Among them, the global image features can be understood as the feature heat map extracted from the re-synthesized target image samples through the global network of the preset image recognition model.
[0062] There are many ways to extract features from target image samples using a preset image recognition model, which can be as follows:
[0063] For example, a preset image recognition model can be used to extract features of a target image sample to obtain sample image features, the sample image features can be channel converted to obtain multiple converted sample image features, the converted sample image features can be fused to obtain global image features of the image sample to be identified.
[0064] Among them, there are many ways to extract features of the target image samples using a preset image recognition model to obtain sample image features. For example, the encoder in the global network of the preset image recognition model can be used to encode the features of the target image samples to obtain sample image features.
[0065] The structure of the encoder can be various, such as a shallow network of Resnet50. Taking the shallow network of Resnet50 as an example, the convolutional neural network used by the encoder consists of three convolutional layers and six ResBlocks (residual modules), such as Figure 4 As shown in the figure, for the input target image sample, after three convolutional layers, the width (w) and height (h) of the input image are reduced to 1 / 4 of the original, and the number of channels is changed from 3 to 128, forming a feature map of w / 4*h / 4*128. The feature map will then pass through a sub-network composed of 6 ResBlocks to generate a new feature map, which will be used as the sample image feature of the target image sample. Alternatively, the target image sample can also be feature encoded for other networks such as restNet or resnest to obtain the sample image feature of the target image sample.
[0066] Among them, the structure of the residual module can be as follows Figure 5 As shown, there are two convolutional layers and one identity (mapping) layer. After the feature map passes through 6 residual modules, the sample image feature is obtained, and the size of the sample image feature can be w / 4*h / 4*128.
[0067] After extracting the sample image features of the image sample to be identified, the sample image features can be subjected to channel conversion. There are many ways of channel conversion. For example, taking the number of channels of the extracted sample image features as 128 as an example, the feature value of each channel is randomly replaced, thereby obtaining multiple converted sample image features.
[0068] After the channel conversion of the sample image features, the converted sample image features are fused. There are many ways to fuse them. For example, related features are extracted from the converted sample image features, and based on the related features, the attention weights of the converted sample image samples are determined. Based on the attention weights, the converted sample image features are weighted to obtain weighted sample image features. The feature values of each pixel of the image sample to be identified are identified in the weighted sample image features, the target feature values are screened out from the feature values, and the target feature values of each pixel are fused to obtain the global image features of the image sample to be identified.
[0069] There are many ways to filter out the target feature value from the feature values. For example, the largest feature can be filtered out from the feature values as the target feature value of the pixel, or the feature value with the largest number can be filtered out from the feature values as the target feature value of the pixel.
[0070] Among them, it should be noted that the attention mechanism is introduced to randomly replace the channels of the acquired feature map. The main purpose is to learn the different connections between channels so that the extracted global image features are more accurate.
[0071] 104. Use a preset image recognition model to extract features of the image subsample to obtain local image features of the image sample to be recognized.
[0072] Among them, the local image features can be understood as the feature heat map of the target area screened out from the feature heat map of the image subsample through the local network of the preset image recognition model.
[0073] There are many ways to extract features from image subsamples using a preset image recognition model, which can be as follows:
[0074] For example, a preset image recognition model can be used to extract features from image subsamples to obtain subsample image features of each image subsample. Based on the subsample image features, the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type are determined. Based on the local prediction probability, the local image features of the image sample to be identified are screened out from the subsample image features.
[0075] There are many ways to use a preset image recognition model to extract features from image subsamples. For example, a local network of a preset image recognition model can be used to extract features from image subsamples to obtain subsample image features. The local network and the global network share a shallow network of Resnet50.
[0076] After extracting the sub-sample image features, the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type can be determined based on the sub-sample image features. The local prediction type can be understood as the image type of the image sample to be identified based on the local image features. The local prediction probability can be the probability of predicting the image type. There are many ways to determine the local prediction type and the local prediction probability. For example, the prediction type corresponding to the sub-sample image features and the prediction probability corresponding to the prediction type can be determined through a fully connected layer (FC), and the prediction type with the largest prediction probability is selected from the prediction types as the local prediction type.
[0077] After determining the local prediction type and the local prediction probability, the local image features of the image sample to be identified can be screened out from the sub-sample image features. There are many ways to screen out the local image features of the image sample to be identified, such as screening out the image sub-sample with the largest local prediction probability from the image sub-samples as the target image sub-sample, and using the sub-sample image features of the target image sub-sample as the local image features of the image sample to be identified.
[0078] 105. Based on the global image features and the local image features, the preset image recognition model is converged to obtain a trained image recognition model.
[0079] There are many ways to converge the preset image recognition model based on global image features and local image features, which can be as follows:
[0080] For example, the contrast loss information of the image sample to be identified can be determined based on the global image features and the local image features, the image loss information of the image to be identified can be determined based on the local prediction type corresponding to the global image features and the local image features, the contrast loss information and the image loss information can be fused, and the preset image recognition model can be converged based on the fused loss information to obtain the trained image recognition model.
[0081] Among them, the contrast loss information can be understood as the loss information of the characteristic values between the global image features and the local image features in each pixel. There are many ways to determine the contrast loss information of the image sample to be identified. For example, the global image features and the local image features are compressed to the same dimension to obtain the compressed global image features and the compressed local image features, and the characteristic values corresponding to the same pixel are extracted from the compressed global image features and the compressed local image features respectively. Based on the characteristic values, the pixel loss information corresponding to the pixel is calculated, and the pixel loss information is fused to obtain the contrast loss information of the image sample to be identified.
[0082] There are many ways to compress the global image features and the local image features to the same dimension. For example, taking the size of the global image features and the local image features as w / 4*h / 4*128 as an example, the global image features and the local image features can be compressed to one dimension, namely w / 4*h / 4*1. At this size, the one-dimensional feature map is subjected to pixel-by-pixel loss information to obtain the pixel loss information of each pixel. Finally, the pixel loss information is fused to obtain the contrast loss information of the image sample to be identified, which can be specifically shown as formula (1):
[0083]
[0084] Among them, pixelloss is the contrast loss information, y ture is the characteristic value of the local image feature at the same pixel, y perd is the characteristic value of the global image feature at the same pixel.
[0085] Among them, the image loss information can be understood as the loss information between the global prediction type of the target image sample and the local prediction type of the image subsample and the labeled image type of the image sample to be identified. Based on the local prediction type corresponding to the global image features and the local image features, there are many ways to determine the image loss information of the image sample to be identified. For example, according to the global image features, the global prediction type of the image sample to be identified is determined, based on the global prediction type, the global image loss information of the image sample to be identified is calculated, and according to the local prediction type, the local image loss information of the image sample to be identified is calculated, and the global image loss information and the local image loss information are fused to obtain the image loss information of the image sample to be identified.
[0086] Among them, there are many ways to determine the global prediction type of the image sample to be identified based on the global image features. For example, a fully connected layer (FC) can be used to determine the global prediction type of the image sample to be identified and the global prediction probability corresponding to the global prediction type based on the global image features.
[0087] After determining the global prediction type of the image sample to be identified, the global image loss information of the image sample to be identified can be calculated. There are many ways to calculate the global image loss information. For example, the image type label of the image sample to be identified can be obtained, and the image type label can be compared with the global prediction type. Based on the global prediction probability and the comparison result, the global image loss information of the image sample to be identified is determined. The loss function for calculating the global image loss information can be a cross entropy loss function, which can be specifically shown in formula (2):
[0088] bceloss=-y true log(y pred )-(1-ytrue )log(1-y pred ) (2)
[0089] Among them, bceloss is the global image loss information, y true is the image type label, y pred is the global prediction probability of the global prediction type.
[0090] Among them, the method of calculating the local image loss information of the image sample to be identified according to the local prediction type is the same as the method of calculating the global image loss information, which is detailed above and will not be repeated here.
[0091] After calculating the global image loss information and the local image loss information, the global image loss information and the local loss information can be fused. There are many ways to fuse them. For example, the global image loss information and the local loss information can be directly added to obtain the image loss information of the image sample to be identified. Alternatively, the weighting coefficients of the global image loss information and the local image loss information can be obtained respectively. Based on the weighting coefficients, the global image loss information and the local image loss information are weighted respectively. The weighted global image loss information and the weighted local image loss information are fused to obtain the image loss information of the image sample to be identified.
[0092] After determining the contrast loss information and the image loss information, the contrast loss information and the image loss information can be fused. There are many ways to fuse them. For example, the contrast loss information and the image loss information can be directly added to obtain the fused loss information of the image sample to be identified. Specifically, it can be shown in formula (3):
[0093] L loss =L gloss +L lloss +L closs (3)
[0094] Among them, L loss is the fusion loss information of the image sample to be identified, L gloss is the global image loss information, L lloss is the local image loss information, L closs To compare the loss information, L gloss and L lloss Both can be cross entropy loss.
[0095] Optionally, weighted information of the contrast loss information and the image loss information may be obtained respectively, and based on the weighted information, the image loss information and the contrast loss information may be weighted respectively, and the weighted image loss information and the weighted contrast loss information may be fused to obtain the fused loss information of the image sample to be identified.
[0096] After the contrast loss information and the image loss information are fused, the preset image recognition model can be converged based on the fused loss information. There are many ways to converge. For example, a gradient descent algorithm can be used to update the network parameters of the preset image recognition model based on the fused loss information to converge the preset image recognition model and obtain a trained image recognition model. Alternatively, other network parameter updating algorithms can be used to update the network parameters of the preset image recognition model based on the fused loss information to obtain a trained image recognition model.
[0097] Optionally, after the preset image recognition model is converged to obtain a trained image recognition model, the image to be recognized can also be recognized based on the trained image recognition model. There can be many ways to recognize the image to be recognized. For example, the image to be recognized can be obtained, and the global network of the trained image recognition model can be used to extract features of the image to be recognized to obtain image features of the image to be recognized, and the image type of the image to be recognized can be determined based on the image features.
[0098] Among them, there can be multiple image types for the identified images to be identified. For example, in a content review scenario, it can be a binary classification of whether it is a normal image or content, or, in a content review scenario, it can also be multiple classifications, for example, it can include various image types that need to be screened and normal.
[0099] Taking the ACG image sample as an example, the process of training the preset recognition model of the ACG image can be as follows: Figure 6As shown in the figure, it mainly includes four parts. The first part is data preprocessing. The ACG image samples are divided into 2*2 numbers and randomly shuffled. For the global network, each part re-synthesizes the target image sample. For the local network, each part is sent to the local network for training. The maximum score value of each image sub-sample is used as the prediction value; the second part is the global network. The global network uses an encoder to encode the target image sample to obtain the sample image feature, and performs channel conversion on the sample image feature to obtain the converted sample image feature. The attention mechanism is introduced to fuse the converted sample image features to obtain the global image feature. Based on the global image feature, the global prediction type of the ACG image sample and the global prediction probability (gscore) corresponding to the global prediction type are determined, and the global image loss information (gloss) of the ACG image sample is calculated according to the global prediction type and the global prediction probability. ); The third part is the local network. The local network uses the shallow network of Resnet50 shared with the global network to extract features from each segmented image subsample, obtain subsample image features, and determine the local prediction type and local prediction probability of each image subsample based on the subsample image features, extract the local prediction type with the highest local prediction probability in multiple examples (image subsamples) as the type of the ACG image sample output by the local network, and use the subsample image features corresponding to the local prediction probability as the local image features of the ACG image sample. Then, calculate the local image loss information of the ACG image sample based on the local prediction type; The fourth part is the comparison module, which is mainly used to compress the global image features and local image features of the ACG image sample to one dimension in the manner of max, and calculate the loss of the one-dimensional feature map pixel by pixel to obtain the comparison loss information. Finally, the comparison loss information, the global image loss information and the local image loss information are fused to obtain the fused loss information of the ACG image sample, and the preset image recognition model is converged based on the fused loss information, so that the trained image recognition model can be obtained.
[0100] Among them, in the process of training the preset image recognition model, by introducing the attention mechanism in the global network, the sample image features of the shuffled whole image are learned to ensure the recall of the area to be screened. In the local network, by introducing multi-instance learning, each segmented image sub-sample is trained separately, and the maximum value of each segmented image sub-sample is taken as the result, which can reduce the misjudgment of normal images and has higher stability and robustness.
[0101] From the above, it can be seen that after obtaining a set of image samples to be identified and dividing each image to be identified in the set of image samples to be identified into a preset number of image sub-samples, the embodiment of the present application randomly combines the image sub-samples to obtain a target image sample corresponding to the image sample to be identified, and then uses a preset image recognition model to extract features from the target image sample to obtain the global image features of the image sample to be identified, and then uses the preset image recognition model to extract features from the image sub-samples to obtain the local image features of the image sample to be identified, and converges the preset image recognition model based on the global image features and the local image features to obtain the trained image recognition model; because the scheme can randomly divide and combine the images to be identified, reducing the dependence on the object structure information, so that the image features can be considered from the granularity of the area to be screened, in addition, by converging the preset image recognition model through global image features and local image features, the recall of the target image can be guaranteed under the premise of low misjudgment of normal images, thereby improving the accuracy of image recognition.
[0102] According to the method described in the above embodiment, the following is further described in detail with examples.
[0103] In this embodiment, the data processing device is specifically integrated in an electronic device, the electronic device is a server, the image sample to be identified is an ACG image sample, and the image to be identified is an ACG image.
[0104] like Figure 7 As shown, a data processing method, the specific process is as follows:
[0105] 201. The server obtains an ACG image sample set.
[0106] For example, the server can directly obtain the ACG image samples uploaded by the user through the terminal, thereby obtaining an ACG image sample set, or can obtain ACG content from the content database, extract image samples from the ACG content as ACG image samples, thereby obtaining an ACG image sample set, or obtain original images on the Internet, filter out ACG content images from the original images, and send the ACG content images to the review server for review, and annotate the ACG content images with the review results as image tags, and use the ACG content images annotated with image tags as ACG image samples, thereby obtaining an ACG image sample set, or, when the number of ACG image samples in the ACG image sample set is large, it can also receive an image recognition request, which carries the storage address of the ACG image sample, and obtain the ACG image sample based on the storage address, thereby obtaining an ACG image sample set.
[0107] 202. The server divides each ACG image sample in the ACG image sample set into a preset number of image sub-samples.
[0108] For example, the server may divide the ACG image sample into 2*2 image regions, each of which has the same area, and divide each image region in the ACG image sample to obtain a preset number of image sub-samples.
[0109] 203. The server randomly combines the image subsamples to obtain a target image sample corresponding to the ACG image sample.
[0110] For example, the server can directly randomly splice the segmented image sub-samples to obtain a target image sample corresponding to an ACG image sample, or the image sub-samples can be numbered, and based on the numbers, the image sub-samples can be randomly synthesized into an image sample, and the spliced image sample can be used as the target image sample.
[0111] 204. The server uses a preset image recognition model to extract features of the target image sample to obtain global image features of the ACG image sample.
[0112] For example, the server can use three convolutional layers in the shallow network of Resnet50 to extract the input target image sample to obtain a feature map of w / 4*h / 4*128, and then perform feature processing through a sub-network composed of 6 ResBlocks to generate a new feature map, and use the generated new feature map as the sample image feature of the target image sample. Alternatively, the server can also perform feature encoding on the target image sample for other networks such as restNet or resnest to obtain the sample image feature of the target image sample.
[0113] The server can randomly replace the feature value of each of the 128 channels in the sample image feature, for example, replace the feature value of channel A with the feature value of channel B, and so on, so as to obtain multiple converted sample image features. Extract the associated features from the converted sample image features, and determine the attention weight of the converted sample image sample based on the associated features. Based on the attention weight, weight the converted sample image features to obtain the weighted sample image features. In the weighted sample image features, identify the feature value of each pixel of the ACG image sample, and select the largest feature from the feature value as the target feature value of the pixel, or select the feature value with the largest number from the feature value as the target feature value of the pixel. The target feature values of each pixel are fused to obtain the global image feature of the ACG image sample.
[0114] 205. The server uses a preset image recognition model to extract features from the image subsample to obtain local image features of the ACG image sample.
[0115] For example, the server can use the local network in the preset image recognition model to extract features from the image subsamples, thereby obtaining subsample image features. The local network shares the shallow network of Resnet50 with the global network. The prediction type corresponding to the subsample image feature and the prediction probability corresponding to the prediction type are determined through the fully connected layer (FC), and the prediction type with the largest prediction probability is selected from the prediction types as the local prediction type. The image subsample with the largest local prediction probability is selected from the image subsamples as the target image subsample, and the subsample image features of the target image subsample are used as the local image features of the ACG image sample.
[0116] 206. The server converges the preset image recognition model based on the global image features and the local image features to obtain a trained image recognition model.
[0117] For example, the server compresses the global image features and the local image features to one dimension, i.e., w / 4*h / 4*1, respectively, to obtain compressed global image features and compressed local image features, extracts feature values corresponding to the same pixel from the compressed global image features and compressed local image features, respectively, calculates pixel loss information corresponding to the pixel based on the feature values, and fuses the pixel loss information to obtain the contrast loss information of the ACG image sample, which can be specifically shown in formula (1).
[0118] The server can use a fully connected layer (FC) to determine the global prediction type of the ACG image sample and the global prediction probability corresponding to the global prediction type based on the global image features, obtain the image type label annotated by the ACG image sample, compare the image type label with the global prediction type, and determine the global image loss information of the ACG image sample based on the global prediction probability and the comparison result. The loss function for calculating the global image loss information can be a cross entropy loss function, which can be specifically shown in formula (2). The method of calculating the local image loss information of the ACG image sample according to the local prediction type is the same as the method of calculating the global image loss information, which is described above and will not be repeated here.
[0119] The server can directly add the global image loss information and the local loss information to obtain the image loss information of the ACG image sample, or can also obtain the weighting coefficients of the global image loss information and the local image loss information respectively, and based on the weighting coefficients, weight the global image loss information and the local image loss information respectively, and fuse the weighted global image loss information and the weighted local image loss information to obtain the image loss information of the ACG image sample.
[0120] The server can directly add the contrast loss information and the image loss information to obtain the fused loss information of the ACG image sample, as shown in formula (3). Alternatively, the server can obtain weighted information of the contrast loss information and the image loss information respectively, and weight the image loss information and the contrast loss information respectively based on the weighted information, and fuse the weighted image loss information and the weighted contrast loss information to obtain the fused loss information of the ACG image sample.
[0121] The server can use a gradient descent algorithm to update the network parameters of the preset image recognition model based on the fused loss information to converge the preset image recognition model and obtain a trained image recognition model. Alternatively, other network parameter update algorithms can be used to update the network parameters of the preset image recognition model based on the fused loss information to obtain a trained image recognition model.
[0122] 207. The server uses the trained image recognition model to recognize the ACG image.
[0123] For example, the server may obtain an ACG image, use a global network of a trained image recognition model to extract features of the ACG image, obtain image features of the ACG image, and determine the image type of the ACG image based on the image features.
[0124] From the above, it can be seen that after the server of this embodiment obtains the ACG image sample set and divides each ACG image in the ACG image sample set into a preset number of image sub-samples, the image sub-samples are randomly combined to obtain the target image sample corresponding to the image sample to be identified, and then, the preset image recognition model is used to extract features of the target image sample to obtain the global image features of the ACG image sample, and then, the preset image recognition model is used to extract features of the image sub-sample to obtain the local image features of the ACG image sample, and the preset image recognition model is converged based on the global image features and the local image features to obtain the trained image recognition model, and the trained image recognition model is used to identify the ACG image; because the scheme can randomly divide and combine the ACG image, reduce the dependence on the object structure information, so that the image features can be considered from the granularity of the area to be screened, and in addition, by converging the preset image recognition model through the global image features and the local image features, the recall of the target image can be guaranteed under the premise of low misjudgment of the normal image, thereby improving the accuracy of image recognition.
[0125] In order to better implement the above method, an embodiment of the present invention further provides a data processing device, which can be integrated in an electronic device, such as a server or a terminal. The terminal may include a tablet computer, a laptop computer and / or a personal computer.
[0126] For example, Figure 8 As shown, the data processing device may include an acquisition unit 301, a combination unit 302, a first extraction unit 303, a second extraction unit 304 and a convergence unit 305, as follows:
[0127] (1) Acquisition unit 301;
[0128] The acquisition unit 301 is used to acquire a set of image samples to be identified, and divide each image sample to be identified in the set of image samples to be identified into a preset number of image sub-samples.
[0129] For example, the acquisition unit 301 can be used to directly acquire the image samples to be identified uploaded by the user through the terminal, so as to obtain the image sample set to be identified, or the ACG content can be acquired from the content database, and the image samples can be extracted from the ACG content as the image samples to be identified, so as to obtain the image sample set to be identified, or the original image can be acquired on the network, and the ACG content image can be screened out from the original image, and the ACG content image can be sent to the review server for review, and the ACG content image can be annotated with the review result as the image tag, and the ACG content image annotated with the image tag can be used as the image sample to be identified, so as to obtain the image sample set to be identified, or when the number of image samples to be identified in the image sample set to be identified is large, an image recognition request can also be received, and the image recognition request carries the storage address of the image sample to be identified, and the image sample to be identified is acquired based on the storage address, so as to obtain the image sample set to be identified. The image sample to be identified is divided into a preset number of image regions, and the area of each image region is the same. Each image region in the image sample to be identified is divided, so as to obtain a preset number of image sub-samples.
[0130] (2) Combination unit 302;
[0131] The combining unit 302 is used to randomly combine the image sub-samples to obtain a target image sample corresponding to the image sample to be identified.
[0132] For example, the combination unit 302 can be specifically used to directly randomly splice the segmented image sub-samples to obtain a target image sample corresponding to the image sample to be identified, or the image sub-samples can be numbered, and based on the numbers, the image sub-samples can be randomly synthesized into an image sample, and the spliced image sample can be used as the target image sample.
[0133] (3) a first extraction unit 303;
[0134] The first extraction unit 303 is used to extract features of the target image sample using a preset image recognition model to obtain global image features of the image sample to be recognized;
[0135] For example, the first extraction unit 303 can be specifically used to use a preset image recognition model to extract features from a target image sample to obtain sample image features, perform channel conversion on the sample image features to obtain a plurality of converted sample image features, extract associated features from the converted sample image features, and determine the attention weight of the converted sample image sample based on the associated features, weight the converted sample image features based on the attention weight to obtain weighted sample image features, identify the feature values of each pixel of the image sample to be identified in the weighted sample image features, filter out the target feature values from the feature values, and fuse the target feature values of each pixel to obtain the global image features of the image sample to be identified.
[0136] (4) a second extraction unit 304;
[0137] The second extraction unit 304 is used to extract features from the image subsamples using a preset image recognition model to obtain local image features of the image samples to be recognized.
[0138] For example, the second extraction unit 304 can be specifically used to use a preset image recognition model to perform feature extraction on image subsamples, obtain subsample image features of each image subsample, determine the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type based on the subsample image features, and based on the local prediction probability, screen out the local image features of the image sample to be identified from the subsample image features.
[0139] (5) convergence unit 305;
[0140] The convergence unit 305 is used to converge the preset image recognition model based on the global image features and the local image features to obtain a trained image recognition model.
[0141] For example, the convergence unit 305 can be specifically used to determine the contrast loss information of the image sample to be identified based on the global image features and the local image features, determine the image loss information of the image to be identified based on the local prediction type corresponding to the global image features and the local image features, fuse the contrast loss information and the image loss information, and converge the preset image recognition model based on the fused loss information to obtain the trained image recognition model.
[0142] Optionally, in some embodiments, the data processing device may further include an identification unit 306, such as Fig. 9 As shown, the specific details can be as follows:
[0143] The recognition unit 306 is used to recognize the image to be recognized and obtain the image type of the image to be recognized.
[0144] For example, the recognition unit 306 can be specifically used to obtain an image to be recognized, use the global network of the trained image recognition model to extract features of the image to be recognized, obtain image features of the image to be recognized, and determine the image type of the image to be recognized based on the image features.
[0145] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0146] As can be seen from the above, in the embodiment of the present application, after the acquisition unit 301 acquires a set of image samples to be identified and divides each image to be identified in the set of image samples to be identified into a preset number of image sub-samples, the combination unit 302 randomly combines the image sub-samples to obtain a target image sample corresponding to the image sample to be identified, and then the first extraction unit 303 uses a preset image recognition model to extract features from the target image sample to obtain the global image features of the image sample to be identified, and then the second extraction unit 304 uses a preset image recognition model to extract features from the image sub-samples to obtain the local image features of the image sample to be identified, and the convergence unit 305 converges the preset image recognition model based on the global image features and the local image features to obtain the trained image recognition model; because the scheme can randomly divide and combine the images to be identified, reducing the dependence on the object structure information, so that the image features can be considered from the granularity of the area to be screened, and in addition, by converging the preset image recognition model through the global image features and the local image features, the recall of the target image can be guaranteed under the premise of low misjudgment of the normal image, thereby improving the accuracy of image recognition.
[0147] The embodiment of the present invention further provides an electronic device, such as Fig.10 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:
[0148] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Fig.10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0149] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0150] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0151] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0152] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0153] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:
[0154] A set of image samples to be identified is obtained, and each image to be identified in the set of image samples to be identified is divided into a preset number of image sub-samples, the image sub-samples are randomly combined to obtain target image samples corresponding to the image samples to be identified, a preset image recognition model is used to perform feature extraction on the target image samples to obtain global image features of the image samples to be identified, a preset image recognition model is used to perform feature extraction on the image sub-samples to obtain local image features of the image samples to be identified, the preset image recognition model is converged based on the global image features and the local image features to obtain a trained image recognition model.
[0155] For example, the electronic device can directly obtain the image samples to be identified uploaded by the user through the terminal, thereby obtaining a set of image samples to be identified, or can obtain ACG content from the content database, extract image samples from the ACG content as the image samples to be identified, thereby obtaining a set of image samples to be identified, or obtain the original image on the network, filter out the ACG content image from the original image, and send the ACG content image to the review server for review, and use the review result as the image label to annotate the ACG content image, and use the ACG content image annotated with the image label as the image sample to be identified, thereby obtaining a set of image samples to be identified, or, when the number of image samples to be identified in the set of image samples to be identified is large, an image recognition request can also be received, and the image recognition request carries the storage address of the image sample to be identified, and the image sample to be identified is obtained based on the storage address, thereby obtaining a set of image samples to be identified. The image sample to be identified is divided into a preset number of image regions, each of which has the same area, and each image region in the image sample to be identified is divided, thereby obtaining a preset number of image sub-samples. Directly randomly splice the segmented image subsamples to obtain a target image sample corresponding to the image sample to be identified, or the image subsamples can be numbered, and based on the number, the image subsamples are randomly synthesized into an image sample, and the spliced image sample is used as the target image sample. Use a preset image recognition model to extract features of the target image sample to obtain sample image features, perform channel conversion on the sample image features to obtain multiple converted sample image features, extract associated features from the converted sample image features, and determine the attention weight of the converted sample image samples based on the associated features, and weight the converted sample image features based on the attention weight to obtain weighted sample image features, identify the feature value of each pixel of the image sample to be identified in the weighted sample image features, filter out the target feature value from the feature value, and fuse the target feature value of each pixel to obtain the global image feature of the image sample to be identified. The preset image recognition model is used to extract features from the image subsamples to obtain the subsample image features of each image subsample. According to the subsample image features, the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type are determined. Based on the local prediction probability, the local image features of the image sample to be identified are screened out from the subsample image features. According to the global image features and the local image features, the contrast loss information of the image sample to be identified is determined. Based on the local prediction type corresponding to the global image features and the local image features, the image loss information of the image to be identified is determined. The contrast loss information and the image loss information are fused, and the preset image recognition model is converged based on the fused loss information to obtain the trained image recognition model.
[0156] The specific implementation of the above operations can be found in the previous embodiments and will not be described in detail here.
[0157] From the above, it can be seen that after obtaining a set of image samples to be identified and dividing each image to be identified in the set of image samples to be identified into a preset number of image sub-samples, the embodiment of the present application randomly combines the image sub-samples to obtain a target image sample corresponding to the image sample to be identified, and then uses a preset image recognition model to extract features from the target image sample to obtain the global image features of the image sample to be identified, and then uses the preset image recognition model to extract features from the image sub-samples to obtain the local image features of the image sample to be identified, and converges the preset image recognition model based on the global image features and the local image features to obtain the trained image recognition model; because the scheme can randomly divide and combine the images to be identified, reducing the dependence on the object structure information, so that the image features can be considered from the granularity of the area to be screened, in addition, by converging the preset image recognition model through global image features and local image features, the recall of the target image can be guaranteed under the premise of low misjudgment of normal images, thereby improving the accuracy of image recognition.
[0158] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0159] To this end, an embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the image recognition methods provided in the embodiments of the present invention. For example, the instructions can execute the following steps:
[0160] A set of image samples to be identified is obtained, and each image to be identified in the set of image samples to be identified is divided into a preset number of image sub-samples, the image sub-samples are randomly combined to obtain target image samples corresponding to the image samples to be identified, a preset image recognition model is used to perform feature extraction on the target image samples to obtain global image features of the image samples to be identified, a preset image recognition model is used to perform feature extraction on the image sub-samples to obtain local image features of the image samples to be identified, the preset image recognition model is converged based on the global image features and the local image features to obtain a trained image recognition model.
[0161] For example, the image samples to be identified uploaded by the user through the terminal are obtained to obtain a set of image samples to be identified, or the ACG content can be obtained from the content database, and the image samples can be extracted from the ACG content as the image samples to be identified, so as to obtain a set of image samples to be identified, or the original image can be obtained on the network, the ACG content image can be screened out from the original image, and the ACG content image can be sent to the review server for review, and the ACG content image can be annotated with the review result as the image tag, and the ACG content image annotated with the image tag can be used as the image sample to be identified, so as to obtain a set of image samples to be identified, or when the number of image samples to be identified in the set of image samples to be identified is large, an image recognition request can also be received, and the image recognition request carries the storage address of the image sample to be identified, and the image sample to be identified is obtained based on the storage address, so as to obtain a set of image samples to be identified. The image sample to be identified is divided into a preset number of image regions, each of which has the same area, and each image region in the image sample to be identified is divided to obtain a preset number of image sub-samples. Directly randomly splice the segmented image subsamples to obtain a target image sample corresponding to the image sample to be identified, or the image subsamples can be numbered, and based on the number, the image subsamples are randomly synthesized into an image sample, and the spliced image sample is used as the target image sample. Use a preset image recognition model to extract features of the target image sample to obtain sample image features, perform channel conversion on the sample image features to obtain multiple converted sample image features, extract associated features from the converted sample image features, and determine the attention weight of the converted sample image samples based on the associated features, and weight the converted sample image features based on the attention weight to obtain weighted sample image features, identify the feature value of each pixel of the image sample to be identified in the weighted sample image features, filter out the target feature value from the feature value, and fuse the target feature value of each pixel to obtain the global image feature of the image sample to be identified. The preset image recognition model is used to extract features from the image subsamples to obtain the subsample image features of each image subsample. According to the subsample image features, the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type are determined. Based on the local prediction probability, the local image features of the image sample to be identified are screened out from the subsample image features. According to the global image features and the local image features, the contrast loss information of the image sample to be identified is determined. Based on the local prediction type corresponding to the global image features and the local image features, the image loss information of the image to be identified is determined. The contrast loss information and the image loss information are fused, and the preset image recognition model is converged based on the fused loss information to obtain the trained image recognition model.
[0162] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0163] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0164] Since the instructions stored in the computer-readable storage medium can execute the steps in any data processing method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any data processing method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0165] According to one aspect of the present application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in various optional implementations of the above-mentioned data processing, image recognition, or ACG content review.
[0166] The above is a detailed introduction to a data processing method, device, electronic device and computer-readable storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A data processing method, It is characterized in that include: Acquire a set of image samples to be identified, and divide each image sample to be identified in the set of image samples to be identified into a preset number of image subsamples; Randomly combining the image subsamples to obtain a target image sample corresponding to the image sample to be identified; Using a preset image recognition model to extract features of the target image sample to obtain global image features of the image sample to be recognized; Using the preset image recognition model to extract features from the image subsamples, to obtain subsample image features of each of the image subsamples; Determining, according to the sub-sample image features, a local prediction type of the image sample to be identified and a local prediction probability corresponding to the local prediction type; Based on the local prediction probability, screening out the local image features of the image sample to be identified from the sub-sample image features; The preset image recognition model is converged based on the global image features and the local image features to obtain a trained image recognition model.
2. The data processing method according to claim 1, It is characterized in that The step of extracting features from the target image sample using a preset image recognition model to obtain global image features of the image sample to be recognized includes: Using a preset image recognition model to extract features from the target image sample to obtain sample image features; Performing channel conversion on the sample image features to obtain a plurality of converted sample image features; The converted sample image features are fused to obtain the global image features of the image sample to be identified.
3. The data processing method according to claim 2, It is characterized in that The step of fusing the converted sample image features to obtain the global image features of the image sample to be identified includes: Extracting associated features from the converted sample image features, and determining attention weights of the converted sample image features based on the associated features; Based on the attention weight, weighting the converted sample image features to obtain weighted sample image features; Identifying a feature value of each pixel of the to-be-identified image sample from the weighted sample image features; A target feature value is screened out from the feature values, and the target feature value of each pixel is fused to obtain a global image feature of the image sample to be identified.
4. The data processing method according to claim 1, It is characterized in that The step of converging the preset image recognition model based on the global image features and the local image features to obtain a trained image recognition model includes: Determining contrast loss information of the image sample to be identified according to the global image features and the local image features; Determining image loss information of the image sample to be identified based on the global image feature and the local prediction type corresponding to the local image feature; The contrast loss information and the image loss information are fused, and the preset image recognition model is converged based on the fused loss information to obtain a trained image recognition model.
5. The data processing method according to claim 4, It is characterized in that The determining, according to the global image features and the local image features, the contrast loss information of the image sample to be identified includes: Compressing the global image features and the local image features to the same dimension to obtain compressed global image features and compressed local image features; Extracting feature values corresponding to the same pixel from the compressed global image features and the compressed local image features respectively; Based on the characteristic value, the pixel loss information corresponding to the pixel is calculated, and the pixel loss information is fused to obtain the contrast loss information of the image sample to be identified.
6. The data processing method according to claim 4, It is characterized in that The determining, based on the global image feature and the local prediction type corresponding to the local image feature, the image loss information of the image sample to be identified includes: Determining the global prediction type of the image sample to be identified according to the global image feature; Based on the global prediction type, calculating the global image loss information of the image sample to be identified, and according to the local prediction type, calculating the local image loss information of the image sample to be identified; The global image loss information and the local loss information are fused to obtain the image loss information of the image sample to be identified.
7. A data processing device, It is characterized in that include: An acquisition unit, used for acquiring a set of image samples to be identified, and dividing each image sample to be identified in the set of image samples to be identified into a preset number of image subsamples; A combining unit, used for randomly combining the image subsamples to obtain a target image sample corresponding to the image sample to be identified; A first extraction unit, configured to extract features of the target image sample using a preset image recognition model to obtain global image features of the image sample to be recognized; A second extraction unit is configured to extract features from the image subsamples using the preset image recognition model to obtain subsample image features of each of the image subsamples; determine the local prediction type of the image sample to be identified and the local prediction probability corresponding to the local prediction type according to the subsample image features; and select the local image features of the image sample to be identified from the subsample image features based on the local prediction probability; A convergence unit is used to converge the preset image recognition model based on the global image features and the local image features to obtain a trained image recognition model.
8. An electronic device, It is characterized in that It comprises a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to execute the steps in the data processing method according to any one of claims 1 to 6.
9. A computer program product comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the steps in the data processing method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the data processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Medical image segmentation method and device and storage medium
CN109872306A
Face recognition model training method and device and computer readable storage medium
CN109934197A
Image recognition model training method and device and image recognition method and device
CN111680701A
Image recognition method and device, electronic equipment and computer readable storage medium
CN113255617A
Method and system for training zero sample classification model, electronic equipment and storage medium
CN113298096A
