An infrared image anomaly detection method, device, equipment and readable storage medium

By training an infrared image anomaly detection model through adaptive calculation of dynamic boundary values, the problems of single features and poor generalization ability in traditional methods are solved, thereby improving detection accuracy and generalization and adapting to different infrared camera models and environmental conditions.

CN122244519APending Publication Date: 2026-06-19RAYTRON(WUXI) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
RAYTRON(WUXI) TECH CO LTD
Filing Date
2026-03-18
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Traditional infrared image anomaly detection methods suffer from limited features, require meticulously designed detection operators for single anomalies, are difficult to implement, have poor generalization ability, and are inaccurate.

Method used

An infrared image anomaly detection model trained based on adaptive calculation of dynamic boundary values ​​for image classification difficulty is adopted. Feature maps are extracted through the backbone network and classified using the classification module. Different image classification difficulties are calculated to generate dynamic boundary values. The contrastive learning loss and binary cross-entropy loss are optimized to improve the model's learning ability for difficult samples.

Benefits of technology

It improves the detection accuracy and generalization of infrared image anomaly detection, enhances the model's adaptability to different infrared camera models and environmental conditions, and reduces the impact of sample imbalance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122244519A_ABST
    Figure CN122244519A_ABST
Patent Text Reader

Abstract

This application discloses an infrared image anomaly detection method, apparatus, device, and readable storage medium, comprising: receiving an infrared image to be detected; calling a target infrared image anomaly detection model trained based on dynamic boundary values ​​calculated according to image classification difficulty; extracting features from the infrared image to be detected using the backbone network of the target infrared image anomaly detection model to obtain a target feature map; and classifying the target feature map using the classification module of the target infrared image anomaly detection model to obtain an infrared image anomaly detection result. This application improves the model's learning ability for difficult samples, enhancing detection accuracy and generalization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of infrared imaging technology, and in particular to an infrared image anomaly detection method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] Infrared thermal imaging technology is widely used in industrial inspection, security monitoring, and medical diagnosis. For infrared camera manufacturers, ensuring the image quality of their products is paramount. However, infrared images are susceptible to various factors during acquisition, such as sensor noise, ambient temperature changes, and lens contamination, leading to abnormal textures in the images and directly impacting product usability and customer satisfaction.

[0003] Traditional infrared image anomaly detection methods have drawbacks such as limited features, the need for carefully designed detection operators for single anomalies, high difficulty, poor generalization ability, and poor accuracy.

[0004] In summary, how to effectively solve the problems of high difficulty, poor generalization ability, and poor accuracy of traditional infrared image anomaly detection methods is an urgent problem that needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this application is to provide an infrared image anomaly detection method, which improves the model's learning ability on difficult samples and enhances detection accuracy and generalization. Another purpose of this application is to provide an infrared image anomaly detection device, equipment, and computer-readable storage medium.

[0006] To solve the above-mentioned technical problems, this application provides the following technical solution: An infrared image anomaly detection method includes: Receive the infrared image to be detected; The target infrared image anomaly detection model trained based on the dynamic boundary value adaptive calculation of image classification difficulty is invoked, and the backbone network of the target infrared image anomaly detection model is used to extract features from the infrared image to be detected to obtain the target feature map. The target feature map is classified using the classification module of the target infrared image anomaly detection model to obtain the infrared image anomaly detection result.

[0007] In one specific embodiment of this application, the training process of the target infrared image anomaly detection model includes: Select a batch of samples from the training data as the current batch of samples, and use the backbone network of the current infrared image anomaly detection model to extract features from each sample group in the current batch of samples to obtain anchor point feature map, positive sample feature map and negative sample feature map; The calculation module of the current infrared image anomaly detection model is used to perform difficulty perception calculation on the anchor point feature map to obtain a difficulty score and generate dynamic boundary values. Calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value; Using the classification module of the current infrared image anomaly detection model, backpropagation training is performed on the current infrared image anomaly detection model according to the contrastive learning loss to obtain a new current infrared image anomaly detection model. Repeat the above steps to determine the current infrared image anomaly detection model obtained last time as the target infrared image anomaly detection model.

[0008] In one specific embodiment of this application, the step of using the classification module of the current infrared image anomaly detection model to perform backpropagation training on the current infrared image anomaly detection model based on the contrastive learning loss includes: Using the classification module of the current infrared image anomaly detection model, the binary cross-entropy loss corresponding to the current batch of samples is calculated based on the classification cross-entropy loss function; The total loss is calculated based on the contrastive learning loss and the binary cross-entropy loss. The current infrared image anomaly detection model is trained by backpropagation based on the total loss.

