Image generation method, device and equipment and computer storage medium
By identifying the activation values and average gradients of suspicious neurons in an image recognition model, new images are generated to expose logical vulnerabilities in the model. This solves the problem of effectively improving model robustness in existing technologies, thereby enhancing model training performance and generalization ability.
Patent Information
- Application Number
- CN202511802669.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-02
- Publication Date
- 2026-01-20
AI Technical Summary
Existing image generation methods are unable to effectively expose logical flaws in image recognition models, resulting in insufficient robustness and generalization ability of the models.
By identifying suspicious neurons with abnormal data output in the image recognition model, obtaining the average gradient between the activation value of the suspicious neurons and the reference image, updating the image data based on the average gradient to generate a new image, and using the gradient ascent algorithm for constraint, a new image that can expose the logic flaws of the model is generated.
This improved the training effect of the image recognition model, enhanced its robustness and generalization ability, and ensured that the new image and the reference image are basically consistent from the human eye's perspective.
Smart Images

Figure CN121366331A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computers, and particularly relates to an image generation method and device, equipment and a computer storage medium. BACKGROUND
[0002] As one of the core technologies of artificial intelligence, an image recognition model is widely used in medical treatment, safety, transportation and other fields, and significantly improves the efficiency and accuracy of image recognition. In the training process of the image recognition model, subtle interference needs to be added to the original image to generate a new image, and the new image is then applied for model training to expose the logical loopholes of the model and improve the robustness of the model. The current image generation method usually randomly samples or adds random noise to the image features of the original image to generate a new image. This image generation method is based on the human eye perspective to update and adjust the image features to obtain a new image. Applying this kind of new image for model training often fails to expose the logical loopholes of the model and cannot improve the performance of the model. SUMMARY
[0003] The embodiments of the present application provide an image generation method, device, equipment and computer storage medium, which can generate a new image more accurately in combination with the logical loopholes of neurons in an image recognition model. When the new image is applied for model training, the logical loopholes of the model can be fully exposed, the training effect of the model can be improved, and the robustness and generalization ability of the model can be improved.
[0004] In a first aspect, the embodiments of the present application provide an image generation method, which comprises: In the neurons of the image recognition model, a plurality of suspicious neurons are determined. The suspicious neurons are neurons whose data output is abnormal in the image recognition process of the image recognition model. A reference image is input into the image recognition model. The reference image is an image that has been correctly recognized by the image recognition model. During the image recognition process of the image recognition model on the reference image, an average gradient between the activation values of the plurality of suspicious neurons and the reference image is obtained. The average gradient is used to indicate the degree of change between the activation values and the reference image. The image data of the reference image is updated based on the average gradient to generate a new image.
[0005] In a second aspect, the embodiments of the present application provide an image generation device, which comprises: A determination module is configured to determine a plurality of suspicious neurons in the neurons of an image recognition model. The suspicious neurons are neurons whose data output is abnormal in the image recognition process of the image recognition model. The input module is configured to input a reference image into the image recognition model, the reference image being an image that has been correctly recognized by the image recognition model. The acquisition module is configured to acquire an average gradient between the activation value of the plurality of suspicious neurons and the reference image during the image recognition process of the reference image by the image recognition model, the average gradient being used to indicate a degree of change between the activation value and the reference image. The generation module is configured to update image data of the reference image based on the average gradient, and generate a new image.
[0006] In a third aspect, an embodiment of the present application provides a computer device, which comprises a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement any of the image generation methods in the above embodiments.
[0007] In a fourth aspect, an embodiment of the present application provides a computer storage medium, which stores computer program instructions; the computer program instructions are executed by a processor to implement any of the image generation methods in the above embodiments.
[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, which comprises a computer program; the computer program is executed by a processor to implement any of the image generation methods in the above embodiments.
[0009] The image generation method, device, equipment and computer storage medium provided by the embodiments of the present application. By acquiring the output data of each neuron in the image recognition model during the image recognition of the image recognition model, determining the suspicious neuron with abnormal data output, inputting the reference image that can be correctly recognized into the image recognition model, acquiring the average gradient between the activation value of the plurality of suspicious neurons and the input reference image during the image recognition process of the reference image by the image recognition model, the average gradient indicating the degree of change between the activation value and the reference image, the possible logical vulnerability of the suspicious neuron can be reflected, and the image data of the reference image is updated and adjusted based on the average gradient to generate a new image. Therefore, the embodiments of the present application combine the logical vulnerability of the neuron in the image recognition model to generate a new image more accurately, and the gradient ascent algorithm with a constraint condition is used when generating the new image to control the update range and degree of the image data, so as to ensure that the new image is basically consistent with the reference image when observed from the perspective of the human eye, and the logical vulnerability of the model can be fully exposed when the new image is applied to model training, so as to improve the training effect of the model and improve the robustness and generalization ability of the model. BRIEF DESCRIPTION OF DRAWINGS
[0010] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments of the present application will be briefly introduced. Those drawings can help the ordinary skilled in the art to obtain other drawings without any creative effort.
[0011] Figure 1 is a schematic diagram of an implementation environment of an image generation method provided by the embodiments of the present application; Figure 2 is a flowchart of an image recognition method provided by the embodiments of the present application; Figure 3 is a flowchart of a suspicious neuron determination method provided by the embodiments of the present application; Figure 4 is a flowchart of an average gradient acquisition method provided by the embodiments of the present application; Figure 5 is a schematic diagram of a structure of an image generation device provided by the embodiments of the present application; Figure 6 is a schematic diagram of a hardware structure of a computer device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0012] The features and exemplary embodiments of various aspects of the present application will be described in detail below, in order to make the purposes, technical solutions and advantages of the present application more clear and apparent, the present application will be further described in detail below in combination with the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, but not to limit the present application. The present application can be implemented without some of these specific details by those skilled in the art. The following description of the embodiments is only to provide a better understanding of the present application by showing examples of the present application.
[0013] It should be noted that, in this paper, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the elements defined by the statement "include" do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0014] To address the problems of existing technologies, embodiments of this application provide an image generation method, apparatus, device, and computer storage medium. By addressing the logical flaws in neurons within an image recognition model, new images are generated more accurately. When these new images are used for model training, the logical flaws in the model are fully exposed, improving the training effect and enhancing the model's robustness and generalization ability. The following detailed description of this solution is provided in conjunction with the accompanying drawings.
[0015] Figure 1 This is a schematic diagram illustrating the implementation environment of an image generation method provided in this application embodiment, such as... Figure 1 As shown, the implementation environment may include a terminal 101 and an image recognition platform 102, with a communication connection between the terminal 101 and the image recognition platform 102.
[0016] In one embodiment, terminal 101 may have an application that supports image recognition installed and running. For example, terminal 101 may be a smartphone, tablet, laptop, desktop computer, smartwatch, etc., and this embodiment does not limit the device type of terminal 101. In one embodiment, terminal 101 may be a user-used terminal, and terminal 101 may send instructions to image recognition platform 102 through an application. These instructions can be used to instruct image recognition platform 102 to perform image recognition tasks. The number of terminals 101 may be one or more, and this embodiment does not limit this.
[0017] In one embodiment, the image recognition platform 102 may be deployed with an image recognition model, which can be used to provide background services for the aforementioned application. For example, the image recognition platform 102 undertakes the primary image data processing work, and the terminal 101 undertakes the secondary image data processing work; or, the image recognition platform 102 undertakes the secondary image data processing work, and the terminal 101 undertakes the primary image data processing work; or, the image recognition platform 102 or the terminal 101 each undertakes image data processing work independently. For example, the image recognition platform 102 may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, network services, cloud communication, CDN (Content Delivery Network), and big data and artificial intelligence platforms, or a cloud computing platform or virtualization center. This application embodiment does not limit the device type of the image recognition platform 102.
[0018] Figure 2 This is a flowchart of an image recognition method provided in an embodiment of this application. This method can be applied to, for example... Figure 1The terminal or image recognition platform in the illustrated implementation environment can be regarded as a kind of computer device, and in the embodiment of the application, the image recognition method is introduced with the computer device as the execution subject. Figure 2 As shown in the figure, the method can include the following steps.
[0019] S201, the computer device determines a plurality of suspicious neurons in the neurons of the image recognition model, and the suspicious neuron is a neuron with abnormal data output in the image recognition process of the image recognition model.
[0020] S202, the computer device inputs a reference image into the image recognition model, and the reference image is an image that has been correctly recognized by the image recognition model.
[0021] S203, the computer device obtains an average gradient between the activation value of the plurality of suspicious neurons and the reference image in the image recognition process of the image recognition model on the reference image, and the average gradient is used to indicate the change degree between the activation value and the reference image.
[0022] S204, the computer device updates the image data of the reference image based on the average gradient to generate a new image.
[0023] In the embodiment of the application, by determining a plurality of suspicious neurons with abnormal data output in the neurons of the image recognition model, inputting a reference image that can be correctly recognized into the image recognition model, obtaining an average gradient between the activation value of the plurality of suspicious neurons and the input reference image in the image recognition process of the reference image, the average gradient indicates the change degree between the activation value and the reference image, which can reflect the possible logical vulnerability of the suspicious neuron, and then updating the image data of the reference image based on the average gradient to generate a new image. Therefore, in the embodiment of the application, the new image is generated more accurately in combination with the logical vulnerability of the neuron in the image recognition model, and when the new image is applied for model training, the logical vulnerability of the model can be fully exposed, the training effect of the model is improved, and the robustness and generalization ability of the model are improved.
[0024] The specific implementation of each step is introduced below.
[0025] In step S201, the computer device determines a plurality of suspicious neurons in the neurons of the image recognition model.
[0026] Among them, the suspicious neuron is a neuron with abnormal data output in the image recognition process of the image recognition model.
[0027] In the embodiment of the present application, the image recognition model can be an artificial intelligence model constructed based on a DNN (Deep Neural Networks), which includes multiple operation layers, for example, an input layer, multiple hidden layers and an output layer. Each operation layer can include multiple neurons. Each neuron receives input data through a weighted connection, performs weighted summation, activation function and other data processing operations on the input data, and generates output data. In the embodiment of the present application, the image recognition model can be a trained model. For example, a training data set can be used to train the image recognition model. The training data set can include multiple training images, each of which can carry annotation information, for example, a bounding box of a detected target in the image, a class label of image classification, etc. The computer device can perform multiple rounds of iterative training on the image recognition model based on the training data set, adjust the neuron parameters of each operation layer, until the error of the output result of the image recognition model is less than an error threshold. The error threshold can be set by a developer. The trained image recognition model can process, analyze and understand the input image, recognize the objects, scenes or features in the image, and the specific training method of the image recognition model is not limited in the embodiment of the present application.
[0028] Figure 3 is a suspicious neuron determination flowchart provided by the embodiment of the present application, as shown in Figure 3 In one embodiment, the process of determining suspicious neurons by the computer device can include the following steps S301-S304.
[0029] S301, the computer device inputs multiple test images into the image recognition model.
[0030] In one embodiment, the computer device acquires a test data set in response to a model test instruction, and the test data set can include multiple test images. For example, the test images can be images stored in the computer device, images captured from a video, or images acquired from any application or webpage, which are not limited in the embodiment of the present application.
[0031] S302, the computer device acquires state distribution data of each neuron in the image recognition process of the image recognition model on the multiple test images.
[0032] The state distribution data can be used to indicate the number of times of the activation state and the inactivation state of the neuron when the image recognition result is correct and incorrect. The activation state and the inactivation state can be determined based on the data of the neuron, that is, the activation value φ(t, n), wherein t represents the input image data of the image recognition model in the current image recognition process, and n represents the weight and bias of the neuron. For example, if the activation value of any neuron is greater than or equal to an activation threshold value, it is determined that the any neuron is in the activation state; if the activation value of any neuron is less than the activation threshold value, it is determined that the any neuron is in the inactivation state. The activation threshold value can be set by the developer.
[0033] In one embodiment, the computer device obtains the state of each neuron and the current image recognition result during the image recognition process of the image recognition model on any test image. The state includes the activation state and the inactivation state. For example, the computer device can record the activation value of each neuron during the image recognition process, and determine the state of each neuron based on the numerical comparison result of the activation value and the activation threshold value. For any neuron, in response to the activation state and the correct current image recognition result, it is determined that any neuron is in the first state; in response to the activation state and the incorrect current image recognition result, it is determined that any neuron is in the second state; in response to the inactivation state and the correct current image recognition result, it is determined that any neuron is in the third state; in response to the inactivation state and the incorrect current image recognition result, it is determined that any neuron is in the fourth state. The computer device can calculate the number of times of the first state, the second state, the third state and the fourth state of each neuron, and determine the number distribution of the first state, the second state, the third state and the fourth state of any neuron as the state distribution data of any neuron.
[0034] S303, the computer device determines the suspicious score of each neuron based on the state distribution data of each neuron.
[0035] The suspicious score is used to indicate the abnormality degree of the neuron data output. In one embodiment, the determination method of the suspicious score can be represented by the following formula (1) SN_score= (1) wherein SN_score represents the suspicious score of the neuron n, represents the number of times of the first state of the neuron n, represents the number of times of the second state of the neuron n, represents the number of times of the third state of the neuron n, The number of times that the neuron n appears in the fourth state is represented. It should be noted that the above description of the suspicious score calculation method is only an exemplary description of a possible implementation, and other calculation formulas can be constructed based on the principle that "the higher the frequency of activation of the neuron when the image recognition model makes a mistake, the lower the frequency of activation of the neuron when the image recognition model makes a correct identification, and the more suspicious the neuron is", and the present embodiment does not limit this.
[0036] In S304, the computer device determines the neuron whose suspicious score meets the preset condition as the suspicious neuron.
[0037] The preset condition can be set by the developer. For example, the preset condition can include the top K neurons with the highest suspicious scores. For example, the computer device can sort the suspicious scores of the neurons in descending order from high to low, and determine the top K neurons with the highest suspicious scores as the suspicious neurons. K is a positive integer, and the value of K is greater than 1 and less than the total number of neurons in the image recognition model. It should be noted that the above description of the preset condition is only an exemplary description, and the preset condition can also be set as neurons with suspicious scores greater than a score threshold, and the present embodiment does not limit the specific content of the preset condition.
[0038] In the present embodiment, the suspicious neurons that can cause the decision logic defects of the image recognition model are determined according to the abnormality degree of the neurons in the image recognition process, which can more accurately locate the vulnerabilities of the image recognition model, and can more targetedly generate new images in the subsequent image generation process.
[0039] In step S202, the computer device inputs the reference image into the image recognition model. The reference image is an image that has been correctly identified by the image recognition model.
[0040] In one embodiment, the computer device can determine the test image correctly identified by the image recognition model as the reference image during the image recognition process of the image recognition model on the plurality of test images. For example, the computer device can record the image recognition results corresponding to each test image during the image recognition process of the image recognition model on the test images, and in response to an image input instruction, obtain the test image with a correct image recognition result from the plurality of test images as the reference image, and input the reference image into the image recognition model. In one embodiment, the reference image can also be an image in the training data set that can be correctly identified by the image recognition model, and the present embodiment does not limit this.
[0041] In step S203, the computer device obtains an average gradient between the activation value of the suspicious neuron and the reference image in the image recognition process of the image recognition model on the reference image.
[0042] The average gradient can be used to indicate the degree of change between the activation value and the reference image. Figure 4 An average gradient obtaining flowchart provided by an embodiment of the present application is shown in FIG. 4. Figure 4 As shown in FIG. 4, in an embodiment, the process of obtaining the average gradient by the computer device can include steps S401-S403.
[0043] S401: The computer device obtains the activation value of each suspicious neuron in the image recognition process of the image recognition model on any reference image.
[0044] In an embodiment, the computer device can obtain M reference images, where M is a positive integer and M≥1. The computer device can input the M reference images into the image recognition model in sequence, and in the image recognition process of the jth reference image, the computer device can traverse each suspicious neuron to obtain the activation value of each neuron. Here, j is a positive integer and 0<j≤M.
[0045] S402: The computer device obtains the gradient between the activation value of each suspicious neuron and the reference image.
[0046] In an embodiment, the calculation method of the gradient can be represented by the following formula (2).
[0047] g i = φ(t,n) / t(2) where g i represents the gradient corresponding to the ith suspicious neuron, i is a positive integer, 0<i≤N, and N is the total number of suspicious neurons; φ(t,n) represents the activation value of the ith suspicious neuron, and t represents the input image data of the image recognition model in the current image recognition process.
[0048] S403: The computer device obtains the average value of the gradients corresponding to the plurality of suspicious neurons as the average gradient.
[0049] In an embodiment, the calculation method of the average gradient can be represented by the following formula (3).
[0050] g mean =( ) / N(3) where g mean represents the average gradient, and g idenotes the gradient corresponding to the i th suspicious neuron, and N denotes the total number of suspicious neurons.
[0051] In the embodiments of the present application, the gradient corresponding to each suspicious neuron is obtained, and the subsequent new image is generated in combination with the gradient, which can generate an image starting from the possible defects and vulnerabilities of the decision logic of the image recognition model, and ensure that the newly generated image can expose the decision logic defects of the model.
[0052] In step S204, the computer device updates the image data of the reference image based on the average gradient to generate a new image.
[0053] In one embodiment, the process of generating a new image by the computer device based on the average gradient and the reference image can include the following steps one to two.
[0054] Step one, the computer device can perform gradient ascent processing on the average gradient based on a reference constraint condition.
[0055] The reference constraint condition is used to limit the change range of the average gradient, and the reference constraint condition can be implemented as a constraint function.
[0056] Step two, the computer device can update the image data of the reference image based on the average gradient after the gradient ascent processing to generate the new image.
[0057] In the embodiments of the present application, the computer device can use the gradient ascent algorithm with the constraint function to generate a new image in combination with the input reference image. For example, the way of generating a new image can be represented by the following formula (4).
[0058] t’ = t + domain_constrain(g mean *step) (4) Wherein, t’ represents the new image; t represents the reference image; g mean represents the average gradient; step represents the step length, which can be used to control the parameter update amplitude; and domain_constrain represents the constraint function.
[0059] In the embodiments of the present application, the gradient of the suspicious neuron is amplified by using the gradient ascent algorithm, that is, the possible defects and vulnerabilities of the model are amplified, and the constraint condition, that is, the constraint function, is used to limit the image update range and update degree of the generated new image, so that the new image can be basically consistent with the reference image when observed from the perspective of the human eye, and will not be identified as a different image by the human eye, ensuring the rationality of the generated new image and improving the image generation quality.
[0060] In an embodiment, after the computer device generates the new image, the computer device can also verify the validity of the new image. For example, the computer device can input the new image into the image recognition model, determine that the new image is invalid in response to the image recognition model correctly recognizing the new image, and determine that the new image is valid in response to the image recognition model incorrectly recognizing the new image. For example, the computer device can input the new image generated based on the jth reference image into the image recognition model, determine that the data update of the jth reference image based on the average gradient of the suspicious neuron is invalid and the new image generated is invalid if the recognition result output by the image recognition model is the same as the recognition result of the jth reference image, i.e., the image recognition model can still correctly recognize the new image. If the recognition result output by the image recognition model is different from the recognition result of the jth reference image, i.e., the image recognition model cannot correctly recognize the new image, it is determined that the data update of the jth reference image based on the average gradient of the suspicious neuron is valid and the new image generated is valid. The recognition result of the jth reference image can be determined based on the recognition of the reference image in step S202, or the reference images are input into the image recognition model for recognition, which is not limited in the embodiments of the present application. In the embodiments of the present application, by verifying the new image, the new image with invalid image data update is removed, and the image generation quality can be improved.
[0061] In an embodiment, the computer device can perform steps S202 to S204 cyclically, i.e., after generating the new image based on the jth reference image, the computer device can input the j+1th reference image into the image recognition model to perform steps S202 to S204 until all reference images are traversed, and the computer device can generate multiple new images. The image generation method of the embodiments of the present application can quickly and low-cost generate new images in batches, and the new images can reflect the logical loopholes of the model, which can be used as adversarial samples for subsequent model training, and the exposed model defects and loopholes can be used for targeted vulnerability repair to improve the recognition accuracy of the model.
[0062] In the embodiment of the present application, by acquiring the output data of each neuron in the image recognition model when the image recognition model performs image recognition, determining the suspicious neuron with abnormal data output, inputting the reference image that can be correctly recognized into the image recognition model, acquiring the average gradient between the activation value of the suspicious neuron and the input reference image in the process of image recognition of the reference image in the image recognition model, the average gradient indicates the change degree between the activation value and the reference image, which can reflect the possible logical vulnerability of the suspicious neuron, and then updating and adjusting the image data of the reference image based on the average gradient to generate a new image. Therefore, in the embodiment of the present application, the new image is generated more accurately in combination with the logical vulnerability of the neuron in the image recognition model, and the gradient ascent algorithm with a constraint condition is used in the generation of the new image to control the update range and degree of the image data, so as to ensure that the new image is basically consistent with the reference image when observed from the perspective of the human eye, and when the new image is applied to model training, the logical vulnerability of the model can be fully exposed, the training effect of the model is improved, and the robustness and generalization ability of the model are improved.
[0063] The embodiment of the present application generates an adversarial sample that can expose the defects of the model from the decision logic defects of the model. The technical scheme provided by the embodiment of the present application is not limited to the image recognition model and image data described above. The adversarial sample generation idea of the present application can also be applied to other types of artificial intelligence models, for example, generating voice data that can expose the defects and vulnerabilities of the speech recognition model, generating text data that can expose the defects and vulnerabilities of the text recognition model, and the embodiment of the present application does not limit the specific application scenarios.
[0064] Figure 5 is a schematic structural diagram of an image generation device provided by the embodiment of the present application. As shown in Figure 5 , the device can include a determination module 510, an input module 520, an acquisition module 530, and a generation module 540.
[0065] The determination module 510 is configured to determine a plurality of suspicious neurons in the neurons of the image recognition model, the suspicious neuron being a neuron with abnormal data output in the process of image recognition of the image recognition model. The input module 520 is configured to input a reference image into the image recognition model, the reference image being an image that has been correctly recognized by the image recognition model. The acquisition module 530 is configured to acquire an average gradient between the activation value of the suspicious neuron and the reference image in the process of image recognition of the reference image in the image recognition model, the average gradient being used to indicate the change degree between the activation value and the reference image. The generation module 540 is configured to update the image data of the reference image based on the average gradient to generate a new image.
[0066] In an embodiment, the determining module 510 comprises: an input unit configured to input a plurality of test images into the image recognition model; an obtaining unit configured to obtain state distribution data of each neuron during an image recognition process of the image recognition model on the plurality of test images, the state distribution data being used to indicate a number of times of occurrence of an active state and an inactive state of the neuron when an image recognition result is correct or incorrect; a first determining unit configured to determine a suspicious score of each neuron based on the state distribution data of each neuron, the suspicious score being used to indicate an abnormality degree of neuron data output; a second determining unit configured to determine a neuron whose suspicious score satisfies a preset condition as the suspicious neuron.
[0067] In an embodiment, the obtaining unit is configured to, during an image recognition process of the image recognition model on any test image, obtain a state of each neuron and a current image recognition result, the state comprising the active state and the inactive state; for any neuron, in response to occurrence of the active state and the current image recognition result being correct, determine that any neuron occurs in a first state; in response to occurrence of the active state and the current image recognition result being incorrect, determine that any neuron occurs in a second state; in response to occurrence of the inactive state and the current image recognition result being correct, determine that any neuron occurs in a third state; in response to occurrence of the inactive state and the current image recognition result being incorrect, determine that any neuron occurs in a fourth state; and distribute a number of times of occurrence of the first state, the second state, the third state and the fourth state of any neuron to determine the state distribution data of any neuron.
[0068] In an embodiment, the preset condition comprises a top K neurons with the highest suspicious scores, wherein K is a positive integer and K>1.
[0069] In an embodiment, the apparatus further comprises an image determining module configured to, during an image recognition process of the image recognition model on the plurality of test images, determine a test image correctly recognized by the image recognition model as the reference image.
[0070] In an embodiment, the obtaining module 530 is configured to, during an image recognition process of the image recognition model on the reference image, obtain an activation value of each suspicious neuron; obtain a gradient between the activation value of each suspicious neuron and the reference image; and obtain an average value of the gradients corresponding to the plurality of suspicious neurons as the average gradient.
[0071] In an embodiment, the generation module 540 is configured to perform gradient ascent processing on the average gradient based on a reference constraint condition for limiting a variation range of the average gradient, and update image data of the reference image based on the average gradient after the gradient ascent processing to generate the new image.
[0072] In an embodiment, the apparatus further includes an identification module configured to input the new image into the image recognition model, determine that the new image is invalid in response to the image recognition model correctly recognizing the new image, and determine that the new image is valid in response to the image recognition model incorrectly recognizing the new image.
[0073] The image generation apparatus provided by the embodiments of the present application can obtain output data of each neuron in the image recognition model when the image recognition model performs image recognition, determine suspicious neurons with abnormal data output, input a reference image that can be correctly recognized into the image recognition model, obtain an average gradient between activation values of the suspicious neurons and the input reference image in the image recognition process of the reference image, the average gradient indicating a variation degree between the activation values and the reference image, and reflecting possible logical vulnerabilities of the suspicious neurons, and update and adjust image data of the reference image based on the average gradient to generate a new image. Thus, the embodiments of the present application can generate a new image more accurately in combination with logical vulnerabilities of neurons in the image recognition model, control the update range and degree of image data by using a gradient ascent algorithm with a constraint condition when generating the new image, ensure that the new image is basically consistent with the reference image when observed from the perspective of human eyes, fully expose logical vulnerabilities of the model when applying the new image for model training, improve the training effect of the model, and improve the robustness and generalization ability of the model.
[0074] Figure 6 FIG. 1 is a schematic diagram of a hardware structure of a computer device provided by an embodiment of the present application. As shown in FIG. 1, the computer device can include a processor 601 and a memory 602 having computer program instructions stored therein. Figure 6
[0075] Specifically, the processor 601 can include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or can be configured as one or more integrated circuits that implement the embodiments of the present application.
[0076] The memory 602 can include mass storage for data or instructions. As an example and not by way of limitation, the memory 602 can include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disc (e.g., a compact disc (CD) or a digital versatile disc (DVD)), a tape drive, a USB drive, or a combination of two or more of these. In one example, the memory 602 can include removable or non-removable (or fixed) media, where the memory 602 is a nonvolatile solid-state memory. The memory 602 can be internal or external to the integrated gateway disaster recovery appliance.
[0077] In one example, the memory 602 can be a Read Only Memory (ROM). In one example, the ROM can be a mask programmed ROM, a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), an Electrically Alterable ROM (EAROM), or a flash memory, or a combination of two or more of these.
[0078] The memory 602 can include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, in general, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software that, when executed (by one or more processors), is operable to perform operations described with reference to methods according to aspects of the present disclosure.
[0079] The processor 601 implements functions by reading and executing computer program instructions stored in the memory 602. Figure 2 The image generation method in the illustrated embodiment.
[0080] In one example, the computer device can further include a communication interface 603 and a bus 606. Wherein, as shown, the processor 601, the memory 602, the communication interface 603 are connected through the bus 604 and complete the communication between each other. Figure 6
[0081] The communication interface 603 is mainly used to realize the communication between each module, device, unit and / or equipment in the embodiment of the application.
[0082] Bus 604 includes a hardware, software, or both that couples components of the online data traffic metering device to each other. As an example without limitation, bus can include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a Micro Channel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association local (VLB) bus, or another suitable bus or a combination of two or more of these. Where appropriate, bus 604 can include one or more buses. Although this application describes and shows a particular bus, this application contemplates any suitable bus or interconnect.
[0083] The computer device can perform the process of generating a new image in the embodiments of the application based on possible defects of the image recognition model, thereby achieving Figure 2 The described image generation method.
[0084] In addition, in combination with the image generation method in the above embodiments, the embodiments of the application can provide a computer storage medium to implement. The computer storage medium has computer program instructions stored thereon; the computer program instructions are executed by the processor to implement any one of the image generation methods in the above embodiments.
[0085] The embodiments of the application also provide a computer program product, comprising a computer program, the computer program is executed by the processor to implement any one of the image generation methods in the above embodiments.
[0086] It needs to be clear that the application is not limited to the specific configurations and processes described above and shown in the drawings. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between steps, after understanding the spirit of the application.
[0087] The functions indicated in the structural block diagrams described above can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, and the like. When implemented in software, the elements of the present application are program or code segments that are used to perform the required tasks. The program or code segments can be stored in a machine-readable medium, or transmitted through a data signal carried in a carrier wave over a transmission medium or communication link. The "machine-readable medium" can include any medium that can store or transfer information. Examples of the machine-readable medium include an electronic circuit, a semiconductor memory device, a read-only memory (ROM), a flash memory, an erasable read-only memory (EROM), a floppy diskette, a compact disk read-only memory (CD-ROM), an optical disk, a hard disk, a fiber optic medium, a radio frequency (RF) link, and the like. The code segments can be downloaded via computer networks such as the Internet, an intranet, and the like.
[0088] It is also noted that the examples mentioned in the present application describe some methods or systems based on a series of steps or devices. However, the present application is not limited to the order of the steps mentioned in the examples, that is, the steps can be performed in the order mentioned in the examples, or in an order different from the examples, or several steps can be performed simultaneously.
[0089] The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other processing device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other processing device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer program instructions can also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other processing device to operate in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function / act specified in the flowchart and / or block diagram block or blocks. The computer program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other processing device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other processing device to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer program instructions can also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other processing device to operate in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function / act specified in the flowchart and / or block diagram block or blocks.
[0090] The above merely describes a specific implementation of the present application. Those skilled in the art can clearly understand the specific working processes of the system, modules and units described above for the convenience and brevity of description, and can refer to the corresponding processes in the foregoing method embodiments, which will not be described herein again. It should be understood that the protection scope of the present application is not limited to this, and any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the present application, and these modifications or replacements should be covered within the protection scope of the present application.
Claims
1. An image generation method characterized by, The method comprises: determining a plurality of suspicious neurons in the neurons of the image recognition model, the suspicious neurons being neurons whose data output is abnormal during the image recognition process of the image recognition model; inputting a reference image into the image recognition model, the reference image being an image that has been correctly recognized by the image recognition model; obtaining an average gradient between the activation values of the plurality of suspicious neurons and the reference image during the image recognition process of the image recognition model on the reference image, the average gradient being used to indicate the degree of change between the activation values and the reference image; updating the image data of the reference image based on the average gradient to generate a new image.
2. The method of claim 1, wherein, The method comprises: inputting a plurality of test images into the image recognition model; obtaining state distribution data of each neuron during the image recognition process of the image recognition model on the plurality of test images, the state distribution data being used to indicate the number of times of activation state and non-activation state of the neuron when the image recognition result is correct and incorrect; determining a suspicious score of each neuron based on the state distribution data of each neuron, the suspicious score being used to indicate the degree of abnormality of the data output of the neuron; determining the neuron whose suspicious score meets a preset condition as the suspicious neuron.
3. The method of claim 2, wherein, The method comprises: obtaining the state and the current image recognition result of each neuron during the image recognition process of the image recognition model on any test image, the state comprising the activation state and the non-activation state; for any neuron, in response to the appearance of the activation state and the correct current image recognition result, determining that any neuron appears in a first state; in response to the appearance of the activation state and the incorrect current image recognition result, determining that any neuron appears in a second state; in response to the appearance of the non-activation state and the correct current image recognition result, determining that any neuron appears in a third state; in response to the appearance of the non-activation state and the incorrect current image recognition result, determining that any neuron appears in a fourth state; determining the number of times of the first state, the second state, the third state and the fourth state of any neuron as the state distribution data of any neuron.
4. The method of claim 2, wherein, The preset condition comprises the top K neurons with the highest suspicious score, wherein K is a positive integer and K>1.
5. The method of claim 2, wherein, After inputting the plurality of test images into the image recognition model, the method further comprises: determining the test image that is correctly recognized by the image recognition model as the reference image during the image recognition process of the image recognition model on the plurality of test images.
6. The method of claim 1, wherein, The average gradient between the activation value of the plurality of suspicious neurons and the reference image is obtained during the image recognition of the reference image by the image recognition model, and the average gradient is used to indicate the change degree between the activation value and the reference image. The activation value of each suspicious neuron is obtained during the image recognition of the reference image by the image recognition model. The gradient between the activation value of each suspicious neuron and the reference image is obtained. The average value of the gradients corresponding to the plurality of suspicious neurons is obtained as the average gradient.
7. The method of claim 1, wherein, The image data of the reference image is updated based on the average gradient to generate a new image, and the new image is input into the image recognition model. The average gradient is subjected to gradient ascent processing based on a reference constraint condition, and the reference constraint condition is used to limit the change range of the average gradient. The image data of the reference image is updated based on the average gradient after the gradient ascent processing to generate the new image.
8. The method of claim 1, wherein, After the image data of the reference image is updated based on the average gradient to generate the new image, the method further comprises: The new image is input into the image recognition model. In response to the image recognition model correctly recognizing the new image, it is determined that the new image is invalid. In response to the image recognition model incorrectly recognizing the new image, it is determined that the new image is valid.
9. An image generation apparatus characterized by comprising: The device comprises: A determination module is configured to determine a plurality of suspicious neurons in the neurons of an image recognition model, wherein the suspicious neurons are neurons with abnormal data output during the image recognition by the image recognition model. An input module is configured to input a reference image into the image recognition model, wherein the reference image is an image that has been correctly recognized by the image recognition model. An acquisition module is configured to obtain an average gradient between the activation value of the plurality of suspicious neurons and the reference image during the image recognition of the reference image by the image recognition model, wherein the average gradient is used to indicate the change degree between the activation value and the reference image. A generation module is configured to update the image data of the reference image based on the average gradient to generate a new image.
10. A computer device, comprising: The device comprises a processor and a memory storing computer program instructions; the processor reads and executes the computer program instructions to implement the image generation method of any one of claims 1-8.
11. A computer readable storage medium, characterized in that, The computer storage medium stores computer program instructions, and the computer program instructions are executed by a processor to implement the image generation method of any one of claims 1-8.
12. A computer program product, characterised in that, The computer program is executed by a processor to implement the image generation method of any one of claims 1-8.
Citation Information
Patent Citations
Method and system for predicting generalization error of image recognition model based on non-check set
CN112598082A