Data processing method, and device and computer-readable storage medium

By generating adversarial sample images and using them to optimize training, the problem of insufficient diversity of training data in the existing technology is solved, the recognition accuracy and generalization of the image recognition model are improved, and the anti-interference ability of the model is enhanced.

WO2024179575A1PCT designated stage expired Publication Date: 2024-09-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Application Number
PCT/CN2024/079587
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-02
Filing Date
2024-03-01
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

In the existing technology, the image recognition model amplifies the training data through random noise, which cannot improve the category label recognition accuracy and generalization of the image recognition model, and the diversity of the training data is insufficient.

Method used

By generating adversarial sample images, the wrong category labels and adversarial sample images are used to optimize the training model and increase the diversity of the training set, thereby improving the recognition accuracy and generalization of the image recognition model.

Benefits of technology

The category label recognition accuracy and generalization of the image recognition model are improved. The optimized and trained model can more accurately identify adversarial sample images, which enhances the model's anti-interference ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024079587_06092024_PF_FP
    Figure CN2024079587_06092024_PF_FP
Patent Text Reader

Abstract

Provided are a data processing method, and a device and a computer-readable storage medium. The method comprises: inputting a sampling sample image in A sample image sets and an error category label among A category labels into an image recognition model, so as to generate a first probability vector of the sampling sample image in respect of the A category labels, wherein the error category label is different from a category label corresponding to a sample image set to which the sampling sample image belongs; and adjusting the sampling sample image according to a first probability element, which indicates the error category label, among A probability elements in the first probability vector, so as to obtain an adversarial sample image corresponding to the sampling sample image, wherein a category prediction result, which is obtained by means of the image recognition model performing category prediction on the adversarial sample image, is the error category label.
Need to check novelty before this filing date? Find Prior Art

Description

Data processing method, device and computer-readable storage medium

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 2, 2023, with application number 202310237098.1 and application name “A Data Processing Method, Device and Computer-Readable Storage Medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of Internet technology, and in particular to a data processing method, device, and computer-readable storage medium. Background Art

[0003] In business scenarios such as image recognition, image classification, image recommendation, and video attribute recognition, it is crucial to correctly determine the category labels of images or video frames (i.e., correctly identify the categories of images or video frames).

[0004] Mainstream image recognition methods are primarily based on machine learning. This involves training an initial image recognition model using a training sample set to generate an image recognition model. Obviously, training data can determine the image recognition model's accuracy in class label recognition and its generalizability. Prior art methods for enhancing training data often involve directly superimposing randomly generated noise onto the training sample images. Obviously, the randomly generated noise and the training sample images are independent data. Therefore, the noise features in the training sample images superimposed with random noise are independent of the image's inherent features. In this case, the image recognition model can easily distinguish between the noise features and the image's inherent features. Therefore, using prior art methods to augment training samples only increases the amount of training data, but does not increase its diversity. Consequently, further training of the image recognition model using prior art methods using augmented training samples does not improve the trained image recognition model's accuracy in class label recognition and its generalizability.

[0005] Summary of the Invention

[0006] The embodiments of the present application provide a data processing method, device, and computer-readable storage medium, which can improve the accuracy and generalization of category label recognition.

[0007] On the one hand, an embodiment of the present application provides a data processing method, including:

[0008] Obtaining A sample image sets and an image recognition model, where A is a positive integer greater than 1, the A sample image sets each corresponding to one of A different category labels, the image recognition model being pre-trained based on the A sample image sets, and the A category labels including error category labels;

[0009] Obtaining a sample sample image from the A sample image sets, inputting the sample sample image and the erroneous category label into the image recognition model to generate a first probability vector for the sample sample image with respect to the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sample sample image belongs; the first probability vector includes A probability elements, each of the A probability elements referring to one of the A category labels, and each probability element is used to represent a probability that the sample sample image belongs to the referred category label;

[0010] Among the A probability elements in the first probability vector, a first probability element representing the incorrect category label is obtained. Based on the first probability element, the sampled sample image is adjusted to obtain an adversarial sample image corresponding to the sampled sample image. The category prediction result obtained by the image recognition model for category prediction of the adversarial sample image is the incorrect category label.

[0011] On the one hand, an embodiment of the present application provides a data processing method, including:

[0012] Acquire a target image and input the target image into an image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize the image recognition model according to the mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels respectively, and the A sample image sets include collected sample images; the correct category label belongs to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training the A sample image sets; the adversarial sample image is obtained by referring to the wrong category label in the A probability elements in the first probability vector The first probability vector is obtained by adjusting the sampling sample image by the first probability element of the signature, the first probability vector is generated by the image recognition model for the sampling sample image, the incorrect category label is different from the category label corresponding to the sample image set to which the sampling sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sampling sample image belongs; the first probability vector includes A probability elements, the A probability elements respectively refer to one of the A category labels, and one probability element is used to represent the probability that the sampling sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the incorrect category label;

[0013] Generating a target probability vector of the target image for the A category labels through the image recognition optimization model;

[0014] The category label corresponding to the maximum probability element in the target probability vector is determined as the category prediction result of the target image.

[0015] In one aspect, an embodiment of the present application provides a data processing device, including:

[0016] a data acquisition module, configured to acquire A sample image sets and an image recognition model, where A is a positive integer greater than 1, the A sample image sets each corresponding to one of A different category labels, the image recognition model being pre-trained based on the A sample image sets, and the A category labels including error category labels;

[0017] a first input module, configured to obtain a sample sample image from the A sample image sets, and input the sample sample image and the erroneous category label into the image recognition model to generate a first probability vector for the sample sample image with respect to the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sample sample image belongs; the first probability vector includes A probability elements, each of the A probability elements referring to one of the A category labels, and each probability element is used to represent a probability that the sample sample image belongs to the referred category label;

[0018] A first adjustment module is configured to obtain a first probability element representing the incorrect category label from the A probability elements in the first probability vector, and adjust the sampled sample image based on the first probability element to obtain an adversarial sample image corresponding to the sampled sample image, wherein a category prediction result obtained by performing category prediction on the adversarial sample image by the image recognition model is the incorrect category label.

[0019] Among them, the first adjustment module is specifically used to generate a negative probability element corresponding to the first probability element, sum the negative probability element and the maximum probability element in the first probability vector, obtain the label loss value of the sampling sample image for the wrong category label, and adjust the sampling sample image according to the label loss value to obtain the adversarial sample image corresponding to the sampling sample image.

[0020] Among them, the first adjustment module is used to adjust the sampling sample image according to the label loss value to obtain the adversarial sample image corresponding to the sampling sample image. It is specifically used to generate an initial gradient value for the sampling sample image according to the label loss value, obtain the numerical sign of the initial gradient value, generate a symbol unit value corresponding to the initial gradient value according to the numerical sign, multiply the initial learning rate and the symbol unit value to obtain a first value to be cropped, crop the first value to be cropped through a first cropping interval generated by the attack intensity to obtain a gradient value for adjusting the sampling sample image, perform difference processing on the sampling sample image and the gradient value to obtain a second value to be cropped, crop the second value to be cropped through a second cropping interval generated by the pixel level to obtain an adversarial sample image corresponding to the sampling sample image.

[0021] The first adjustment module includes:

[0022] A first adjustment unit is configured to adjust the sample image according to the first probability element to obtain an initial adversarial sample image corresponding to the sample image;

[0023] A first generating unit is configured to input the erroneous category label and the initial adversarial sample image into the image recognition model, and generate a second probability vector of the initial adversarial sample image for A category labels through the image recognition model;

[0024] A first acquiring unit is configured to acquire a second probability element for the error category label from the A probability elements included in the second probability vector;

[0025] The first adjustment unit is further configured to continue adjusting the initial adversarial sample image according to the second probability element if the second probability element does not satisfy the boundary constraint condition, or if the category prediction result obtained by performing category prediction on the adversarial sample image is not the wrong category label;

[0026] The first acquisition unit is further configured to determine the initial adversarial sample image as the adversarial sample image corresponding to the sampling sample image if the second probability element satisfies a boundary constraint condition and the category prediction result obtained by performing category prediction on the adversarial sample image is the incorrect category label; and when the category prediction result is the incorrect category label, the second probability element is the maximum value of the A probability elements contained in the second probability vector.

[0027] The first acquisition unit is further configured to compare the second probability element with a probability constraint value; the probability constraint value is the inverse of A;

[0028] The first acquiring unit is further configured to determine that the second probability element does not satisfy a boundary constraint condition if the second probability element is less than the probability constraint value;

[0029] The first acquiring unit is further configured to determine that the second probability element satisfies a boundary constraint condition if the second probability element is equal to or greater than the probability constraint value.

[0030] The data processing device further includes:

[0031] A second input module is configured to input the A sample image sets, the A category labels, the correct category label, and the adversarial sample image into the image recognition model; the correct category label refers to the category label corresponding to the sample image set to which the sample image belongs;

[0032] The second input module is further configured to generate, through the image recognition model, first predicted categories corresponding to the A sample image sets and second predicted categories corresponding to the adversarial sample images;

[0033] A second adjustment module is used to generate a first loss value based on the first predicted category and the A category labels, generate a second loss value based on the second predicted category and the correct category label, and adjust the parameters in the image recognition model according to the first loss value and the second loss value to obtain the image recognition optimization model; the category prediction result obtained by the image recognition optimization model for performing category prediction on the adversarial sample image is the correct category label.

[0034] The A sample image sets include a sample image set Cb; b is a positive integer and is less than or equal to A; the first input module includes:

[0035] A first determining unit is configured to determine a sampling ratio, and perform sampling processing on the sample images in the sample image set Cb according to the sampling ratio to obtain sampled sample images;

[0036] The second acquiring unit is configured to acquire, from the A category labels, a category label that is different from the category label of the sample image set Cb, and determine the acquired category label as an erroneous category label.

[0037] The data acquisition module includes:

[0038] A third acquisition unit is used to acquire A sample image sets, and input A category labels and the A sample image sets into the image recognition initial model respectively;

[0039] A second generating unit is configured to generate predicted initial categories corresponding to the A sample image sets respectively through an image recognition initial model;

[0040] A second determining unit is configured to determine the category loss values ​​corresponding to the A sample image sets respectively according to the predicted initial category and the A category labels;

[0041] A third determining unit is used to determine a total loss value corresponding to the initial image recognition model according to the category loss values ​​corresponding to the A sample image sets;

[0042] The second adjustment unit is used to adjust the parameters in the initial image recognition model according to the total loss value to obtain an image recognition model; the category prediction result obtained by the image recognition model for the sample image set Cb is the category label of the sample image set Cb; the A sample image sets include the sample image set Cb; b is a positive integer and b is less than or equal to A.

[0043] The third acquisition unit includes:

[0044] An image acquisition subunit is configured to acquire A original image sets and input each of the A original image sets into an object detection model; the A original image sets each correspond to one of A different category information; the A original image sets include an original image set Db; the original image set Db includes an original image Ef; f is a positive integer, and f is less than or equal to the total number of original images in the original image set Db;

[0045] The second determining subunit is used to determine the region coordinates of the key region in the original image Ef through the object detection model, and generate a sample image to be labeled corresponding to the original image Ef according to the region coordinates;

[0046] The third determining subunit is configured to determine the sample image to be labeled corresponding to each original image in the original image set Db as the sample image set to be labeled;

[0047] The fourth determining subunit is configured to generate a category label Hb according to the category information corresponding to the original image set Db, and determine the set of sample images to be labeled that are labeled with the category label Hb as the sample image set Cb.

[0048] The second determining subunit includes:

[0049] A third processing sub-unit is configured to generate an initial detection frame including the key region according to the region coordinates, and to expand the initial detection frame to obtain a detection frame including the target object; the key region belongs to the target object;

[0050] A fourth processing subunit is configured to obtain, in the detection frame, an image to be scaled including the target object, obtain a first image size, and scale the image to be scaled according to the first image size to obtain an image to be cropped;

[0051] The fifth processing subunit is configured to obtain a second image size, and perform cropping processing on the image to be cropped according to the second image size to obtain a sample image to be labeled corresponding to the original image Ef; the second image size is smaller than the first image size.

[0052] In one aspect, an embodiment of the present application provides a data processing device, including:

