An X-ray image contraband detection method, device, equipment and medium

By extracting contours and performing multi-scale feature analysis in X-ray image contraband detection, and combining this with a cosine classification loss function, the problem of inaccurate contraband category identification in existing technologies is solved, achieving efficient and accurate automatic detection of contraband.

CN116385957BActive Publication Date: 2026-01-30CHONGQING INST OF GREEN & INTELLIGENT TECH CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310209462.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-06
Publication Date
2026-01-30
Estimated Expiration
2043-03-06

AI Technical Summary

Technical Problem

Existing X-ray methods for detecting prohibited items cannot accurately identify the types of prohibited items, especially those with large differences within a category but small differences between categories.

Method used

By acquiring the X-ray image of the target, extracting the target feature image based on the contour, performing global and multi-scale feature extraction, using the attention feature image for localization, and using a preset cosine classification loss function to classify the contraband in the localization box to achieve accurate identification.

Benefits of technology

It improves the accuracy and efficiency of prohibited item detection, can automatically identify the types of prohibited items, reduce human interference, and improve security inspection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116385957B_ABST
    Figure CN116385957B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, device, and medium for detecting contraband in X-ray images. The method includes acquiring an X-ray image to be tested; obtaining a target feature image based on the contour of the X-ray image; extracting global features from the target feature image to obtain an attention feature image; extracting multi-scale features from the attention feature image to obtain a multi-scale feature image; locating multiple bounding boxes from the multi-scale feature image; and classifying the contraband obtained in the bounding boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be tested. This invention provides a method for detecting contraband in X-ray images, solving the technical problem that existing X-ray contraband detection methods cannot accurately identify the types of contraband.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of security inspection, and in particular to a method, apparatus, equipment and medium for detecting contraband using X-ray images. Background Technology

[0002] Security checks, as one of the most effective security measures, are widely used in important locations such as airports, high-speed railways, and subways. However, X-ray images require professionally trained security personnel for interpretation, resulting in high labor costs. Furthermore, the condition of security personnel can affect the accuracy of detections, sometimes leading to missed items. In recent years, the rapid development of artificial intelligence and big data technologies has made it possible to shift from manual to automated detection of prohibited items, becoming a pressing and common technological need for security departments at civil aviation airports both domestically and internationally. Building upon existing image detection systems, intelligent methods are used to automatically detect prohibited items in X-ray images, allowing security personnel to focus on interpreting more complex images, thereby improving their work efficiency and significantly enhancing the quality and effectiveness of security checks.

[0003] Current methods for automated X-ray contraband detection are based on visible light target detection frameworks to detect X-ray images. However, traditional detection methods are not sensitive to targets with large intra-class differences and small inter-class differences. Since an X-ray image is the sum of projections after X-rays penetrate the different densities and thicknesses of an object, it is an image of the superposition of projections of each layer along the penetration path. Therefore, existing X-ray contraband detection methods have the technical problem of not being able to accurately identify the types of contraband. Summary of the Invention

[0004] In view of the shortcomings of the prior art described above, the present invention provides a method, apparatus, equipment and medium for detecting contraband in X-ray images, so as to solve the technical problem that the existing X-ray contraband detection cannot accurately identify the types of contraband.

[0005] This invention provides a method for detecting contraband in X-ray images, comprising: acquiring an X-ray image to be tested; obtaining a target feature image based on the contour of the X-ray image to be tested; performing global feature extraction on the target feature image to obtain an attention feature image; performing multi-scale feature extraction on the attention feature image to obtain a multi-scale feature image; locating multiple bounding boxes in the multi-scale feature image; and classifying the contraband in the bounding boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be tested.

[0006] In one embodiment of the present invention, the contour of the X-ray image to be tested is extracted to generate a contour image; a convolution operation is performed on the X-ray image to be tested to extract a shallow feature image; the shallow feature image and the contour image are stitched together to obtain a fused feature image; the X-ray image to be tested is input into a backbone network to obtain a deep feature image; the deep feature image and the fused feature image are stitched together to obtain a target feature image.

