Training method and device of activation-like graph generation model, equipment and medium

By enhancing the sample images and deep feature extraction, combining intra-class and cross-category comparison strategies, model parameters are adjusted to generate accurate class activation maps, the accuracy problem of class activation map generation under complex image backgrounds is solved.

CN119672488APending Publication Date: 2025-03-21PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411697699.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-03-21

AI Technical Summary

Technical Problem

The prior art is difficult to accurately generate class activation maps under complex image backgrounds, and is disturbed by background noise and non-target category areas.

Method used

By enhancing the sample images of each category, depth feature information is extracted, and intra-class comparison and cross-category comparison strategies are adopted to adjust model parameters to generate more accurate class activation maps.

Benefits of technology

Improve the accuracy of the class activation map, reduce background noise and class confusion, and make the generated class activation map more focused on the key areas of the target category.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119672488A_ABST
    Figure CN119672488A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of artificial intelligence, and relates to a class activation graph generation model training method comprising the following steps: obtaining a sample image set comprising multiple classes, and carrying out enhancement processing on each class of images to obtain multiple enhanced samples; a preset initial class activation graph is adopted to generate a model, depth features of an enhanced sample are extracted, and a loss function of the model contains two initial parts. Performing intra-class comparison on the enhanced sample based on a preset intra-class comparison strategy and the first initial loss function, and calculating intra-class loss; meanwhile, based on a cross-class comparison strategy and the second initial loss function, cross-class comparison is carried out, and cross-class loss is calculated. And combining the two types of losses, adjusting model parameters, and finally generating a class activation graph generation model. The invention further provides a device, equipment and a medium. In addition, the invention also relates to a block chain technology, and the sample image set can be stored in a block chain. The accuracy of the class activation graph can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a training method, device, equipment and medium for generating a class activation map model. Background Art

[0002] With the rapid development of deep learning technology, Class Activation Map (CAM), as a visualization tool, plays a vital role in explaining the decision-making process of deep learning models, especially in computer vision tasks such as image classification and object detection. Class Activation Map helps researchers and developers understand the decision basis of the model by highlighting the image areas that contribute most to the model's prediction results, thereby further optimizing the model performance.

[0003] However, the generation process of traditional class activation maps is not perfect. In practical applications, due to the presence of complex background noise and interference areas of non-target categories in images, these unfavorable factors will seriously affect the accuracy of class activation maps. Specifically, background noise may cause the activation area to deviate from the actual target, while non-target category areas may introduce unnecessary interference, making the generated class activation map unable to accurately reflect the model's true focus area on the target category. Therefore, how to accurately generate class activation maps in complex image backgrounds to reduce background noise and interference from non-target category areas has become a key issue that needs to be urgently solved in the current deep learning field. Summary of the invention

[0004] The purpose of the embodiments of the present application is to propose a training method, device, equipment and medium for a class activation map generation model to solve the problem that it is difficult to accurately generate a class activation map due to interference from background noise and non-target category areas.

[0005] In order to solve the above technical problems, the embodiment of the present application provides a training method for a class activation map generation model, which adopts the following technical solutions:

[0006] A sample image set is obtained, the sample image set includes sample images of multiple categories; the sample images of each category are enhanced to obtain multiple enhanced sample images of each category; a preset initial class activation map generation model is used to extract the depth feature information of the multiple enhanced sample images, the loss function of the initial class activation map generation model includes a first initial loss function and a second initial loss function; based on the preset intra-class comparison strategy, the depth feature information and the first initial loss function, the multiple enhanced sample images are compared within the class to obtain the intra-class loss function; based on the preset cross-class comparison strategy, the depth feature information and the second initial loss function, the multiple enhanced samples are compared across categories to obtain the cross-class loss function; based on the intra-class loss function and the cross-class loss function, the parameters of the initial class activation map generation model are adjusted to generate a class activation map generation model.

[0007] Furthermore, based on the preset intra-class comparison strategy, the depth feature information and the first initial loss function, the multiple enhanced sample images are compared within the class to obtain the step of the intra-class loss function, which specifically includes:

[0008] From multiple enhanced sample images, multiple target sample image pairs are determined, and the images of each target sample image pair are enhanced sample images under the same category; from the depth feature information, the target depth feature information of the image of each target sample image pair is obtained; based on the preset intra-class comparison strategy, the target depth feature information and the first initial loss function, the multiple target sample image pairs are compared within the class to obtain the intra-class loss function.

[0009] Further, based on the preset intra-class comparison strategy, the target depth feature information and the first initial loss function, the step of performing intra-class comparison on multiple target sample image pairs to obtain the intra-class loss function specifically includes:

[0010] Based on the preset intra-class comparison strategy and target depth feature information, the cosine values ​​of multiple target sample image pairs are calculated; the cosine values ​​and the first initial loss function are fused to obtain the intra-class loss function.

[0011] Further, based on the preset cross-category comparison strategy, the deep feature information and the second initial loss function, a cross-category comparison is performed on multiple enhanced samples to obtain a cross-category loss function, specifically including:

[0012] An anchor sample image is determined from multiple enhanced sample images; based on the anchor sample image, multiple positive sample images and multiple negative sample images are determined from the multiple enhanced sample images, each positive sample image and the anchor sample image are enhanced sample images under the same category, and each negative sample image and the anchor sample image are enhanced sample images under different categories; based on a preset cross-class comparison strategy and deep feature information, distance measurement is performed on the anchor sample image, multiple positive sample images and multiple negative sample images to obtain distance values; the distance values ​​are fused with the second initial loss function to obtain a cross-class loss function.

[0013] Furthermore, based on the preset cross-class comparison strategy and deep feature information, distance measurement is performed on the anchor sample image, multiple positive sample images, and multiple negative sample images to obtain the distance value, which specifically includes:

[0014] Based on the preset cross-category comparison strategy and depth feature information, the distance between the anchor sample image and each positive sample image is calculated to obtain a first distance; based on the cross-category comparison strategy and depth feature information, the distance between the anchor sample image and each negative sample image is calculated to obtain a second distance; based on the first distance and the second distance, a distance value is obtained.

[0015] Further, the step of performing enhancement processing on the sample images of each category to obtain a plurality of enhanced sample images under each category specifically includes:

