Contraband detection method based on multi-order feature extraction

By constructing a multi-order feature extraction contraband detection method, combining input preprocessing, feature extraction and detection head network, the RT-DETR model is optimized, and the challenges of occlusion and computing resources in X-ray security images are solved, and efficient and accurate contraband detection is achieved.

CN120580641APending Publication Date: 2025-09-02GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202510668102.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

The existing X-ray security image detection methods rely on manual detection to be susceptible to fatigue and experience, and computer vision algorithms such as CNNs are difficult to capture global features when processing complex occlusion scenarios, resulting in low detection efficiency and easy missed detection and missed detection. The DETR algorithm has challenges in real-time and computing resources.

Method used

The contraband detection method based on multi-order feature extraction is adopted. By constructing an input preprocessing network, a feature extraction backbone network (including Conv structure and multi-order gated aggregation network MogaBlock), an Efficient Hybrid Encoder network and a Decoder detection head network, combined with the RT-DETR model, the feature extraction and detection process is optimized, and the calculation overhead is reduced and detection accuracy is improved.

Benefits of technology

It realizes efficient and accurate detection of contraband in complex occlusion scenarios, improves security inspection efficiency and accuracy, reduces the demand for computing resources, and is suitable for real-time security inspection environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580641A_ABST
    Figure CN120580641A_ABST
Patent Text Reader

Abstract

The invention discloses a contraband detection method based on multi-order feature extraction, and the method achieves the high-precision detection of contrabands in X-ray security check based on a multi-order feature extraction network. The model is improved in that a multi-order gating aggregation network module is introduced into a backbone network of the model, a global-local space aggregation network GLSA and a FlexFusion module based on a bidirectional feature pyramid network BiFPN are introduced into an Encoder network, and global and local space information of a multi-scale feature map is captured. A global attention mechanism and a local attention mechanism are utilized to improve the feature expression ability and inhibit foreground information irrelevant to an X-ray contraband security check image, and the ability of the model to process feature fusion of different scales is optimized. According to the method, the feature interference of the overlapped articles in the X-ray image is reduced, the network feature extraction capability and the high-level feature fusion capability are enhanced, and the recognition capability and speed of the model on the contraband under the X-ray object are improved.
Need to check novelty before this filing date? Find Prior Art

Description

(1) Technical field

[0001] The present invention belongs to the technical field of computer vision and image processing, and in particular relates to a contraband detection method based on multi-order feature extraction. (2) Background technology

[0002] X-ray imaging is an indispensable tool for security checks in key areas such as airports, cargo facilities, and public places. It uses X-ray penetration to generate security images based on the differences in X-ray absorption rates of different items. Security personnel then use these images to detect prohibited items. However, manual inspections are limited by staff fatigue and personal experience, making it difficult to guarantee the accuracy of inspections. Furthermore, due to the complexity and ambiguity of the images themselves, as well as the occlusion, disorder, and overlapping objects caused by the random arrangement of items in luggage, not only is the efficiency low, but prohibited items are also prone to being missed or misdetected. Overcoming the complex interference of X-ray security images has become a difficult problem in contraband detection methods. Therefore, the development of automated solutions using advanced computer vision and deep learning methods has received significant impetus.

[0003] Although computer vision methods already exist to help personnel identify contraband, current research shows that improved machine vision algorithms, such as convolutional neural networks (CNNs), play a key role in the analysis of X-ray security images, particularly in the detection and classification of prohibited items. The YOLO algorithm, in particular, has become a research hotspot in the field of X-ray contraband detection due to its excellent real-time performance and low parameter count. However, because CNNs rely on local feature extraction, they still face serious limitations when processing X-ray images in complex, crowded or occluded scenes, which often fail to capture the image features of the global context of the object.

[0004] To address these limitations, research on Transformer-based DETR detection models has become a hot topic in contraband detection methods. While DETR-based models offer improved accuracy, they also present challenges when processing X-ray images, such as high computational complexity and model parameter count, complex network structures, and long training times. However, their high computational requirements and slow inference times pose challenges for real-time deployment in safety-critical environments such as airports and train stations. In real-world applications, high throughput and real-time performance are crucial, and these models may struggle to meet practical requirements in busy security checkpoints, for example. (3) Summary of the invention

[0005] In order to solve the above technical problems, the present invention provides a contraband detection method based on multi-order feature extraction, which can improve the security inspection efficiency in public places and the detection accuracy of contraband, and reduce the economic cost of enterprises and units to train professional security personnel.

[0006] To achieve the above-mentioned object, the contraband detection method based on multi-order feature extraction provided by the present invention comprises the following steps performed in sequence:

[0007] Step 1: Create the X-ray security image dataset SecureXray required for model training and divide the dataset into training set, validation set, and test set; the datasets used are all from open source public datasets including OPIXray, CLCXray, SIXray, PIXray, and PIDray;

[0008] Step 2: Build a contraband detection model based on multi-order feature extraction. This model includes the following networks: input preprocessing network, feature extraction backbone network, efficient hybrid encoder network, and decoder detection head network.

[0009] Step 3: Set the hyperparameters of the improved RT-DETR contraband detection model, then train the model using the training set created in step 1, and verify the detection effect using the validation set;