[0007] In one embodiment of the present invention, the target feature image is converted into an image matrix based on an attention convolutional layer; after transposing and multiplying the image matrix, a first global feature image is obtained based on a preset feature mapping; the dimension of the target feature image is transformed through a fully connected layer to obtain a second global feature image; and the attention feature image is obtained based on the first global feature image and the second global feature image.

[0008] In one embodiment of the present invention, an additive angle boundary and a multiplicative angle boundary are set for the cosine classification loss function, and the decision boundary of the cosine classification loss function is:

[0009] s(cos(n 2 θ1+m)-cosθ2)=0

[0010] Where s is The normalized representation of , where W is the fully connected layer, x is the sample, i is the i-th row, j is the j-th column, n is the integer of the control angle for multiplication angle, θ is the angle between two samples, and m is the integer of the control angle for addition angle.

[0011] In one embodiment of the present invention, the preset cosine classification loss function is:

[0012]

[0013] Where N is the number of samples, and s is... The normalized representation of , where W is the fully connected layer, x is the sample, i is the i-th row, j is the j-th column, n is the integer for the control angle of multiplication angle, m is the integer for the control angle of addition angle, and y is the class label.

[0014] In one embodiment of the present invention, the multi-scale feature image is extracted based on the attention image through a first feature layer, a second feature layer, a third feature layer and a fourth feature layer, wherein the first feature layer is a 14×14 convolutional layer, the second feature layer is a 7×7 convolutional layer, the third feature layer is a 3×3 convolutional layer and the fourth feature layer is a 1×1 convolutional layer.

[0015] In one embodiment of the present invention, the localization boxes on the multi-scale feature map are used as initial detection boxes; it is determined whether the overlap between an initial detection box and the remaining initial detection boxes is greater than a preset threshold, and the initial detection boxes with an overlap greater than the preset threshold are deleted; the overlap between multiple initial detection boxes and the remaining initial detection boxes is repeatedly determined to be greater than the preset threshold until the overlap between any initial box and the remaining initial boxes is less than or equal to the preset threshold; the retained initial detection boxes are used as target detection boxes, and the type of contraband in the target detection boxes is output.

[0016] The present invention also provides an X-ray image contraband detection device, comprising: an image acquisition module for acquiring an X-ray image to be tested; an attention feature extraction module for obtaining a target feature image based on the contour of the X-ray image to be tested, and performing global feature extraction on the target feature image to obtain an attention feature image; a multi-scale feature extraction module for performing multi-scale feature extraction on the attention feature image to obtain a multi-scale feature image; and a localization and classification module for localizing the multi-scale feature image to obtain multiple localization boxes, and classifying the contraband in the localization boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be tested.

[0017] The present invention also provides an electronic device, the electronic device comprising: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device enables the X-ray image contraband detection method as described in any of the above embodiments.

[0018] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer processor, causes the computer to perform the X-ray image contraband detection method as described in any of the above embodiments.

[0019] The beneficial effects of this invention are as follows: This invention provides a method, apparatus, device, and medium for detecting contraband in X-ray images. The method involves acquiring an X-ray image to be tested, obtaining a target feature image based on the contour of the X-ray image, extracting global features from the target feature image to obtain an attention feature image, focusing on items within the image through the attention of the attention feature image itself, extracting multi-scale features from the attention feature image to obtain multi-scale feature images, making contraband detection more comprehensive and sensitive to small targets through images at different scales, locating multiple bounding boxes from the multi-scale feature images, and classifying the contraband within the bounding boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be tested. The cosine classification function has a good ability to optimize inter-class spacing, effectively solving the problem of large differences within the same contraband class and small differences between classes, thus providing an accurate method for detecting contraband in X-ray images. Attached Figure Description