[0016] According to the preset data enhancement strategy, the image transformation operation that needs to be performed on the sample images of each category is determined, and the image transformation operation includes at least one of image rotation, image scaling, image flipping, and image cropping; the image transformation operation is performed on the sample images of each category to obtain multiple enhanced sample images under each category.

[0017] Furthermore, after the step of adjusting the parameters of the initial class activation map generation model based on the intra-class loss function and the cross-class loss function to generate the class activation map generation model, the method further includes:

[0018] The network structure of the class activation map generation model is obtained, and the target convolution layer of the class activation map generation model is determined based on the network structure; the target image is obtained, and the target image is input into the class activation map generation model to obtain the feature map of the target image output by the target convolution layer; the weight vector corresponding to each classification category in the classification layer of the class activation map generation model is obtained; the feature map and the weight vector corresponding to each classification category are weighted summed to obtain the class activation map of the target image corresponding to each classification category.

[0019] In order to solve the above technical problems, the embodiment of the present application also provides a training device for a class activation map generation model, which adopts the following technical solution:

[0020] An acquisition module, used to acquire a sample image set, where the sample image set includes sample images of multiple categories;

[0021] An enhancement module is used to enhance the sample images of each category to obtain multiple enhanced sample images of each category;

[0022] An extraction module, used to extract deep feature information of multiple enhanced sample images by using a preset initial class activation map generation model, wherein the loss function of the initial class activation map generation model includes a first initial loss function and a second initial loss function;

[0023] An intra-class comparison module, used to perform intra-class comparison on multiple enhanced sample images based on a preset intra-class comparison strategy, deep feature information and a first initial loss function to obtain an intra-class loss function;

[0024] A cross-category comparison module, used to perform cross-category comparison on multiple enhanced samples based on a preset cross-category comparison strategy, deep feature information and a second initial loss function to obtain a cross-category loss function;

[0025] The adjustment module is used to adjust the parameters of the initial class activation map generation model based on the intra-class loss function and the cross-class loss function to generate the class activation map generation model.

[0026] In order to solve the above technical problems, an embodiment of the present application also provides a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the training method for generating a class activation map model as described above are implemented.

[0027] In order to solve the above technical problems, an embodiment of the present application also provides a computer-readable storage medium, which stores computer-readable instructions. The computer-readable instructions can be executed by at least one processor to enable at least one processor to perform the steps of the training method for generating a class activation map model as described above.

[0028] Compared with the prior art, the embodiments of the present application mainly have the following beneficial effects: by enhancing the sample images of each category, the generalization ability of the model is increased. Subsequently, the initial class activation map generation model is used to extract deep feature information, which provides a basis for subsequent contrastive learning. Intra-class contrastive learning ensures that the model can learn the feature consistency of samples of the same category under different conditions, so that the generated class activation map is more focused on the key areas of the target category, reducing the false activation of background or non-target areas. Cross-category contrastive learning significantly improves the model's ability to distinguish by maximizing the differences between samples of different categories, so that the model can accurately distinguish the target category from other categories, and further reduces the false activation of non-target category areas in the class activation map. This joint learning method not only maintains the accuracy and consistency of feature details, but also significantly reduces background noise and category confusion, thereby improving the accuracy of the class activation map. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0030] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0031] Figure 2 It is a flowchart of a training method for a class activation map generation model provided by the present application;

[0032] Figure 3 It is a structural schematic diagram of a training device for a class activation map generation model provided by the present application;

[0033] Figure 4 It is a structural schematic diagram of a computer device provided by this application. DETAILED DESCRIPTION

[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0035] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0036] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0037] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.

[0038] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0039] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.

[0040] The server 103 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal device 101 .

[0041] It should be noted that the training method for the class activation map generation model provided in the embodiment of the present application is generally executed by a server, and accordingly, the training device for the class activation map generation model is generally set in the server.

[0042] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0043] Continue to refer Figure 2 , shows a flow chart of an embodiment of a training method for a class activation map generation model according to the present application. The training method for a class activation map generation model comprises the following steps:

[0044] Step S201: Acquire a sample image set, where the sample image set includes sample images of multiple categories.

[0045] In this embodiment, the training method of the class activation map generation model is executed on the electronic device (e.g. Figure 1 The server shown in the figure) can obtain the sample image set through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0046] The sample image set refers to a set of multiple different image samples, which are used to train and test the model. They come from different categories and are used for training and optimizing deep learning models. For example, a set of images of multiple categories such as cats, dogs, and cars is a sample image set.

[0047] Among them, multiple categories refer to the different kinds of objects involved in the image classification task. Such as animals, plants, vehicles, etc. In the deep learning model, each category has a corresponding label to guide the model's learning process. For example, in the animal classification task, multiple categories can include cats, dogs, birds, etc.

[0048] A sample image refers to a single image obtained from a real environment and used for model training. Each sample image contains certain information, such as color, texture, shape, etc., which is the key to model learning. For example, an image containing a cat is a sample image.

[0049] Step S202: Perform enhancement processing on the sample images of each category to obtain a plurality of enhanced sample images of each category.

[0050] Among them, enhancement processing refers to a series of transformation operations on the original image to increase the diversity and richness of the image, thereby improving the generalization ability of the model. These transformation operations can include rotation, scaling, flipping, cropping, etc. For example, a cat image is rotated and scaled to obtain multiple enhanced sample images.

[0051] Among them, enhanced sample images refer to image samples that have been enhanced. They have more changes and diversity than the original images, which helps the model learn more robust features. For example, an image of a cat that has been rotated and scaled is an enhanced sample image.

[0052] Step S203, using a preset initial class activation map generation model to extract deep feature information of multiple enhanced sample images, the loss function of the initial class activation map generation model includes a first initial loss function and a second initial loss function.

[0053] The initial class activation map generation model refers to a preliminary model used to generate class activation maps. The model extracts feature information from the image through deep learning technology and generates the corresponding class activation map. The initial model needs to be trained and optimized to improve performance. For example, a model based on a convolutional neural network can be used as an initial class activation map generation model.