[0009] In one specific embodiment of this application, the step of using the classification module of the current infrared image anomaly detection model to calculate the binary cross-entropy loss corresponding to the current batch of samples according to the classification cross-entropy loss function includes: The classification module of the current infrared image anomaly detection model is used to classify and predict the anchor feature maps of the anchor images in each sample group within the current batch of samples, so as to obtain the prediction probability corresponding to the anchor feature map in each sample group; wherein, each infrared image in the infrared image dataset is labeled with an image type; The binary cross-entropy loss corresponding to the current batch of samples is calculated using the classification cross-entropy loss function based on the predicted probability.

[0010] In one specific embodiment of this application, before selecting a batch of samples from the training data as the current batch of samples, training data is obtained based on an infrared image dataset; the process of obtaining training data based on the infrared image dataset includes: An infrared image is randomly selected from the infrared image dataset as the anchor image; One infrared image is randomly selected from all infrared images in the infrared image dataset that are of the same image type as the anchor image as a positive sample, and one infrared image is randomly selected from all infrared images in the infrared image dataset that are of a different image type than the anchor image as a negative sample; Sample groups were constructed using the anchor point images, positive samples, and negative samples obtained from each round of screening. The selected sample groups are divided into batches to obtain the training data, which includes multiple batches of samples, and each batch of samples includes multiple sample groups.

[0011] In one specific embodiment of this application, the process of acquiring the infrared image dataset includes: The original infrared image dataset is augmented to obtain the infrared image dataset.

[0012] In one specific embodiment of this application, the step of using the calculation module of the current infrared image anomaly detection model to perform difficulty-aware calculation on the anchor point feature map to obtain a difficulty score and generate a dynamic boundary value, and calculating the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value, includes: The anchor point feature map, the positive sample feature map, and the negative sample feature map are respectively subjected to feature projection to obtain the anchor point feature projection map, the positive sample feature projection map, and the negative sample feature projection map; The difficulty score is obtained by using the difficulty perception module of the current infrared image anomaly detection model to perform difficulty perception calculation on the anchor point feature projection map; The adaptive boundary value module of the current infrared image anomaly detection model generates the dynamic boundary value based on the difficulty score; the triplet loss function is used to calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value, anchor feature projection map, positive sample feature projection map, and negative sample feature projection map corresponding to each sample group.

[0013] An infrared image anomaly detection device, comprising: The image receiving module is used to receive the infrared image to be detected; The target feature map acquisition module is used to call the target infrared image anomaly detection model trained based on the dynamic boundary value calculated by image classification difficulty, and use the backbone network of the target infrared image anomaly detection model to extract features from the infrared image to be detected to obtain the target feature map. The detection result acquisition module is used to classify the target feature map using the classification module of the target infrared image anomaly detection model to obtain the infrared image anomaly detection result.

[0014] An infrared image anomaly detection device, comprising: Memory, used to store computer programs; A processor is used to execute the computer program to implement the steps of the infrared image anomaly detection method as described above.

[0015] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the infrared image anomaly detection method described above.

[0016] The infrared image anomaly detection method provided in this application includes: receiving an infrared image to be detected; calling a target infrared image anomaly detection model trained based on dynamic boundary values ​​calculated by image classification difficulty; using the backbone network of the target infrared image anomaly detection model to extract features from the infrared image to be detected to obtain a target feature map; and using the classification module of the target infrared image anomaly detection model to classify the target feature map to obtain an infrared image anomaly detection result.

[0017] As described above, the target infrared image anomaly detection model is trained by adaptively calculating dynamic boundary values ​​based on image classification difficulty. This calculates different image classification difficulties, thus replacing the fixed contrastive learning boundary parameters with dynamic values ​​based on difficulty scores. The classification module of the trained target infrared image anomaly detection model is then used to detect infrared image anomalies in the target feature map. Compared to the fixed contrastive learning boundary parameters in traditional methods, this application improves the model's learning ability for difficult samples, enhancing detection accuracy and generalization.

[0018] Accordingly, this application also provides an infrared image anomaly detection device, equipment, and computer-readable storage medium corresponding to the above-mentioned infrared image anomaly detection method, which have the above-mentioned technical effects, and will not be elaborated here. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 This is a flowchart illustrating one implementation of the infrared image anomaly detection method in this application. Figure 2 This is a network structure diagram of an infrared image anomaly detection model in an embodiment of this application; Figure 3 This is a structural block diagram of an infrared image anomaly detection system according to an embodiment of this application; Figure 4 This is a structural block diagram of an infrared image anomaly detection device according to an embodiment of this application; Figure 5 This is a structural block diagram of an infrared image anomaly detection device according to an embodiment of this application; Figure 6 This is a schematic diagram of the specific structure of an infrared image anomaly detection device provided in an embodiment of this application. Detailed Implementation

[0021] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are merely some embodiments of the present application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0022] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0023] See Figure 1 , Figure 1 This is a flowchart illustrating one implementation of the infrared image anomaly detection method in this application. The method may include the following steps: S101: Receive the infrared image to be detected.