[0020] Figure 1 This is an exemplary embodiment of the present invention illustrating an X-ray image contraband detection system;

[0021] Figure 2 This is a schematic flowchart illustrating an exemplary embodiment of the present invention for detecting contraband in X-ray images;

[0022] Figure 3 This is an exemplary embodiment of the present invention illustrating an X-ray image contraband detection network;

[0023] Figure 4 This is a block diagram of an X-ray image contraband detection device shown in an exemplary embodiment of the present invention;

[0024] Figure 5 A schematic diagram of a computer system suitable for implementing embodiments of the present invention is shown. Detailed Implementation

[0025] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.

[0026] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0027] In the following description, numerous details are explored to provide a more thorough explanation of embodiments of the invention. However, it will be apparent to those skilled in the art that embodiments of the invention may be practiced without these specific details. In other embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring embodiments of the invention.

[0028] First, it should be noted that the cosine classification loss function has a good ability to optimize inter-class distance and is currently widely used in nonlinear word vector learning, semi-supervised learning, and face recognition. In the field of face recognition, the cosine loss function is used for face verification, usually by representing an image as a vector and then comparing the distance between two vectors to determine whether two images are of the same person. In X-ray contraband detection, due to the varying angles at which contraband is placed in luggage, the same contraband may appear very different from certain perspectives, while the differences between different types of contraband may be very small. Therefore, X-ray contraband detection suffers from the problem of large intra-class differences and small inter-class differences in contraband. To solve these problems, embodiments of the present invention propose an X-ray image contraband detection system, an X-ray image contraband detection method, an X-ray image contraband detection device, an electronic device, and a computer-readable storage medium, which will be described in detail below.

[0029] Please refer to Figure 1 , Figure 1 This is an exemplary embodiment of the X-ray image contraband detection system of the present invention. The computer device 102 can be at least one of a desktop graphics processing unit (GPU) computer, a GPU computing cluster, a neural network computer, etc. Those skilled in the art can use the computer device 102 to process the X-ray image to be tested, extract features from the X-ray image, and then locate and classify it to obtain the type of contraband in the X-ray image. The image acquisition device 101 is used to acquire the X-ray image to be tested. In this embodiment, the image acquisition device 101 uses an X-ray security inspection machine to acquire the X-ray image to be tested and provides it to the computer device 102 for processing.

[0030] In one embodiment of the present invention, after acquiring the X-ray image to be tested input by the image acquisition device 101, the computer device 102 obtains a target feature image based on the contour of the X-ray image to be tested, performs global feature extraction on the target feature image to obtain an attention feature image, performs multi-scale feature extraction on the attention feature image to obtain a multi-scale feature image, locates multiple bounding boxes on the multi-scale feature image, and classifies the contraband in the bounding boxes based on a preset cosine classification loss function to obtain the type of contraband in the X-ray security inspection image. It can be seen that the solution in this embodiment can automatically classify the types of contraband through image processing, avoid human interference, improve the speed and accuracy of contraband detection, and replace manual inspection, effectively improving detection efficiency.

[0031] It should be noted that this embodiment is not limited to receiving the X-ray image to be tested acquired by a single image acquisition device 101. In practical application scenarios, the computer device 102 can simultaneously interact with multiple image acquisition devices 101. Multiple image acquisition devices 101 can be identified through identification. The image acquisition devices 101 can interact with the computer device 102 via wired means, or via near-field wireless technologies such as infrared, Bluetooth, and NFC. They can also communicate with the computer device 102 via wireless networks such as GPRS (General Packet Radio Service), 3G (third-generation mobile information technology), 4G (fourth-generation mobile information technology), and 5G (fifth-generation mobile information technology). This invention does not impose any limitations on these methods.

[0032] Please see Figure 2 , Figure 2 This is a schematic flowchart illustrating an exemplary embodiment of the present invention for detecting contraband in X-ray images, as shown below. Figure 2 As shown, in an exemplary embodiment, the X-ray image contraband detection method includes at least steps S210 to S240, which are described in detail below:

[0033] Step S210: Obtain the X-ray image to be tested.

[0034] In one embodiment of the present invention, the X-ray image to be tested can be acquired by a computer processing device through an X-ray security inspection machine connected thereto, or the X-ray image to be tested can be input into the computer processing device by relevant technicians. The acquired X-ray image to be tested includes contraband and other items.

[0035] Step S220: Obtain the target feature image based on the contour of the X-ray image to be tested, and perform global feature extraction on the target feature image to obtain the attention feature image.

[0036] In one embodiment of the present invention, the contour of the X-ray image to be tested is extracted to generate a contour image; a convolution operation is performed on the X-ray image to be tested to extract a shallow feature image; the shallow feature image and the contour image are stitched together to obtain a fused feature image; the X-ray image to be tested is input into a backbone network to obtain a deep feature image; the deep feature image and the fused feature image are stitched together to obtain a target feature image.

[0037] In one embodiment of the present invention, the contour details of the X-ray security inspection image are extracted, and a contour image is generated using Gaussian convolution and double threshold filtering. The X-ray security inspection image is then convolved to extract a shallow feature image. The shallow feature image and the contour image are then stitched together to obtain a fused feature image. The X-ray image to be tested is then input into the backbone network to obtain a deep feature image. Finally, the deep feature image and the fused feature image are stitched together to obtain a target feature image.

[0038] It's important to understand that dual-threshold filtering assumes that all lines generated by noise are disconnected from the image's contours, and sets a high threshold and a low threshold. The low threshold filters out noise and lines with indistinct abrupt changes, while the high threshold preserves the contour lines. Lines between the low and high thresholds that are adjacent to the contour lines are retained; otherwise, they are discarded.

[0039] In one embodiment of the present invention, the target feature image is converted into an image matrix based on an attention convolutional layer; after transposing and multiplying the image matrix, a first global feature image is obtained based on a preset feature mapping; the dimension of the target feature image is transformed through a fully connected layer to obtain a second global feature image; and an attention feature image is obtained based on the first global feature image and the second global feature image.

[0040] In one embodiment of the present invention, the target feature image is input into an attention feature extraction unit and two fully connected layers. The attention feature extraction unit obtains the attention of the target feature image itself, focusing on luggage and miscellaneous items in the X-ray image. In the attention feature extraction unit, the target feature image is converted into an image matrix through two 1×1 convolutions and a preset feature mapping. After another 1×1 convolution transformation, the image matrix is ​​transposed and multiplied, and then the transposed and multiplied image matrix is ​​converted into a first global feature image through the preset feature mapping. The dimension of the target feature image is transformed through the fully connected layers to obtain a second global feature image. The first global feature image and the second global feature image are weighted to obtain the attention feature image.

[0041] Step S230: Perform multi-scale extraction on the attention feature image to obtain a multi-scale feature image.

[0042] In one embodiment of the present invention, multi-scale feature images are extracted based on attention images through a first feature layer, a second feature layer, a third feature layer and a fourth feature layer. The first feature layer is a 14×14 convolutional layer, the second feature layer is a 7×7 convolutional layer, the third feature layer is a 3×3 convolutional layer and the fourth feature layer is a 1×1 convolutional layer.

[0043] Step S240: Locate multiple bounding boxes in the multi-scale feature image, and classify the contraband in the bounding boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray security inspection image.

[0044] In one embodiment of the present invention, an additive angle boundary and a multiplicative angle boundary are set for the preset cosine classification loss function, and the decision boundary of the cosine classification loss function is:

[0045] s(cos(n 2 θ1+m)-cosθ2)=0 Equation (1)

[0046] In equation (1), s is The normalized representation of , where W is the fully connected layer, x is the sample, i is the i-th row, j is the j-th column, n is the integer of the control angle for multiplication angle, θ is the angle between two samples, and m is the integer of the control angle for addition angle.