[0053] An image acquisition module is used to acquire a target image and input the target image into an image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize and train the image recognition model based on a mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels, and the A sample image sets include collected sample images; the correct category labels belong to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training the A sample image sets; the adversarial sample images are obtained by referring to the wrong category labels in the A probability elements in the first probability vector The first probability element of the erroneous category label is obtained by adjusting the sample sample image, the first probability vector is generated by the image recognition model for the sample sample image, the erroneous category label is different from the category label corresponding to the sample image set to which the sample sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sample sample image belongs; the first probability vector includes A probability elements, the A probability elements respectively refer to one of the A category labels, and one probability element is used to represent the probability that the sample sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the erroneous category label;

[0054] A vector generation module is used to generate a target probability vector for a target image with respect to A category labels through an image recognition optimization model;

[0055] The category determination module is used to determine the category label corresponding to the maximum probability element in the target probability vector as the category prediction result of the target image.

[0056] On one hand, the present application provides a computer device, including: a processor, a memory, and a network interface;

[0057] The above-mentioned processor is connected to the above-mentioned memory and the above-mentioned network interface, wherein the above-mentioned network interface is used to provide data communication function, the above-mentioned memory is used to store computer programs, and the above-mentioned processor is used to call the above-mentioned computer program so that the computer device executes the method in the embodiment of the present application.

[0058] On one hand, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is suitable for being loaded by a processor and executing the method in the embodiment of the present application.

[0059] On the one hand, an embodiment of the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method in the embodiment of the present application.

[0060] In an embodiment of the present application, a computer device can obtain A sample image sets and an image recognition model; wherein the A sample image sets respectively correspond to one of A different category labels, and the image recognition model is pre-trained based on the A sample image sets, so the image recognition model can accurately determine the category labels of the sample images in the A sample image sets; further, the computer device obtains a sampled sample image from the A sample image sets, and inputs the wrong category label and the sampled sample image into the image recognition model, wherein the wrong category label belongs to the A category labels, and the wrong category label is different from the category label corresponding to the sample image set to which the sampled sample image belongs; the image recognition model can generate a first probability vector for the sampled sample image for the A category labels, and the first probability vector includes A probability elements, and the A probability elements respectively refer to one of the A category labels. A probability element is used to characterize the probability that the sampled sample image belongs to the referred category label; since the image recognition model can accurately determine the category labels of the sample images in the A sample image set, the probability element referring to the correct category label is the largest in the first probability vector, or in other words, the probability element referring to the correct category label is much larger than the first probability element referring to the wrong category label, and the correct category label refers to the category label corresponding to the sample image set to which the sampled sample image belongs; further, according to the first probability element, the computer device can adjust the sampled sample image to obtain an adversarial sample image corresponding to the sampled sample image, wherein the category prediction result obtained by the image recognition model for category prediction of the adversarial sample image is the wrong category label, that is, by adjusting the sampled sample image, the image recognition model can incorrectly determine the category label of the adversarial sample image. From the above, it can be seen that an embodiment of the present application proposes a method for generating adversarial sample images. Through this method, adversarial sample images that are incorrectly recognized by an image recognition model can be generated. The adversarial sample images can improve the sample diversity of the training set used to optimize the training of the image recognition model. Through the training set with sample diversity, the optimization training accuracy of the image recognition model can be improved, and then the category label recognition accuracy and recognition generalization of the optimized trained image recognition model can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0062] FIG1 is a schematic diagram of a system architecture provided by an embodiment of the present application;

[0063] FIG2a is a schematic diagram of a data processing scenario provided in an embodiment of the present application;

[0064] FIG2b is a second schematic diagram of a data processing scenario provided by an embodiment of the present application;

[0065] FIG3 is a flow chart of a data processing method according to an embodiment of the present application;

[0066] FIG4 is a schematic diagram of a classification boundary surface trained with clean sample data provided by an embodiment of the present application;

[0067] FIG5 is a schematic diagram of a classification boundary surface trained by first mixed sample data provided by an embodiment of the present application;

[0068] FIG6 is a schematic diagram of a classification boundary surface trained by second mixed sample data provided by an embodiment of the present application;

[0069] FIG7 is a second flow chart of a data processing method provided in an embodiment of the present application;

[0070] FIG8 is a third flow chart of a data processing method provided in an embodiment of the present application;

[0071] FIG9 is a first structural diagram of a data processing device provided in an embodiment of the present application;

[0072] FIG10 is a second structural diagram of a data processing device provided in an embodiment of the present application;

[0073] FIG11 is a schematic structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0075] To facilitate understanding, we first provide a brief explanation of some nouns:

[0076] Artificial Intelligence (AI) refers to the theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. AI also involves studying the design principles and implementation methods of various intelligent machines, enabling them to possess the capabilities of perception, reasoning, and decision-making.

[0077] Artificial intelligence (AI) technology is a comprehensive discipline encompassing a wide range of fields, encompassing both hardware and software technologies. Foundational AI technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, speech processing, natural language processing, as well as machine learning / deep learning, autonomous driving, and smart transportation.

[0078] Computer vision technology (CV) is a science that studies how to make machines "see". To put it more specifically, it refers to machine vision that uses cameras and computers to replace human eyes to identify and measure targets, and further performs graphic processing to make computer processing into images that are 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 generally includes image processing, image recognition, image semantic understanding, image retrieval, optical character recognition (OCR), video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous positioning and mapping, autonomous driving, smart transportation and other technologies. In an embodiment of the present application, computer vision technology can be used to identify category labels in images (such as people, cats, dogs, or real people, paper people, mold people, etc.).

[0079] Machine Learning (ML) is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithmic complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills, and reorganize existing knowledge structures to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and self-learning techniques. In the embodiments of the present application, the image recognition model and the object detection model are both AI models based on machine learning. The image recognition model can be used to identify and process images, and the object detection model can be used to detect key areas of target objects in images.

[0080] Please refer to Figure 1, which is a schematic diagram of a system architecture provided by an embodiment of the present application. As shown in Figure 1, the system may include a service server 100 and a terminal device cluster. The terminal device cluster may include: terminal device 200a, terminal device 200b, terminal device 200c, ..., terminal device 200n. It is understood that the above system may include one or more terminal devices, and this application does not limit the number of terminal devices.

[0081] Among them, there can be communication connections between terminal device clusters, for example, there is a communication connection between terminal device 200a and terminal device 200b, and there is a communication connection between terminal device 200a and terminal device 200c. At the same time, any terminal device in the terminal device cluster can have a communication connection with the business server 100, for example, there is a communication connection between terminal device 200a and business server 100. The above-mentioned communication connection is not limited to the connection method, and can be directly or indirectly connected through wired communication, directly or indirectly connected through wireless communication, or through other methods, and this application does not impose any restrictions on this.

[0082] It should be understood that each terminal device in the terminal device cluster shown in FIG1 may be installed with an application client. When the application client is running in each terminal device, it can respectively exchange data with the service server 100 shown in FIG1, i.e., the aforementioned communication connection. The application client may be a video application, live broadcast application, social application, instant messaging application, game application, music application, shopping application, novel application, browser, or other application client with target image recognition function.

[0083] The application client can be a standalone client or an embedded sub-client integrated into a client (e.g., a social client, an educational client, a multimedia client, etc.), without limitation. Taking a shopping application as an example, the business server 100 can be a collection of multiple servers, including a backend server corresponding to the shopping application and a data processing server. Therefore, each terminal device can communicate with the business server 100 via the application client corresponding to the shopping application. For example, each terminal device can upload a target image to the business server 100 via the application client of the shopping application, and the business server 100 can then determine the category label of the target image.

[0084] It is understandable that in the specific implementation of this application, related data such as user information (such as target images) is involved. When the embodiments in this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0085] To facilitate subsequent understanding and explanation, in the embodiment of the present application, a terminal device can be selected from the terminal device cluster shown in FIG1 as a target terminal device, for example, terminal device 200a is selected as the target terminal device. Upon acquiring an image recognition model and receiving a model optimization instruction for the image recognition model, terminal device 200a can send a model optimization request for the image recognition model to the service server 100 via the application client. The image recognition model refers to a neural network model used to recognize images and determine image category information.

[0086] Furthermore, after the business server 100 receives the model optimization request sent by the terminal device 200a, the business server 100 can obtain A sample image sets and an image recognition model, wherein the A sample image sets are multiple sample image sets, and the A sample image sets correspond to different category labels respectively. Therefore, the number of category labels can also be A, that is, the A sample image sets correspond to one of the A different category labels. It can be understood that a category label is used to indicate a category information, so the category information corresponding to the A sample image sets is different from each other. The embodiment of the present application does not limit the category information and can be set according to the actual application scenario. Optionally, the category information can be object information. In this case, the object information corresponding to the A sample image sets is different from each other. For example, the object information of the first sample image set in the A sample image set is a cat (that is, each sample image in the first sample image set is related to a cat), and the object information of the second sample image set in the A sample image set is a dog (that is, each sample image in the second sample image set is related to a dog). Optionally, the category information may be object carrier information. In this case, the object information corresponding to each of the A sample image sets may be the same or different, but the object carrier information corresponding to each of the A sample image sets is different from each other. For example, in a key feature recognition scenario, the object carrier information of the third sample image set in the A sample image set is a copied screen, the object carrier information of the fourth sample image set in the A sample image set is a key feature mold, and the object carrier information of the fifth sample image set in the A sample image set is a piece of paper.

[0087] The embodiment of the present application does not limit the manner in which the business server 100 obtains A sample image sets and an image recognition model. It can be set according to the actual application scenario. For example, the model optimization request sent by the terminal device 200a carries A sample image sets or an image recognition model, or carries A sample image sets and an image recognition model at the same time, such as obtaining A sample image sets and an image recognition model from a database, such as obtaining A sample image sets and an image recognition model from a blockchain network. In addition, the image recognition model is pre-trained based on A sample image sets. The generation process of the image recognition model is not described here. Please refer to the description of step S101 in the embodiment corresponding to Figure 3 below.

[0088] For ease of description and understanding, the embodiment of the present application is described using the sample image set C1 in the A sample image set as an example. It can be understood that the processing process of the remaining sample image sets in the A sample image set is the same as the processing process of the sample image set C1 described below. The business server 100 obtains the sample sample images in the sample image set C1 (which can be obtained randomly or by polling), and further obtains the error category label from the A category labels. The error category label belongs to the category label in the A category label other than the category label of the sample image set C1 (which can be called the remaining category label). Specifically, the category label randomly obtained from the remaining category label can be determined as the error category label, for example, the error category label is the category label of the sample image set C2. Further, the error category label and the sample sample image can be input into the image recognition model, wherein the error category label and the sample sample image can be input into the image recognition model as two independent data, and there is a mapping relationship between the error category label and the sample sample image; alternatively, the error category label can be added to the file header or file footer of the sample sample image, and then the sample sample image carrying the error category label can be input into the image recognition model. Furthermore, the business server 100 can generate a first probability vector for the sampled sample image for A category labels through the image recognition model; the first probability vector includes A probability elements, each of which refers to one of the A category labels, and one of the probability elements is used to characterize the probability that the sampled sample image belongs to the category label referred to. It can be understood that the vector dimension of the first probability vector is equal to A, that is, the elements on a vector dimension (also referred to as probability elements in the embodiment of the present application) can characterize the predicted probability value of a category label, that is, the larger the value of a certain probability element, the greater the possibility that the sampled sample image belongs to the category label referred to by the probability element. Therefore, the category label referred to by the probability element with the largest value in the first probability vector can usually be determined as the category prediction result using the sample image. Therefore, in the first probability vector, the business server 100 can obtain the first probability element that refers to the wrong category label. Further, according to the first probability element, the sampled sample image can be adjusted to obtain the adversarial sample image corresponding to the sampled sample image. The image recognition model predicts the adversarial image as an incorrect category label, meaning the image recognition model cannot accurately identify the adversarial image, resulting in an incorrect category classification. For example, if a sample image contains a cat and its category label is a cat label, then by adjusting a sample image with a dog label (i.e., an incorrect category label) to obtain its corresponding adversarial image, the image recognition model optimizer may accurately identify the adversarial image as a cat image, but the image recognition model may mistakenly identify the adversarial image as a dog image.