[0010] Step 4: Use the improved RT-DETR model trained in Step 3 to perform object detection evaluation on the test set constructed in Step 1. This test set allows you to fully verify the accuracy and reliability of the model in identifying contraband in X-ray images, thereby evaluating its application in actual security inspection scenarios.

[0011] In step 1, the method for creating the X-ray contraband dataset SecureXray and dividing the dataset into a training set, a validation set, and a test set is as follows:

[0012] First, the prohibited items categories in different public datasets were classified and counted, and images with duplicate categories and some non-representative features were excluded to ensure that there were multiple original X-ray images in different postures. Then, the image annotation tool LabelImg was used to annotate the different types of prohibited items contained in all the selected original X-ray images with boxes into a JSON file. The JSON file was then converted into a TXT file to obtain X-ray contraband images containing annotated information. All X-ray contraband images constituted the X-ray contraband image dataset SecureXray. The X-ray contraband image dataset SecureXray was then divided into training set, validation set, and test set in a ratio of 8:1:1.

[0013] In step 2, the input preprocessing network mainly preprocesses the X-ray contraband inspection images in the training set in step 1. The detailed process is as follows: first, black edge padding is performed on the images of different sizes in the training set to unify the image size to 640×640. Then, the enhanced X-ray contraband inspection images are spliced ​​together through methods including random scaling, random rotation, random cropping, and random permutation, finally completing the preprocessing process steps;

[0014] The feature extraction backbone network module is a backbone network for extracting the features of contraband in the preprocessed training set, and is composed of a Conv structure and a multi-stage gated aggregation network MogaBlock, wherein the parameters of the Conv structure are kernel=3, stride=2; the specific structure is composed of a group of Conv structures + (Conv structure + multi-stage gated aggregation network MogaBlock)×4+multi-stage gated aggregation network MogaBlock×2 connected in series; wherein the second Conv structure of the backbone network, the fourth Conv structure of the backbone network, the sixth Conv structure of the backbone network and the last multi-stage gated aggregation network MogaBlock in the backbone network are respectively input The feature maps P2, P3, P4, and P5 with sizes of 160×160×128, 80×80×256, 40×40×384, and 20×20×384 are output. The first two Conv structures slice the image, that is, the original image of size 640×640×3 is cut into a feature map of 160×160×128. The multi-order gated aggregation network MogaBlock uses the multi-order gated aggregation idea to effectively capture the local and global features of the input feature map, and keeps the number of feature map channels unchanged in the backbone network of this model; the internal structure of the multi-order gated aggregation network MogaBlock includes a feature decomposition module, a multi-order context aggregation module, and a gating mechanism. First, the feature decomposition module (FD) extracts local features (0th order) through 1×1 convolution and extracts global shape features (nth order) through global average pooling (GAP), using GELU activation and scaling factor γ s Dynamically filter out useful features. Then, the multi-level context aggregation module (Moga) captures features of different levels through parallel depth-wise separable convolution (DWConv): 5×5 convolution (expansion rate d=1) is used for low-level, 5×5 and 7×7 convolution (expansion rates d=2 and d=3) are used for medium-level and high-level respectively, and then the output is spliced ​​into multi-level context Y by channel. C Next, the gating mechanism uses the SiLU activation function to smoothly filter features and enhances the aggregation effect of useful features by multiplying the output of the feature decomposition module (FD) and Moga. Finally, the original input X is added to the aggregated features to obtain the output of MogaBlock;

[0015] The Efficient Hybrid Encoder network module consists of an attention-based intra-scale feature interaction network AIFI, a global-local spatial aggregation network GLSA, a bidirectional feature pyramid network BiFPN-based FlexFusion, and a convolutional re-parameterization structure RepC3. The attention-based intra-scale feature interaction network AIFI uses a single-scale Transformer encoder to perform intra-scale interactions on the P5 feature map of size 20×20×384, thereby capturing the connections between conceptual entities. The global-local spatial aggregation network GLSA performs intra-scale interactions on the feature maps of P3, P4, and P5 of sizes 80×80×256, 40×40×384, and 20×20×128, respectively. It captures global and local spatial information, increases feature fusion, and suppresses irrelevant foreground information in X-ray contraband inspection images. The number of channels in the output feature maps P3' and P4' is 128. Then, based on the FlexFusion of the bidirectional feature pyramid network BiFPN, feature maps of the same size, such as 80×80×128, 40×40×128, and 20×20×128, are adaptively and dynamically fused to obtain P3", P4", and P5". The mechanism can dynamically adjust the contribution of each feature map according to its content. Finally, the feature maps P3", P4", and P5" are respectively input into three convolutional reparameterization structures RepC3 for structural reparameterization to obtain intermediate feature maps M3, M4, and M5.

[0016] The Decoder detection head network has three input branches in total, and its input is the output intermediate feature maps M3, M4, and M5 of the Efficient Hybrid Encoder network module, with sizes of 80×80×128, 40×40×128, and 20×20×128.

[0017] In step 3, hyperparameters are set for the contraband detection model based on multi-order feature extraction built in step 2. The model is then trained using the training set of the SecureXray dataset built in step 1, and its detection performance is verified using the validation set. The specific method is as follows:

[0018] 1) Import the training set constructed in step 1 as the data input source into the improved RT-DETR-based X-ray contraband detection model, and also import the validation set to evaluate the detection performance of the model;

[0019] 2) Use the hyperparameters set during training of RT-DETR’s pre-trained weights (RT-DETR.pt) as the initial parameters for model training;

[0020] 3) Output the currently trained weights in each iteration, and perform target detection verification on the validation set in step 1 based on the weights, outputting relevant performance indicators to monitor the training progress;

[0021] 4) When the training reaches the set number of iterations, the optimal weight of the model is derived.

[0022] In step 4, the multi-order feature extraction-based X-ray contraband detection model trained in step 3 is used to perform object detection on the test set constructed in step 1. The purpose of this step is to comprehensively evaluate the model's detection effectiveness and generalization performance on unseen data, thereby confirming the model's reliability and accuracy in practical applications. The specific method is as follows:

[0023] 1) Load the multi-order feature extraction-based X-ray contraband detection model trained in step 3 into the test environment and specify the optimal weight file generated in step 3 as the main parameter. This optimal weight file records the best detection performance achieved by the model on the validation set, ensuring that the model performs at the highest level on the test set.

[0024] 2) Input the test set constructed in step 1 into the test framework loaded with the improved RT-DETR model. The test set contains X-ray image samples from a variety of real-world scenarios, including samples of both prohibited and normal items, ensuring that the test data is broadly representative and accurately reflects the model's detection capabilities. During testing, the model performs target detection on each test sample one by one and outputs the detection results, including the location, category, confidence level, and other information of the prohibited items. Through its internal multi-layer convolution and feature extraction mechanism, combined with the multi-order context aggregation characteristics of the RT-DETR structure, the model can effectively identify and locate subtle and complex features in the image.

[0025] 3) Finally, all test results are compared with the true labels of the test set to calculate key performance indicators such as precision and recall.

[0026] The improved RT-DETR X-ray contraband detection method proposed in the present invention has the following significance:

[0027] 1. This is a detection framework based on real-time DETR that can solve the fundamental challenges of detecting prohibited items in X-ray security images. Through the innovative combination of three modules, it specifically addresses the inherent difficulties of overlapping occlusion and feature entanglement in X-ray contraband image detection.

[0028] 2. Extensive evaluation on five challenging datasets (CLCXray, OPIXray, SIXray, PIXray and PIDray) shows that our proposed method surpasses the current state-of-the-art baselines with mAP scores of 63.1%, 91.9%, 91.2%, 85.5% and 84.7% respectively, and an FPS of 64.1. These comprehensive experimental results demonstrate that our method has excellent ability in optimizing the balance between computational efficiency and detection accuracy.

[0029] Further features and advantages of the present invention will be further elucidated in the subsequent description. Some features will be gradually revealed in the description or revealed through the specific implementation of the present invention. The objectives and other advantages of the present invention are achieved through the structures described in detail in the description, claims, and drawings, thereby providing greater practicality and innovation in technology. (IV) Description of the accompanying drawings

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

[0031] Figure 1 A flow chart of the method for constructing an X-ray contraband detection model implemented and provided by the present invention;

[0032] Figure 2 A schematic diagram of the X-ray contraband detection model architecture implemented and provided by the present invention;

[0033] Figure 3 A schematic diagram of the MogaBlock module structure in the X-ray contraband detection model implemented and provided by the present invention;

[0034] Figure 4 A schematic diagram of the GLSA module structure in the X-ray contraband detection model implemented and provided by the present invention;

[0035] Figure 5 A schematic diagram of the FlexFusion module structure in the X-ray contraband detection model implemented and provided by the present invention;

[0036] Figure 6 A schematic diagram of multi-scale fusion details in the X-ray contraband detection model implemented and provided by the present invention;

[0037] Figure 7 A comparison chart of the predicted results of contraband identification results by the X-ray contraband detection model implemented and provided by the present invention. (V) Specific implementation methods

[0038] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.

[0039] This application provides a multi-level feature extraction-based X-ray contraband detection model method, combined with Figure 1 As shown, the method includes:

[0040] S210, making the data set required for the model.

[0041] S220, input the training set in the data set into the detection model of the present invention, and perform deep training on the backbone network of the model to fully extract the key target feature information in the training samples, thereby generating a high-quality target feature vector set.

[0042] In this model, the improved detection model of the present invention is innovative compared to the existing RT-DETR model with ResNet as the backbone network. By integrating MogaBlock into the backbone network, we significantly improve the model's feature extraction capabilities while reducing computational overhead. MogaBlock utilizes multi-order gated aggregation to effectively capture local and global features, making it superior to traditional residual blocks in terms of computational cost and number of parameters. This adjustment not only reduces the number of floating-point operations per second (FLOPs) but also minimizes memory consumption, making the architecture well-suited for real-time X-ray security inspection applications. Our approach ensures faster detection without sacrificing accuracy, thus achieving an optimal balance between performance and resource efficiency.

[0043] S230, according to the feature map extracted by the backbone network, the global spatial attention and the local spatial attention in the GLSA module are processed in sequence to obtain an enhanced target feature map.