[0047] Classifying prohibited items in the location box based on a preset cosine classification loss function also includes, where the preset cosine classification loss function is:

[0048]

[0049] In equation (2), N is the number of samples, and s is... The normalized representation of , where W is the fully connected layer, x is the sample, i is the i-th row, j is the j-th column, n is the integer for the control angle of multiplication angle, m is the integer for the control angle of addition angle, and y is the class label.

[0050] In another embodiment of the present invention, the cosine loss function further includes a cosine similarity loss function, which is used to determine whether two input vectors are similar. The definition corresponding to the i-th sample is:

[0051]

[0052] In equation (3), a i b i Representing the two input vectors, y i Category label: y i =1 represents similarity; y i=-1 indicates dissimilarity. cos(a i b i ) represents two vectors a i b i The cosine of the angle, margin represents the spacing: when the label y i =-1 and cos(a) i b i ) < margin, l i =0, indicating dissimilar samples that are easily classified, and therefore not included in the loss; when label y i =-1 and] find cos(a i b i > margin, at this time l i =cos(a i b i -margin; when the label y i =1,l i =1-cos(a) i b i When vector a i b i When the included angle is 0, l i =0.

[0053] In another embodiment of the invention, the cosine loss function further includes an L-Softmax loss function. The idea behind the L-Softmax loss function is to improve the discriminative power, intra-class compactness, and inter-class separability of features by incorporating a variable that controls the distance. The L-softmax Loss function is defined as follows:

[0054]

[0055] In equation (4), the label yi is used to define the i-th input function xi. It is the fully connected layer W. i List, m is an integer controlling the angular boundary; a larger m results in a larger classification margin and better model classification performance, but also increases the optimization difficulty. θ is the angle between two samples, and D(θ) is a monotonically decreasing function.

[0056] In another embodiment of the invention, the cosine loss function further includes an A-Softmax function, which is based on the L-Softmax function loss by introducing an angle parameter. and restrictions b = 0 transforms the decision boundary into ||x||(cosθ1 - cosθ2) = 0, where the boundary decision depends only on the angle. The A-softmax Loss function is defined as:

[0057]

[0058] In equation (5), k∈[0,m-1], N is the number of samples, θ is the angle between two samples, m is an integer controlling the angle boundary. The larger m is, the larger the classification margin, the better the model classification effect, and the greater the optimization difficulty. i is the i-th row, j is the j-th column, and x is the sample.

[0059] In another embodiment of the present invention, the cosine loss function further includes an LMCL function, defined as:

[0060]

[0061] In equation (6), N is the number of samples. c is the total number of categories, and P is the expected posterior probability of a certain category. The LMCL function directly subtracts a hyperparameter m from the cosine value to ensure a stable boundary distance. In this case, the angle boundary control parameter m is a hyperparameter and is not affected by θ, where θ is the angle between two samples, i is the i-th row, j is the j-th column, and x is the sample.

[0062] In another embodiment of the invention, the cosine loss function includes the ArcsFace function, which has a geometrically constant linear angle margen. By compressing the intra-class angle range and expanding the inter-class angle range through the parameter m, the model's discriminative ability is improved while training becomes stable. The ArcFace function is defined as:

[0063]

[0064] In equation (7), T is the transpose symbol, θ is the angle between two samples, i is the i-th row, j is the j-th column, x is the sample, W is the fully connected layer, N is the number of samples, and m is an integer controlling the angle boundary.

[0065] In one embodiment of the present invention, after locating multiple bounding boxes by multi-scale feature images and classifying the contraband in the bounding boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be tested, the X-ray image contraband detection method further includes: using the bounding boxes on the multi-scale feature image as initial detection boxes; determining whether the overlap between an initial detection box and the remaining initial detection boxes is greater than a preset threshold, and deleting the initial detection boxes with an overlap greater than the preset threshold; repeatedly determining whether the overlap between multiple initial detection boxes and the remaining initial detection boxes is greater than the preset threshold, until the overlap between any initial box and the remaining initial boxes is less than or equal to the preset threshold; using the retained initial detection boxes as target detection boxes, and outputting the types of contraband in the target detection boxes.

[0066] Please see Figure 3 , Figure 3 An exemplary embodiment of the present invention illustrates a contraband detection network for X-ray images, the network including a contour-color feature extraction unit, an attention feature extraction unit, and a multi-scale feature extraction unit.

[0067] Input the acquired X-ray image to be tested as follows: Figure 3 In the X-ray image contraband detection network shown, the contour details of the X-ray security inspection image are extracted in the contour-color feature extraction module. The contour map is generated by Gaussian convolution and double threshold filtering. Then, the X-ray image to be tested is convolved to extract shallow features and obtain a shallow feature image. The shallow feature image and the contour image are then stitched together to obtain a fused feature image. Finally, the fused feature image is input into the attention feature extraction module.

[0068] The X-ray security inspection image to be tested is input into the VGG-16 backbone network to obtain a deep feature image, which is then input into the attention feature extraction module. The fused feature image and the deep feature image are concatenated to obtain the target feature image, which is then input into the attention feature extraction module and two fully connected layers. The attention feature extraction unit obtains the attention of the target feature map itself, focusing on luggage and miscellaneous items in the X-ray image. In the attention feature extraction unit, the target feature image is transformed into an image matrix through two 1×1 convolutions using a preset feature mapping. After another 1×1 convolution transformation, the image matrix is ​​transposed and multiplied, and then transformed again through the preset feature mapping to obtain the first global feature image. The dimension of the target feature image is transformed through the fully connected layers to obtain the second global feature image. The first and second global feature images are weighted to obtain the attention feature image.

[0069] The attention feature image is input into the multi-scale feature extraction unit, which uses multiple feature layers of sizes 14×14, 7×7, 3×3 and 1×1 to obtain multi-scale feature maps. Shallow information is used in the large feature map to predict small targets, while depth information is used in the small feature map to predict large targets. Multi-scale detection can make the detection more comprehensive and sensitive to small targets.

[0070] The obtained multi-scale feature maps are localized and classified. A preset cosine classification loss function is introduced during the classification process to make the detection of contraband more accurate. Finally, NMS (non-maximum suppression) is performed to obtain the detection results of the X-ray image to be tested.

[0071] In an embodiment of the present invention, by extracting the contour of the X-ray image to be tested, focusing on cluttered items is achieved, thereby improving the average accuracy of X-ray image contraband detection.

[0072] In an embodiment of the present invention, the attention of the image itself is obtained by extracting the attention feature image, focusing on the clutter in the luggage, thereby improving the average accuracy of X-ray image contraband detection.

[0073] In embodiments of the present invention, by setting boundaries for the cosine classification loss function, the function integrates additive and multiplicative angular boundaries, paying more attention to intra-class compactness and inter-class differences, and making the decision boundary more obvious.

[0074] In embodiments of the present invention, by presetting a cosine classification function and using quadratic term parameter constraints, the inter-class spacing is further increased, resulting in better detection performance for contraband.

[0075] In this embodiment of the invention, multi-scale feature maps can be used to detect small targets in images of different scales, making the detection of small targets more thorough and sensitive, and avoiding the situation where small contraband cannot be detected.

[0076] In this embodiment of the invention, the target detection box is obtained by filtering the positioning boxes, and redundant positioning boxes can be removed.

[0077] Figure 4 This is a block diagram of an X-ray image contraband detection device illustrated in an exemplary embodiment of the present invention, such as... Figure 4 As shown, the exemplary X-ray image contraband detection device includes an image acquisition module 401, a contour-attention feature extraction module 402, a multi-scale feature extraction module 403, and a localization and classification module 404.

[0078] Image acquisition module 401 is used to acquire the X-ray image to be tested;

[0079] The contour-attention feature extraction module 402 is used to obtain a target feature image based on the contour of the X-ray image to be tested, and to perform global feature extraction on the target feature image to obtain an attention feature image;

[0080] The multi-scale feature extraction module 403 is used to extract multi-scale features from the attention feature image to obtain a multi-scale feature image.

[0081] The localization and classification module 404 is used to locate multiple localization boxes in the multi-scale feature image, and classify the contraband in the localization boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be tested.

[0082] It should be noted that the X-ray image contraband detection device and the X-ray image contraband detection method provided in the above embodiments belong to the same concept. The specific operation methods of each module and unit have been described in detail in the method embodiments and will not be repeated here. In practical applications, the X-ray image contraband detection device provided in the above embodiments can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. This is not a limitation here.

[0083] Embodiments of the present invention also provide an electronic device, including: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device enables the X-ray image contraband detection method provided in the above embodiments.

[0084] Figure 5 A schematic diagram of a computer system suitable for implementing embodiments of the present invention is shown. It should be noted that... Figure 5 The computer system 500 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.

[0085] like Figure 5As shown, the computer system 500 includes a Central Processing Unit (CPU) 501, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 502 or programs loaded from storage portion 508 into Random Access Memory (RAM) 503, such as performing the methods described in the above embodiments. The RAM 503 also stores various programs and data required for system operation. The CPU 501, ROM 502, and RAM 503 are interconnected via a bus 504. An Input / Output (I / O) interface 505 is also connected to the bus 504.

[0086] The following components are connected to I / O interface 505: an input section 506 including a keyboard, mouse, etc.; an output section 507 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to I / O interface 505 as needed. Removable media 511, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 510 as needed so that computer programs read from them can be installed into storage section 508 as needed.

[0087] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 509, and / or installed from removable medium 511. When the computer program is executed by central processing unit (CPU) 501, it performs various functions defined in the system of the present invention.

[0088] It should be noted that the computer-readable medium shown in the embodiments of the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0089] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0090] The units described in the embodiments of the present invention can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0091] Another aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer processor, causes the computer to perform the X-ray image contraband detection method as described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.