[0089] Through the above process, the business server 100 can generate adversarial sample images. Subsequently, the image recognition model can be optimized and trained using A sample image sets, correct category labels, and adversarial sample images to obtain an image recognition optimization model. The correct category label refers to the category label of the sample image set C1. It can be understood that since the model loss is calculated by calculating the predicted category label and the correct category label for the adversarial sample image when training the image recognition model, the trained image recognition optimization model can accurately identify the adversarial sample image, and further accurately identify that the predicted category result of the adversarial sample image is the correct category label. Therefore, the image recognition optimization model can have a stronger anti-interference ability.

[0090] Subsequently, the business server 100 can generate a model optimization completion message for the image recognition optimization model and send the model optimization completion message to the terminal device 200a. After the terminal device 200a receives the model optimization completion message sent by the business server 100, it can obtain the image recognition optimization model. The embodiment of the present application does not limit the way in which the terminal device 200a obtains the image optimization recognition model, and can be set according to the actual application scenario. For example, the model optimization completion message carries the image optimization recognition model, for example, the image recognition optimization model is obtained from a database, for example, the image recognition optimization model is obtained from a blockchain network.

[0091] Optionally, if the terminal device 200a locally stores the aforementioned image recognition model and A sample image sets, and has offline computing capabilities, then upon receiving a model optimization instruction for the image recognition model, the terminal device 200a can locally obtain sample images from the sample image set C1 and use the obtained sample images as the sampled sample images. The terminal device 200a then inputs the error category labels and the sampled sample images into the image recognition model. The subsequent processing is the same as that described above and is therefore not further described here.

[0092] It is understandable that the embodiment of the present application assigns an incorrect category label to the sampled sample image, and through the image recognition model, obtains a first probability element indicating the incorrect category label, and adjusts the sampled sample image through the first probability element to obtain an adversarial sample image that can cause the image recognition model to incorrectly predict the category. The embodiment of the present application uses adversarial sample images to amplify and enhance the training samples of the A sample image set (i.e., training data), thereby improving the richness of the sample training set used to optimize the training image recognition model, thereby improving the recognition accuracy of the image recognition optimization model.

[0093] It should be noted that the above-mentioned business server 100, terminal device 200a, terminal device 200b, terminal device 200c..., terminal device 200n can all be blockchain nodes in the blockchain network, and the data described in the full text (such as A sample image sets and image recognition models) can be stored. The storage method can be that the blockchain node generates blocks based on the data and adds the blocks to the blockchain for storage.

[0094] Blockchain is a novel application model of computer technologies, integrating distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. It primarily organizes data in chronological order and encrypts it into a ledger, rendering it tamper-proof and forgery-proof. It also enables data verification, storage, and updates. A blockchain is essentially a decentralized database, in which each node stores an identical blockchain. A blockchain network can categorize nodes into core nodes, data nodes, and light nodes. Core nodes, data nodes, and light nodes collectively constitute blockchain nodes. Core nodes are responsible for consensus across the entire blockchain network; in other words, they serve as consensus nodes within the blockchain network. The process by which transaction data is written to the ledger in a blockchain network involves data nodes or light nodes acquiring transaction data and passing it around the network (in a relay-like fashion) until a consensus node receives the transaction data. The consensus node then packages the transaction data into a block, performs consensus on the block, and writes the transaction data to the ledger after consensus is complete. Here, transaction data of A sample image sets and an image recognition model are used as examples. After reaching a consensus on the transaction data, the business server 100 (blockchain node) generates a block based on the transaction data and stores the block in the blockchain network. As for reading the transaction data (i.e., A sample image sets and an image recognition model), the blockchain node can obtain the block containing the transaction data in the blockchain network, and further obtain the transaction data in the block.

[0095] It is understandable that the method provided in the embodiments of the present application can be executed by a computer device, including but not limited to a terminal device or a business server. Among them, the business 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 basic cloud computing services such as cloud databases, cloud services, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Among them, the terminal device and the business server can be directly or indirectly connected by wired or wireless means, and the embodiments of the present application are not limited here.

[0096] Further, please refer to Figure 2a, which is a schematic diagram of a data processing scenario provided by an embodiment of the present application. The embodiment of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, audio and video, etc. The embodiment of the present application can be applicable to business scenarios such as image search scenarios, image generation scenarios, image recommendation scenarios, image distribution scenarios, and specific business scenarios will not be listed one by one here. Among them, the implementation process of the data processing scenario can be carried out in a business server, or in a terminal device, or interactively in a terminal device and a business server, and there is no restriction here. Among them, the terminal device can be any terminal device in the terminal device cluster of the embodiment corresponding to Figure 1 above, and the business server can be the business server 100 of the embodiment corresponding to Figure 1 above. For the convenience of description and understanding, the embodiment of the present application is described by taking the operation in the business server as an example.

[0097] As shown in FIG2a , the business server 100 can obtain A sample image sets 20a and an image recognition model 20d, where A is a positive integer greater than 1. For ease of description and understanding, the embodiment of the present application uses A as an example of 4, that is, the number of sample image sets is 4, such as the sample image set 201a, the sample image set 202a, the sample image set 203a, and the sample image set 204a shown in FIG2a (the number of sample images contained in the sample image set 201a, the sample image set 202a, the sample image set 203a, and the sample image set 204a can be the same or different). The category information corresponding to each of the four sample image sets is different. For example, the category information of the sample image set 201a shown in FIG2a is radish, the category information of the sample image set 202a is pepper, the category information of the sample image set 203a is pumpkin, and the category information of the sample image set 204a is onion. Therefore, the business server 100 can set different category labels for the above four sample image sets, setting the category label of radish to 0, that is, the category label of sample image set 201a is 0, setting the category label of pepper to 1, that is, the category label of sample image set 202a is 1, setting the category label of pumpkin to 2, that is, the category label of sample image set 203a is 2, and setting the category label of onion to 3, that is, the category label of sample image set 204a is 3.

[0098] It is understood that the examples in this application are for the purpose of description and understanding, using radish, pepper, pumpkin, and onion as examples of category information. In actual application, category information should be set according to the actual scenario. Similarly, the examples in this application are for the purpose of description and understanding, using 0-3 numerical values ​​as examples of category labels. In actual application, category labels should be set according to the actual scenario.

[0099] Furthermore, the service server 100 obtains sample images from each of the four sample image sets. As shown in FIG2a , the service server 100 obtains sample image 201b from sample image set 201a, sample image 202b from sample image set 202a, sample image 203b from sample image set 203a, and sample image 204b from sample image set 204a. This embodiment of the present application does not limit the total number of sample images 201b; the number may be one or more. Similarly, this embodiment of the present application does not limit the total number of sample images 202b, sample images 203b, and sample images 204b; each may be one or more.

[0100] The service server 100 inputs sample image 201b, sample image 202b, sample image 203b, and sample image 204b into image recognition model 20d. Image recognition model 20d is pre-trained based on the aforementioned four sample image sets. It is understood that the service server 100 processes each sample image identically using image recognition model 20d. Therefore, the following description uses one sample image (sample image 201c, shown in FIG. 2a ) as an example. The processing of the remaining sample images can be referred to as the processing of sample image 201c below.

[0101] Sample image 201c and its incorrect category label can be input into image recognition model 20d. As shown in FIG2a , sample image 201c is an image with the category information "radish," meaning that sample image 201c belongs to sample image set 201a. It is understood that the correct category label for sample image 201c is the category label for radish, i.e., 0. FIG2a illustrates the incorrect category label for sample image 201c using the category label for pepper (i.e., 1). (The incorrect category label can be obtained by randomly selecting from peppers, pumpkins, and onions.) It should be noted that the incorrect category label for sample image 201c is randomly generated.

[0102] Furthermore, the business server 100 can generate a first probability vector 201e for the four category labels of the sample image 201c through the image recognition model 20d. It can be understood that the dimension of the first probability vector 201e is the same as the total number of category labels, and the element value on each dimension can represent the predicted probability value of the corresponding category label. Therefore, in Figure 2a, 0.9 on the first dimension of the first probability vector 201e can represent the predicted probability of category label 0, 0.02 on the second dimension can represent the predicted probability of category label 1, and 0.03 on the third dimension can represent the predicted probability of category label 2; 0.05 on the fourth dimension can represent the predicted probability of category label 3. The predicted probabilities on these four dimensions can also be called four probability elements. Through the first probability vector 201e, the image recognition model 20d can determine that the numerical value of the predicted probability referring to category label 0 is the largest, so it can be determined that the category prediction result of the sample image 201c is category label 0, which is different from the wrong category label (i.e., 1) input to the image recognition model 20d. This result occurs because the image recognition model 20d is pre-trained using the sample image set 201a, the sample image set 202a, the sample image set 203a, and the sample image set 204a in FIG2a, and the sample sample image 201c comes from the sample image set 201a. Therefore, the image recognition model 20d identifies the category prediction result of the sample sample image 201c as category label 0.

[0103] Furthermore, the service server 100 can use the image recognition model 20d to obtain a first probability element (0.02, as shown in the example of FIG2a ) in the first probability vector 201e , indicating the incorrect class label (class label 1). The service server 100 can adjust the sample image 201c based on the first probability element to obtain an adversarial sample image corresponding to the sample image 201c.

[0104] Among them, according to the first probability element, the sampling sample image 201c is adjusted to obtain the specific process of the adversarial sample image corresponding to the sampling sample image 201c, which may include: the business server 100 can adjust the sampling sample image 201c according to the first probability element to obtain the initial adversarial sample image corresponding to the sampling sample image 201c. Please refer to Figure 2b, which is a second schematic diagram of a data processing scenario provided by an embodiment of the present application. As shown in Figure 2b, the business server 100 generates a negative probability element corresponding to the first probability element (0.02 as shown in Figure 2a), that is, -0.02 in Figure 2b, and sums the negative probability element and the maximum probability element in the first probability vector 201e (0.9 as shown in Figures 2a and 2b) to obtain the label loss value of the sampling sample image 201c for the wrong category label, that is, 0.88 in Figure 2b. Further, the business server 100 adjusts the sampling sample image 201c according to the label loss value to obtain the initial adversarial sample image 202c corresponding to the sampling sample image 201c. The specific process of adjusting the sample image 201c according to the label loss value to obtain the initial adversarial sample image 202c corresponding to the sample image 201c will not be described in detail in this embodiment of the present application. Please refer to the description of step S103 in the embodiment corresponding to Figure 3 below.

[0105] Referring again to Figure 2b , the service server 100 inputs the incorrect category label (category label 1 as shown in the examples in Figures 2a and 2b ) and the initial adversarial sample image 202c into the image recognition model 20d . The service server 100 can use the image recognition model 20d to generate a second probability vector 202e for the initial adversarial sample image 202c with respect to the aforementioned four category labels. The meaning of the second probability vector 202e is the same as that of the first probability vector 201e , so the meaning of the second probability vector 202e is not explained here. Please refer to the description of the meaning of the first probability vector 201e above.

[0106] Furthermore, service server 100 obtains a second probability element (0.08, as shown in FIG2b ) in second probability vector 202e, indicating the incorrect class label (i.e., class label 1 in the examples shown in FIG2a and FIG2b ). Service server 100 can determine the adversarial example image corresponding to sampled image 201c based on the second probability element. That is, the business server 100 can analyze whether the second probability element is the probability element with the largest value in the second probability vector 202e. If so, the initial adversarial sample image 202c can be determined as the adversarial sample image corresponding to the sampling sample image 201c (that is, at this time the image recognition model 20d can mistakenly identify the category prediction result of the adversarial sample image as the wrong category label 1); if it is analyzed that the second probability element is not the probability element with the largest value in the second probability vector 202e, the initial adversarial sample image 202c will be further adjusted. The purpose of the adjustment is to hope that the image recognition model 20d outputs a probability element referring to the wrong category label in the third probability vector for the adjusted initial adversarial sample image, which becomes larger, until the image recognition model 20d can mistakenly identify the adversarial sample image after multiple rounds of adjustment as the wrong category label 1.

[0107] It is understandable that the category prediction result of the image recognition model 20d for the adversarial sample image is the wrong category label 1, that is, the adversarial sample image is still an image containing radish, but the image recognition model 20d will mistakenly identify the category prediction result of the adversarial sample image as the category label 1 of pepper. Subsequently, the business server 100 can continue to optimize the training of the image recognition model 20d using the correct category label (i.e., the category label 0 of radish) and the adversarial sample image to obtain an optimized image recognition model. It is understandable that the image optimization recognition model (i.e., the optimized and trained image recognition model) can accurately identify the category prediction result of the adversarial sample image as category label 0, i.e., the category label of radish.