[0054] Among them, deep feature information refers to the deep feature information extracted by the deep learning model to describe the image content. This feature information is usually more abstract and advanced than the original image, which helps the model to accurately classify and identify.

[0055] The loss function is a function used to measure the difference between the model's prediction results and the actual results in a deep learning model. The smaller the loss function, the more accurate the model's prediction results. In the class activation map generation task, the loss function is used to guide the training and optimization of the model.

[0056] The first initial loss function refers to the loss function used to guide the intra-class comparison training process in the initial class activation map generation model. It is usually combined with the intra-class comparison strategy to optimize the model's feature representation ability on similar samples.

[0057] The second initial loss function refers to the loss function used to guide the cross-category comparison training process in the initial class activation map generation model. It is usually combined with the cross-category comparison strategy to optimize the model's feature discrimination ability on heterogeneous samples.

[0058] Step S204: Based on a preset intra-class comparison strategy, the depth feature information, and the first initial loss function, intra-class comparison is performed on the multiple enhanced sample images to obtain an intra-class loss function.

[0059] Among them, the intra-class comparison strategy refers to a strategy for optimizing the model's feature representation ability by comparing the feature differences between samples of the same type during deep learning model training. It helps the model learn a more compact and consistent representation of similar features. For example, calculating the cosine similarity between samples of the same type to guide model training is an intra-class comparison strategy.

[0060] Among them, intra-class comparison refers to the feature comparison process between samples of the same type based on the intra-class comparison strategy. By comparing the feature differences of samples of the same type, the model's feature representation ability on samples of the same type can be optimized. For example, in the image classification task, optimizing the model's feature representation ability for cats by comparing the image features of different cats is intra-class comparison.

[0061] The intra-class loss function refers to the loss function calculated based on the intra-class comparison strategy, deep feature information, and the first initial loss function. It is used to measure the size of the feature differences between samples of the same type and guide the model for training and optimization.

[0062] Step S205 , based on the preset cross-category comparison strategy, the depth feature information and the second initial loss function, a cross-category comparison is performed on the multiple enhanced samples to obtain a cross-category loss function.

[0063] Among them, the cross-category comparison strategy refers to a strategy for optimizing the model's feature differentiation ability by comparing the feature differences between samples of different classes during deep learning model training. It helps the model learn more dispersed and distinguishable heterogeneous feature representations.

[0064] Among them, cross-category comparison refers to the feature comparison process between samples of different categories based on the cross-category comparison strategy. By comparing the feature differences of heterogeneous samples, the model's feature distinction ability on heterogeneous samples can be optimized. For example, in image classification tasks, optimizing the model's feature distinction ability for cats and dogs by comparing the image features of cats and dogs is cross-category comparison.

[0065] The cross-class loss function refers to the loss function calculated based on the cross-class comparison strategy, deep feature information, and the second initial loss function. It is used to measure the size of the feature differences between heterogeneous samples and guide the model to train and optimize.

[0066] Step S206: Based on the intra-class loss function and the cross-class loss function, adjust the parameters of the initial class activation map generation model to generate a class activation map generation model.

[0067] The parameters of the initial class activation map generation model refer to the variables that need to be optimized during the training process of the initial class activation map generation model, which may include weights and biases, etc. These parameters determine the performance and capabilities of the model.

[0068] The class activation map generation model refers to a deep learning model that can generate a class activation map after training and optimizing the initial class activation map generation model. The model can extract feature information from an image and generate a corresponding class activation map based on the feature information.

[0069] The embodiment of the present application can increase the generalization ability of the model by enhancing the sample images of each category. Subsequently, the initial class activation map generation model is used to extract deep feature information, which provides a basis for subsequent contrastive learning. Intra-class contrastive learning ensures that the model can learn the feature consistency of samples of the same category under different conditions, so that the generated class activation map is more focused on the key areas of the target category, reducing the misactivation of background or non-target areas. Cross-category contrastive learning significantly improves the distinguishing ability of the model by maximizing the differences between samples of different categories, so that the model can accurately distinguish the target category from other categories, and further reduces the misactivation of non-target category areas in the class activation map. This joint learning method not only maintains the accuracy and consistency of feature details, but also significantly reduces background noise and category confusion, thereby improving the accuracy of the class activation map.

[0070] In some optional implementations of this embodiment, step 202, performing enhancement processing on the sample images of each category to obtain multiple enhanced sample images of each category, specifically includes the following steps:

[0071] According to the preset data enhancement strategy, the image transformation operation that needs to be performed on the sample images of each category is determined, and the image transformation operation includes at least one of image rotation, image scaling, image flipping, and image cropping; the image transformation operation is performed on the sample images of each category to obtain multiple enhanced sample images under each category.

[0072] The data augmentation strategy refers to a series of transformation methods and rules used to generate enhanced sample images. The data augmentation strategy aims to increase the diversity and richness of images, thereby improving the generalization ability of the model. For example, operations such as random rotation, scaling, flipping, and cropping can constitute a data augmentation strategy.

[0073] The image transformation operation refers to a series of transformations performed on the image, including rotation, scaling, flipping, cropping, etc. These operations can change the image's shape, size, and orientation, thereby generating different enhanced sample images. For example, rotating a cat image by 45 degrees is an image transformation operation.

[0074] In one example, in the financial field, taking check image recognition in a check processing system as an example, the method of this embodiment first defines a set of data enhancement strategies for check images. According to the characteristics of check images, the strategy determines four image transformation operations: image rotation (simulating changes in shooting angles, with a range of ±15°), image scaling (simulating size changes caused by shooting at different distances, with a scaling ratio of 0.8 to 1.2), image flipping (horizontal flipping, simulating mirror effects), and image cropping (randomly cropping to 90% of the original image, simulating partial occlusion or incomplete shooting). Then, for each category of check images (such as checks issued by different banks), image transformation operations can be performed according to the above strategy. For example, for a certain type of check image, one or more combinations of the four transformations of image rotation of 10°, image scaling to 1.1 times the original size, horizontal flipping, and cropping to 85% of the original image are randomly selected to generate multiple enhanced sample images under this category.