[0044] S240, the feature map of the backbone network processed by the GLSA module is input into the FlexFusion module for further multi-scale feature fusion to enhance the expressiveness of the features and ultimately generate a more robust target feature map.

[0045] At step S250, the enhanced object feature map is fed into the decoder detection head module, which uses an IoU-aware query selection process to select fixed, relevant features as the initial query. The decoder refines these features over multiple iterations and outputs a predicted recognition result, including the category, bounding box, and confidence score.

[0046] S260: Calculate the model recognition error using the preset GIoU_loss loss function, and continuously iterate the model using the AdamW optimizer until the model meets the preset contraband recognition accuracy requirements.

[0047] The X-ray contraband detection model based on multi-level feature extraction includes an input preprocessing network, a backbone network, an Efficient Hybrid Encoder network, and a Decoder detection head network. The backbone network is a feature extraction network, which includes multiple convolutional units (combined with Figure 3 The EfficientHybrid Encoder network is a feature fusion network whose main operation is to realize single-scale self-attention calculation and multi-scale feature fusion to capture targets of different sizes. It includes multiple GLSA modules, Conv unit modules and FlexFusion modules, as well as UPSample modules (upsampling modules). The Decoder detection head network includes detection layers of different scales, each of which is responsible for predicting target categories and bounding box information.

[0048] Combined model architecture Figure 2 As shown, in this application, the RT-DETR benchmark model is used as the basis, and the BasicBlock unit of ResNet18 in the original model backbone network is improved to a MogaBlock (multi-order gated aggregation module) unit. The global-local spatial aggregation network (GLSA) module is introduced in the Efficient Hybrid Encoder network to capture global and local spatial information of multi-scale feature maps. The global and local attention mechanisms are used to improve feature expression capabilities and suppress irrelevant foreground information in X-ray contraband security inspection images. The model feature fusion network is then improved based on the FlexFusion of the bidirectional feature pyramid network BiFPN to optimize the model's ability to handle feature fusion at different scales. The enhanced target feature map will be input into the Decoder detection head module. The IoU-aware query selection process selects fixed relevant features as the initial query. The Decoder gradually refines these features in multiple iterations and outputs predicted recognition results, including categories, bounding boxes, and confidence scores. The model recognition error is calculated using a preset loss function, and the optimizer continuously iterates the model to improve the model's recognition accuracy for different types of contraband, thereby improving detection efficiency.

[0049] Step S210: The specific process of making the data set required for the model is as follows:

[0050] S211, access to open source public datasets including OPIXray, CLCXray, SIXray, PIXray, and PIDray;

[0051] All images in the OPIXray dataset were scanned by security inspection machines and manually annotated by professional inspectors at international airports. The annotation standards are based on those used to train security inspectors. The OPIXray dataset contains 8,885 X-ray images (7,019 for training and 1,776 for testing), including five types of knives: folding knives, straight knives, scissors, utility knives, and multi-purpose knives. Obviously, the OPIXray dataset cannot cover all scenarios involving prohibited items. To improve data generalization and expand the scope of the model, data augmentation and enhancement will be conducted using other public dataset sources.

[0052] The SIXray image dataset includes multiple SIXray image data. The SIXray image dataset containing prohibited items is based on X-ray security images obtained after X-ray security equipment at locations such as airports, train stations, and subway stations captures items. There are six common categories of prohibited items in the SIXray image dataset, namely guns, knives, wrenches, pliers, scissors, and hammers.

[0053] The CLCXray dataset is different from the OPIXray dataset. CLCXray pays more attention to the overlap between the target and the similar background. The CLCXray dataset contains 9565 X-ray images, of which 4543 X-ray images (real data) are from real subway scenes and 5022 X-ray images (simulated data) are from manual design. All images were scanned using the same type of X-ray scanner, and all labels were marked by 8 junior employees (professionals with less than 5 years of work experience) and reviewed by 2 senior employees (with more than 5 years of work experience). There are 12 categories in the CLCXray dataset, including 5 types of cutters and 7 types of liquid containers. The five types of knives include blades, daggers, knives, scissors, and Swiss Army knives, and the seven types of liquid containers include cans, boxed drinks, glass bottles, plastic bottles, vacuum cups, spray cans, and cans.

[0054] The PIXray dataset collects 5,046 X-ray images, containing 15 categories of prohibited items including guns, bats, darts, knives, pliers, wrenches, lighters, batteries, hammers, scissors, fireworks, saw blades, blades, screwdrivers and pressure vessels, covering sharp objects, explosives, flammable materials and corrosive items.

[0055] The PIDray dataset is the largest prohibited item detection dataset to date. It collects 47,677 X-ray images for 12 categories of prohibited items. Each image is manually annotated after careful inspection. The 12 categories of prohibited items include guns, knives, wrenches, pliers, scissors, hammers, handcuffs, batons, sprayers, power banks, lighters and bullets. In order to maintain diversity, the dataset specially prepares 2 to 15 instances for each prohibited item to ensure the universality of prohibited items.

[0056] S212, by merging samples of the same category from different data sets, excluding samples of repeated categories and some images that are not representative of features, to ensure that there are multiple original X-ray image samples in different postures, and to grade the recognition difficulty according to the degree of overlap of prohibited items and the number of recognized targets in a single image.

[0057] S213 , using the LabelImg image annotation tool, relabels the different types of contraband contained in all selected original X-ray images using boxes into a JSON file. The JSON file is then converted into a TXT file to obtain X-ray contraband images containing the labeled information. All X-ray contraband images constitute the SecureXray X-ray contraband image dataset. As an implementable approach, image data enhancement can also be performed through geometric transformation, contrast transformation, noise perturbation, color change, cropping, affine transformation, and other methods. The SecureXray X-ray contraband image dataset is then partitioned into a training set, a validation set, and a test set in a ratio of 8:1:1.

[0058] Step S220: Input the training set in the data set into the detection model of the present invention, and perform deep training on the backbone network of the model to fully extract the key target feature information in the training samples, thereby generating a high-quality target feature vector set, specifically including:

[0059] S221, for each training sample, the detection model extracts features from the training sample to obtain an initial feature vector corresponding to the training sample.

[0060] S222 , performing a convolution downsampling operation on the training samples to obtain feature vectors P1 , P2 , P3 , P4 , and P5 at multiple scales.

[0061] S223, by integrating MogaBlock into the backbone, we significantly improve the model's feature extraction capabilities while reducing computational overhead. MogaBlock utilizes multi-order gated aggregation to effectively capture local and global features, making it superior to traditional residual blocks in terms of computational cost and number of parameters. This adjustment not only reduces the number of floating-point operations per second (FLOPs) but also minimizes memory consumption, making the architecture well-suited for real-time X-ray security inspection applications. As a result, our approach ensures faster detection without sacrificing accuracy, achieving an optimal balance between performance and resource efficiency.

[0062] Combine Figure 3 As shown in Figure 2, the multi-stage gated aggregation network MogaBlock includes a feature decomposition module (FD), a multi-stage context aggregation module, and a gating mechanism. The definition formula is as follows:

[0063] F moga =X+H Moga (H FD (Norm(X)));

[0064] Among them, H FD is the eigendecomposition module (FD), H Moga is a multi-order gated aggregation module (Moga), and the feature decomposition module (FD) uses static and adaptive regional perception to extract multi-order features using convolution operations alone. In addition to m-order interactions, the model also contains 0-order and n-order interactions. 0-order interactions capture common local textures, while n-order interactions encapsulate complex global shapes, which are achieved through Conv1×1 operations and global average pooling (GAP). In addition, to ensure that the model focuses on meaningful multi-order interactions, the FD module dynamically excludes trivial interactions. The specific formula is as follows:

[0065] Y=H Conv1 (X), Z in =H GELU (Y+γ s ⊙(YH GAP (Y)));

[0066] in, Indicates the scale factor starting from 0, H Conv1 Represents Conv1×1 convolution operation, H GELU Represents the GELU activation function, H GAP Represents the global average pooling function; the multi-order context aggregation module (Moga) captures features of different orders through three parallel depth-wise separable convolutions (DWConv). Assume that H FD The output features of are the input of the multi-stage context aggregation module (Moga) Then Decomposed along the channel dimension into and And C l +C m +C h = C; and use different depth-wise separable convolutions for features of different orders, using 5×5 convolutions (expansion rate d=1) for low-order, 5×5 and 7×7 convolutions (expansion rates d=2 and d=3) for medium and high orders respectively;

[0067] Finally, Z l , Z m and Z h The output is spliced ​​along the channel dimension to generate a multi-level context as follows:

[0068]

[0069] In order to effectively aggregate the features extracted from the context branch, we use the SiLU activation function in the gating branch. The use of the SiLU activation function not only retains the gating properties of Sigmoid, but also contributes to more stable training dynamics. The output of FD(·) is used as the input of Moga, where the Moga module can represent a network containing the gating branch. and context branches For the multi-order gated aggregation module, we instantiate the formula as follows:

[0070]

[0071] Step S230, based on the feature map extracted by the backbone network, the global spatial attention and the local spatial attention in the GLSA module are processed in sequence to obtain an enhanced target feature map. The specific steps include:

[0072] S231, since P2, P3, and P4 have higher-level and richer semantic features, they are used as the input of the global-local spatial aggregation (GLSA) module in the EfficientHybrid Encoder network to enhance feature fusion by capturing the global and local spatial information of high-level semantic features;

[0073] The integration of this module enables a more efficient combination of multi-scale features P2, P3, and P4 from the backbone network. Its dual-stream architecture is particularly advantageous in the context of X-ray images. Because the fixed imaging angle and pseudo-color representation of sample images often lead to feature entanglement, the GLSA module significantly improves the model's ability to distinguish between permitted and prohibited items by achieving accurate feature extraction at different scales (from small hidden objects to large recognizable objects).

[0074] S232, the global-local spatial aggregation (GLSA) module captures the global and local spatial information of the P2, P3, and P4 feature maps, and efficiently extracts feature information of the same scale with a channel number of 128.

[0075] Combine Figure 4 As shown in Figure 2, the structural design of the global-local spatial aggregation (GLSA) module is described in detail, which consists of two parts: global spatial attention (GSA) and local spatial attention (LSA). Specifically, the feature map with 128 channels is Divide equally into two feature map groups The input is fed into the Global Spatial Attention (GSA) module and the Local Spatial Attention (LSA) module respectively. The outputs of the two attention units are finally concatenated and passed through a 1×1 convolutional layer. We formalize this process as follows:

[0076]

[0077]

[0078] Among them, G sa represents the global spatial attention, L sa Represents local spatial attention. is the output feature.

[0079] S233, Global Spatial Attention (GSA): The GSA module focuses on capturing long-distance pixel relationships in the spatial domain to supplement local spatial attention. Integrating long-distance interactions can enhance feature representation capabilities. Through experiments, we can obtain a method for extracting long-distance dependencies. We generate a global spatial attention map and As input, the specific process is shown in the following formula:

[0080]

[0081]

[0082] Among them, Att Global (·) represents the global attention operation, H Conv1 represents 1×1 convolution, Denotes matrix multiplication. MLP(·) consists of two fully connected layers with ReLU activation function and normalization layer. The first layer of MLP projects the input into a higher dimensional space with dilation factor 2, and the second layer reduces the dimension back to the original input size.

[0083] S234, Local Spatial Attention (LSA) Module: The LSA module is designed to effectively extract local features within the region of interest, especially in the spatial dimension of the feature map, and is therefore well suited for detecting small objects. By focusing on local regions, LSA enhances the model’s sensitivity to fine details that may be ignored by the global attention mechanism. Specifically, we use the feature map As input, calculate the local spatial attention response The formula is as follows:

[0084]

[0085]

[0086] in, Represents a cascade of three 1×1 convolutional layers and a 3×3 depthwise separable convolutional layer. The number of channels is adjusted to 64, Att Local(·) is the local attention operation, σ(·) is the Sigmoid function, and ⊙ represents point-by-point multiplication. This structural design can efficiently aggregate local spatial information with fewer parameters.

[0087] S240, the feature map of the backbone network processed by the GLSA module is input into the FlexFusion module for further multi-scale feature fusion to enhance the expressiveness of the features and ultimately generate a more robust target feature map.

[0088] Traditional target detection models use an FPN+PAN structure to fuse multi-scale features through lateral connections and a pyramid-like hierarchical structure. However, due to the different resolutions of the input features, the contribution of the FPN+PAN structure to the fused output features is often uneven, and the features between different scales cannot be fully utilized. In the detection model of the present invention, a simple and efficient improved network structure FlexFusion module based on BiFPN is introduced. The BiFPN network structure strengthens the fusion of higher-level features, processes each bidirectional path as a feature network layer, and repeats it multiple times on the same layer. Unlike traditional fixed-weight fusion methods, FlexFusion uses a flexible weight distribution mechanism that can dynamically adjust the contribution of each feature map based on its content. This adaptability enables the model to better adapt to the diverse scales of targets in X-ray images, thereby improving the detection of small hidden objects and large visible objects.

[0089] S241, such as Figure 5 As shown in Figure 2, the FlexFusion architecture first applies 1×1 convolution to the input feature maps {F1, F2, F3} to normalize the channel dimension and provide consistency for subsequent operations. The processed feature maps {F′1, F′2, F′3} are then concatenated, and the weights of each feature map are calculated through 1×1 convolution and Softmax operations to ensure that the sum of the weights is 1, achieving adaptive and balanced feature combination. The calculated weights {W1, W2, W3} are then applied to the respective feature maps, and the final fused feature map is obtained through weighted summation, as shown in the following formula:

[0090] F flex =W1·F1+W2·F2+W3·F3;

[0091] In the contraband detection model based on multi-order feature extraction of the present invention, multiple FlexFusion feature fusion modules are used in the Efficient HybridEncoder network. The multi-scale feature fusion details are as follows: Figure 6 As shown, the filled circle represents a FlexFusion unit.

[0092] S242, such as Figure 6 As shown in the figure, after the multi-scale feature map is processed by the FlexFusion feature fusion module, three-scale enhanced target feature maps P3", P4", and P5" are generated and respectively input into three convolutional re-parameterized structures RepC3 for structural re-parameterization operations to obtain detection input feature maps M3, M4, and M5, which are used by the Decoder detection head module;

[0093] S250, the input feature maps M3, M4, and M5 are input to the Decoder detection head module. First, the Decoder detection head uses the IoU-aware query selection mechanism to filter out relevant features with high IoU from feature maps of different scales and generates a fixed number of initial query sets. These initial queries contain the potential location information of the target object and extract information through interaction with the feature maps.

[0094] In S251, over multiple iterations, the decoder leverages multi-layered interactions between query features and input feature maps to progressively refine and refine the query results, more accurately capturing object boundaries and category information. In each iteration, the decoder outputs a set of predicted bounding boxes, category labels, and corresponding confidence scores. Through layer-by-layer feature enhancement and position refinement, the decoder ultimately produces stable detection results that effectively handle objects of varying scales and ensure recognition accuracy.

[0095] S260, calculate the model recognition error using the preset GIoU_loss loss function, and continuously iterate the model using the AdamW optimizer until the model meets the preset contraband recognition accuracy requirements to obtain the best-performing detection model weight best.pt. This model weight is used as the optimal model for target detection on the test set described in step S213.

[0096] The GIoU_loss loss function is used to calculate the degree of overlap between the predicted box and the target box. Its formula is as follows:

[0097]

[0098] Among them, I is the intersection area of ​​the prediction box and the target box, U is the union area of ​​the prediction box and the target box, C is the area of ​​the minimum closed box containing the prediction box and the target box, and the first item is the standard IoU, the second It is a penalty term for non-overlapping areas, ensuring that the relative position and shape of the box are closer to the target box under the same IoU.

[0099] In the present invention, the development and training of the model are based on the PyTorch 2.1.2 deep learning framework, and the acceleration libraries of CUDAv11.8 and cuDNN v8.0.5 are used to ensure the efficiency of the training process. In terms of hardware configuration, the model training is run on an NVIDIA RTX 4090 GPU with 24GB of video memory. In both the training and inference stages, the input size is fixed to 640×640, the batch size is 8, and the number of target queries is set to 300. The number of training rounds is 100, and the AdamW optimizer (with decoupled weight decay) is used, the weight decay coefficient is 0.0001, the momentum is 0.9, and the initial learning rate is 0.0001.

[0100] The improved RT-DETR contraband detection model trained based on the above process is used to perform target detection on the SecureXray test set using the optimal weight as the main parameter file. The test set detection results in the present invention are shown in Figure 2. Figure 7 shown.

[0101] Depend on Figure 7 It can be seen that the results demonstrate the outstanding performance of the model of the present invention in addressing the various challenges of contraband detection. In five sets of images from different data sets, the model of the present invention showed high confidence and detection accuracy in various scenarios. In these complex scenes, contraband often has significant overlap and occlusion with other objects, and its unique features are weakened. This feature attenuation is a major challenge for most detection models, often leading to an increase in false detections and missed detections. However, even under these difficult conditions, the model of the present invention can still accurately identify contraband. Its enhanced performance in noise suppression and occlusion processing fully demonstrates the robustness of the model of the present invention, and also shows its potential to improve the reliability of X-ray security inspection systems in practical applications.

[0102] The above disclosure is only a preferred embodiment of the present invention, and certainly cannot be used to limit the scope of the rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiment and equivalent changes made in accordance with the claims of the present invention are still within the scope of the invention.

Claims

1. In order to solve the above-mentioned technical difficulties, the present invention provides a contraband detection method based on multi-order feature extraction, which can improve the security inspection efficiency in public places and the detection accuracy of contraband, and reduce the economic cost of enterprises and units to train professional security personnel.

2. The contraband detection method based on multi-order feature extraction according to claim 1 comprises the following steps performed in sequence: Step 1: Create the X-ray security image dataset SecureXray required for model training and divide the dataset into training set, validation set, and test set; the datasets used are all from open source public datasets including OPIXray, CLCXray, SIXray, PIXray, and PIDray; Step 2: Build a contraband detection model based on multi-order feature extraction. This model includes the following networks: input preprocessing network, feature extraction backbone network, efficient hybrid encoder network, and decoder detection head network. Step 3: Set the hyperparameters of the improved RT-DETR contraband detection model, then train the model using the training set created in step 1, and verify the detection effect using the validation set; Step 4: Use the improved RT-DETR model trained in Step 3 to perform object detection evaluation on the test set constructed in Step 1. This test set allows you to comprehensively verify the accuracy and reliability of the model in identifying contraband in X-ray images, thereby evaluating its application in actual security inspection scenarios.

3. In the SecureXray X-ray contraband dataset described in claims 1 and 2, the method for dividing the dataset into a training set, a validation set, and a test set is as follows: First, the prohibited items categories in different public datasets were classified and counted, and images with duplicate categories and some non-representative features were excluded to ensure that there were multiple original X-ray images in different postures. Then, the image annotation tool LabelImg was used to annotate the different types of prohibited items contained in all the selected original X-ray images with boxes into a JSON file. The JSON file was then converted into a TXT file to obtain X-ray contraband images containing annotated information. All X-ray contraband images constituted the X-ray contraband image dataset SecureXray. The X-ray contraband image dataset SecureXray was then divided into training set, validation set, and test set in a ratio of 8:1:

1.

4. In the contraband detection method of claim 1, in step 2, the input preprocessing network primarily preprocesses the X-ray contraband inspection images in the training set in step 1. The detailed process is as follows: first, black-border padding is performed on images of different sizes in the training set to unify the image size to 640×640. Then, the enhanced X-ray contraband inspection images are spliced ​​together through methods including random scaling, random rotation, random cropping, and random permutation, thereby completing the preprocessing process steps. The feature extraction backbone network module is a backbone network for extracting the features of contraband in the preprocessed training set, and is composed of a Conv structure and a multi-stage gated aggregation network MogaBlock, wherein the parameters of the Conv structure are kernel=3, stride=2; the specific structure is composed of a group of Conv structures + (Conv structure + multi-stage gated aggregation network MogaBlock)×4+multi-stage gated aggregation network MogaBlock×2 connected in series; wherein the second Conv structure of the backbone network, the fourth Conv structure of the backbone network, the sixth Conv structure of the backbone network and the last multi-stage gated aggregation network MogaBlock in the backbone network are respectively input The feature maps P2, P3, P4, and P5 with sizes of 160×160×128, 80×80×256, 40×40×384, and 20×20×384 are output. The first two Conv structures slice the image, that is, the original image of size 640×640×3 is cut into a feature map of 160×160×128. The multi-order gated aggregation network MogaBlock uses the multi-order gated aggregation idea to effectively capture the local and global features of the input feature map, and keeps the number of feature map channels unchanged in the backbone network of this model; the internal structure of the multi-order gated aggregation network MogaBlock includes a feature decomposition module, a multi-order context aggregation module, and a gating mechanism. First, the feature decomposition module (FD) extracts local features (0th order) through 1×1 convolution and extracts global shape features (nth order) through global average pooling (GAP), using GELU activation and scaling factor γ s Dynamically filter out useful features. Then, the multi-level context aggregation module (Moga) captures features of different levels through parallel depth-wise separable convolution (DWConv): 5×5 convolution (expansion rate d=1) is used for low-level, 5×5 and 7×7 convolution (expansion rates d=2 and d=3) are used for medium-level and high-level respectively, and then the output is spliced ​​into multi-level context Y by channel. C Next, the gating mechanism uses the SiLU activation function to smoothly filter features and enhances the aggregation effect of useful features by multiplying the output of the feature decomposition module (FD) and Moga. Finally, the original input X is added to the aggregated features to obtain the output of MogaBlock; The Efficient Hybrid Encoder network module consists of an attention-based intra-scale feature interaction network AIFI, a global-local spatial aggregation network GLSA, a bidirectional feature pyramid network BiFPN-based FlexFusion, and a convolutional re-parameterization structure RepC3. The attention-based intra-scale feature interaction network AIFI uses a single-scale Transformer encoder to perform intra-scale interactions on the P5 feature map of size 20×20×384, thereby capturing the connections between conceptual entities. The global-local spatial aggregation network GLSA performs intra-scale interactions on the feature maps of P3, P4, and P5 of sizes 80×80×256, 40×40×384, and 20×20×128, respectively. It captures global and local spatial information, increases feature fusion, and suppresses irrelevant foreground information in X-ray contraband inspection images. The number of channels in the output feature maps P3' and P4' is 128. Then, based on the FlexFusion of the bidirectional feature pyramid network BiFPN, feature maps of the same size, such as 80×80×128, 40×40×128, and 20×20×128, are adaptively and dynamically fused to obtain P3", P4", and P5". The mechanism can dynamically adjust the contribution of each feature map according to its content. Finally, the feature maps P3", P4", and P5" are respectively input into three convolutional reparameterization structures RepC3 for structural reparameterization to obtain intermediate feature maps M3, M4, and M5. The Decoder detection head network has three input branches in total, and its input is the output intermediate feature maps M3, M4, and M5 of the Efficient Hybrid Encoder network module, with sizes of 80×80×128, 40×40×128, and 20×20×128. In step 3, hyperparameters are set for the contraband detection model based on multi-order feature extraction built in step 2. The model is then trained using the training set of the SecureXray dataset built in step 1, and its detection performance is verified using the validation set. The specific method is as follows: 1) Import the training set constructed in step 1 as the data input source into the improved RT-DETR-based X-ray contraband detection model, and also import the validation set to evaluate the detection performance of the model; 2) Use the hyperparameters set during training of RT-DETR’s pre-trained weights (RT-DETR.pt) as the initial parameters for model training; 3) Output the currently trained weights in each iteration, and perform target detection verification on the validation set in step 1 based on the weights, outputting relevant performance indicators to monitor the training progress; 4) When the training reaches the set number of iterations, the optimal weight of the model is derived.