[0108] From the above, it can be seen that the embodiment of the present application proposes a method for generating adversarial sample images. Through this method, adversarial sample images that are incorrectly recognized by the image recognition model can be generated. Through the adversarial sample images, the sample diversity of the training set used to optimize the training of the image recognition model can be improved. Through the training set with sample diversity, the optimization training accuracy of the image recognition model can be improved, and then the category label recognition accuracy and recognition generalization of the optimized trained image recognition model can be improved. Moreover, compared with the sampling sample image, the adversarial sample image is an image with strong disturbance (i.e., an image that will cause the image recognition model to incorrectly recognize it), and the image optimization recognition model can overcome the strong disturbance, i.e., the image optimization recognition model can accurately identify the category prediction result of the adversarial sample image as the correct category label (i.e., category label 0) through its stronger anti-interference ability.

[0109] Further, please refer to Figure 3, which is a flow chart of a data processing method provided in an embodiment of the present application. The data processing method can be executed by a business server (for example, the business server 100 shown in Figure 1 above), or by a terminal device (for example, the terminal device 200a shown in Figure 1 above), or by the business server and the terminal device interacting with each other. For ease of understanding, the embodiment of the present application is described by taking the method being executed by a business server as an example. As shown in Figure 3, the data processing method can at least include the following steps S101-S103.

[0110] Step S101, obtain A sample image sets and an image recognition model, where A is a positive integer greater than 1, and the A sample image sets respectively correspond to one of A different category labels. The image recognition model is pre-trained based on the A sample image sets, and the A category labels include error category labels.

[0111] Specifically, the service server obtains A sample image sets, and the category information corresponding to each of the A sample image sets is different. For example, the category information of one sample image set is radish (i.e., each sample image in the sample image set is related to radish), and the category information of another sample image set is chili pepper (i.e., each sample image in the sample image set is related to chili pepper). Therefore, the service server can set a different category label for each sample image set. For example, the category label of radish is set to 0, i.e., the category label of the sample image set with the category information of radish is 0; or the category label of chili pepper is set to 1, i.e., the category label of the sample image set with the category information of chili pepper is 1.

[0112] The business server inputs A sample image sets into the image recognition initial model respectively; generates a predicted initial category corresponding to each sample image set through the image recognition initial model; determines the category loss value corresponding to each sample image set according to the predicted initial category corresponding to each sample image set and the category label corresponding to each sample image set; determines the total loss value corresponding to the image recognition initial model according to the category loss values ​​corresponding to the A sample image sets; adjusts the parameters in the image recognition initial model according to the total loss value to obtain the image recognition model; the image recognition model has the ability to accurately identify the category prediction results of the A sample image sets, such as the image recognition model can accurately identify that the category prediction result of the sample image set with category information of radish is a category label of 0 (the category prediction result can also be understood as the category prediction result for each sample image in the sample image set).

[0113] The embodiments of the present application do not limit the number of sample images in a sample image set; the number may be one or more. It is understood that the category information corresponding to the sample images in the same sample image set is the same, and therefore the category labels corresponding to the sample images in the same sample image set are the same. The embodiments of the present application also do not limit the number of sample image sets; the number may be two or more.

[0114] The category labels in the embodiments of this application refer to labels used to identify category information. The embodiments of this application do not limit the category information and can be set based on the actual application scenario. For example, the category information can be object information, in which case each sample image set contains different object information, such as cat, dog, car, etc. For example, the category information can be object carrier information, in which case each sample image contains different object carrier information, such as mask object, mold object, photograph object, paper object, real object, etc.

[0115] The embodiments of the present application do not limit the model type of the initial image recognition model, and can be composed of any one or more neural networks, such as Convolutional Neural Networks (CNN), Residual Networks (ResNet), Convolutional Neural Networks based on extended channel number learning mechanism (Wide Residual Networks, Wide-ResNet), High-Resolution Net (HRNet), etc.

[0116] The specific process of the business server training the image recognition initial model can be: inputting A sample image sets into the image recognition initial model respectively. It can be understood that the image recognition initial model processes each sample image in the A sample image set in the same way, so the following description takes the first sample image carrying the first category label as an example, and the processing process of the remaining sample images is described below. Among them, the first sample image is any sample image in the A sample image set. If the first sample image belongs to the sample image set C1, the first category label is the category label corresponding to the sample image set C1; if the first sample image belongs to the sample image set C2, the first category label is the category label corresponding to the sample image set C2; other situations are as described above and will not be described one by one. The business server can obtain the first initial probability vector corresponding to the first sample image through the image recognition initial model. The dimension of the first initial probability vector is the same as A (that is, one dimension corresponds to one category label). The element value on each dimension in the first initial probability vector (also called probability element) represents the predicted probability of the corresponding category label, and the sum of the element values ​​on each dimension is 1. The category label corresponding to the largest element value in the first initial probability vector, that is, the predicted initial category corresponding to the first sample image, can be understood that in the initial stage of training, the predicted initial category corresponding to the first sample image may be different from the first category label, so the business server can generate a category loss value corresponding to the first sample image based on the predicted initial category corresponding to the first sample image and the first category label. Through the above process, the business server can obtain the category loss value corresponding to each sample image in the set of A sample images, sum the obtained category loss values, and obtain the total loss value corresponding to the initial image recognition model. Furthermore, the business server adjusts the parameters in the initial image recognition model according to the total loss value to obtain a pre-trained image recognition model, which can accurately identify the category prediction result of each sample image in the set of A sample images. For example, the image recognition model can accurately identify that the category prediction result of the first sample image is the first category label. The embodiment of the present application does not limit the adjustment method of the parameters in the initial image recognition model, and can be set according to the actual application scenario. In addition, the embodiment of the present application does not limit the number of iterations (epochs) of the initial image recognition model, which can be set according to the actual application scenario, nor does it limit the total loss threshold of the model, which can be set according to the actual application scenario.

[0117] Step S102: obtaining a sampling sample image from the A sample image set, inputting the sampling sample image and the erroneous category label into the image recognition model to generate a first probability vector for the sampling sample image for the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sampling sample image belongs; the first probability vector includes A probability elements, each of the A probability elements referring to one of the A category labels, and one of the probability elements is used to represent the probability that the sampling sample image belongs to the referred category label.

[0118] Specifically, a sample image set service server Cb in a sample image set A is used as an example for description, where b is a positive integer and is less than or equal to A. The service server may determine a sampling ratio, and perform sampling processing on the sample images in the sample image set Cb according to the sampling ratio to obtain sampled sample images; and obtain a category label (which may be obtained randomly) from the A category labels that is different from the category label of the sample image set Cb, and determine the obtained category label as an incorrect category label.

[0119] Please refer to Figure 2a again. The service server 100 obtains sample images from the four sample image sets mentioned above. One feasible sampling method is as follows: a sampling ratio is determined, for example, 5%. The service server 100 then randomly samples images from the sample image set 201a to obtain 5% of the sample images in the sample image set 201a, which are then combined into sample image 201b. For example, if there are 10,000 sample images in the sample image set 201a, the number of sample images 201b is 500. The generation process of the sample images corresponding to the other sample image sets (including the sample images 202b, 203b, and 204b in Figure 2a) can be referred to the generation process of the sample image 201b, and will not be repeated here.

[0120] For ease of description and understanding, the sampling sample image 201b in the example of FIG2a of the embodiment of the present application includes a first sampling sample image and a second sampling sample image. It can be understood that the first sampling sample image and the second sampling sample image are both sample images containing radish, so the correct category labels corresponding to the first sampling sample image and the second sampling sample image are both the category label of radish, that is, the category label 0 shown in FIG2a. The sampling sample image 202b in the example of FIG2a of the embodiment of the present application includes a third sampling sample image and a fourth sampling sample image. It can be understood that the third sampling sample image and the fourth sampling sample image are both sample images containing chili peppers, so the correct category labels corresponding to the third sampling sample image and the fourth sampling sample image are both the category label of chili peppers, that is, the category label 1 shown in FIG2a.

[0121] The business server 100 randomly extracts a category label, such as category label 1, from the category label 1, category label 2, and category label 3 shown in FIG2a, and sets it as the incorrect category label for the first sampling sample image. Similarly, the business server 100 randomly extracts a category label, such as category label 2, from the category label 1, category label 2, and category label 3 shown in FIG2a, and sets it as the incorrect category label for the second sampling sample image. The business server 100 randomly extracts a category label, such as category label 2, from the category label 0, category label 2, and category label 3 shown in FIG2a, and sets it as the incorrect category label for the third sampling sample image. Similarly, the business server 100 randomly extracts a category label, such as category label 0, from the category label 0, category label 2, and category label 3 shown in FIG2a, and sets it as the incorrect category label for the fourth sampling sample image.

[0122] It can be understood that the process of setting the error category label for each sampling sample image is the same, so it will not be described here one by one. Please refer to the process of setting the error category label for the first sampling sample image, the second sampling sample image, the third sampling sample image and the fourth sampling sample image mentioned above.

[0123] If, in actual application, the image recognition model is used to identify real objects (such as people), the embodiment of the present application can also set incorrect category labels for the sampled sample images through the following process. For the convenience of description and understanding, A is exemplified as 3, that is, 3 sample image sets, namely sample image set 3a, sample image set 3b and sample image set 3c. The category information of sample image set 3a is a real object, and its category label is 30a; the category information of sample image set 3b is a paper object, and its category label is 30b; the category information of sample image set 3c is a mask object, and its category label is 30c. At this time, sample image set 3b and sample image set 3c can be regarded as attack sample image sets of sample image set 3a.

[0124] The process by which the service server obtains the sample images corresponding to sample image sets 3a, 3b, and 3c is identical to the process described above and will not be further described here. Assume that the sample images in sample image set 3a include the fifth and sixth sample images, the sample images in sample image set 3b include the seventh and eighth sample images, and the sample images in sample image set 3c include the ninth and tenth sample images. The service server 100 randomly extracts a category label, such as category label 30b, from category labels 30b and 30c and sets it as the incorrect category label for the fifth sample image. Similarly, the service server 100 randomly extracts a category label, such as category label 30c, from category labels 30b and 30c and sets it as the incorrect category label for the sixth sample image. The service server sets the incorrect category labels corresponding to the seventh, eighth, ninth, and tenth sample images, respectively, as category label 30a. Therefore, the embodiment of the present application provides two methods for setting error category labels. In actual application, one of the two setting methods can be selected according to actual needs.

[0125] Furthermore, the service server inputs the sample images corresponding to each of the A sample image sets into the image recognition model. It is understood that the image recognition model processes each sample image in the same manner, so please refer to the description of the sample image 201c in the embodiment corresponding to FIG. 2a above.

[0126] It can be understood that the image recognition model can obtain the first probability vector corresponding to each sampling sample image, and each first probability vector includes A probability values ​​(also referred to as probability elements). Since the image recognition model is pre-trained through A sample image sets, the image recognition model can output the correct probability distribution for each sampling sample image (the correct probability distribution indicates that the probability value of the output first probability vector referring to the correct category label is the largest). For ease of understanding, please refer to Figure 2a again. For each sampling sample image in the sampling sample image 201b (including the sampling sample image 201c), the first element of the first probability vector (including the first probability vector 201e shown in Figure 2a) output by the image recognition model 20d (also referred to as a probability element, which is used to refer to the category label 0, and which is used to characterize the probability that the sampling sample image belongs to the referred category label 0) can be infinitely close to 1, and the remaining three elements will be infinitely close to 0. For each sample image in the sample images 202b, the second element of the first probability vector output by the image recognition model 20d can be infinitely close to 1, while the remaining three elements (specifically, the first element, the third element, and the fourth element) are infinitely close to 0. For each sample image in the sample images 203b, the third element of the first probability vector output by the image recognition model 20d can be infinitely close to 1, while the remaining three elements (specifically, the first element, the second element, and the fourth element) are infinitely close to 0. For each sample image in the sample images 204b, the fourth element of the first probability vector output by the image recognition model 20d can be infinitely close to 1, while the remaining three elements (specifically, the first element, the second element, and the fourth element) are infinitely close to 0.