[0075] The embodiment of the present application can perform image transformation operations for sample images of each category by implementing a preset data enhancement strategy, thereby achieving effective expansion and diversity improvement of image data. Specifically, transformation operations such as image rotation, scaling, flipping and cropping can simulate various morphological changes that may occur in images in real environments, such as changes in perspective, size differences, direction reversal and partial occlusion. This transformation not only enriches the training data set, but also enhances the model's ability to fully capture image features and improves the generalization performance of the model. In addition, image transformation is performed separately for each category to ensure the consistency of the enhanced sample image with the original category, which helps the model to learn the intrinsic features of each category of images more accurately. By increasing the number of enhanced samples under each category, the adequacy and stability of model training are further improved.

[0076] In some optional implementations of this embodiment, step S204, based on a preset intra-class comparison strategy, depth feature information, and a first initial loss function, performs intra-class comparison on multiple enhanced sample images to obtain an intra-class loss function, specifically including the following steps:

[0077] From multiple enhanced sample images, multiple target sample image pairs are determined, and the images of each target sample image pair are enhanced sample images under the same category; from the depth feature information, the target depth feature information of the image of each target sample image pair is obtained; based on the preset intra-class comparison strategy, the target depth feature information and the first initial loss function, the multiple target sample image pairs are compared within the class to obtain the intra-class loss function.

[0078] The target sample image pair refers to a sample image pair of the same type used to compare feature differences during the intra-class comparison process. The target sample image pair is selected from the enhanced sample images to guide the model to perform intra-class comparison training. For example, two different cat images are selected from the cat class samples as the target sample image pair.

[0079] The target depth feature information refers to the depth feature information extracted from the target sample image pair and used to compare feature differences. The target depth feature information is usually extracted by a deep learning model and used to guide the model to perform intra-class comparison training.

[0080] In one example, the original sample image can be transformed according to a preset data enhancement strategy (such as image rotation, scaling, flipping, cropping, etc.) to generate multiple enhanced sample images. These enhanced sample images retain the category attributes of the original sample images, but the morphology has changed. Then, from the generated enhanced sample images, two enhanced sample images of the same category are randomly selected to form a target sample image pair. Through multiple selections, multiple target sample image pairs are constructed for subsequent depth feature information comparison. Then, using the pre-trained initial class activation map generation model, the image in each target sample image pair is feature extracted to obtain the target depth feature information. This feature information can reflect the similarity and difference of the image in high-level semantics. Then, based on the preset intra-class comparison strategy (such as cosine similarity, Euclidean distance, etc.), the similarity measure between the target depth feature information of each target sample image pair is calculated. Then, combined with the first initial loss function, an intra-class loss function is constructed. This loss function aims to minimize the distance between similar images in the depth feature space and enhance the recognition consistency of the model for similar images.

[0081] The embodiment of the present application can achieve a detailed comparison of enhanced sample images at the intra-class level by constructing multiple target sample image pairs and extracting their deep feature information. Specifically, each target sample image pair contains different enhanced sample images under the same category, which ensures the pertinence and effectiveness of the comparison. Using the preset intra-class comparison strategy, this embodiment can accurately measure the similarity between the target deep feature information, and then combine the first initial loss function to construct a more refined intra-class loss function. This function not only reflects the distribution characteristics of similar images in the deep feature space, but also guides the parameter adjustment direction of the initial class activation map generation model during the training process.

[0082] In some optional implementations of this embodiment, the step of “performing intra-class comparison on multiple target sample image pairs based on a preset intra-class comparison strategy, target depth feature information, and a first initial loss function to obtain an intra-class loss function” specifically includes the following steps:

[0083] Based on the preset intra-class comparison strategy and target depth feature information, the cosine values ​​of multiple target sample image pairs are calculated; the cosine values ​​and the first initial loss function are fused to obtain the intra-class loss function.

[0084] In one example, the cosine value between the depth feature information of each target sample image pair can be calculated based on a preset intra-class comparison strategy. The cosine value is a function that measures the cosine of the angle between two vectors, and its range is [-1,1]. The larger the value, the more similar the two vectors are. In this embodiment, the cosine value can be used to measure the similarity between two enhanced sample images of the same category in the depth feature space. Then, the calculated cosine value can be fused with the first initial loss function to construct an intra-class loss function. Specifically, the cosine value can be added to the initial loss function as a regularization term, or the negative of the cosine value can be used as a new loss term and weighted summed with the initial loss function to obtain the intra-class loss function.

[0085] The embodiment of the present application can innovatively construct an intra-class loss function by fusing the cosine value with the first initial loss function, effectively improving the model's ability to recognize features of similar images. The preset intra-class comparison strategy ensures that in the deep feature space, the cosine values ​​of similar image pairs can accurately reflect their degree of similarity, thereby enhancing the model's learning of the intrinsic features of similar images. Combining the cosine value as a regularization term or a new loss term with the initial loss function not only retains the model's ability to distinguish between categories, but also significantly improves the accuracy and consistency of identifying similar images.

[0086] In some optional implementations of this embodiment, step S205, based on a preset cross-category comparison strategy, deep feature information, and a second initial loss function, performs cross-category comparison on multiple enhanced samples to obtain a cross-category loss function, specifically including the following steps:

[0087] An anchor sample image is determined from multiple enhanced sample images; based on the anchor sample image, multiple positive sample images and multiple negative sample images are determined from the multiple enhanced sample images, each positive sample image and the anchor sample image are enhanced sample images under the same category, and each negative sample image and the anchor sample image are enhanced sample images under different categories; based on a preset cross-class comparison strategy and deep feature information, distance measurement is performed on the anchor sample image, multiple positive sample images and multiple negative sample images to obtain distance values; the distance values ​​are fused with the second initial loss function to obtain a cross-class loss function.

[0088] The anchor sample image refers to an image sample used as a benchmark and reference in the cross-category comparison process. The anchor sample image can be selected from the enhanced sample image for comparison with the positive sample image and the negative sample image. For example, in an image classification task, a cat image is selected as an anchor sample image.

[0089] Among them, the positive sample image refers to the image sample that belongs to the same category as the anchor sample image during the cross-category comparison process. The positive sample image is used to compare with the anchor sample image to optimize the model's feature representation ability on the same type of samples. For example, a cat image similar to the anchor sample image is selected as the positive sample image in the cat sample.