[0092] Another aspect of the present invention provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the X-ray image contraband detection method provided in the various embodiments described above.

[0093] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.

Claims

1. An X-ray image contraband detection method characterized by, The X-ray image contraband detection method comprises: obtaining an X-ray image to be detected; obtaining a target feature image based on the contour of the X-ray image to be detected, performing global feature extraction on the target feature image to obtain an attention feature image; performing multi-scale feature extraction on the attention feature image to obtain a multi-scale feature image; performing positioning on the multi-scale feature image to obtain a plurality of positioning boxes, and classifying the contraband in the positioning boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be detected; wherein the classification of the contraband in the positioning boxes based on the preset cosine classification loss function comprises: setting an additive angle boundary and a multiplicative angle boundary for the cosine classification loss function, and the decision boundary of the cosine classification loss function is: where s is , normalized representation of where W is a fully connected layer, x is a sample, i is the ith row, j is the jth column, n is an integer for the control angle distance of the multiplication angle distance, θ is the included angle between two samples, m is an integer for the control angle distance of the addition angle distance; the classification of the contraband in the positioning frame based on the preset cosine classification loss function further comprises that the preset cosine classification loss function is: where N is the number of samples, s is the , normalized representation of the softmax function, where W is the fully connected layer, x is the sample, i is the ith row, j is the jth column, n is an integer for the control angle of the multiplication angle, m is an integer for the control angle of the addition angle, and y is the class label.