5. In the contraband detection method of claim 1, the multi-order feature extraction-based X-ray contraband detection model trained in step 3 is used to perform an object detection test on the test set constructed in step 1. The purpose of this step is to comprehensively evaluate the detection effect and generalization performance of the model on unseen data, so as to confirm the reliability and accuracy of the model in practical applications. The specific method is as follows: 1) Load the multi-order feature extraction-based X-ray contraband detection model trained in step 3 into the test environment and specify the optimal weight file generated in step 3 as the main parameter. This optimal weight file records the best detection performance achieved by the model on the validation set, ensuring that the model performs at the highest level on the test set. 2) Input the test set constructed in step 1 into the test framework loaded with the improved RT-DETR model. The test set contains X-ray image samples from a variety of real-world scenarios, including samples of both prohibited and normal items, ensuring that the test data is broadly representative and accurately reflects the model's detection capabilities. During testing, the model performs target detection on each test sample one by one and outputs the detection results, including the location, category, confidence level, and other information of the prohibited items. Through its internal multi-layer convolution and feature extraction mechanism, combined with the multi-order context aggregation characteristics of the RT-DETR structure, the model can effectively identify and locate subtle and complex features in the image. 3) Finally, all test results are compared with the true labels of the test set to calculate key performance indicators such as precision and recall.

Citation Information

Cited By

  • Image detection method, electronic equipment and storage medium

    CN121280707A

  • Contraband few-sample learning identification method for security inspection machine

    CN121438027A

  • A contraband few sample learning identification method for a security inspection machine

    CN121438027B