[0090] Among them, negative sample images refer to image samples that belong to different categories from the anchor sample images during the cross-category comparison process. Negative sample images are used to compare with anchor sample images to optimize the model's feature differentiation ability on heterogeneous samples. For example, in an image classification task, an image of a dog is selected as a negative sample image that is different from the anchor sample image (cat).

[0091] In one example, first, a large amount of animal image data can be collected and data enhancement processing such as rotation, scaling, flipping, etc. can be performed to generate multiple enhanced sample images. These enhanced sample images enrich the original data set and improve the generalization ability of the model. Next, one is randomly selected from the enhanced sample images as an anchor sample image. Then, multiple enhanced sample images of the same category as the anchor sample image are selected as positive sample images, and multiple enhanced sample images of different categories from the anchor sample image are selected as negative sample images. In this way, a sample set including anchor samples, positive samples and negative samples is formed. Then, the pre-trained initial class activation map generation model is used to extract the deep feature information of each image in the sample set. These deep feature information can reflect the feature representation of the image at a high level of semantics. Then, based on the preset cross-class comparison strategy, the deep feature information of the anchor sample image, the positive sample image and the negative sample image is distance-measured to obtain the distance value. The smaller the distance value, the closer the distance between the two samples in the deep feature space and the higher the similarity; conversely, the larger the distance value, the farther the distance between the two samples in the deep feature space and the higher the difference. The calculated distance value is fused with the second initial loss function to construct a cross-class loss function. Specifically, the distance value can be added to the second initial loss function as a regularization term, or a certain transformation form of the distance value can be used as a new loss term and weighted summed with the second initial loss function to obtain a cross-class loss function.

[0092] The embodiment of the present application can accurately select anchor samples from multiple enhanced sample images, and determine positive and negative samples accordingly, ensuring the representativeness and pertinence of the sample selection. Subsequently, using deep feature information and a preset cross-class comparison strategy, a detailed distance measurement is performed on the anchor, positive, and negative samples to accurately characterize the similarities and differences between the samples. Finally, the distance measurement result is cleverly combined with the second initial loss function to construct a more sophisticated cross-class loss function. This function not only enhances the model's ability to extract features of similar samples, but also significantly improves the model's ability to distinguish heterogeneous samples.

[0093] In some optional implementations of this embodiment, the step of “based on a preset cross-class comparison strategy and deep feature information, performing distance measurement on the anchor sample image, multiple positive sample images, and multiple negative sample images to obtain distance values” may specifically include the following steps:

[0094] Based on the preset cross-category comparison strategy and depth feature information, the distance between the anchor sample image and each positive sample image is calculated to obtain a first distance; based on the cross-category comparison strategy and depth feature information, the distance between the anchor sample image and each negative sample image is calculated to obtain a second distance; based on the first distance and the second distance, a distance value is obtained.

[0095] In one example, the distance between the anchor sample image and each positive sample image is calculated to obtain a first distance. The smaller the first distance, the more consistent the directions of the two samples in the depth feature space, and the higher the similarity. Similarly, the distance between the anchor sample image and each negative sample image is calculated to obtain a second distance. The larger the second distance, the more inconsistent the directions of the two samples in the depth feature space, and the higher the degree of difference. Finally, based on the first distance and the second distance, a distance value is obtained.

[0096] The embodiments of the present application can achieve accurate calculation of the distance between the anchor sample image and the positive and negative sample images by introducing a preset cross-category comparison strategy and combining the depth feature information. Specifically, the high-level semantic features of the image can be captured using the depth feature information, and then the first distance between the anchor sample image and the positive sample image, and the second distance between the anchor sample image and the negative sample image are calculated respectively through the cross-category comparison strategy. The first distance reflects the closeness between samples of the same type, while the second distance reveals the degree of alienation between samples of different types. Finally, based on the comprehensive consideration of the first distance and the second distance, a distance value is obtained, which not only reflects the relative position relationship between samples, but also implies the comparison of category information.

[0097] In some optional implementations of this embodiment, in step S206, after adjusting the parameters of the initial class activation map generation model based on the intra-class loss function and the cross-class loss function to generate the class activation map generation model, the following steps may be specifically included:

[0098] The network structure of the class activation map generation model is obtained, and the target convolution layer of the class activation map generation model is determined based on the network structure; the target image is obtained, and the target image is input into the class activation map generation model to obtain the feature map of the target image output by the target convolution layer; the weight vector corresponding to each classification category in the classification layer of the class activation map generation model is obtained; the feature map and the weight vector corresponding to each classification category are weighted summed to obtain the class activation map of the target image corresponding to each classification category.

[0099] The network structure refers to the hierarchical structure and connection relationship in the class activation map generation model. The network structure determines the information processing flow and feature extraction capabilities of the model.

[0100] The target convolution layer refers to a specific convolution layer used to extract image feature information in the class activation map generation model. The target convolution layer is usually located at the last layer of the model and can extract more abstract and advanced feature information.

[0101] The feature map refers to a two-dimensional matrix containing image feature information extracted by the convolutional layer in the class activation map generation model. Feature maps are usually used to represent local features of an image, such as texture, edges, etc. For example, if the class activation map generation model is a convolutional neural network, then in the convolutional neural network, the result of the convolutional layer output is the feature map.

[0102] The classification layer refers to the layer used to classify and identify the extracted feature information in the class activation map generation model. The classification layer is usually located in the last few layers of the model, and the classification function is realized through structures such as fully connected layers or global average pooling layers.

[0103] Each classification category refers to a different type of object involved in the image classification task. Each classification category has a corresponding label and weight vector to guide the model for classification and recognition. For example, in an animal classification task, each classification category may include cats, dogs, birds, etc.

[0104] The weight vector refers to the vector used to represent the feature information of each classification category in the class activation map generation model. The weight vector usually corresponds to the neurons in the classification layer and is used to calculate the score or probability of each category.

