Luggage safety detection method and device, electronic equipment and medium
By constructing a luggage image detection model using a cross-shaped window conversion network and a high-level screening feature pyramid network, the problem of poor luggage X-ray image detection in the prior art is solved, and more efficient local small object detection is achieved.
Patent Information
- Application Number
- CN202411753767.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-14
AI Technical Summary
In the prior art, the receptive field of the luggage X-ray image detection model is limited and it is difficult to capture global dependence, resulting in poor detection effects, especially when facing luggage stacking, packaging occlusion and foreign object interference.
The initial luggage image detection model is constructed, including feature extraction module and feature fusion module. The feature extraction module is constructed using a cross-shaped window conversion network. The feature fusion module is constructed using a high-level screening feature pyramid network. The image is processed through the cross-shaped window self-attention mechanism and local enhanced position coding, and combined with the high-level screening feature pyramid network to achieve multi-level feature fusion.
It effectively improves the model's detection effect on luggage X-ray images, especially local small targets, solves the multi-scale challenges in the image, and improves the accuracy and efficiency of detection.
Smart Images

Figure CN119625497A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a baggage safety detection method, device, electronic equipment and medium. Background Art
[0002] With the rapid development of the times, modern transportation networks such as dense subway lines, fast highways and extensive air routes have jointly built an efficient and connected urban system. While traveling is convenient, the most important thing is personal safety. Baggage X-ray security inspection is an important security inspection method in modern society and is crucial to ensuring the safety of passengers.
[0003] In the prior art, convolutional networks, such as CNN models, are usually used for luggage X-ray image detection.
[0004] When faced with problems such as luggage stacking, parcels, etc. that may be blocked or covered by prohibited items or interfered with by foreign objects, it is necessary to identify local small targets. However, the receptive field of the CNN model is limited, making it difficult to capture global dependencies, and the detection effect is poor. Summary of the invention
[0005] In view of this, it is necessary to provide a baggage safety detection method, device, electronic device and medium to solve the problem of poor detection effect in the prior art.
[0006] In order to solve the above problems, the present application provides a baggage safety detection method, comprising: Constructing an initial baggage image detection model, wherein the baggage image detection model includes a feature extraction module and a feature fusion module, wherein the feature extraction module is constructed by using a cross window transformation network, and the feature fusion module is constructed by using a high-level screening feature pyramid network; Based on a preset baggage image data set, the initial baggage image detection model is trained to obtain a fully trained baggage image detection model; Based on the well-trained baggage image detection model, security detection is performed on the baggage image to be detected.
[0007] In some possible implementations, the feature extraction module includes a plurality of feature extraction units connected in sequence, and the feature extraction unit includes a cross-shaped window conversion layer.
[0008] In some possible implementations, the feature extraction unit further includes a convolutional word embedding layer, and an output of the convolutional word embedding layer is connected to an input of the cross window conversion layer.
[0009] In some possible implementations, the feature extraction units except the last feature extraction unit among the several feature extraction units also include a compression and excitation attention layer, and the output of the cross-shaped window conversion layer is connected to the input of the compression and excitation attention layer.
[0010] In some possible implementations, the number of the feature extraction units is four.
[0011] In some possible implementations, the cross-window transformation layer is composed of a series structure of a layer normalization layer and a cross-window self-attention layer, a series structure of a layer normalization layer and a multi-layer perceptron layer, and two jump connections.
[0012] In some possible implementations, the high-level screening feature pyramid network includes a feature selection unit and a feature fusion unit connected in sequence, the feature selection unit is used to screen the multi-scale features output by the feature extraction module through a channel attention and dimension matching mechanism, and the feature fusion unit is used to fuse the features screened by the feature selection unit through a selective feature fusion mechanism.
[0013] The present application also provides a luggage safety detection device, comprising: A model building unit, used to build an initial baggage image detection model, wherein the baggage image detection model includes a feature extraction module and a feature fusion module, wherein the feature extraction module is built by using a cross window transformation network, and the feature fusion module is built by using a high-level screening feature pyramid network; A model training unit, used for training the initial baggage image detection model based on a preset baggage image data set to obtain a fully trained baggage image detection model; The model detection unit is used to perform safety detection on the luggage image to be detected based on the fully trained luggage image detection model.
[0014] The present application also provides an electronic device, including a memory and a processor; The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the above-mentioned baggage safety detection method.
[0015] The present application also provides a computer-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the above-mentioned baggage safety detection method are implemented.
[0016] The beneficial effects of the present application are as follows: the baggage security detection method provided by the present application introduces a cross-window self-attention mechanism through a cross-window transformation network, which not only effectively enables the horizontal and vertical strips of the image to be processed in parallel, but also proposes a local enhanced position encoding (LePE), which can better process local position information and realize global feature information extraction, and then combines with a high-level screening feature pyramid network to realize multi-level feature fusion, solve the multi-scale challenges in the image, and effectively improve the model's detection effect on baggage X-ray images, especially local small targets. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A schematic diagram of an embodiment of the baggage safety detection method provided in this application; Figure 2 A schematic diagram of the feature extraction module structure provided for this application; Figure 3 Schematic diagram of the CSwin Transformer Block structure provided for this application; Figure 4 Schematic diagram of the HS-FPN structure provided for this application; Figure 5 A schematic diagram of the structure of an embodiment of a luggage safety detection device provided in this application; Figure 6 A schematic diagram of the structure of an embodiment of an electronic device provided in this application. DETAILED DESCRIPTION
[0018] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0019] It should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowcharts may be implemented out of order, and steps without logical contextual relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flowcharts, or may remove one or more operations from the flowcharts, under the guidance of the content of this application. Some of the block diagrams shown in the accompanying drawings are functional entities, and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor systems and / or microcontroller systems.
[0020] The descriptions of "first", "second", etc. involved in the embodiments of the present application are only used to describe the implicit purpose, and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the technical features defined as "first" and "second" may explicitly or implicitly include at least one of the features. "And / or" describes the association relationship of the associated objects, indicating that three relationships may exist, for example: A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone.
[0021] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0022] The present application provides a baggage safety detection method, which is described below.
[0023] Figure 1 A schematic diagram of an embodiment of the baggage safety detection method provided in this application is as follows: Figure 1 As shown, the baggage security detection method includes: S101, constructing an initial baggage image detection model, which includes a feature extraction module and a feature fusion module. The feature extraction module is constructed by using a cross window transformation network, and the feature fusion module is constructed by using a high-level screening feature pyramid network; It should be noted that the English name of the cross window transformation network is CSWin-Transformer, and the English name of the high-level screening feature pyramid network is HS-FPN.
[0024] S102, training the initial baggage image detection model based on a preset baggage image data set to obtain a fully trained baggage image detection model; S103: Based on the well-trained luggage image detection model, perform security detection on the luggage image to be detected.
[0025] Compared with the prior art, the present application introduces a cross-window self-attention mechanism through a cross-window transformation network, which not only effectively enables the horizontal and vertical strips of the image to be processed in parallel, but also proposes a local enhanced position encoding, which can better process local position information and realize global feature information extraction. It is then combined with a high-level screening feature pyramid network to realize multi-level feature fusion, solve the multi-scale challenges in the image, and effectively improve the model's detection effect on baggage X-ray images, especially local small targets.
[0026] In order to better perform feature extraction, in some embodiments, such as Figure 2 As shown, the feature extraction module includes a plurality of feature extraction units connected in sequence. In a specific embodiment, there are four feature extraction units, and the feature extraction units except the last feature extraction unit include a convolutional token embedding layer, a cross window transformation layer (CSwin Transformer Block) and a compression and excitation attention layer (Squeeze and Excitation Attention, SE attention for short) connected in sequence. The last feature extraction unit includes a convolutional word embedding layer and a cross window transformation layer connected in sequence.
[0027] Specifically, firstly, an H×W×3 X-ray image is input and the image is divided into H / 4×W / 4 patchtokens. The convolutional token embedding layer first performs a convolution operation on the two-dimensional feature map and then performs layer normalization, which can not only gradually reduce the sequence length and increase the dimension of the block (Token) feature across stages, but also capture local information; then, features are extracted through four stages of cross-window transformation layers (CSwin TransformerBlock), which solves the problem of limited receptive field in the CNN model, and adds cross-window self-attention and local enhanced position encoding; finally, an SE attention module is added after the cross-window transformation layer (CSwin Transformer Block), so that the model can generate features with channel information and improve the performance of the backbone network; the global feature information extraction of the model is realized through four stages of operations.
[0028] It should be noted that the cross window transformation layer (CSwin Transformer Block) is the core component of the cross window transformation network (CSwin Transformer), such as Figure 3As shown in the figure, the cross-shaped window transformation layer (CSwinTransformer Block) uses the cross-shaped window self-attention mechanism (Cross-Shaped Window Self-Attention) to group attention, parallelly calculate the horizontal and vertical self-attention, and introduces a local inductive bias. A local enhancement projection encoder (Local Enhancement Projection Encoder, LePE) parallel module is added to the cross-shaped window self-attention branch. This layer consists of a layer normalization layer (Layer Normalization, LN) and a cross-shaped window self-attention layer (Cross-ShapedWindow Self-Attention) series structure, a layer normalization layer (LN) and a multi-layer perceptron layer (Multi-LayerPerceptron, MLP) series structure, and two jump connections. Compared with the ordinary transformation layer (transformer block), the cross-shaped window transformation layer (CSwin Transformer Block) Block) achieves better results with less computation, making the model more friendly to input of any resolution as input for downstream tasks, improving the generalization ability of the model. The formula of the cross window conversion layer (CSwin Transformer Block) is as follows:
[0029]
[0030] In the formula, Indicates The output of the cross-shaped window transformation layer, Represents Cross-Shaped Window Self-Attention.
[0031] Among them, the Cross-Shaped Window Self-Attention mechanism is one of the core features of the Cross-Shaped Window Transformer (CSwin Transformer). It divides Multi-Head Attention into two groups and processes the horizontal and vertical strips of the image in parallel. This attention mechanism enables the model to focus on important features in the cross region while limiting the high computational cost of Global Self-Attention. This attention mechanism not only maintains the balance between local and global information, but also improves processing speed and efficiency. In the Transformer block, the feature map is first downsampled, and then the attention values of the number of self-attention heads are spliced in the channel dimension, and finally the information of different sub-attention heads is fused through a linear layer.
[0032] HS-FPN is a network structure for target detection tasks that is improved on the basis of traditional FPN. It solves the multi-scale problem in target detection by introducing a hierarchical structure. The core idea of HS-FPN is to divide FPN into multiple sub-pyramids, each of which has its own feature fusion and upsampling operations. This operation can retain more detailed information and solve the problem of high computational complexity. At the same time, according to the quality of features at different scales, HS-FPN introduces an adaptive feature selection mechanism to select the optimal features for fusion. Figure 4 As shown in the figure, the HS-FPN structure includes two important components, namely the feature selection module and the feature fusion module. First, the feature selection module combines the channel attention (CA) and dimension matching (DM) mechanisms to screen feature maps of different scales, and after global maximum pooling and global average pooling operations, the Sigmoid function is used to calculate the weights, effectively extracting important information in the channel. Subsequently, the feature fusion module performs feature fusion through the selective feature fusion (SFF) mechanism, using high-level features as weights to filter out the semantic information contained in low-scale features, and fuses them with high-level features, so as to solve the problem that high-level features are semantically rich but have inaccurate positioning information and low-level features are accurately positioned but have limited semantic information. This feature fusion network enables the model to capture more accurate and comprehensive feature information.
[0033] In order to better implement a baggage safety detection method in an embodiment of the present application, based on a baggage safety detection method, correspondingly, Figure 5 As shown, the embodiment of the present application further provides a luggage safety detection device 500, comprising: The model building unit 501 is used to build an initial baggage image detection model, which includes a feature extraction module and a feature fusion module. The feature extraction module is built using a cross window transformation network, and the feature fusion module is built using a high-level screening feature pyramid network. A model training unit 502 is used to train the initial baggage image detection model based on a preset baggage image data set to obtain a fully trained baggage image detection model; The model detection unit 503 is used to perform safety detection on the luggage image to be detected based on the well-trained luggage image detection model.
[0034] The luggage safety detection device 500 provided in the above embodiment can implement the technical solution described in the above luggage safety detection method embodiment. The specific implementation principles of the above units can refer to the corresponding contents in the above luggage safety detection method embodiment, which will not be repeated here.
[0035] like Figure 6 As shown, the present application also provides an electronic device 600. The electronic device 600 includes a processor 601, a memory 602 and a display 603. Figure 6 Only some components of the electronic device 600 are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0036] In some embodiments, the memory 602 may be an internal storage unit of the electronic device 600, such as a hard disk or memory of the electronic device 600. In other embodiments, the memory 602 may also be an external storage device of the electronic device 600, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 600.
[0037] Furthermore, the memory 602 may include both an internal storage unit of the electronic device 600 and an external storage device. The memory 602 is used to store application software installed in the electronic device 600 and various data.
[0038] In some embodiments, the processor 601 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run program codes or process data stored in the memory 602, such as the baggage safety detection method in the present application.
[0039] In some embodiments, the display 603 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 603 is used to display information on the electronic device 600 and to display a visual user interface. The components 601-603 of the electronic device 600 communicate with each other via a system bus.
[0040] In some embodiments of the present application, when the processor 601 executes the luggage safety detection program in the memory 602, the following steps may be implemented: Construct an initial baggage image detection model, which includes a feature extraction module and a feature fusion module. The feature extraction module is constructed using a cross-shaped window transformation network, and the feature fusion module is constructed using a high-level screening feature pyramid network. Based on the preset baggage image dataset, the initial baggage image detection model is trained to obtain a fully trained baggage image detection model; Based on the well-trained baggage image detection model, security detection is performed on the baggage images to be detected.
[0041] It should be understood that: when the processor 601 executes the luggage safety detection program in the memory 602, in addition to the above functions, other functions can also be implemented. For details, please refer to the description of the corresponding method embodiment above.
[0042] Furthermore, the embodiment of the present application does not specifically limit the type of the electronic device 600 mentioned, and the electronic device 600 may be a portable electronic device such as a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device, a laptop computer, etc. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable electronic devices may also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the present application, the electronic device 600 may not be a portable electronic device, but a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0043] Accordingly, an embodiment of the present application also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, the steps or functions of the baggage safety detection method provided in the above-mentioned method embodiments can be implemented.
[0044] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the above-mentioned program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0045] The above is a detailed introduction to a baggage security detection method provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. At the same time, for technicians in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present application.
[0046] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed in the present application should be covered within the protection scope of the present application.
Claims
1. A baggage safety detection method, characterized in that: include: Constructing an initial baggage image detection model, wherein the baggage image detection model includes a feature extraction module and a feature fusion module, wherein the feature extraction module is constructed by using a cross window transformation network, and the feature fusion module is constructed by using a high-level screening feature pyramid network; Based on a preset baggage image data set, the initial baggage image detection model is trained to obtain a fully trained baggage image detection model; Based on the well-trained baggage image detection model, security detection is performed on the baggage image to be detected.
2. The luggage safety detection method according to claim 1, characterized in that: The feature extraction module includes a plurality of feature extraction units connected in sequence, and the feature extraction unit includes a cross-shaped window conversion layer.
3. The luggage safety detection method according to claim 2, characterized in that: The feature extraction unit also includes a convolutional word embedding layer, and the output of the convolutional word embedding layer is connected to the input of the cross window conversion layer.
4. The luggage safety detection method according to claim 2, characterized in that: Except for the last feature extraction unit, the other feature extraction units among the several feature extraction units also include a compression and excitation attention layer, and the output of the cross-shaped window conversion layer is connected to the input of the compression and excitation attention layer.
5. The luggage safety detection method according to claim 2, characterized in that: The number of the feature extraction units is four.
6. The luggage safety detection method according to claim 2, characterized in that: The cross-window transformation layer is composed of a series structure of a layer normalization layer and a cross-window self-attention layer, a series structure of a layer normalization layer and a multi-layer perceptron layer, and two jump connections.
7. The luggage safety detection method according to claim 1, characterized in that: The high-level screening feature pyramid network includes a feature selection unit and a feature fusion unit connected in sequence. The feature selection unit is used to filter the multi-scale features output by the feature extraction module through a channel attention and dimension matching mechanism, and the feature fusion unit is used to fuse the features filtered by the feature selection unit through a selective feature fusion mechanism.
8. A luggage safety detection device, characterized in that: include: A model building unit, used to build an initial baggage image detection model, wherein the baggage image detection model includes a feature extraction module and a feature fusion module, wherein the feature extraction module is built by using a cross window transformation network, and the feature fusion module is built by using a high-level screening feature pyramid network; A model training unit, used for training the initial baggage image detection model based on a preset baggage image data set to obtain a fully trained baggage image detection model; The model detection unit is used to perform safety detection on the luggage image to be detected based on the fully trained luggage image detection model.
9. An electronic device, characterized in that: including memory and processor; The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the baggage security detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the baggage safety detection method described in any one of claims 1 to 7 are implemented.