[0127] Step S103: Obtain a first probability element representing the wrong category label from the A probability elements in the first probability vector, adjust the sample image according to the first probability element, and obtain an adversarial sample image corresponding to the sample image. The category prediction result obtained by performing category prediction on the adversarial sample image by the image recognition model is the wrong category label.

[0128] Specifically, the service server adjusts the sampled sample image according to the first probability element to obtain an initial adversarial sample image corresponding to the sampled sample image; the error category label and the initial adversarial sample image are input into the image recognition model, wherein the error category label and the initial adversarial sample image can be input into the image recognition model as two independent data, and there is a mapping relationship between the error category label and the initial adversarial sample image; alternatively, the error category label can be added to the file header or file footer of the initial adversarial sample image, and then the initial adversarial sample image carrying the error category label can be input into the image recognition model. Through the image recognition model, a second probability vector for the initial adversarial sample image with respect to A category labels is generated. The second probability vector also includes A probability elements, each of which refers to one of the A category labels, and each probability element is used to represent the probability that the initial adversarial sample image belongs to the referred category label; in the second probability vector, a second probability element referring to the error category label is obtained, and based on the second probability element, the adversarial sample image corresponding to the sampled sample image is determined. One way to determine the adversarial sample image: the business server can analyze whether the second probability element is the probability element with the largest value in the second probability vector. If so, the initial adversarial sample image can be determined as the adversarial sample image corresponding to the sampling sample image (that is, at this time the image recognition model can incorrectly identify the category prediction result of the adversarial sample image as an incorrect category label); if the analysis shows that the second probability element is not the probability element with the largest value in the second probability vector, the initial adversarial sample image will be further adjusted. The purpose of the adjustment is to hope that the image recognition model outputs a probability element referring to the incorrect category label in the third probability vector for the adjusted initial adversarial sample image, which becomes larger until the image recognition model can incorrectly identify the adversarial sample image after multiple rounds of adjustment as an incorrect category label.

[0129] The specific process of adjusting the sample image according to the first probability element to obtain the initial adversarial sample image corresponding to the sample image may include: generating a negative probability element corresponding to the first probability element, summing the negative probability element and the maximum probability element in the first probability vector to obtain a label loss value for the sample image with respect to the incorrect category label; and adjusting the sample image according to the label loss value to obtain the initial adversarial sample image corresponding to the sample image. If the initial adversarial sample image can be directly used as the adversarial sample image corresponding to the sample image, it can also be understood that the sample image is adjusted according to the label loss value to directly obtain the adversarial sample image corresponding to the sample image.

[0130] The specific process of adjusting the sample image according to the label loss value to obtain the initial adversarial sample image corresponding to the sample image may include: generating an initial gradient value for the sample image according to the label loss value, obtaining the numerical sign of the initial gradient value, and generating a symbol unit value corresponding to the initial gradient value according to the numerical sign; multiplying the initial learning rate and the symbol unit value to obtain a first value to be clipped, clipping the first value to be clipped using a first clipping interval generated by the attack intensity to obtain a gradient value for adjusting the sample image; performing a difference processing on the sample image and the gradient value (the gradient value may also be referred to as a perturbation value, and the difference processing may be understood as adding the perturbation value to the sample image to obtain an image containing noise) to obtain a second value to be clipped, clipping the second value to be clipped using a second clipping interval generated by the pixel level to obtain the initial adversarial sample image corresponding to the sample image (if the initial adversarial sample image can be directly used as the adversarial sample image corresponding to the sample image, then the initial adversarial sample image here may also be directly referred to as the adversarial sample image).

[0131] Specifically, after the business server obtains the first probability vector of the sampled sample image, the business server uses the maximum probability element in the first probability vector as the first loss value, uses the first probability element corresponding to the wrong category label in the first probability vector as the second loss value, and subtracts the difference between the first loss value and the second loss value as the label loss value of the sampled sample image for the wrong category label. Furthermore, the business server can adjust the sampled sample image according to the label loss value to obtain the initial adversarial sample image of the sampled sample image. The specific implementation method can adopt the Project Gradient Descent (an iterative attack algorithm, referred to as PGD) attack algorithm. Among them, the specific implementation process of adopting the PGD attack algorithm can be described by the following formula (1).

[0132] Wherein, t in formula (1) represents the current iteration, and t is a positive integer, which means that the image recognition model will undergo at least one iteration, and that the sample image will undergo at least one adjustment. Represents the result data of the t-th iteration, such as the initial adversarial sample image generated after the first iteration, or the adversarial sample image generated after the last iteration. Represents the input data of the t-th iteration. For example, the input data of the first iteration is the sampled sample image. It can be understood that if there is a second iteration, the input data of the second iteration is the initial adversarial sample image, that is, the result data of the first iteration; similarly, if there are more iterations, the input data of the next iteration is the result data of the previous iteration. represents the initial gradient value, Represents the label loss value of the tth iteration, for example, the label loss value of the first iteration. α represents the learning rate. sign(.) represents the sign function, which can change each element of the initial gradient value (map) to {-1, 0, 1}. eps represents the attack strength, that is, the absolute value of each element value of the gradient map used for adjustment each time cannot be greater than the attack strength. The attack strength is an adjustable parameter, generally set to 8 / 255, 16 / 255, 32 / 255, etc. The clip(.,.) function represents clipping, that is, the clip(.,.) function can control all values ​​​​to be within the specified closed interval. [-eps,eps] represents the first clipping interval, and [0,255] represents the second clipping interval.

[0133] The embodiments of the present application do not limit the method of adjusting the image. The above-mentioned PGD attack method can also be replaced by other attack methods, such as Fast Gradient Sign Method (an algorithm based on gradient generation adversarial samples, referred to as FGSM), Iterative Fast Gradient Sign Method (improved version of FGSM, referred to as I-FGSM), Momentum Iterative Fast Gradient Sign Method (another improved version of FGSM, referred to as MI-FGSM), etc.

[0134] Furthermore, the service server inputs the incorrect category label and the initial adversarial sample image into the image recognition model. The image recognition model then generates a second probability vector for the initial adversarial sample image with respect to A category labels. Generally speaking, to achieve a successful adversarial attack, both α and the number of iterations t must meet a certain number to ensure that the adjusted sampled sample image can cross the interface of the image recognition model and become a sample image that can be recognized by the image recognition model as having the incorrect category label. (To distinguish them from adversarial sample images, the sample images here are referred to as strong adversarial sample images, i.e., the probability element output by the image recognition model for the strong adversarial sample image indicating the incorrect category label approaches 1.) However, while selecting such strong adversarial sample images can improve the robustness of the image recognition model, they cannot be used as a suitable data augmentation method to improve the accuracy of the image recognition model. Because the strong adversarial sample images are completely in the distribution of the wrong category labels, if the image recognition model is optimized and trained using the strong adversarial sample images, the interface of the optimized and trained image recognition model will become a non-soft curve, such as a jagged shape. Please refer to Figures 4 and 5. Figure 4 is a schematic diagram of a classification boundary surface trained by clean sample data provided in an embodiment of the present application, and Figure 5 is a schematic diagram of a classification boundary surface trained by the first mixed sample data provided in an embodiment of the present application. Among them, the clean sample data refers to the above-mentioned A sample image sets, and the first mixed sample data includes the above-mentioned A sample image sets and the above-mentioned strong adversarial sample images. For the sake of ease of description and understanding, A can be equal to 2, that is, the A category labels include the first category label and the second category label as shown in Figures 4 and 5. Alternatively, A is greater than 2, but one category label is used as the true category label, and the remaining one or more category labels are used as attack category labels. In Figure 4, the category feature distribution area corresponding to the first category label (i.e., the area where the symbol "+" is located) and the category feature distribution area corresponding to the second category label (i.e., the area where the symbol "-" is located) are independent of each other, that is, the image recognition model can accurately identify the first category label and the second category label.

[0135] In Figure 5, the feature distribution regions corresponding to the first class label (i.e., the region containing the "+" symbol and the "△" symbol) and the feature distribution regions corresponding to the second class label (i.e., the region containing the "-" symbol and the "○" symbol) interact with each other. To better fit strong adversarial examples, the image recognition model creates a jagged interface. While this improves the robustness of the optimized image recognition model to strong adversarial examples, it also misclassifies some low-confidence samples near the interface. For example, in Figure 5, some "-" symbols are located in the feature region corresponding to the first class label, while some "+" symbols are located in the feature region corresponding to the second class label. In this case, the image recognition model cannot accurately distinguish between the first and second class labels, compromising the accuracy of the optimized image recognition model. If A is greater than 2 and does not distinguish between true and attack class labels, the number of feature distribution regions is the same as A. For example, if A = 3, there are three feature distribution regions.

[0136] After the above analysis, the purpose of the embodiment of the present application should be to improve the accuracy and generalization of the image recognition model while improving the robustness. Therefore, the embodiment of the present application adds boundary constraints to screen adversarial sample images. In other words, the adversarial sample images used for data enhancement should not go too far beyond the boundary. Therefore, another way to determine the adversarial sample image can be: the business server adjusts the sampling sample image according to the first probability element to obtain the initial adversarial sample image corresponding to the sampling sample image; the wrong category label and the initial adversarial sample image are input into the image recognition model, and the image recognition model is used to generate a second probability vector for the initial adversarial sample image for the A category labels; among the A probability elements contained in the second probability vector, the second probability element for the wrong category label is obtained; if the second probability element does not meet the boundary constraint, or the category prediction result obtained by performing category prediction on the adversarial sample image is not the wrong category label, then the initial adversarial sample image is continued to be predicted according to the second probability element. The adversarial sample image is adjusted at the beginning (the process of continuing to adjust the initial adversarial sample image is the same as the specific implementation process of adjusting the sampling sample image according to the first probability element to obtain the initial adversarial sample image, so it will not be repeated here, please refer to the description above. It can be understood that in the subsequent model iteration process (i.e., the image adjustment process), the image adjustment method is the same as the adjustment method of the sampling sample image); if the second probability element meets the boundary constraint condition, and the category prediction result obtained by performing category prediction on the adversarial sample image is the wrong category label, then the initial adversarial sample image is determined to be the adversarial sample image corresponding to the sampling sample image; in the case where the category prediction result is the wrong category label, the second probability element is the maximum value of the A probability elements contained in the second probability vector. It can be seen that the adversarial sample image expected by the present application is one that can both meet the boundary constraint condition and ensure that the image recognition model can incorrectly identify the adversarial sample image. In which, the business server can also compare the second probability element and the probability constraint value; the probability constraint value is the inverse of A; if the second probability element is less than the probability constraint value, it is determined that the second probability element does not meet the boundary constraint condition; if the second probability element is equal to or greater than the probability constraint value, it is determined that the second probability element meets the boundary constraint condition.That is, this application controls the learning rate and the number of iterations. If the probability element (including the above-mentioned second probability element) corresponding to the wrong category label in the probability vector (including the above-mentioned second probability vector) just exceeds 1 / A, and the probability element corresponding to the wrong category label at this time is the maximum value in the probability vector (the probability element with the maximum value is used to indicate that the category prediction result of the image recognition model for the initial adversarial sample image is the category label referred to by the probability element), the model iteration (i.e., image adjustment) is stopped, and the current adjusted sample image is used as a reasonable adversarial sample image, rather than waiting for the probability element corresponding to the wrong category label to approach 1.

[0137] Based on the above, the adversarial sample images obtained in the embodiment of the present application can be located near the classification boundary surface, rather than in the distribution of the wrong category labels, and the classification boundary surface of the image recognition model optimized and trained by the adversarial sample images will be softer. Please refer to Figure 6, which is a schematic diagram of a classification boundary surface trained by the second mixed sample data provided by the embodiment of the present application. The second mixed sample data includes the above-mentioned A sample image sets and the above-mentioned adversarial sample images. As shown in Figure 6, the category feature distribution area corresponding to the first category label (i.e., the area where the symbol "+" is located and the area where the symbol "△" is located), and the category feature distribution area corresponding to the second category label (i.e., the area where the symbol "-" is located and the area where the symbol "○" is located) basically do not interact, and there are a few interactive category features that are also basically located on the classification boundary surface. At this time, the optimized image recognition model can accurately identify the first category label and the second category label, that is, it can ensure that the optimized image recognition model (referred to as the image recognition optimization model) maintains or improves the original recognition accuracy, and can also supplement the deficiencies of the training data, so the defense capability and security of the image recognition optimization model can be improved.