[0105] In one example, taking the ResNet-50 model as the initial class activation map generation model, first, a trained ResNet-50 model can be obtained as the class activation map generation model. The model can include multiple convolutional layers, pooling layers, fully connected layers and other structures. In the ResNet-50 model, the last convolutional layer is selected as the target convolutional layer. The target convolutional layer can output a feature map with a higher resolution. Next, an image containing an animal is selected as the target image, such as an image containing a cat. The target image is input into the ResNet-50 model, and the feature map output by the target convolutional layer is extracted. The feature map contains high-level semantic features of the target image in the convolutional layer, such as edges, textures, etc. Then, the weight vector corresponding to each classification category is extracted from the classification layer of the ResNet-50 model. For the classification category of "cat", the feature map and the weight vector corresponding to the classification category are weighted summed to obtain the class activation map of the target image for the classification category of "cat". Each value in the class activation map represents the importance of the corresponding position in the target image for the classification category of "cat". By visualizing the class activation map, we can intuitively see which parts of the target image have an important impact on the classification result of "cat".

[0106] The embodiment of the present application can achieve accurate extraction of deep features of the target image by accurately obtaining the network structure of the class activation map generation model and intelligently determining the target convolution layer. After the target image is input into the model, the resulting feature map is rich in high-level semantic information of the image. Furthermore, by cleverly obtaining the weight vector corresponding to each classification category in the classification layer and performing weighted summation with the feature map, the class activation map corresponding to each classification category can be automatically generated. These class activation maps not only intuitively show the areas in the image that play a key role in classification decisions, but also significantly improve the interpretability and accuracy of image classification tasks.

[0107] It should be emphasized that in order to further ensure the privacy and security of the above-mentioned sample image set, multiple enhanced sample images, deep feature information, intra-class loss function and cross-class loss function, the above-mentioned sample image set, multiple enhanced sample images, deep feature information, intra-class loss function and cross-class loss function can also be stored in a node of a blockchain.

[0108] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0109] The embodiments of the present application can build and optimize related models and networks based on artificial intelligence technology, such as initial class activation map generation model, class activation map generation model, etc. Among them, artificial intelligence (AI) models are the crystallization of theory and practice that simulates the decision-making process of human intelligence through algorithms and data analysis to solve complex problems, predict future trends, or realize automation tasks. These models use a large amount of historical data and real-time information, and are trained and optimized through a specific algorithm framework to achieve efficient, accurate and reliable performance.

[0110] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0111] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0112] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a training device for a class activation map generation model, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0113] like Figure 3 As shown, the training device 400 for generating a class activation map model of this embodiment includes: an acquisition module 401, an enhancement module 402, an extraction module 403, an intra-class comparison module 404, an inter-class comparison module 405 and an adjustment module 406. Among them:

[0114] An acquisition module 401 is used to acquire a sample image set, where the sample image set includes sample images of multiple categories;

[0115] An enhancement module 402 is used to perform enhancement processing on the sample images of each category to obtain multiple enhanced sample images of each category;

[0116] An extraction module 403 is used to extract deep feature information of multiple enhanced sample images using a preset initial class activation map generation model, where the loss function of the initial class activation map generation model includes a first initial loss function and a second initial loss function;

[0117] An intra-class comparison module 404 is used to perform intra-class comparison on multiple enhanced sample images based on a preset intra-class comparison strategy, depth feature information, and a first initial loss function to obtain an intra-class loss function;

[0118] A cross-category comparison module 405 is used to perform cross-category comparison on multiple enhanced samples based on a preset cross-category comparison strategy, deep feature information and a second initial loss function to obtain a cross-category loss function;

[0119] The adjustment module 406 is used to adjust the parameters of the initial class activation map generation model based on the intra-class loss function and the cross-class loss function to generate a class activation map generation model.

[0120] The embodiment of the present application can increase the generalization ability of the model by enhancing the sample images of each category. Subsequently, the initial class activation map generation model is used to extract deep feature information, which provides a basis for subsequent contrastive learning. Intra-class contrastive learning ensures that the model can learn the feature consistency of samples of the same category under different conditions, so that the generated class activation map is more focused on the key areas of the target category, reducing the misactivation of background or non-target areas. Cross-category contrastive learning significantly improves the distinguishing ability of the model by maximizing the differences between samples of different categories, so that the model can accurately distinguish the target category from other categories, and further reduces the misactivation of non-target category areas in the class activation map. This joint learning method not only maintains the accuracy and consistency of feature details, but also significantly reduces background noise and category confusion, thereby improving the accuracy of the class activation map.

[0121] In one embodiment, the enhancement module 402 includes:

[0122] An operation determination submodule is used to determine the image transformation operation that needs to be performed on the sample images of each category according to a preset data enhancement strategy, where the image transformation operation includes at least one of image rotation, image scaling, image flipping, and image cropping;

[0123] The image transformation submodule is used to perform image transformation operations on sample images of each category to obtain multiple enhanced sample images under each category.

[0124] The embodiment of the present application can perform image transformation operations for sample images of each category by implementing a preset data enhancement strategy, thereby achieving effective expansion and diversity improvement of image data. Specifically, transformation operations such as image rotation, scaling, flipping and cropping can simulate various morphological changes that may occur in images in real environments, such as changes in perspective, size differences, direction reversal and partial occlusion. This transformation not only enriches the training data set, but also enhances the model's ability to fully capture image features and improves the generalization performance of the model. In addition, image transformation is performed separately for each category to ensure the consistency of the enhanced sample image with the original category, which helps the model to learn the intrinsic features of each category of images more accurately. By increasing the number of enhanced samples under each category, the adequacy and stability of model training are further improved.

[0125] In one embodiment, the intra-class comparison module 404 includes:

[0126] An image pair determination submodule, used to determine a plurality of target sample image pairs from a plurality of enhanced sample images, wherein the images of each target sample image pair are enhanced sample images of the same category;

[0127] An acquisition submodule, used to acquire target depth feature information of an image of each target sample image pair from the depth feature information;

[0128] The intra-class comparison submodule is used to perform intra-class comparison on multiple target sample image pairs based on a preset intra-class comparison strategy, target depth feature information and a first initial loss function to obtain an intra-class loss function.