[0024] When infrared image anomaly detection is required, the infrared image to be detected is sent to the infrared image anomaly detection system, and the infrared image anomaly detection system receives the infrared image to be detected.

[0025] S102: Call the target infrared image anomaly detection model trained based on the dynamic boundary value calculated by image classification difficulty, and use the backbone network of the target infrared image anomaly detection model to extract features from the infrared image to be detected, and obtain the target feature map.

[0026] A target infrared image anomaly detection model is pre-trained based on dynamic boundary values ​​calculated according to the image classification difficulty. The target infrared image anomaly detection model includes a backbone network for feature extraction. After receiving the infrared image to be detected, the infrared image anomaly detection system calls the target infrared image anomaly detection model and uses the backbone network (such as ConvNeXt) with pre-trained network parameters in the target infrared image anomaly detection model to extract features from the infrared image to be detected, thereby obtaining the target feature map.

[0027] S103: The target feature map is classified using the classification module of the target infrared image anomaly detection model to obtain the infrared image anomaly detection result.

[0028] The target infrared image anomaly detection model also includes a classification module. After extracting features from the infrared image to be detected using the backbone network of the target infrared image anomaly detection model to obtain the target feature map, the classification module of the model is used to classify the target feature map to obtain the infrared image anomaly detection result. The infrared image anomaly detection result is either the image is normal or the image is abnormal. Abnormal images can include distorted images, noisy images, etc.

[0029] As described above, the target infrared image anomaly detection model is trained by adaptively calculating dynamic boundary values ​​based on image classification difficulty. This calculates different image classification difficulties, thus replacing the fixed contrastive learning boundary parameters with dynamic values ​​based on difficulty scores. The classification module of the trained target infrared image anomaly detection model is then used to detect infrared image anomalies in the target feature map. Compared to the fixed contrastive learning boundary parameters in traditional methods, this application improves the model's learning ability for difficult samples, enhancing detection accuracy and generalization.

[0030] It should be noted that, based on the above embodiments, this application also provides corresponding improvement solutions. In subsequent embodiments, steps that are the same as or corresponding to those in the above embodiments can be referred to each other, and the corresponding beneficial effects can also be referred to each other. These improvements will not be elaborated upon in the following improved embodiments.

[0031] In one specific embodiment of this application, the training process of the target infrared image anomaly detection model may include the following steps: Step 1: Select a batch of samples from the training data as the current batch of samples, and use the backbone network of the current infrared image anomaly detection model to extract features from each sample group in the current batch of samples to obtain anchor point feature map, positive sample feature map and negative sample feature map; Step 2: Use the calculation module of the current infrared image anomaly detection model to perform difficulty perception calculation on the anchor point feature map, obtain a difficulty score, and generate dynamic boundary values; Step 3: Calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value; Step 4: Using the classification module of the current infrared image anomaly detection model, backpropagation training is performed on the current infrared image anomaly detection model according to the contrastive learning loss to obtain a new current infrared image anomaly detection model. Step 5: Repeat steps 1 to 4, and determine the current infrared image anomaly detection model obtained last time as the target infrared image anomaly detection model.

[0032] For ease of description, the above steps can be combined for explanation.

[0033] An original infrared image anomaly detection model can be pre-built. The original infrared image anomaly detection model can be a model built based on the ConvNeXt backbone network. The original infrared image anomaly detection model is obtained and determined as the current infrared image anomaly detection model.

[0034] Prepare an infrared image dataset in advance, and then filter the dataset into sample groups. Each sample group includes anchor images, positive samples, and negative samples. Randomly divide the selected sample groups into batches to obtain the samples in each batch.

[0035] After dividing the selected sample groups into batches and obtaining each batch of samples, a batch of samples is randomly selected from each batch as the current batch of samples.

[0036] See Figure 2 , Figure 2 This is a network structure diagram of an infrared image anomaly detection model in an embodiment of this application. After randomly selecting a batch of samples from each batch as the current batch, the backbone network ConvNeXt of the current infrared image anomaly detection model is used to extract features from the anchor point image, positive sample, and negative sample for each sample group in the current batch, respectively, to obtain the anchor point feature map F. A Positive sample feature map F P and negative sample feature map F N .

[0037] After extracting the anchor point feature map, positive sample feature map, and negative sample feature map, the difficulty perception module of the current infrared image anomaly detection model is used to perform difficulty perception calculation on the anchor point feature map to obtain a difficulty score.

[0038] After performing difficulty-aware calculations on the anchor point feature map to obtain a difficulty score, the adaptive boundary value module of the current infrared image anomaly detection model is used to generate dynamic boundary values ​​based on the difficulty score.

