Contraband detection method for X-ray security images based on large kernel feature injection mechanism
Through the large-kernel feature injection mechanism, the feature extraction and label assignment of the single-stage target detection algorithm are optimized, which solves the problem of low accuracy in contraband detection in X-ray security inspection images and achieves efficient contraband detection.
Patent Information
- Application Number
- CN202510771943.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-11
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2045-06-11
AI Technical Summary
Existing single-stage target detection algorithms perform poorly in X-ray security inspection images, especially when dealing with overlapping and hidden contraband, where the detection accuracy is low and it is difficult to meet public safety needs.
A method based on the large kernel feature injection mechanism is adopted to enhance the feature extraction capability through the incremental large kernel attention efficient layer aggregation network (LKNA). Combined with the neck alignment fusion injection module (IFFBN) and the task alignment simplified optimal transfer allocation strategy (TATA), the feature extraction and label allocation process are optimized to improve the detection accuracy.
It significantly improves the detection accuracy and speed of prohibited items in X-ray security inspection images, can effectively identify small targets in complex scenes, and maintain high efficiency, real-time performance and accuracy.
Smart Images

Figure CN120318805B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of deep learning and target detection. Specifically, a single-stage contraband target detection method in X-ray security inspection images based on a large kernel feature injection mechanism is proposed. Background Art
[0002] As the number of people at public transportation stations continues to rise, public safety is becoming increasingly important. In the security inspection process, X-ray scanners are widely used to perform luggage X-ray inspections to generate X-ray security images. Security personnel identify potentially dangerous items in luggage by observing the differences in the absorption and scattering abilities of different materials to X-rays, combined with visual features such as the color, outline, and shape of the items. However, compared to natural light images, X-ray security images have the following characteristics: (1) Overlapping: stacked items will overlap in the image, resulting in blurred surface textures; (2) Concealment: Contraband is difficult to detect by the detection system due to its small size and overlap with other items.
[0003] In recent years, the development of deep learning object detection technology has driven the automation of X-ray contraband detection. Common object detection frameworks include single-stage, dual-stage, and sparse object detection frameworks. Single-stage object detection algorithms are widely used due to their excellent real-time performance, scalability, and accuracy. However, most single-stage object detection algorithms are designed for natural light images and do not perform well in X-ray contraband detection. Summary of the Invention
[0004] This paper proposes a contraband detection method for X-ray security images based on a large-kernel feature injection mechanism. This method comprehensively optimizes a single-stage object detection algorithm (using YOLOv7 as an example) and proposes a three-level progressive feature optimization architecture to overcome existing technical bottlenecks. This method, based on the adaptive improvements of the feature extraction backbone of the large-kernel spatial perception module, the neck alignment and fusion injection mechanism, and the global task alignment label assignment strategy, significantly improves the detection accuracy of contraband in X-ray security images while maintaining high detection speed. This method improves detection accuracy by optimizing the backbone, neck, and label assignment process of the single-stage object detection framework. Specifically, a LKNA backbone network is designed using an incremental large-kernel architecture, enhancing the model's ability to extract global contextual features of contraband. Then, by aligning and fusing some features from the backbone and injecting them into the neck network, a neck feature fusion module (IFFBN) is designed to compensate for the loss of small object information caused by frequent up- and down-sampling operations. Finally, by taking a global perspective and introducing a consistency metric into the label assignment process to intelligently match positive and negative samples, a TATA label assignment strategy was designed. This effectively combines the advantages of global optimization and task consistency, further improving the performance of the detection framework. This approach, based on an incremental large kernel structure, a neck-aligned fusion injection mechanism, and a globally consistent label assignment strategy, aims to improve the performance and accuracy of contraband detection in security inspections.
[0005] The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism includes the following steps:
[0006] Step (1) first obtains an X-ray security inspection image dataset containing target bounding boxes and category annotations, divides the dataset into a training set and a validation set, and preprocesses the security inspection images.
[0007] Step (2) In the YoloV7 network backbone, the efficient layer aggregation network (ELAN) is replaced with the incremental large kernel layer aggregation network LKNA, an incremental convolution kernel structure is added, and an attention mechanism is added inside the LKNA to extract the spatial feature information in the image. The feature map sets with different resolution sizes are obtained through the B2, B3, B4, and B5 layers of the LKNA backbone network. .Will Calculate again in the attention module to obtain a further refined feature map and .
[0008] Step (3) In the YoloV7 network neck network fusion stage, the alignment injection fusion mechanism IFFBN proposed in this paper is used to perform alignment, fusion, and injection operations. Feature information is injected into the neck network to generate corresponding 、 as well as Features. Then use these features and feature maps and Perform fusion interaction operations to obtain refined feature maps .
[0009] Step (4) Use the lightweight network RepVGG to refine the feature map Classification and regression calculations are performed to obtain the classification and regression values for each detected anchor frame. During the label assignment phase, the TATA allocation strategy, a simplified optimal transfer assignment strategy based on task alignment, replaces the original SimOTA allocation strategy. The optimal anchor frame that matches the ground truth (GT) is globally searched for as the positive sample, and the remaining anchor frames are assigned as negative samples. During the matching process, the system uses the classification and regression values to measure the consistency between the classification and regression subtasks, mitigating the misalignment of ambiguous anchor frames.
[0010] Step (5) sets the training parameters, inputs the training data set obtained in step (1) into the model constructed by steps (2)-(5) for iterative training, verifies on the validation set, obtains the optimal parameter model, and outputs the contraband detection effect diagram.
[0011] Furthermore, step (2) is specifically:
[0012] (2-1) In the main part, the original ELAN is improved to obtain LKNA. Training data set Images in Input into LKNA to extract multi-level features and obtain the output feature map set of the four stages B2, B3, B4, and B5 layers after the backbone network .
[0013] Specifically, in LKNA, a progressively larger kernel design is adopted, that is, large core convolution kernels of different sizes are used in the {B3, B4, B5} layers in the backbone network: Specifically, LKNA has two The convolution operation divides the feature map into two parts, namely ,in Represents two The weights of the convolution kernel. Does not participate in the calculation. The other part of the feature map , while being cut off by the transition layer in ELAN, passing through two Large convolution kernels learn detailed information in feature maps, i.e. . After the CA attention module, the spatial position information of the items in the feature map is aggregated, that is, This spatial information aggregation operation is very important for X-ray security images that lack surface texture features. After concatenation, the gradients are sent to the transition layer to participate in subsequent calculations. In ELAN, the gradient flow is divided into four paths, and the shortest gradient path is 1.
[0014] (2-2) In the multi-level feature map On the basis of, two GAM attention modules are used to process and obtain further refined feature maps. and ,Right now , . and The extracted small target spatial feature information is included.
[0015] Furthermore, step (3) is specifically:
[0016] (3-1) Add an alignment, injection, and fusion mechanism, IFFBN, between the neck and the trunk. IFFBN includes sequentially executed alignment, fusion, and injection operations.
[0017] (3-1-1) Alignment operation. Align the multi-level features in the backbone , the multi-level features are pooled and concatenated, and then the aligned features are obtained through partial convolution cross-stage operations.
[0018] (3-1-2) Fusion operation. IFFBN adaptively fuses multi-level features. For the two fused features X and Y, after adding the features X and Y element by element, it extracts features in two branches. One branch passes through the filter block to obtain local features, and the other branch passes through the global pooling block to obtain global features. The global features and local features are added element by element to obtain the weight factor m. The weighted addition of features X and Y is performed to obtain the fused features. The weight of feature X is m, and the weight of feature Y is 1-m. The filter block is composed of Convolution, BN, and activation function SiLU are connected sequentially.
[0019] (3-1-3) Injection operation. Inject the alignment feature into the fusion feature, perform convolution extraction on the fusion feature and the alignment feature respectively, and generate the injected local feature and the injected global feature; after the injected global feature is averaged and pooled, use it as the weight to perform weighted operation on the injected local feature and add it element by element with the injected global feature to obtain the final injected feature; different multi-level features generate different injected features, i.e. .
[0020] (3-2) The features obtained in step (2) , optimize the feature map set , And the three multi-level features obtained from (3-1) Input into the improved neck network to generate refined features .
[0021] (3-2-1) After processing by convolutional network, the number of channels is reduced and features are extracted to obtain the feature map .Then After the three-way max pooling, the results are spliced to integrate information of different scales. Finally, the obtained feature map is processed by a Convolutional layer, a After the convolutional layer, go through The feature maps processed by the convolutional layer are spliced to form the final feature map .
[0022] (3-2-2) Optimizing the feature map set , Perform bilinear interpolation upsampling operation to obtain upsampling features , and , Inject into In the , we get the refined features .right After upsampling and convolution operation through ELAN module, the obtained feature map is combined with After fusion, the feature map is obtained after the ELAN module and downsampling operation. .Will Inject into After that, we get the refined features .Will After the ELAN module and downsampling operation, the downsampled feature map is obtained .Will and Inject into Afterwards, we get the refined features .
[0023] Furthermore, step (4) is specifically:
[0024] (4-1) Divide the image into The grid array is composed of a grid point, each of which is responsible for detecting whether the grid contains the center of the object to be tested. In this process, the output of each grid is a prediction vector, expressed as ,in Represent the center point coordinates and width and height of the candidate bounding box respectively, represents the confidence that the target center point falls within the current bounding box, and Represents the predicted probability of the object category within the current bounding box.
[0025] (4-2) In the label allocation stage, the task alignment is used to simplify the optimal transmission allocation strategy TATA allocation strategy to replace the original transmission allocation SimOTA strategy.
[0026] (4-2-1) First, through the prediction and processing operations, that is, the input image representation, the prior anchor box set, and the true annotation box GT are preprocessed to generate the predicted bounding box , predicted category scores . The target bounding box obtained after GT preprocessing , One-Hot encoding of GT label categories .
[0027] (4-2-2) Calculate the target bounding box and predicted bounding box The IoU value between them generates the corresponding Value. value and dynamic K matching algorithm to calculate the number of positive samples required for each GT .
[0028] (4-2-3) Calculate the consistency metric according to the following formula , and compare it with Multiplication is equivalent to using the consistency metric right Perform weighted operations to finally obtain the predicted label value .
[0029] (4-2-4) By calculation and the true label category The binary cross entropy of ;pass Formula to calculate regression loss .pass , calculate the cost matrix of the anchor box , and sort them.
[0030] (4-2-5) According to dynamic matching count , choose the one with the lowest cost Anchor boxes As a positive sample. When a fuzzy anchor box matches multiple GTs, the GT with the lowest cost is selected as the GT matched by the anchor box. Finally, in the non-maximum suppression (NMS) stage, duplicate anchor boxes are deleted.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] Unlike previous methods that added separately designed specific modules to the existing detection framework to process features such as shape and material in X-ray images, the present invention adopts a holistic design strategy to improve detection performance by enhancing the model's ability to process spatial information of contraband. Specifically, the present invention first uses a progressive large kernel attention efficient layer aggregation network LKNA to enhance the ability to capture global dependencies during feature extraction. Then, a trunk-to-neck feature integration fusion module IFBN is designed to compensate for the small object feature information lost due to frequent up and down sampling operations. Finally, the task alignment is used to simplify the optimal transmission allocation strategy TATA, combining the advantages of local optimization and task consistency, to optimize the allocation of fuzzy anchor frames and improve detection accuracy. Compared with the original single-stage target detection algorithm, higher accuracy is achieved in the detection of X-ray security image sets, and real-time requirements are met to maintain a high detection speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 is a process flow chart of the present invention;
[0034] Figure 2 This is the overall structural diagram of the model of the present invention;
[0035] Figure 3 This is the LKNA structure diagram in the present invention. DETAILED DESCRIPTION
[0036] In order to better understand the purpose, structure and function of the present invention, the technical solution of the present invention is further described in detail below with reference to the accompanying drawings.
[0037] This example proposes a method for detecting contraband in X-ray security images based on single-stage target detection. The overall process is as follows: Figure 1 The overall structure of the model is shown in Figure 2 First, the present invention designs the LKNA backbone network, as shown in FIG. Figure 3 As shown in the figure. It enhances the model's ability to extract global context features of contraband through an incremental large kernel structure. Then, the present invention redesigns a neck feature alignment injection fusion module IFBN, as shown in the figure. Figure 2 As shown in the figure. Through alignment, fusion, and injection operations, IFFBN not only compensates for the loss of small target information caused by frequent up- and down-sampling operations, but also reduces computational costs while maintaining high computational efficiency through lightweight design. Finally, the present invention introduces the TATA label assignment strategy. Starting from a global perspective, it introduces a consistency measurement factor to intelligently match positive and negative samples, effectively combining the advantages of global optimization and task consistency, further improving the performance of the detection framework.
[0038] The method of the present invention comprises the steps of:
[0039] Step (1) Download the X-ray security inspection image dataset, divide the two data X-ray security inspection image datasets into training set and validation set, and perform preprocessing operations on the images. Specifically:
[0040] (1-1) The image collection is divided into two main parts: one part is used for model training, namely ; The other part is used to verify the accuracy of the model, i.e. . Where R is the real number field, represents the number of image samples in the training set, represents the i-th training image sample, represents the number of image samples in the validation set, represents the jth verification image sample, H represents the image height, W represents the image width, and 3 represents the number of RGB channels;
[0041] (1-2) Each training sample Corresponding tags ;in Represents an image sample The number of targets contained in express Middle The true categories of the targets, where C represents the total number of categories in the dataset, express Middle The bounding box of an object consists of the horizontal coordinate x of the center point, the vertical coordinate y of the center point, the width w of the object, and the height h.
[0042] (1-3) Before formal training, a series of data augmentation operations are performed on the images. This involves randomly selecting four images from the training set, performing a series of transformations such as flipping, scaling, and adjusting hue, and then concatenating these images into a new sample while preserving their original labels. Furthermore, the images are resized to a uniform size of 640×640 pixels and pixel values are normalized to ensure consistency and validity of the model input.
[0043] Step (2) On the network backbone, the original ELAN is improved to obtain LKNA, an incremental large kernel structure is added, and an attention mechanism is added between the large kernel structures to extract the spatial feature information in the image and obtain a feature map set. The LKNA network structure is as follows: Figure 3 As shown. The multi-level feature map Processed again in the attention module to obtain a further refined feature map and Specifically:
[0044] (2-1) In the LKNA of the backbone, a progressively larger kernel design is adopted, that is, large core convolution kernels of different sizes are used in the {B3, B4, B5} layers in the backbone network: The corresponding convolution operation is: The convolution operation divides the feature map into two parts, namely ,in Represents two The weights of the convolution kernel. Does not participate in the calculation and is directly cut off by the transition layer. , while being cut off by the transition layer, passing through two Large convolution kernels learn detailed information in feature maps, i.e. . After the CA attention module ( Figure 2 At position ① in the middle), the spatial location information of the items in the aggregated feature graph is This spatial information aggregation operation is very important for X-ray security images that lack surface texture features. After splicing, it is sent to the transition layer to participate in subsequent calculations. In LKNA, the gradient flow is divided into four paths, and the shortest gradient path is 1.
[0045] (2-2) Training Dataset Images in Input into LKNA to extract multi-level features and obtain the output feature map set of the backbone network B3, B4, and B5 layers ;
[0046] (2-3) In the multi-level feature map Based on this, two GAM attention modules are used for processing ( Figure 2 At positions ② and ③ in the middle), a further refined feature map is obtained and ,Right now , . and The extracted small target spatial feature information is included.
[0047] Step (3) In the neck network fusion stage, the feature information in the backbone is injected into the neck network through alignment, fusion and injection operations using IFFBN to generate the corresponding 、 as well as Features. Then use these features and feature maps and Perform fusion interaction operations to obtain refined feature maps Specifically:
[0048] (3-1) An alignment, fusion, and injection mechanism (IFFBN) is added between the neck and backbone. IFFBN balances the design of the backbone and neck structures, ensuring that the backbone network effectively extracts deep image features while the neck structure further optimizes and utilizes these features to improve object detection performance. IFFBN consists of sequentially executed alignment, fusion, and injection operations.
[0049] (3-1-1) Alignment operation. IFFBN aligns the multi-level features in the backbone , get the aligned features ,Right now .in, Represents a splicing operation, represents the global pooling operation, The output resolution defaults to Same resolution. Refers to the CSP cross-stage operation, that is, by dividing the base layer feature map into two parts, one part of the feature map does not participate in the operation, and the other part is directly merged with the features that do not participate in the operation in the transition layer after being calculated by dense blocks.
[0050] (3-1-2) Fusion operation. In the fusion stage, IFBN does not simply concatenate multi-level features, but performs adaptive fusion. The fusion process can be expressed as:
[0051]
[0052]
[0053]
[0054]
[0055] in, Block by It consists of convolution, BN, and activation function SiLU. Indicates the global pooling operation. X and Y represent the two features that need to be fused. In the fusion process, the X and Y features are first combined, that is, after the "+" operation, they are sent to the filtering module. Extract local features and get Similarly, after the average pooling operation, the global features are obtained. Then and After fusion, calculate the weight factor m of the X feature. Finally, use the weight factor to calculate the final fused feature This fusion strategy effectively solves the semantic and scale inconsistency problem of features in different layers or branches, not only improving the overall quality of the fused features, but also significantly improving the fusion accuracy of small object features that are easily overlooked under the action of the global channel attention mechanism.
[0056] (3-1-3) Injection operation. IFFBN will Inject into The final injection characteristics are obtained The injection process is expressed as:
[0057]
[0058]
[0059]
[0060]
[0061] Among them, A and B represent two features of the injection process: global features and local features, namely and , Indicates the average pooling operation. During the injection process, feature A and feature B are convolved and extracted to generate local features. With global features . In the After average pooling, it is used as the weight pair Perform weighted operations to obtain the final injection features Different multi-level features will generate different injection features, namely .
[0062] (3-2) The features obtained in step (2) , optimize the feature map set , And the three multi-level features obtained from (3-1) Input into the improved neck network.
[0063] (3-2-1) After a Convolutional layer, a Convolutional layer, a The convolution layer is used to reduce the number of channels and extract features to obtain the feature map .Then After the three-way max pooling, the results are spliced to integrate information of different scales. Finally, the obtained feature map is processed by a Convolutional layer, a After the convolutional layer, go through The feature maps processed by the convolutional layer are spliced to form the final feature map .
[0064] (3-2-2) Optimizing the feature map set , Perform bilinear interpolation upsampling operation to obtain upsampling features , and , Inject into In the , we get the refined features .right After upsampling and convolution operation through ELAN module, the obtained feature map is combined with After fusion, the feature map is obtained after the ELAN module and downsampling operation. .Will Inject into After that, we get the refined features .Will After the ELAN module and downsampling operation, the downsampled feature map is obtained .Will and Inject into Afterwards, we get the refined features .
[0065] Step (4) In the label assignment phase, the TATA assignment strategy is used to simplify the optimal transmission assignment strategy using task alignment to replace the original transmission assignment SimOTA strategy. The optimal anchor box matching the GT is globally found as the positive sample, and the rest are assigned as negative samples. In the assignment process, the consistency between the classification subtask and the regression subtask is measured to reduce the misalignment problem of the fuzzy anchor box. Specifically:
[0066] (4-1) Divide the image into The grid array is composed of a grid point, each of which is responsible for detecting whether the grid contains the center of the object to be tested. In this process, the output of each grid is a prediction vector, expressed as ,in Represent the center point coordinates and width and height of the candidate bounding box respectively, represents the confidence that the target center point falls within the current bounding box, and Represents the predicted probability of the object category within the current bounding box.
[0067] (4-2) In the label allocation phase, the new TATA allocation strategy is used to replace the original SimOTA strategy.
[0068] (4-2-1) First, through the prediction and processing operations, that is, the input image representation, the prior anchor box set, and the true annotation box GT are preprocessed to generate the predicted bounding box , predicted category scores . The target bounding box obtained after GT preprocessing , One-Hot encoding of GT label categories .
[0069] (4-2-2) Calculate the target bounding box and predicted bounding box The IoU value between Value. value and dynamic K matching algorithm to calculate the number of positive samples required for each GT .
[0070] (4-2-3) Calculate the consistency metric according to the following formula , and compare it with Multiplication is equivalent to using the consistency metric right Perform weighted operations to finally obtain the predicted label value .
[0071]
[0072] Among them, and Represents the classification score and the IoU value between the current anchor box and GT, and These are hyperparameters that control the contribution of the cls and reg tasks to task consistency, with default values of 1.0 and 6.0 respectively. Represents the maximum value obtaining function.
[0073] (4-2-4) By calculation and the true label category The binary cross entropy of ;pass Formula to calculate regression loss .pass , calculate the cost matrix of the anchor box , and sort them.
[0074] (4-2-5) According to dynamic matching count , choose the one with the lowest cost Anchor boxes As a positive sample. When a fuzzy anchor box matches multiple GTs, the GT with the lowest cost is selected as the GT matched by the anchor box. Finally, in the non-maximum suppression (NMS) stage, duplicate anchor boxes are deleted.
[0075] Step (5) sets the training parameters, inputs the training data set obtained in step (1) into the model constructed by steps (2)-(4) for iterative training, verifies on the validation set, obtains the optimal parameter model, and outputs the contraband detection effect diagram. The specific operation is:
[0076] (5-1) During the initial model training phase, a set of key hyperparameters must be set, such as the initial learning rate, momentum factor, learning rate decay rate, batch size, number of GPUs used, selected optimization algorithm, and the total number of training rounds. Subsequently, the prepared dataset is fed into the model framework constructed in the previous steps and trained over multiple rounds. During training, the mAP50 metric is used as a metric to continuously monitor the model's performance on the validation set.
[0077] Whenever the best mAP50 value is obtained during training, the corresponding model configuration is recorded and saved as the optimal parameters. This helps find the best parameter combination during training, thereby improving the model's prediction accuracy.
[0078] (5-2) After the training is completed, the validation set is used to verify the optimal model obtained in step (5-1), and the index parameters of the final model for detecting the data set are obtained. The category of the detected contraband and the confidence level are marked on the detection results.
[0079] The above embodiments have been described in detail to illustrate the objectives, technical solutions, and advantages of the present invention. It should be understood that these embodiments represent only some preferred implementations of the present invention and are not intended to limit its scope. Any modification, equivalent replacement, or improvement, subject to the core concepts and principles of the present invention, should be considered to be within the scope of protection of the present invention.
[0080] Example:
[0081] This experiment used two X-ray security inspection datasets: OPIXray and CLCXray. The OPIXray dataset, containing small and potentially overlapping images of prohibited items, poses significant challenges for detection models. The CLCXray dataset, on the other hand, focuses on distinguishing contraband from similar backgrounds, particularly when these items overlap. Figure 1 details the distribution of prohibited items in both datasets.
[0082] Table 1 OPIXray and CLCXray datasets
[0083]
[0084] The OPIXray dataset contains 8,885 images of prohibited knives from five categories: folding knives, straight knives, scissors, utility knives, and multi-tool knives. OPIXray focuses on occluded prohibited knives, which are often small and easily obscured by other objects, posing new challenges for X-ray security inspections. The CLCXray dataset contains 9,565 images, 4,543 of which are from real subway station security inspection scenarios and 5,022 from artificially designed scenarios. The biggest feature of the CLCXray dataset is that it contains multiple images of prohibited items that are similar to the background and overlap with each other. It includes 12 categories in total, namely: Blade, Dagger, Knife, Scissors, Tin, Cans, Carton Drinks, Glass Bottle, Plastic Bottle, Vacuum Cup, Spray Cans, and Swiss Army Knife.
[0085] Experimental comparison description:
[0086] Table 2 Comparison results of the present invention and other SOTA methods on OPIXray
[0087]
[0088] Table 2 lists the detection results of X-Safe compared to several other state-of-the-art (SOTA) algorithms on the OPIXray dataset. X-Safe achieves a high accuracy of 93.1%, significantly outperforming the other compared algorithms. Specifically, X-Safe outperforms or approaches the best existing methods across all categories. For example, compared to YOLOv7 using the SimOTA label assignment strategy, X-Safe achieves a 9.4% improvement in mAP50; compared to YOLOv7u6 (TAL) using the TAL label assignment strategy, X-Safe achieves a 1.1% improvement in mAP50. Furthermore, compared to the baseline SSD+DOAM algorithm on the OPIXray dataset, X-Safe achieves a 19.1% improvement in accuracy. These results demonstrate X-Safe's significant advantage in the contraband detection task. Furthermore, while maintaining high detection accuracy for easily identifiable categories such as Scissor (98.4%) and Multi-tool Knife (96.4%), X-Safe effectively improves detection of objects with complex surface textures, such as Straight Knife, demonstrating its superior feature representation capabilities. In the Utility Knife category, it achieved breakthrough detection accuracy, improving by 8.9% compared to the next-best method, POD-Y, demonstrating a significant improvement in the model's ability to capture the local spatial features of the tool. These results demonstrate that X-Safe has significant advantages in handling complex scenarios and diverse targets, effectively improving the accuracy and reliability of contraband detection.
[0089] Table 3 Comparison results of the present invention and other SOTA methods on CLC Ray
[0090]
[0091] Table 3 compares the performance of different YOLO models on the CLCXray dataset. The results show significant differences in performance across the models, particularly in the key mAP50 metric. YOLOv7 (SimOTA) and YOLOv9-m performed particularly well, achieving mAP50 scores of 83.6% and 84.7%, respectively. YOLOv10-m achieved an mAP50 score of 79.7% by optimizing inference speed, but its accuracy was slightly lower than that of YOLOv9-m and YOLOv11-m (84.6%). The proposed X-Safe model, through comprehensive optimization of feature extraction and training strategies, further improved detection accuracy, achieving an mAP50 score of 85.1%, making it the highest-performing model to date.
[0092] The above embodiments have been described in detail to illustrate the objectives, technical solutions, and advantages of the present invention. It should be understood that these embodiments represent only some preferred implementations of the present invention and are not intended to limit its scope. Any modification, equivalent replacement, or improvement, subject to the core concepts and principles of the present invention, should be considered to be within the scope of protection of the present invention.
Claims
1. A method for detecting contraband in X-ray security images based on a large kernel feature injection mechanism, characterized by: The following steps are involved: Step 1: Obtain an X-ray security inspection image dataset containing target bounding boxes and category annotations, divide the dataset into a training set and a validation set, and preprocess the security inspection images; Step 2: Based on the YoloV7 network, the pre-processed security inspection image is improved by performing incremental convolution on the backbone to extract features. The features are then fused through the alignment injection fusion mechanism to obtain a refined feature map. The specific implementation process is as follows: Step 2.1: In the YoloV7 network backbone, the efficient layer aggregation network ELAN is improved to obtain the incremental layer aggregation network LKNA, adding an incremental convolution kernel structure and adding an attention mechanism inside LKNA to extract spatial feature information in the image. , get the refined feature map; The incremental hierarchical aggregation network LKNA is specifically implemented as follows: the feature map is divided into two parts through two convolution operations, namely , feature map While being truncated by the transition layer in the ELAN block, it passes through two convolutional layers to learn the information in the feature map and obtain the feature map , and then pass through the CA attention module to aggregate the spatial position information of the objects in the feature map to obtain the feature map ;Will After splicing, it is sent to the transition layer to participate in subsequent calculations; Step 2.2, in the YoloV7 network neck network fusion stage, the alignment injection fusion mechanism IFFBN is used to perform alignment, fusion, and injection operations. The feature information is injected into the neck network and then fused and interacted with the refined feature map to obtain a refined feature map; Step 3: Perform classification and regression calculations on the refined feature map to obtain the classification and regression calculation values of each detection anchor frame, and output the contraband detection results of the X-ray security inspection image; Step 4: Use the test set to iteratively train the model built in steps 2 and 3, verify it on the validation set, obtain the optimal parameter model, and output the contraband detection effect diagram.
2. The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism according to claim 1 is characterized in that: The specific implementation process of step 2.1 is as follows: Step 2.1.1: In the backbone, the original ELAN is improved to obtain LKNA. In LKNA, a progressive kernel design is adopted, that is, convolution kernels of gradually increasing sizes are used in the backbone network: The images in the training data set are input into LKNA to extract multi-level features, and the four stages B2, B3, B4, and B5 layers after the backbone network output feature map sets respectively. ; Step 2.1.2, in the multi-level feature map Based on this, two GAM attention modules are used to process the feature maps to obtain the refined feature maps. and .
3. The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism according to claim 2, characterized in that: The specific implementation process of step 2.2 is as follows: Step 2.2.
1. Add an alignment-injection-fusion mechanism (IFFBN) between the neck and the trunk. IFFBN includes sequential alignment, fusion, and injection operations to obtain different multi-level features and generate different injection features. Step 2.2.2, the features , feature map collection , And three multi-level features Input into the improved neck network to generate refined features.
4. The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism according to claim 3 is characterized in that: The operations in the alignment injection fusion mechanism IFBN are specifically as follows: Alignment operation: align the multi-level features in the backbone { , multi-level features are pooled and concatenated, and then the alignment features are obtained through partial convolution cross-stage operations; Fusion operation: IFFBN adaptively fuses multi-level features. For the two fused features X and Y, after adding the features X and Y element by element, the feature extraction is divided into two branches. One branch passes through the filter block to obtain local features, and the other branch passes through the global pooling and then obtains the global features from the filter block. The global features and local features are added element by element to obtain the weight factor m. The weighted addition of features X and Y is performed to obtain the fused features. The weight of feature X is m, and the weight of feature Y is 1-m. The filter block is composed of Convolution, BN, and activation function SiLU are connected sequentially; Injection operation: Inject the aligned features into the fused features, perform convolution extraction on the fused features and aligned features respectively, and generate the injected local features and injected global features; after the injected global features are average-pooled, they are used as weights to perform weighted operations on the injected local features and added element-by-element to the injected global features to obtain the final injected features; Different multi-level features generate different injection features, i.e. .
5. The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism according to claim 4 is characterized in that: The specific implementation process of step 2.2.2 is as follows: After being processed by a convolutional network and then by three-way maximum pooling, the results are spliced to integrate information of different scales; finally, the obtained feature map is passed through two convolution layers with increasing convolution kernels and then combined with The feature maps processed by the convolution layer are spliced to form the final feature map ; For feature map collection , Perform bilinear interpolation upsampling to obtain upsampling features , and 、 Inject into , and obtain refined features ;right After upsampling and convolution operation through ELAN module, the obtained feature map is combined with After fusion, the feature map is obtained after the ELAN module and downsampling operation. ;Will Inject into After that, we get the refined features ;Will After the ELAN module and downsampling operation, the downsampled feature map is obtained ;Will and Inject into Afterwards, we get the refined features .
6. The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism according to claim 5, characterized in that: The specific implementation process of step 3 is as follows: Step 3.1: Divide the image into a grid array. Each grid point is responsible for detecting whether the grid contains the center of the object to be tested. In this process, the output of each grid is a prediction vector. Step 3.2: In the label allocation phase, the task alignment is used to simplify the optimal transmission allocation strategy TATA allocation strategy to replace the original transmission allocation SimOTA strategy.
7. The method for detecting contraband in X-ray security inspection images based on a large kernel feature injection mechanism according to claim 6, characterized in that: The specific implementation process of the task alignment simplified optimal transmission allocation strategy is as follows: Perform data dimension conversion preprocessing on the input image representation, prior anchor box set, and true annotation box GT to generate predicted bounding boxes and predicted category scores; perform one-hot encoding on the target bounding boxes obtained after GT preprocessing; Calculate the IoU value between the target bounding box and the predicted bounding box to generate the corresponding Value, through the dynamic K matching algorithm, calculate the number of positive samples required for each GT ; Calculate the consistency metric and multiply it by the predicted category score, which is equivalent to weighting the predicted category score using the consistency metric value to finally obtain the predicted label value; The classification loss is obtained by calculating the binary cross entropy between the predicted label value and the true label category; The formula calculates the regression loss, calculates the cost matrix of the anchor box through the weighted sum of the classification loss and the regression loss, and sorts them; Based on dynamic match count , choose the one with the lowest cost anchor boxes as positive samples; when a fuzzy anchor box matches multiple GTs, the GT with the smallest cost will be selected as the GT matched by the anchor box; finally, in the non-maximum suppression NMS stage, the duplicate anchor boxes are deleted.
Citation Information
Patent Citations
Flame detection method based on MPGD-YOLO network
CN116758393A
Unmanned aerial vehicle-oriented power transmission line lightning stroke point and bolt defect detection method and system
CN118014968A
X-ray image contraband detection method based on de-overlapping and associated attention mechanism
CN118261853A