[0129] The embodiment of the present application can construct multiple target sample image pairs and extract their deep feature information, thereby realizing a detailed comparison of enhanced sample images at the intra-class level. Specifically, each target sample image pair contains different enhanced sample images under the same category, which ensures the pertinence and effectiveness of the comparison. Using the preset intra-class comparison strategy, the present embodiment can accurately measure the similarity between the target deep feature information, and then combine the first initial loss function to construct a more refined intra-class loss function. This function not only reflects the distribution characteristics of similar images in the deep feature space, but also guides the parameter adjustment direction of the initial class activation map generation model during the training process.

[0130] In one embodiment, the intra-class comparison submodule is further used to calculate the cosine values ​​of multiple target sample image pairs based on a preset intra-class comparison strategy and target depth feature information; and fuse the cosine values ​​and the first initial loss function to obtain the intra-class loss function.

[0131] The embodiment of the present application can innovatively construct an intra-class loss function by fusing the cosine value with the first initial loss function, effectively improving the model's ability to recognize features of similar images. The preset intra-class comparison strategy ensures that in the deep feature space, the cosine values ​​of similar image pairs can accurately reflect their degree of similarity, thereby enhancing the model's learning of the intrinsic features of similar images. Combining the cosine value as a regularization term or a new loss term with the initial loss function not only retains the model's ability to distinguish between categories, but also significantly improves the accuracy and consistency of identifying similar images.

[0132] In one embodiment, the cross-category comparison module 405 includes:

[0133] A first image determination submodule, used to determine an anchor point sample image from a plurality of enhanced sample images;

[0134] A second image determination submodule is used to determine a plurality of positive sample images and a plurality of negative sample images from a plurality of enhanced sample images based on an anchor sample image, wherein each positive sample image and the anchor sample image are enhanced sample images of the same category, and each negative sample image and the anchor sample image are enhanced sample images of a different category;

[0135] A distance measurement submodule is used to perform distance measurement on the anchor sample image, multiple positive sample images, and multiple negative sample images based on a preset cross-class comparison strategy and deep feature information to obtain a distance value;

[0136] The fusion submodule is used to fuse the distance value and the second initial loss function to obtain a cross-class loss function.

[0137] The embodiment of the present application can accurately select anchor samples from multiple enhanced sample images, and determine positive and negative samples accordingly, ensuring the representativeness and pertinence of the sample selection. Subsequently, using deep feature information and a preset cross-class comparison strategy, a detailed distance measurement is performed on the anchor, positive, and negative samples to accurately characterize the similarities and differences between the samples. Finally, the distance measurement result is cleverly combined with the second initial loss function to construct a more sophisticated cross-class loss function. This function not only enhances the model's ability to extract features of similar samples, but also significantly improves the model's ability to distinguish heterogeneous samples.

[0138] In one embodiment, the distance measurement submodule is also used to calculate the distance between the anchor sample image and each positive sample image based on a preset cross-category comparison strategy and depth feature information to obtain a first distance; calculate the distance between the anchor sample image and each negative sample image based on the cross-category comparison strategy and depth feature information to obtain a second distance; and obtain a distance value based on the first distance and the second distance.

[0139] The embodiments of the present application can achieve accurate calculation of the distance between the anchor sample image and the positive and negative sample images by introducing a preset cross-category comparison strategy and combining the depth feature information. Specifically, the high-level semantic features of the image can be captured using the depth feature information, and then the first distance between the anchor sample image and the positive sample image, and the second distance between the anchor sample image and the negative sample image are calculated respectively through the cross-category comparison strategy. The first distance reflects the closeness between samples of the same type, while the second distance reveals the degree of alienation between samples of different types. Finally, based on the comprehensive consideration of the first distance and the second distance, a distance value is obtained, which not only reflects the relative position relationship between samples, but also implies the comparison of category information.

[0140] In one embodiment, the training device for the class activation map generation model may further include:

[0141] A structure acquisition module is used to obtain the network structure of the class activation map generation model and determine the target convolution layer of the class activation map generation model based on the network structure;

[0142] An input module is used to obtain a target image and input the target image into the class activation map generation model to obtain a feature map of the target image output by the target convolution layer;

[0143] A vector acquisition module is used to obtain a weight vector corresponding to each classification category in the classification layer of the class activation map generation model;

[0144] The weighted summation module is used to perform weighted summation on the feature map and the weight vector corresponding to each classification category to obtain a class activation map of the target image corresponding to each classification category.

[0145] The embodiment of the present application can achieve accurate extraction of deep features of the target image by accurately obtaining the network structure of the class activation map generation model and intelligently determining the target convolution layer. After the target image is input into the model, the resulting feature map is rich in high-level semantic information of the image. Furthermore, by cleverly obtaining the weight vector corresponding to each classification category in the classification layer and performing weighted summation with the feature map, the class activation map corresponding to each classification category can be automatically generated. These class activation maps not only intuitively show the areas in the image that play a key role in classification decisions, but also significantly improve the interpretability and accuracy of image classification tasks.

[0146] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.

[0147] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 6 having a memory 61, a processor 62, and a network interface 63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.

[0148] Computer devices can be computing devices such as desktop computers, notebooks, PDAs, and cloud servers. Computer devices can interact with users through keyboards, mice, remote controls, touch pads, or voice control devices.

[0149] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as computer-readable instructions of the training method of the class activation map generation model, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.

[0150] The processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run computer-readable instructions stored in the memory 61 or process data, such as computer-readable instructions for running a training method for generating a class activation map model.

[0151] The network interface 63 may include a wireless network interface or a wired network interface, and the network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.

[0152] The embodiment of the present application can increase the generalization ability of the model by enhancing the sample images of each category. Subsequently, the initial class activation map generation model is used to extract deep feature information, which provides a basis for subsequent contrastive learning. Intra-class contrastive learning ensures that the model can learn the feature consistency of samples of the same category under different conditions, so that the generated class activation map is more focused on the key areas of the target category, reducing the misactivation of background or non-target areas. Cross-category contrastive learning significantly improves the distinguishing ability of the model by maximizing the differences between samples of different categories, so that the model can accurately distinguish the target category from other categories, and further reduces the misactivation of non-target category areas in the class activation map. This joint learning method not only maintains the accuracy and consistency of feature details, but also significantly reduces background noise and category confusion, thereby improving the accuracy of the class activation map.

[0153] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the training method for generating a class activation map model as described above.