[0039] After generating dynamic boundary values ​​based on difficulty scores, the triplet loss function is used to calculate the contrastive learning loss for the current batch of samples based on the dynamic boundary values, anchor feature maps, positive sample feature maps, and negative sample feature maps corresponding to each sample group.

[0040] After calculating the contrastive learning loss corresponding to the current batch of samples, the classification module of the current infrared image anomaly detection model is used to backpropagate and train the current infrared image anomaly detection model according to the contrastive learning loss, so as to obtain a new current infrared image anomaly detection model.

[0041] The number of rounds required to traverse each batch of samples can be preset. After backpropagation training of the current infrared image anomaly detection model based on the contrastive learning loss to obtain a new current infrared image anomaly detection model, it is determined whether the preset number of rounds has been traversed for each batch of samples. For example, when the preset number of rounds is 20, it is necessary to determine whether each batch of samples has been traversed 20 times. If not, it means that the current infrared image anomaly detection model needs to continue training, and the process returns to step S203. If yes, it means that the model training is complete, and step S210 is executed.

[0042] It should be noted that the preset number of rounds and the number of sample groups in each batch can be set and adjusted according to the actual situation. The comparison of the embodiments in this application is not limited. For example, the preset number of rounds can be set to 20 and the number of sample groups in each batch can be set to 32.

[0043] When it is determined that the preset number of rounds have been traversed for each batch of samples, it indicates that the model training is complete, and the current infrared image anomaly detection model obtained from the last training is determined as the target infrared image anomaly detection model.

[0044] By innovatively introducing the concept of contrastive learning, this study addresses the weak generalization ability of infrared image anomaly detection, improving the generalization capability of the trained target infrared image anomaly detection model across different infrared camera models and environmental conditions. Through the design of a difficulty-aware mechanism and an adaptive margin calculation method, the boundary constraints in contrastive learning are dynamically adjusted for infrared image samples of varying difficulty, thereby more accurately distinguishing between normal and abnormal images.

[0045] By introducing the contrastive learning mechanism from unsupervised learning into supervised anomaly detection training, the model learns to increase inter-class distance and decrease intra-class distance without increasing model complexity, thereby improving model accuracy and generalization. Simultaneously, increasing the randomness of data loading mitigates the problem of imbalanced samples. A difficulty-aware module is proposed to calculate the classification difficulty of different images, thus changing the fixed contrastive learning boundary parameters to dynamic values ​​based on difficulty scores. This improves the model's ability to learn from difficult samples, enhancing detection accuracy and generalization.

[0046] After training the target infrared image anomaly detection model, the trained target infrared image anomaly detection model can be tested on the test set to calculate the test accuracy and statistically analyze the prediction time, thus meeting the requirements for accuracy and real-time performance.

[0047] After testing the target infrared image anomaly detection model, a backend service framework such as FastAPI is used to build a detection system service and provide interfaces for users to use.

[0048] See Figure 3 , Figure 3 This is a structural block diagram of an infrared image anomaly detection system according to an embodiment of this application. The infrared image anomaly detection system includes a user interface layer, a data acquisition layer, a network transmission layer, a cloud service layer, and a model calculation layer.

[0049] In one specific embodiment of this application, before selecting a batch of samples from the training data as the current batch of samples, training data is obtained based on an infrared image dataset; obtaining training data based on the infrared image dataset may include the following steps: Step 1: Randomly select an infrared image from the infrared image dataset as the anchor image; Step 2: Randomly select one infrared image from the infrared images in the infrared image dataset that are of the same image type as the anchor image as a positive sample, and randomly select one infrared image from the infrared image dataset that are of a different image type than the anchor image as a negative sample; Step 3: Construct sample groups using the anchor point images, positive samples, and negative samples obtained from each round of screening; Step 4: Divide the selected sample groups into batches to obtain the training data. The training data includes multiple batches of samples, and each batch of samples includes multiple sample groups.

[0050] For ease of description, the four steps above can be combined for explanation.

[0051] When filtering sample groups in an infrared image dataset, an infrared image is randomly selected as the anchor image. Another infrared image of the same type as the anchor image is randomly selected as a positive sample. Finally, an infrared image of a different type than the anchor image is randomly selected as a negative sample. Sample groups are constructed using the anchor image, positive sample, and negative sample obtained from each round of filtering. The selected sample groups are then divided into batches to obtain the training data. The training data includes multiple batches of samples, and each batch includes multiple sample groups.

[0052] Image types include normal images and abnormal images. Anchor images can be either abnormal or normal. When the anchor image is abnormal, the corresponding positive samples are displayed as abnormal images and the negative samples as normal images. When the anchor image is normal, the corresponding positive samples are displayed as normal images and the negative samples as abnormal images.

[0053] In one specific embodiment of this application, the process of acquiring an infrared image dataset may include the following steps: The original infrared image dataset is augmented to obtain an infrared image dataset.