[0138] The embodiment of the present application proposes a new adversarial data enhancement based on boundary constraints, which utilizes the particularity of the distribution of adversarial data at the boundary to amplify and enhance the training data, thereby improving the defense capability and generalization of the optimized image recognition model.

[0139] In an embodiment of the present application, a computer device can obtain A sample image sets and an image recognition model; wherein the A sample image sets respectively correspond to one of A different category labels, and the image recognition model is pre-trained based on the A sample image sets, so the image recognition model can accurately determine the category labels of the sample images in the A sample image sets; further, the computer device obtains a sampled sample image from the A sample image sets, and inputs the wrong category label and the sampled sample image into the image recognition model, wherein the wrong category label belongs to the A category labels, and the wrong category label is different from the category label corresponding to the sample image set to which the sampled sample image belongs; the image recognition model can generate a first probability vector for the sampled sample image for the A category labels, and the first probability vector includes A probability elements, and the A probability elements respectively refer to one of the A category labels. A probability element is used to characterize the probability that the sampled sample image belongs to the referred category label; since the image recognition model can accurately determine the category labels of the sample images in the A sample image set, the probability element referring to the correct category label is the largest in the first probability vector, or in other words, the probability element referring to the correct category label is much larger than the first probability element referring to the wrong category label, and the correct category label refers to the category label corresponding to the sample image set to which the sampled sample image belongs; further, according to the first probability element, the computer device can adjust the sampled sample image to obtain an adversarial sample image corresponding to the sampled sample image, wherein the category prediction result obtained by the image recognition model for category prediction of the adversarial sample image is the wrong category label, that is, by adjusting the sampled sample image, the image recognition model can incorrectly determine the category label of the adversarial sample image. As can be seen from the above, the embodiment of the present application proposes a method for generating adversarial sample images. Through this method, adversarial sample images that are incorrectly recognized by the image recognition model can be generated. The adversarial sample images can improve the sample diversity of the training set used to optimize the training of the image recognition model. By using a training set with sample diversity, the optimization training accuracy of the image recognition model can be improved, and the category label recognition accuracy and recognition generalization of the optimized trained image recognition model can be improved. Moreover, because the second probability element for the incorrect category label predicted by the image recognition model for the adversarial sample image meets the boundary constraint condition, the classification boundary of the optimized trained image recognition model can be made softer, further ensuring the model accuracy.

[0140] Please refer to Figure 7, which is a second flow chart of a data processing method provided by an embodiment of the present application. The method can be executed by a business server (for example, the business server 100 shown in Figure 1 above), or by a terminal device (for example, the terminal device 200a shown in Figure 1 above), or can be executed interactively by a business server and a terminal device. For ease of understanding, the embodiment of the present application is described using the method executed by a business server as an example. As shown in Figure 7, the method may include at least the following steps.

[0141] Step S201, obtain A sample image sets and an image recognition model, where A is a positive integer greater than 1, and the A sample image sets respectively correspond to one of A different category labels. The image recognition model is pre-trained based on the A sample image sets, and the A category labels include error category labels.

[0142] Specifically, the business service obtains A original image sets and inputs each of the A original image sets into the object detection model; each of the A original image sets corresponds to one of A different category information; the A original image sets include the original image set D b ; Original image set D b Including the original image E f ; f is a positive integer, and f is less than or equal to the original image set D b The total number of original images in the object detection model is used to determine the original image E f The region coordinates of the key region in the image are used to generate the original image E. f The corresponding sample image to be labeled; the original image set D b The sample images to be labeled corresponding to each original image in are determined as the sample image set to be labeled; according to the category information corresponding to the original image set Db, the category label Hb is generated, and the sample image set to be labeled with the category label Hb is determined as the sample image set Cb.

[0143] Among them, the specific process of generating a sample image to be labeled corresponding to the original image Ef according to the region coordinates may include: generating an initial detection frame including a key area according to the region coordinates, expanding the initial detection frame to obtain a detection frame including the target object; the key area belongs to the target object; in the detection frame, obtaining an image to be scaled including the target object, obtaining a first image size, scaling the image to be scaled according to the first image size, and obtaining an image to be cropped; obtaining a second image size, cropping the image to be cropped according to the second image size, and obtaining a sample image to be labeled corresponding to the original image Ef; the second image size is smaller than the first image size.

[0144] The business server does not limit the model type of object detection models and can be set according to the actual application scenario. For example, Region with CNN feature (an object detection model, referred to as Faster R-CNN), Single Shot MultiBox Detector (another object detection model, referred to as SSD), You Only Look Once (a simple and fast object detection algorithm, referred to as YOLO), etc.

[0145] The key area is the target object. This embodiment of the application does not limit the target object. For example, it can be a cat, dog, person, table, chili pepper, etc. Therefore, the key area is not limited and should be set according to the target object. The expansion factor of the initial detection frame should be set according to the key area. Therefore, this embodiment of the application does not limit the expansion factor. The second image size refers to the input size of the image recognition model.

[0146] Step S202: obtain a sampling sample image from the A sample image set, input the sampling sample image and the erroneous category label into the image recognition model to generate a first probability vector for the sampling sample image for the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sampling sample image belongs; the first probability vector includes A probability elements, each of the A probability elements refers to one of the A category labels, and one of the probability elements is used to represent the probability that the sampling sample image belongs to the referred category label.

[0147] Step S203: Obtain a first probability element representing the wrong category label from the A probability elements in the first probability vector, adjust the sample image according to the first probability element, and obtain an adversarial sample image corresponding to the sample image. The category prediction result obtained by performing category prediction on the adversarial sample image by the image recognition model is the wrong category label.

[0148] For the specific implementation process of steps S202 to S203, please refer to steps S102 and S103 in the embodiment corresponding to FIG3 above, which will not be described in detail here.

[0149] Step S204: input the A sample image sets, the A category labels, the correct category label, and the adversarial sample image into the image recognition model; the correct category label refers to the category label corresponding to the sample image set to which the sample image belongs.

[0150] Among them, the A sample image sets, the A category labels, the correct category label and the adversarial sample image can be respectively input into the image recognition model as four independent data, and there is a mapping relationship between the A sample image sets and the A category labels, and there is a mapping relationship between the correct category label and the adversarial sample image; or, the category label can be added to the file header or file tail of the sample image in the sample image set, and the correct category label can be added to the file header or file tail of the adversarial sample image, and then the sample image carrying the category label and the adversarial sample image carrying the correct category label can be input into the image recognition model.

[0151] Step S205 , using the image recognition model, generates first prediction categories corresponding to the A sample image sets and second prediction categories corresponding to the adversarial sample images.

[0152] Step S206: Generate a first loss value based on the first predicted category and the A category labels, generate a second loss value based on the second predicted category and the correct category label, and adjust the parameters in the image recognition model based on the first loss value and the second loss value (specifically, the first loss value and the second loss value can be weighted and summed to obtain a total loss value, and then the parameters in the image recognition model are adjusted based on the total loss value) to obtain the image recognition optimization model; the category prediction result obtained by the image recognition optimization model for category prediction of the adversarial sample image is the correct category label, and the category prediction result obtained by the image recognition optimization model for category prediction of the sample image in the sample image set is still the category label corresponding to the sample image set.

[0153] Among them, the optimization training process of the image recognition model by the business server is the same as the training process of the initial image recognition model by the business server. Therefore, for the specific implementation process of steps S204 to S206, please refer to step S101 in the embodiment corresponding to Figure 3 above, which will not be repeated here.

[0154] The image recognition optimization model proposed in the embodiment of the present application can be deployed on a terminal device, for example, to detect an image input for real object recognition (e.g., real-person recognition). If it is a real object, it passes and enters the subsequent recognition process. If it is not a real object, such as a photo object, an error is reported and a retry prompt is given. The embodiment of the present application can be applied to all object recognition-related applications, including but not limited to: online payment, offline payment, access control unlocking system, mobile phone unlocking recognition, automatic object recognition clearance, etc.

[0155] From the above, it can be seen that an embodiment of the present application proposes a method for generating adversarial sample images. Through this method, adversarial sample images that are incorrectly recognized by the image recognition model can be generated. Through the adversarial sample images, the sample diversity of the training set used to optimize the training of the image recognition model can be improved. Through the training set with sample diversity, the optimization training accuracy of the image recognition model can be improved, and then the category label recognition accuracy and recognition generalization of the optimized trained image recognition model can be improved.

[0156] Please refer to Figure 8, which is a flow chart of a data processing method provided in an embodiment of the present application. The method can be executed by a business server (for example, the business server 100 shown in Figure 1 above), or by a terminal device (for example, the terminal device 200a shown in Figure 1 above), or by the business server and the terminal device interacting with each other. For ease of understanding, the embodiment of the present application is described by taking the method executed by the business server as an example. As shown in Figure 8, the method may include at least the following steps.

[0157] Step S301, obtain the target image, and input the target image into the image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize the image recognition model according to the mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels respectively, and the A sample image sets include collected sample images; the correct category label belongs to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training based on the A sample image sets; the adversarial sample image is obtained by referring to the error in the A probability elements in the first probability vector The first probability element of the category label is obtained by adjusting the sampling sample image, the first probability vector is generated by the image recognition model for the sampling sample image, the incorrect category label is different from the category label corresponding to the sample image set to which the sampling sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sampling sample image belongs; the first probability vector includes A probability elements, and the A probability elements respectively refer to one of the A category labels, and one probability element is used to characterize the probability that the sampling sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the incorrect category label.

[0158] Step S302 : Generate a target probability vector of the target image for A category labels through an image recognition optimization model.

[0159] Step S303: Determine the category label corresponding to the maximum probability element in the target probability vector as the category prediction result of the target image.

[0160] Specifically, the image recognition model in the embodiments of the present application can be used to identify real objects, such as real people. In this case, the image recognition model can be referred to as a real object detection model. Currently, in intelligent object recognition payment services, real object detection technology is increasingly being applied to products, effectively ensuring payment security. However, in the actual application scenarios of real object detection, the attacks launched by criminals are diverse and novel, making them difficult to defend against. For example, in paper attacks, among the various types of materials, there is always one that the model has not been trained on, which can bypass the real object detection model and achieve the attack. This problem also arises in high-precision 3D attacks. Once a new material appears, the real object detection model will be unable to defend against it. The reason for this is that the training data does not cover the entire category space. Therefore, the embodiments of the present application propose a new real object detection technology based on boundary constraint adversarial data enhancement. By designing a special adversarial sample image, the real object training data is enhanced, thereby improving the overall performance of real object detection. For the specific process of generating the adversarial sample image, please refer to the description of the embodiments corresponding to Figures 3 and 7 above.

[0161] From the above, it can be seen that an embodiment of the present application proposes a method for generating adversarial sample images. Through this method, adversarial sample images that are incorrectly recognized by the image recognition model can be generated. Through the adversarial sample images, the sample diversity of the training set used to optimize the training of the image recognition model can be improved. Through the training set with sample diversity, the optimization training accuracy of the image recognition model can be improved, and then the category label recognition accuracy and recognition generalization of the optimized trained image recognition model can be improved.

[0162] Further, please refer to Figure 9, which is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. The above-mentioned data processing device 1 can be used to perform the corresponding steps of the method provided in an embodiment of the present application. As shown in Figure 9, the data processing device 1 may include: a data acquisition module 11, a first input module 12, and a first adjustment module 13.

[0163] A data acquisition module 11 is configured to acquire A sample image sets and an image recognition model, where A is a positive integer greater than 1, the A sample image sets each corresponding to one of A different category labels, the image recognition model being pre-trained based on the A sample image sets, and the A category labels including error category labels;

[0164] A first input module 12 is configured to obtain a sample sample image from the A sample image sets, and input the sample sample image and the erroneous category label into the image recognition model to generate a first probability vector for the sample sample image with respect to the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sample sample image belongs; the first probability vector includes A probability elements, each of the A probability elements referring to one of the A category labels, and each probability element is used to represent a probability that the sample sample image belongs to the referred category label;

[0165] The first adjustment module 13 is used to obtain a first probability element referring to the wrong category label from the A probability elements in the first probability vector, and adjust the sampled sample image according to the first probability element to obtain an adversarial sample image corresponding to the sampled sample image, where the category prediction result obtained by the image recognition model for the adversarial sample image is the wrong category label.