[0154] The embodiment of the present application can increase the generalization ability of the model by enhancing the sample images of each category. Subsequently, the initial class activation map generation model is used to extract deep feature information, which provides a basis for subsequent contrastive learning. Intra-class contrastive learning ensures that the model can learn the feature consistency of samples of the same category under different conditions, so that the generated class activation map is more focused on the key areas of the target category, reducing the misactivation of background or non-target areas. Cross-category contrastive learning significantly improves the distinguishing ability of the model by maximizing the differences between samples of different categories, so that the model can accurately distinguish the target category from other categories, and further reduces the misactivation of non-target category areas in the class activation map. This joint learning method not only maintains the accuracy and consistency of feature details, but also significantly reduces background noise and category confusion, thereby improving the accuracy of the class activation map.

[0155] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0156] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A training method for a class activation map generation model, characterized in that: The steps include: Acquire a sample image set, where the sample image set includes sample images of multiple categories; Performing enhancement processing on the sample images of each category to obtain a plurality of enhanced sample images under each category; Using a preset initial class activation map generation model to extract deep feature information of the multiple enhanced sample images, the loss function of the initial class activation map generation model includes a first initial loss function and a second initial loss function; Based on a preset intra-class comparison strategy, the depth feature information and the first initial loss function, performing intra-class comparison on the multiple enhanced sample images to obtain an intra-class loss function; Based on a preset cross-category comparison strategy, the depth feature information, and the second initial loss function, performing cross-category comparison on the multiple enhanced samples to obtain a cross-category loss function; Based on the intra-class loss function and the cross-class loss function, the parameters of the initial class activation map generation model are adjusted to generate a class activation map generation model.

2. The method according to claim 1, characterized in that The step of performing intra-class comparison on the multiple enhanced sample images based on the preset intra-class comparison strategy, the depth feature information and the first initial loss function to obtain the intra-class loss function specifically includes: Determine a plurality of target sample image pairs from the plurality of enhanced sample images, wherein the images of each target sample image pair are enhanced sample images of the same category; Acquire target depth feature information of the image of each target sample image pair from the depth feature information; Based on a preset intra-class comparison strategy, the target depth feature information and the first initial loss function, intra-class comparison is performed on the multiple target sample image pairs to obtain an intra-class loss function.

3. The method according to claim 2, characterized in that The step of performing intra-class comparison on the plurality of target sample image pairs based on the preset intra-class comparison strategy, the target depth feature information and the first initial loss function to obtain the intra-class loss function specifically includes: Based on a preset intra-class comparison strategy and the target depth feature information, the cosine values ​​of the plurality of target sample image pairs are calculated; The cosine value and the first initial loss function are fused to obtain an intra-class loss function.

4. The method according to claim 1, characterized in that: The step of performing cross-category comparison on the multiple enhanced samples based on the preset cross-category comparison strategy, the depth feature information and the second initial loss function to obtain a cross-category loss function specifically includes: Determine an anchor sample image from the multiple enhanced sample images; Based on the anchor sample image, determine a plurality of positive sample images and a plurality of negative sample images from the plurality of enhanced sample images, wherein each positive sample image and the anchor sample image are enhanced sample images of the same category, and each negative sample image and the anchor sample image are enhanced sample images of a different category; Based on a preset cross-class comparison strategy and the depth feature information, performing distance measurement on the anchor sample image, the multiple positive sample images, and the multiple negative sample images to obtain distance values; The distance value and the second initial loss function are fused to obtain a cross-class loss function.

5. The method according to claim 4, characterized in that The step of performing distance measurement on the anchor sample image, the multiple positive sample images, and the multiple negative sample images based on the preset cross-class comparison strategy and the deep feature information to obtain distance values ​​specifically includes: Based on a preset cross-category comparison strategy and the depth feature information, calculating the distance between the anchor point sample image and each of the positive sample images to obtain a first distance; Based on the cross-category comparison strategy and the depth feature information, calculating the distance between the anchor sample image and each negative sample image to obtain a second distance; A distance value is obtained based on the first distance and the second distance.

6. The method according to claim 1, characterized in that The step of performing enhancement processing on the sample images of each category to obtain a plurality of enhanced sample images of each category specifically includes: According to a preset data enhancement strategy, determine the image transformation operation that needs to be performed on the sample images of each category, wherein the image transformation operation includes at least one of image rotation, image scaling, image flipping, and image cropping; The image transformation operation is performed on the sample images of each category to obtain a plurality of enhanced sample images of each category.

7. The method according to claim 1, characterized in that After the step of adjusting the parameters of the initial class activation map generation model based on the intra-class loss function and the cross-class loss function to generate a class activation map generation model, the method further includes: Acquire a network structure of the class activation map generation model, and determine a target convolutional layer of the class activation map generation model based on the network structure; Acquire a target image, and input the target image into the class activation map generation model to obtain a feature map of the target image output by the target convolutional layer; Obtaining a weight vector corresponding to each classification category in the classification layer of the class activation map generation model; The feature map and the weight vector corresponding to each classification category are weightedly summed to obtain a class activation map of the target image corresponding to each classification category.

8. A training device for a class activation map generation model, characterized in that: include: An acquisition module, used to acquire a sample image set, wherein the sample image set includes sample images of multiple categories; An enhancement module, used to perform enhancement processing on the sample images of each category to obtain a plurality of enhanced sample images of each category; An extraction module, configured to extract the depth feature information of the plurality of enhanced sample images by using a preset initial class activation map generation model, wherein the loss function of the initial class activation map generation model includes a first initial loss function and a second initial loss function; An intra-class comparison module, configured to perform intra-class comparison on the plurality of enhanced sample images based on a preset intra-class comparison strategy, the depth feature information, and the first initial loss function to obtain an intra-class loss function; A cross-category comparison module, configured to perform cross-category comparison on the plurality of enhanced samples based on a preset cross-category comparison strategy, the depth feature information, and the second initial loss function to obtain a cross-category loss function; An adjustment module is used to adjust the parameters of the initial class activation map generation model based on the intra-class loss function and the cross-class loss function to generate a class activation map generation model.

9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the training method for generating a class activation map model as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the training method for generating a class activation map model as described in any one of claims 1 to 7 are implemented.