[0054] After obtaining the raw infrared image dataset, data augmentation processing is performed on the raw infrared image dataset, such as converting the infrared images in the dataset to grayscale and scaling them to 224. The infrared image dataset was obtained through processing including 224, 50% probability horizontal flipping, 50% probability vertical flipping, and color jittering (brightness 0.2, contrast 0.2, saturation 0.2, hue 0.1). Data augmentation of the infrared image dataset avoided model overfitting. Targeting the characteristics of infrared images, the visible light data augmentation types were optimized, adding only grayscale conversion, brightness modification, and flipping changes to avoid unnecessary data augmentation that could turn normal images into abnormal ones. The use of the augmentation model improved robustness to changes in infrared images and reduced the impact of sample imbalance on training.

[0055] In one specific embodiment of this application, the calculation module includes a difficulty-aware module and an adaptive boundary value module. The calculation module of the current infrared image anomaly detection model performs difficulty-aware calculation on the anchor point feature map to obtain a difficulty score and generates a dynamic boundary value. The module also calculates the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value. This may include the following steps: Step 1: Perform feature projection on the anchor point feature map, positive sample feature map, and negative sample feature map respectively to obtain the anchor point feature projection map, positive sample feature projection map, and negative sample feature projection map; Step 2: Calculate the difficulty score by using the difficulty perception module of the current infrared image anomaly detection model to perform difficulty perception calculation on the anchor point feature projection map; Step 3: Use the adaptive boundary value module of the current infrared image anomaly detection model to generate the dynamic boundary value based on the difficulty score; Step 4: Using the triplet loss function, calculate the contrastive learning loss for the current batch of samples based on the dynamic boundary values, anchor feature projection maps, positive sample feature projection maps, and negative sample feature projection maps corresponding to each sample group.

[0056] For ease of description, the two steps above can be combined for explanation.

[0057] like Figure 2 As shown, feature projection is performed on the anchor point feature map, positive sample feature map, and negative sample feature map, respectively. For example, the projection module is used to project the three feature maps F respectively. A F P F N Feature projection is performed to obtain 128 dimensions, resulting in anchor point feature projection map A, positive sample feature projection map P, and negative sample feature projection map N. The difficulty perception module of the current infrared image anomaly detection model is used to perform difficulty perception calculation on the anchor point feature projection map to obtain the difficulty score. The adaptive boundary value module of the current infrared image anomaly detection model is used to generate the dynamic boundary value based on the difficulty score. The triplet loss function is used to calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value, anchor point feature projection map, positive sample feature projection map, and negative sample feature projection map corresponding to each sample group.

[0058] The difficulty perception module can adopt a two-layer fully connected neural network structure. The difficulty score d of the anchor feature projection map A can be calculated using the following formula: ; Where W1, W2, b1, and b2 are the parameters of the two-layer network matrix.

[0059] The difficulty score d is calculated to generate a dynamic value, which is then added to a manually preset fixed value (which can be set to 1 in this method) to obtain the dynamic margin value m for this round of training. The formula is as follows: ; in, This is the minimum margin, i.e., a manually preset fixed value. The network matrix parameters W3, W4, b3, and b4 are defined as scaling factors to determine the range of variation.

[0060] The contrastive learning loss is obtained by calculating the triplet loss function on the obtained feature projection map and dynamic boundary values. The formula is as follows: ; Where d(.) is the Euclidean distance function, and M is the number of sample groups in the current batch. This is the anchor point feature projection map for the i-th sample group in the current batch of samples. This is the feature projection map of the positive samples in the i-th sample group of the current batch. This is the feature projection map of the negative samples in the i-th sample group of the current batch. This represents the dynamic boundary value of the i-th sample group in the current batch.

[0061] In one specific embodiment of this application, using the classification module of the current infrared image anomaly detection model and backpropagating to train the current infrared image anomaly detection model based on the contrastive learning loss may include the following steps: Step 1: Using the classification module of the current infrared image anomaly detection model, calculate the binary cross-entropy loss corresponding to the current batch of samples based on the classification cross-entropy loss function; Step 2: Calculate the total loss based on the contrastive learning loss and the binary classification cross-entropy loss; Step 3: Train the current infrared image anomaly detection model through backpropagation based on the total loss.

[0062] For ease of description, the three steps above can be combined for explanation.

[0063] like Figure 3 As shown, by utilizing the classification module of the current infrared image anomaly detection model, the binary cross-entropy loss corresponding to the current batch of samples is calculated using the classification cross-entropy loss function. The total loss is calculated based on the contrastive learning loss and the binary cross-entropy loss. The entire current infrared image anomaly detection model, including the classification module and the backbone network, is then trained by backpropagation based on the total loss. This achieves simultaneous optimization of the contrastive learning loss and the binary cross-entropy loss, further improving the model accuracy.