[0166] The specific functional implementation of the data acquisition module 11, the first input module 12 and the first adjustment module 13 can be found in steps S101 to S103 in the embodiment corresponding to FIG3 above, and will not be repeated here.

[0167] Among them, the first adjustment module 13 can be specifically used to generate a negative probability element corresponding to the first probability element, sum the negative probability element and the maximum probability element in the first probability vector, obtain the label loss value of the sampling sample image for the wrong category label, and adjust the sampling sample image according to the label loss value to obtain the adversarial sample image corresponding to the sampling sample image.

[0168] Among them, the first adjustment module 13 is used to adjust the sampling sample image according to the label loss value to obtain the adversarial sample image corresponding to the sampling sample image. It is specifically used to generate an initial gradient value for the sampling sample image according to the label loss value, obtain the numerical sign of the initial gradient value, generate a symbol unit value corresponding to the initial gradient value according to the numerical sign, multiply the initial learning rate and the symbol unit value to obtain a first value to be cropped, crop the first value to be cropped through a first cropping interval generated by the attack intensity to obtain a gradient value for adjusting the sampling sample image, perform difference processing on the sampling sample image and the gradient value to obtain a second value to be cropped, crop the second value to be cropped through a second cropping interval generated by the pixel level to obtain an adversarial sample image corresponding to the sampling sample image.

[0169] Referring again to FIG. 9 , the first adjustment module 13 may include: a first adjustment unit 131 , a first generation unit 132 , and a first acquisition unit 133 .

[0170] A first adjustment unit 131 is configured to adjust the sample image according to the first probability element to obtain an initial adversarial sample image corresponding to the sample image;

[0171] A first generating unit 132 is configured to input the incorrect category label and the initial adversarial sample image into the image recognition model, and generate a second probability vector of the initial adversarial sample image for A category labels through the image recognition model;

[0172] A first acquiring unit 133 is configured to acquire a second probability element for the error category label from the A probability elements included in the second probability vector;

[0173] The first adjustment unit 131 is further configured to continue adjusting the initial adversarial image according to the second probability element if the second probability element does not satisfy the boundary constraint condition, or if the category prediction result obtained by performing category prediction on the adversarial image is not the wrong category label;

[0174] The first acquisition unit 133 is further configured to determine the initial adversarial sample image as the adversarial sample image corresponding to the sampling sample image if the second probability element satisfies a boundary constraint condition and the category prediction result obtained by performing category prediction on the adversarial sample image is the incorrect category label; and when the category prediction result is the incorrect category label, the second probability element is the maximum value among the A probability elements contained in the second probability vector.

[0175] The specific functional implementation of the first adjustment unit 131 , the first generation unit 132 and the first acquisition unit 133 can be found in step S103 in the embodiment corresponding to FIG. 3 , which will not be described in detail here.

[0176] The first acquiring unit 133 is further configured to compare the second probability element with a probability constraint value; the probability constraint value is the inverse of A;

[0177] The first acquiring unit 133 is further configured to determine that the second probability element does not satisfy the boundary constraint condition if the second probability element is less than the probability constraint value;

[0178] The first acquiring unit 133 is further configured to determine that the second probability element satisfies a boundary constraint condition if the second probability element is equal to or greater than the probability constraint value.

[0179] Referring again to FIG. 9 , the data processing device 1 may further include: a second input module 14 and a second adjustment module 15 .

[0180] A second input module 14 is configured to input the A sample image sets, the A category labels, the correct category label, and the adversarial sample image into the image recognition model; the correct category label refers to the category label corresponding to the sample image set to which the sample image belongs;

[0181] The second input module 14 is further configured to generate, through the image recognition model, first predicted categories corresponding to the A sample image sets and second predicted categories corresponding to the adversarial sample images;

[0182] The second adjustment module 15 is used to generate a first loss value based on the first predicted category and the A category labels, generate a second loss value based on the second predicted category and the correct category label, and adjust the parameters in the image recognition model according to the first loss value and the second loss value to obtain the image recognition optimization model; the category prediction result obtained by the image recognition optimization model for category prediction of the adversarial sample image is the correct category label.

[0183] The specific functional implementation of the second input module 14 and the second adjustment module 15 can be found in steps S204 to S206 in the embodiment corresponding to FIG7 , and will not be described in detail here.

[0184] Referring again to FIG. 9 , the first input module 12 may include: a first determining unit 121 and a second acquiring unit 122 .

[0185] Wherein, the A sample image sets include a sample image set Cb; b is a positive integer and b is less than or equal to A;

[0186] The first determining unit 121 is configured to determine a sampling ratio, and perform sampling processing on the sample images in the sample image set Cb according to the sampling ratio to obtain sampled sample images;

[0187] The second acquiring unit 122 is configured to acquire, from the A category labels, a category label that is different from the category label of the sample image set Cb, and determine the acquired category label as an incorrect category label.

[0188] The specific functional implementation of the first determining unit 121 and the second acquiring unit 122 can be found in step S102 of the embodiment corresponding to FIG. 3 , and will not be described in detail here.

[0189] Referring again to FIG. 9 , the data acquisition module 11 may include: a third acquisition unit 111 , a second generation unit 112 , a second determination unit 113 , a third determination unit 114 , and a second adjustment unit 115 .

[0190] A third acquisition unit 111 is used to acquire A sample image sets, and input A category labels and the A sample image sets into the image recognition initial model respectively;

[0191] A second generating unit 112 is configured to generate predicted initial categories corresponding to the A sample image sets respectively through an image recognition initial model;

[0192] A second determining unit 113 is configured to determine the category loss values ​​corresponding to the A sample image sets respectively according to the predicted initial category and the A category labels;

[0193] The third determining unit 114 is configured to determine a total loss value corresponding to the initial image recognition model based on the category loss values ​​corresponding to the A sample image sets;

[0194] The second adjustment unit 115 is used to adjust the parameters in the initial image recognition model according to the total loss value to obtain an image recognition model; the category prediction result obtained by the image recognition model for the sample image set Cb is the category label of the sample image set Cb; the A sample image sets include the sample image set Cb; b is a positive integer and b is less than or equal to A.

[0195] Among them, the specific functional implementation of the third acquisition unit 111, the second generation unit 112, the second determination unit 113, the third determination unit 114 and the second adjustment unit 115 can be found in step S101 in the embodiment corresponding to Figure 3 above, and will not be repeated here.

[0196] Referring again to FIG. 9 , the third acquiring unit 111 may include: an image acquiring subunit 1111 , a second determining subunit 1112 , a third determining subunit 1113 , and a fourth determining subunit 1114 .

[0197] The image acquisition subunit 1111 is configured to acquire A original image sets and input each of the A original image sets into an object detection model; the category information corresponding to each of the A original image sets is different from one another; the A original image sets include an original image set Db; the original image set Db includes an original image Ef; f is a positive integer, and f is less than or equal to the total number of original images in the original image set Db;

[0198] The second determining subunit 1112 is configured to determine the region coordinates of the key region in the original image Ef using the object detection model, and generate a sample image to be labeled corresponding to the original image Ef according to the region coordinates;

[0199] The third determining subunit 1113 is configured to determine the sample image to be labeled corresponding to each original image in the original image set Db as a sample image set to be labeled;

[0200] The fourth determining subunit 1114 is configured to generate a category label Hb according to the category information corresponding to the original image set Db, and determine the set of sample images to be labeled with the category label Hb as the sample image set Cb.

[0201] Among them, the specific functional implementation of the image acquisition subunit 1111, the second determination subunit 1112, the third determination subunit 1113 and the fourth determination subunit 1114 can refer to step S201 in the embodiment corresponding to Figure 7 above, and will not be repeated here.

[0202] Please refer to Figure 9 again, the second determining subunit 1112 may include: a third processing subunit 11121, a fourth processing subunit 11122 and a fifth processing subunit 11123.

[0203] The third processing sub-unit 11121 is configured to generate an initial detection frame including the key region according to the region coordinates, and to expand the initial detection frame to obtain a detection frame including the target object; the key region belongs to the target object;

[0204] The fourth processing subunit 11122 is configured to obtain, in the detection frame, an image to be scaled including the target object, obtain a first image size, and scale the image to be scaled according to the first image size to obtain an image to be cropped.

[0205] The fifth processing subunit 11123 is configured to obtain a second image size, and perform cropping processing on the image to be cropped according to the second image size to obtain a sample image to be labeled corresponding to the original image Ef; the second image size is smaller than the first image size.

[0206] Among them, the specific functional implementation of the third processing sub-unit 11121, the fourth processing sub-unit 11122 and the fifth processing sub-unit 11123 can be found in step S201 in the embodiment corresponding to Figure 7 above, and will not be repeated here.

[0207] As can be seen from the above, the embodiments of the present application propose a method for generating adversarial sample images. By this method, adversarial sample images that are incorrectly recognized by an image recognition model can be generated. The adversarial sample images can improve the sample diversity of the training set used to optimize the training of the image recognition model. The training set with sample diversity can improve the optimization training accuracy of the image recognition model, thereby improving the category label recognition accuracy and recognition generalization of the optimized trained image recognition model. Moreover, because the second probability element for the incorrect category label predicted by the image recognition model for the adversarial sample image satisfies the boundary constraint condition, the classification boundary of the optimized trained image recognition model can be made softer, further ensuring the model accuracy.

[0208] Further, please refer to Figure 10, which is a second structural diagram of a data processing device provided in an embodiment of the present application. The above-mentioned data processing device 2 can be used to perform the corresponding steps of the method provided in an embodiment of the present application. As shown in Figure 10, the data processing device 2 may include: an image acquisition module 21, a vector generation module 22, and a category determination module 23.

[0209] The image acquisition module 21 is used to acquire a target image and input the target image into an image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize the image recognition model according to the mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels respectively, and the A sample image sets include collected sample images; the correct category label belongs to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training the A sample image sets; the adversarial sample image is represented by the A probability elements in the first probability vector The first probability element of the erroneous category label is obtained by adjusting the sample sample image, the first probability vector is generated by the image recognition model for the sample sample image, the erroneous category label is different from the category label corresponding to the sample image set to which the sample sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sample sample image belongs; the first probability vector includes A probability elements, the A probability elements respectively refer to one of the A category labels, and one probability element is used to represent the probability that the sample sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the erroneous category label;

[0210] A vector generation module 22 is used to generate a target probability vector for a target image with respect to A category labels through an image recognition optimization model;

[0211] The category determination module 23 is configured to determine the category label corresponding to the maximum probability element in the target probability vector as the category prediction result of the target image.

[0212] The specific functional implementation of the image acquisition module 21, the vector generation module 22 and the category determination module 23 can be found in steps S301 to S303 in the embodiment corresponding to FIG8 above, and will not be repeated here.

[0213] From the above, it can be seen that an embodiment of the present application proposes a method for generating adversarial sample images. Through this method, adversarial sample images that are incorrectly recognized by the image recognition model can be generated. Through the adversarial sample images, the sample diversity of the training set used to optimize the training of the image recognition model can be improved. Through the training set with sample diversity, the optimization training accuracy of the image recognition model can be improved, and then the category label recognition accuracy and recognition generalization of the optimized trained image recognition model can be improved.

[0214] Further, please refer to Figure 11, which is a structural diagram of a computer device provided in an embodiment of the present application. As shown in Figure 11, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. Wherein, the communication bus 1002 is used to realize the connection and communication between these components. Wherein, in some embodiments, the user interface 1003 may include a display screen (Display), a keyboard (Keyboard), and the network interface 1004 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As shown in Figure 11, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application.

[0215] In the computer device 1000 shown in FIG11 , the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0216] Obtaining A sample image sets and an image recognition model, where A is a positive integer greater than 1, the A sample image sets each corresponding to one of A different category labels, the image recognition model being pre-trained based on the A sample image sets, and the A category labels including error category labels;

[0217] Obtaining a sample sample image from the A sample image sets, inputting the sample sample image and the erroneous category label into the image recognition model to generate a first probability vector for the sample sample image with respect to the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sample sample image belongs; the first probability vector includes A probability elements, each of the A probability elements referring to one of the A category labels, and each probability element is used to represent a probability that the sample sample image belongs to the referred category label;

[0218] Among the A probability elements in the first probability vector, a first probability element representing the incorrect category label is obtained. Based on the first probability element, the sampled sample image is adjusted to obtain an adversarial sample image corresponding to the sampled sample image. The category prediction result obtained by the image recognition model for category prediction of the adversarial sample image is the incorrect category label.