2. The X-ray image contraband detection method of claim 1, wherein, obtaining a target feature image based on the contour of the X-ray image to be detected comprises: extracting the contour of the X-ray image to be detected to generate a contour image; performing convolution operation on the X-ray image to be detected to extract a shallow feature image, and splicing the shallow feature image and the contour image to obtain a fusion feature image; inputting the X-ray image to be detected into a backbone network to obtain a deep feature image, and splicing the deep feature image and the fusion feature image to obtain a target feature image.

3. The X-ray image contraband detection method of claim 1, wherein, performing global feature extraction on the target feature image to obtain an attention feature image comprises: converting the target feature image into an image matrix based on an attention convolution layer; after transposing and multiplying the image matrix, obtaining a first global feature image based on a preset feature mapping; transforming the dimension of the target feature image through a full connection layer to obtain a second global feature image; obtaining the attention feature image based on the first global feature image and the second global feature image.

4. The X-ray image baggage inspection method according to any one of claims 1 to 3, characterized in that, performing multi-scale feature extraction on the attention feature image to obtain a multi-scale feature image comprises: extracting the multi-scale feature image based on the attention feature image through a first feature layer, a second feature layer, a third feature layer and a fourth feature layer, the first feature layer is a 14x14 convolution layer, the second feature layer is a 7x7 convolution layer, the third feature layer is a 3x3 convolution layer, and the fourth feature layer is a 1x1 convolution layer.