[0064] In one specific embodiment of this application, the classification module of the current infrared image anomaly detection model calculates the binary cross-entropy loss corresponding to the current batch of samples based on the classification cross-entropy loss function, which may include the following steps: Step 1: Use the classification module of the current infrared image anomaly detection model to classify and predict the anchor feature maps of the anchor images in each sample group within the current batch of samples, and obtain the prediction probability corresponding to the anchor feature map in each sample group; where each infrared image in the infrared image dataset is labeled with its image type. Step 2: Calculate the binary cross-entropy loss corresponding to the current batch of samples based on the predicted probability using the classification cross-entropy loss function.

[0065] For ease of description, the two steps above can be combined for explanation.

[0066] like Figure 2 As shown, each infrared image in the infrared image dataset is labeled with its image type, which includes normal and abnormal images. The classification module of the current infrared image anomaly detection model is used to classify and predict the anchor point feature maps of the anchor point images in each sample group within the current batch of samples. The predicted probabilities corresponding to the anchor point feature maps in each sample group are obtained. The binary cross-entropy loss for the current batch of samples is then calculated based on the predicted probabilities using the classification cross-entropy loss function.

[0067] The anchor point feature map is analyzed using the classification module. The predicted probability q is obtained by classification, as shown in the following formula: ; in, , These are the network matrix parameters for the classification module.

[0068] The binary cross-entropy loss is calculated based on the predicted probability q obtained from the classification, using the following formula: ; in, It is the true label (0 or 1) of the anchor point feature map. It is the predicted probability corresponding to the i-th sample group in the current batch of samples. This is the cross-entropy loss for binary classification.

[0069] The total training loss L is obtained by combining the contrastive learning loss and the binary classification cross-entropy loss, as shown in the following formula: ; in, The weight can be set to 1 in this method.

[0070] The process of the classification module of the infrared image anomaly detection model classifying the feature map to obtain the infrared image anomaly detection result can be divided into two steps: the classification module first performs classification prediction on the feature map to obtain the prediction probability, and then determines whether the infrared image anomaly detection result is normal or abnormal based on the prediction probability. For example, a prediction probability threshold can be preset. When the prediction probability corresponding to a certain image type exceeds the prediction probability threshold, the infrared image anomaly detection result is determined to be the corresponding image type, which is one of the two types: normal image and abnormal image.

[0071] Corresponding to the above method embodiments, this application also provides an infrared image anomaly detection device. The infrared image anomaly detection device described below can be referred to in correspondence with the infrared image anomaly detection method described above.

[0072] See Figure 4 , Figure 4 This is a structural block diagram of an infrared image anomaly detection device according to an embodiment of this application. The device may include: Image receiving module 41 is used to receive the infrared image to be detected; The target feature map acquisition module 42 is used to call the target infrared image anomaly detection model trained by calculating dynamic boundary values ​​based on image classification difficulty, and use the backbone network of the target infrared image anomaly detection model to extract features from the infrared image to be detected to obtain the target feature map. The detection result acquisition module 43 is used to classify the target feature map using the classification module of the target infrared image anomaly detection model to obtain the infrared image anomaly detection result.

[0073] As described above, the target infrared image anomaly detection model is trained by adaptively calculating dynamic boundary values ​​based on image classification difficulty. This calculates different image classification difficulties, thus replacing the fixed contrastive learning boundary parameters with dynamic values ​​based on difficulty scores. The classification module of the trained target infrared image anomaly detection model is then used to detect infrared image anomalies in the target feature map. Compared to the fixed contrastive learning boundary parameters in traditional methods, this application improves the model's learning ability for difficult samples, enhancing detection accuracy and generalization.

[0074] In one specific embodiment of this application, the device may further include a model training module, which may include: The feature extraction submodule is used to select a batch of samples from the training data as the current batch of samples, and use the backbone network of the current infrared image anomaly detection model to extract features from each sample group in the current batch of samples to obtain anchor point feature map, positive sample feature map and negative sample feature map. The boundary value generation submodule is used to perform difficulty perception calculation on the anchor point feature map using the calculation module of the current infrared image anomaly detection model, obtain a difficulty score, and generate dynamic boundary values. The contrastive learning loss calculation submodule is used to calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value. The new model obtains a sub-module, which uses the classification module of the current infrared image anomaly detection model to perform backpropagation training on the current infrared image anomaly detection model according to the contrastive learning loss, so as to obtain a new current infrared image anomaly detection model. The target model determination submodule is used to repeat the steps in the above submodules and determine the current infrared image anomaly detection model obtained last time as the target infrared image anomaly detection model.