[0219] Alternatively, the processor 1001 may be configured to call a device control application stored in the memory 1005 to implement:

[0220] Acquire a target image and input the target image into an image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize the image recognition model according to the mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels respectively, and the A sample image sets include collected sample images; the correct category label belongs to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training the A sample image sets; the adversarial sample image is obtained by referring to the wrong category label in the A probability elements in the first probability vector The first probability vector is obtained by adjusting the sampling sample image by the first probability element of the signature, the first probability vector is generated by the image recognition model for the sampling sample image, the incorrect category label is different from the category label corresponding to the sample image set to which the sampling sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sampling sample image belongs; the first probability vector includes A probability elements, the A probability elements respectively refer to one of the A category labels, and one probability element is used to represent the probability that the sampling sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the incorrect category label;

[0221] Generating a target probability vector of the target image for the A category labels through the image recognition optimization model;

[0222] The category label corresponding to the maximum probability element in the target probability vector is determined as the category prediction result of the target image.

[0223] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the description of the data processing method or device in the above embodiments, which will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated.

[0224] The present application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the data processing methods or apparatuses described in the preceding embodiments, which are not described in detail here. Furthermore, the description of the beneficial effects of the same methods is not described in detail here.

[0225] The computer-readable storage medium may be the data processing device provided in any of the aforementioned embodiments or the internal storage unit of the computer device, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Furthermore, the computer-readable storage medium may also include both the internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

[0226] The present application also provides a computer program product, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, enabling the computer device to perform the data processing methods or apparatuses described in the preceding embodiments, which are not further detailed here. Furthermore, the beneficial effects of the same methods are not further detailed here.

[0227] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.

[0228] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0229] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. An image processing method, characterized in that: include: Obtain A sample image sets and an image recognition model, where A is a positive integer greater than 1, the A sample image sets respectively correspond to one of A different category labels, the image recognition model is pre-trained based on the A sample image sets, and the A category labels include error category labels; Acquire a sampling sample image from the A sample image sets, input the sampling sample image and the erroneous category label into the image recognition model to generate a first probability vector of the sampling sample image for the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sampling sample image belongs; the first probability vector includes A probability elements, each of the A probability elements refers to one of the A category labels, and one of the probability elements is used to represent the probability that the sampling sample image belongs to the referred category label; Among the A probability elements in the first probability vector, obtain a first probability element referring to the wrong category label, and adjust the sampled sample image according to the first probability element to obtain an adversarial sample image corresponding to the sampled sample image, and the category prediction result obtained by performing category prediction on the adversarial sample image by the image recognition model is the wrong category label.

2. The method according to claim 1, characterized in that The step of adjusting the sampled sample image according to the first probability element to obtain an adversarial sample image corresponding to the sampled sample image includes: Generate a negative probability element corresponding to the first probability element, sum the negative probability element and the maximum probability element in the first probability vector, and obtain a label loss value of the sample image for the wrong category label; According to the label loss value, the sampled sample image is adjusted to obtain an adversarial sample image corresponding to the sampled sample image.

3. The method according to claim 1 or 2, characterized in that: The step of adjusting the sampled sample image according to the label loss value to obtain an adversarial sample image corresponding to the sampled sample image includes: Generate an initial gradient value for the sample image according to the label loss value, obtain a numerical sign of the initial gradient value, and generate a symbol unit value corresponding to the initial gradient value according to the numerical sign; Performing a product process on the initial learning rate and the symbol unit value to obtain a first value to be clipped, and clipping the first value to be clipped using a first clipping interval generated by the attack intensity to obtain a gradient value for adjusting the sample image; The sampling sample image and the gradient value are subjected to difference processing to obtain a second value to be cropped, and the second value to be cropped is cropped using a second cropping interval generated by the pixel level to obtain an adversarial sample image corresponding to the sampling sample image.

4. The method according to any one of claims 1 to 3, characterized in that: The step of adjusting the sampled sample image according to the first probability element to obtain an adversarial sample image corresponding to the sampled sample image includes: According to the first probability element, the sampled sample image is adjusted to obtain an initial adversarial sample image corresponding to the sampled sample image; Inputting the wrong category label and the initial adversarial sample image into the image recognition model, and generating a second probability vector of the initial adversarial sample image for the A category labels through the image recognition model; Obtaining a second probability element for the error category label from among the A probability elements included in the second probability vector; If the second probability element does not satisfy the boundary constraint condition, or the category prediction result obtained by performing category prediction on the adversarial sample image is not the wrong category label, then continue to adjust the initial adversarial sample image according to the second probability element; If the second probability element satisfies the boundary constraint condition and the category prediction result obtained by performing category prediction on the adversarial sample image is the wrong category label, the initial adversarial sample image is determined as the adversarial sample image corresponding to the sampling sample image; when the category prediction result is the wrong category label, the second probability element is the maximum value of the A probability elements contained in the second probability vector.

5. The method according to any one of claims 1 to 4, characterized in that: Also includes: comparing the second probability element with the probability constraint value; The probability constraint value is the reciprocal of A; If the second probability element is less than the probability constraint value, determining that the second probability element does not satisfy the boundary constraint condition; If the second probability element is equal to or greater than the probability constraint value, it is determined that the second probability element satisfies the boundary constraint condition.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Inputting the A sample image sets, the A category labels, the correct category label and the adversarial sample image into the image recognition model; the correct category label refers to the category label corresponding to the sample image set to which the sample image belongs; Generate, by means of the image recognition model, first prediction categories corresponding to the A sample image sets, respectively, and a second prediction category corresponding to the adversarial sample image; A first loss value is generated based on the first predicted category and the A category labels, and a second loss value is generated based on the second predicted category and the correct category labels. The image recognition optimization model is obtained by adjusting the parameters in the image recognition model according to the first loss value and the second loss value; and the category prediction result obtained by the image recognition optimization model for category prediction of the adversarial sample image is the correct category label.

7. The method according to any one of claims 1 to 6, characterized in that: The A sample image sets include sample image set C b ; b is a positive integer and b is less than or equal to A; The acquiring of the sampled sample images in the A sample image sets comprises: Determine a sampling ratio, and according to the sampling ratio, b The sample image in is sampled to obtain a sampled sample image; Among the A category labels, obtain b The acquired category label is determined as the wrong category label.

8. The method according to any one of claims 1 to 7, characterized in that: The obtaining of A sample image sets and an image recognition model includes: Obtain A sample image sets, and input A category labels and the A sample image sets into the image recognition initial model respectively; Generate predicted initial categories corresponding to the A sample image sets respectively through the image recognition initial model; Determine, according to the predicted initial category and the A category labels, category loss values ​​corresponding to the A sample image sets respectively; Determine the total loss value corresponding to the image recognition initial model according to the category loss values ​​corresponding to the A sample image sets respectively; According to the total loss value, the parameters in the initial image recognition model are adjusted to obtain an image recognition model; the image recognition model is used for the sample image set C b The category prediction result obtained by performing category prediction is the sample image set C b The A sample image sets include the sample image set C b ; b is a positive integer and b is less than or equal to A.

9. The method according to claim 8, characterized in that The obtaining of A sample image sets comprises: Obtain A original image sets, and input the A original image sets into the object detection model; the A original image sets correspond to one of A different category information respectively; the A original image sets include original image sets D b ; The original image set D b Including the original image E f ; f is a positive integer, and f is less than or equal to the original image set D b The total number of original images in ; By using the object detection model, the original image E is determined f The region coordinates of the key region in the image are used to generate the original image E according to the region coordinates. f The corresponding sample image to be labeled; The original image set D b The sample images to be labeled corresponding to each original image in are determined as a set of sample images to be labeled; According to the original image set D b Corresponding category information, generate category label H b , will be marked with the category label H b The sample image set to be labeled is determined as the sample image set C b .

10. The method according to claim 9, characterized in that The original image E is generated according to the region coordinates. f The corresponding sample images to be labeled include: generating an initial detection frame including the key region according to the region coordinates, and performing expansion processing on the initial detection frame to obtain a detection frame including the target object; the key region belongs to the target object; In the detection frame, an image to be scaled including the target object is obtained, a first image size is obtained, and the image to be scaled is scaled according to the first image size to obtain an image to be cropped; Obtain the second image size, and perform cropping processing on the image to be cropped according to the second image size to obtain the original image E f The corresponding sample image to be labeled; the size of the second image is smaller than the size of the first image.

11. A data processing method, characterized in that: include: Acquire a target image and input the target image into an image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize the image recognition model according to the mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels respectively, and the A sample image sets include collected sample images; the correct category label belongs to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training the A sample image sets; the adversarial sample image is obtained by referring to the wrong category label in the A probability elements in the first probability vector The first probability vector is obtained by adjusting the sampled sample image by the first probability element of the signature, the first probability vector is generated by the image recognition model for the sampled sample image, the wrong category label is different from the category label corresponding to the sample image set to which the sampled sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sampled sample image belongs; the first probability vector includes A probability elements, the A probability elements respectively refer to one of the A category labels, and one probability element is used to characterize the probability that the sampled sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the wrong category label; Generate a target probability vector of the target image for the A category labels through the image recognition optimization model; The category label corresponding to the maximum probability element in the target probability vector is determined as the category prediction result of the target image.

12. A data processing device, characterized in that: include: A data acquisition module, used to acquire A sample image sets and an image recognition model, where A is a positive integer greater than 1, the A sample image sets respectively correspond to one of A different category labels, the image recognition model is pre-trained based on the A sample image sets, and the A category labels include error category labels; A first input module is used to obtain a sampled sample image from the A sample image sets, and input the sampled sample image and the erroneous category label into the image recognition model to generate a first probability vector of the sampled sample image for the A category labels, wherein the erroneous category label is different from the category label corresponding to the sample image set to which the sampled sample image belongs; the first probability vector includes A probability elements, each of the A probability elements refers to one of the A category labels, and one of the probability elements is used to represent the probability that the sampled sample image belongs to the referred category label; The first adjustment module is used to obtain a first probability element referring to the wrong category label from the A probability elements in the first probability vector, and adjust the sampled sample image according to the first probability element to obtain an adversarial sample image corresponding to the sampled sample image, wherein the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the wrong category label.

13. A data processing device, characterized in that: include: An image acquisition module is used to acquire a target image and input the target image into an image recognition optimization model; the image recognition optimization model is obtained by continuing to optimize the image recognition model according to a mixed sample training set; the mixed sample training set includes A sample image sets, A category labels, correct category labels and adversarial sample images; the A sample image sets correspond to one of A different category labels respectively, and the A sample image sets include collected sample images; the correct category label belongs to the A category labels; A is a positive integer greater than 1; the image recognition model is obtained by pre-training the A sample image sets; the adversarial sample image is obtained by referring to the wrong category label in the A probability elements in the first probability vector The first probability element of the wrong category label is adjusted to obtain the sampled sample image, the first probability vector is generated by the image recognition model for the sampled sample image, the wrong category label is different from the category label corresponding to the sample image set to which the sampled sample image belongs, and the correct category label is the category label corresponding to the sample image set to which the sampled sample image belongs; the first probability vector includes A probability elements, the A probability elements respectively refer to one of the A category labels, and one probability element is used to characterize the probability that the sampled sample image belongs to the referred category label; the category prediction result obtained by the image recognition model performing category prediction on the adversarial sample image is the wrong category label; A vector generation module, used to generate a target probability vector of the target image for the A category labels through the image recognition optimization model; The category determination module is used to determine the category label corresponding to the maximum probability element in the target probability vector as the category prediction result of the target image.

14. A computer device, characterized in that: include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method described in any one of claims 1 to 11.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 11.

16. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a computer-readable storage medium. The computer program is suitable for being read and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Adversarial sample generation method and device based on feature enhancement

    CN110210617A

  • Method and system for enhancing anti-attack capability of model based on adversarial samples

    CN111046380A

  • Image processing method, device, computer equipment and storage medium

    CN113569611A

  • Data processing method and device and computer readable storage medium

    CN116977692A

  • Method and apparatus of training Anti-spoofing model, method and apparatus of performing Anti-spoofing, and device

    EP4075395A2

Cited By

  • Method and system for improving recognition accuracy of human body behavior recognition system against attacks

    CN119004222A