5. The X-ray image baggage inspection method according to any one of claims 1 to 3, characterized by, After performing positioning on the multi-scale feature image to obtain a plurality of positioning boxes, and classifying the contraband in the positioning boxes based on a preset cosine classification loss function to obtain the types of contraband in the X-ray image to be detected, the X-ray image contraband detection method further comprises: taking the positioning boxes on the multi-scale feature image as initial detection boxes; judging whether the overlap degree of an initial detection box and the remaining initial detection boxes is greater than a preset threshold, and deleting the initial detection box whose overlap degree is greater than the preset threshold; repeatedly judging whether the overlap degree of a plurality of initial detection boxes and the remaining initial detection boxes is greater than the preset threshold until the overlap degree of any initial detection box and the remaining initial detection boxes is less than or equal to the preset threshold; taking the remaining initial detection boxes as target detection boxes, and outputting the types of contraband in the target detection boxes.

6. An X-ray image contraband detection apparatus, characterized by, The X-ray image contraband detection device comprises: An image acquisition module is configured to acquire an X-ray image to be detected. An outline-attention feature extraction module is configured to obtain a target feature image based on an outline of the X-ray image to be detected, and perform global feature extraction on the target feature image to obtain an attention feature image. A multi-scale feature extraction module is configured to perform multi-scale feature extraction on the attention feature image to obtain a multi-scale feature image. A positioning and classification module is configured to obtain a plurality of positioning frames by performing positioning on the multi-scale feature image, and perform classification on contraband in the positioning frames based on a preset cosine classification loss function to obtain a contraband category in the X-ray image to be detected. The classification on the contraband in the positioning frames based on the preset cosine classification loss function includes setting an additive angle boundary and a multiplicative angle boundary for the cosine classification loss function, and a decision boundary of the cosine classification loss function is: where s is , normalized representation of where W is a fully connected layer, x is a sample, i is the ith row, j is the jth column, n is an integer for the control angle distance of the multiplication angle distance, θ is the included angle between two samples, m is an integer for the control angle distance of the addition angle distance; the classification of the contraband in the positioning frame based on the preset cosine classification loss function further comprises that the preset cosine classification loss function is: where N is the number of samples, s is the , normalized representation of the equation where W is the fully connected layer, x is the sample, i is the ith row, j is the jth column, n is an integer for the control angle of the multiplication angle, m is an integer for the control angle of the addition angle, and y is the class label.

7. An electronic device, comprising: The electronic device includes: One or more processors; A storage device configured to store one or more programs that, when executed by the one or more processors, cause the electronic device to implement the X-ray image contraband detection method of any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer executes the X-ray image contraband detection method of any one of claims 1 to 5.