[0075] In one specific embodiment of this application, the new model acquisition submodule may include: The binary cross-entropy loss calculation unit is used to calculate the binary cross-entropy loss corresponding to the current batch of samples based on the classification module of the current infrared image anomaly detection model and the classification cross-entropy loss function. The total loss calculation unit is used to calculate the total loss based on the contrastive learning loss and the binary classification cross-entropy loss. The backpropagation training unit is used to backpropagate and train the current infrared image anomaly detection model based on the total loss.

[0076] In one specific embodiment of this application, the binary classification cross-entropy loss calculation unit may include: The prediction probability acquisition subunit is used to classify and predict the anchor feature maps of anchor images in each sample group within the current batch of samples using the classification module of the current infrared image anomaly detection model, and obtain the prediction probability corresponding to the anchor feature map in each sample group; wherein, each infrared image in the infrared image dataset is labeled with the image type. The binary cross-entropy loss calculation subunit is used to calculate the binary cross-entropy loss corresponding to the current batch of samples based on the predicted probability using the classification cross-entropy loss function.

[0077] In one specific embodiment of this application, a training data acquisition module may be included, which may include: The anchor image selection submodule is used to randomly select an infrared image from the infrared image dataset as the anchor image; The negative sample selection submodule is used to randomly select one infrared image as a positive sample from all infrared images in the infrared image dataset that are of the same image type as the anchor image, and to randomly select one infrared image as a negative sample from all infrared images in the infrared image dataset that are of a different image type than the anchor image. The sample group is constructed from a module, which is used to construct sample groups using the anchor point images, positive samples, and negative samples obtained from each round of screening; The training data acquisition submodule is used to divide the selected sample groups into batches to obtain the training data, which includes multiple batches of samples, and each batch of samples includes multiple sample groups.

[0078] In one specific embodiment of this application, an image dataset acquisition module is also included. The image dataset acquisition module is used to perform data augmentation processing on the original infrared image dataset to obtain the infrared image dataset.

[0079] In one specific embodiment of this application, the boundary value generation submodule may include: The feature projection map acquisition unit is used to perform feature projection on the anchor point feature map, positive sample feature map and negative sample feature map respectively to obtain the anchor point feature projection map, positive sample feature projection map and negative sample feature projection map; The difficulty perception calculation unit is used to perform difficulty perception calculation on the anchor point feature projection map using the difficulty perception module of the current infrared image anomaly detection model to obtain the difficulty score. A dynamic boundary value generation unit is used to generate the dynamic boundary value based on the difficulty score using the adaptive boundary value module of the current infrared image anomaly detection model. The contrastive learning loss calculation submodule is specifically designed to use the triplet loss function to calculate the contrastive learning loss for the current batch of samples based on the dynamic boundary values, anchor feature projection maps, positive sample feature projection maps, and negative sample feature projection maps corresponding to each sample group.

[0080] For the method embodiments described above, see [link to relevant documentation]. Figure 5 , Figure 5 This is a schematic diagram of the infrared image anomaly detection device provided in this application. The device may include: Memory 332 is used to store computer programs; The processor 322 is used to implement the steps of the infrared image anomaly detection method of the above method embodiment when executing a computer program.

[0081] For details, please refer to Figure 6 , Figure 6 This is a schematic diagram illustrating the specific structure of an infrared image anomaly detection device provided in this embodiment. The infrared image anomaly detection device can vary significantly due to different configurations or performance. It may include a processor (central processing unit, CPU) 322 (e.g., one or more processors) and a memory 332. The memory 332 stores one or more computer programs 342 or data 344. The memory 332 can be temporary or persistent storage. The program stored in the memory 332 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the data processing device. Furthermore, the processor 322 may be configured to communicate with the memory 332 and execute the series of instruction operations stored in the memory 332 on the infrared image anomaly detection device 301.

[0082] The infrared image anomaly detection device 301 may also include one or more power supplies 326, one or more wired or wireless network interfaces 350, one or more input / output interfaces 358, and / or one or more operating systems 341.

[0083] The steps in the infrared image anomaly detection method described above can be implemented by the structure of an infrared image anomaly detection device.

[0084] Corresponding to the above method embodiments, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can perform the following steps: Receive the infrared image to be detected; call the target infrared image anomaly detection model trained based on the dynamic boundary value calculated by the image classification difficulty, use the backbone network of the target infrared image anomaly detection model to extract features from the infrared image to be detected, and obtain the target feature map; use the classification module of the target infrared image anomaly detection model to classify the target feature map, and obtain the infrared image anomaly detection result.

[0085] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0086] For a description of the computer-readable storage medium provided in this application, please refer to the above method embodiments; further details will not be repeated here.

[0087] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatuses, devices, and computer-readable storage media disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.

[0088] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for detecting anomalies in infrared images, characterized in that, include: Receive the infrared image to be detected; The target infrared image anomaly detection model trained based on dynamic boundary values ​​calculated by image classification difficulty is invoked, and the backbone network of the target infrared image anomaly detection model is used to extract features from the infrared image to be detected to obtain a target feature map. The target feature map is classified using the classification module of the target infrared image anomaly detection model to obtain the infrared image anomaly detection result.

2. The infrared image anomaly detection method according to claim 1, characterized in that, The training process of the target infrared image anomaly detection model includes: Select a batch of samples from the training data as the current batch of samples, and use the backbone network of the current infrared image anomaly detection model to extract features from each sample group in the current batch of samples to obtain anchor point feature map, positive sample feature map and negative sample feature map; The calculation module of the current infrared image anomaly detection model is used to perform difficulty perception calculation on the anchor point feature map to obtain a difficulty score and generate dynamic boundary values. Calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary value; Using the classification module of the current infrared image anomaly detection model, backpropagation training is performed on the current infrared image anomaly detection model according to the contrastive learning loss to obtain a new current infrared image anomaly detection model. Repeat the above steps to determine the current infrared image anomaly detection model obtained last time as the target infrared image anomaly detection model.

3. The infrared image anomaly detection method according to claim 2, characterized in that, The step of using the classification module of the current infrared image anomaly detection model to perform backpropagation training on the current infrared image anomaly detection model based on the contrastive learning loss includes: Using the classification module of the current infrared image anomaly detection model, the binary cross-entropy loss corresponding to the current batch of samples is calculated based on the classification cross-entropy loss function; The total loss is calculated based on the contrastive learning loss and the binary cross-entropy loss. The current infrared image anomaly detection model is trained by backpropagation based on the total loss.

4. The infrared image anomaly detection method according to claim 3, characterized in that, The classification module of the current infrared image anomaly detection model calculates the binary cross-entropy loss corresponding to the current batch of samples based on the classification cross-entropy loss function, including: The classification module of the current infrared image anomaly detection model is used to classify and predict the anchor feature maps of the anchor images in each sample group within the current batch of samples, so as to obtain the prediction probability corresponding to the anchor feature map in each sample group; wherein, each infrared image in the infrared image dataset is labeled with an image type; The binary cross-entropy loss corresponding to the current batch of samples is calculated using the classification cross-entropy loss function based on the predicted probability.

5. The infrared image anomaly detection method according to claim 2, characterized in that, Before selecting a batch of samples from the training data as the current batch of samples, training data is obtained based on the infrared image dataset; The training data obtained from the infrared image dataset includes: An infrared image is randomly selected from the infrared image dataset as the anchor image; One infrared image is randomly selected from all infrared images in the infrared image dataset that are of the same image type as the anchor image as a positive sample, and one infrared image is randomly selected from all infrared images in the infrared image dataset that are of a different image type than the anchor image as a negative sample; Sample groups were constructed using the anchor point images, positive samples, and negative samples obtained from each round of screening. The selected sample groups are divided into batches to obtain the training data, which includes multiple batches of samples, and each batch of samples includes multiple sample groups.

6. The infrared image anomaly detection method according to claim 5, characterized in that, The process of acquiring the infrared image dataset includes: The original infrared image dataset is augmented to obtain the infrared image dataset.

7. The infrared image anomaly detection method according to any one of claims 2 to 5, characterized in that, The step of using the calculation module of the current infrared image anomaly detection model to perform difficulty-aware calculation on the anchor point feature map, obtain a difficulty score, generate dynamic boundary values, and calculate the contrastive learning loss corresponding to the current batch of samples based on the dynamic boundary values ​​includes: The anchor point feature map, the positive sample feature map, and the negative sample feature map are respectively subjected to feature projection to obtain the anchor point feature projection map, the positive sample feature projection map, and the negative sample feature projection map; The difficulty score is obtained by using the difficulty perception module of the current infrared image anomaly detection model to perform difficulty perception calculation on the anchor point feature projection map; The adaptive boundary value module of the current infrared image anomaly detection model generates the dynamic boundary value based on the difficulty score; The contrastive learning loss for the current batch of samples is calculated using the triplet loss function based on the dynamic boundary value, the anchor point feature projection map, the positive sample feature projection map, and the negative sample feature projection map corresponding to each sample group.

8. An infrared image anomaly detection device, characterized in that, include: The image receiving module is used to receive the infrared image to be detected; The target feature map acquisition module is used to call the target infrared image anomaly detection model trained based on the dynamic boundary value calculated by image classification difficulty, and use the backbone network of the target infrared image anomaly detection model to extract features from the infrared image to be detected to obtain the target feature map. The detection result acquisition module is used to classify the target feature map using the classification module of the target infrared image anomaly detection model to obtain the infrared image anomaly detection result.

9. An infrared image anomaly detection device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the infrared image anomaly detection method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the infrared image anomaly detection method as described in any one of claims 1 to 7.