A method for detecting dangerous goods in X-ray security inspection images based on deep learning
By building a deep learning model that integrates DenseNet and Yolov3, automatic recognition of X-ray security inspection images solves the problems of low efficiency and insufficient accuracy of manual observation in the existing technology, realizes automated identification and early warning of dangerous items, and improves security inspection. Efficiency and safety.
Patent Information
- Application Number
- CN202010706378.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-21
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2040-07-21
AI Technical Summary
Existing X-ray security inspection technology relies on manual observation, which is inefficient and can easily lead to missed detections and false detections. It is also difficult to meet the real-time and accuracy requirements in places with high population density and high freight flow, and there are great human fatigue and safety risks.
Using a method based on deep learning, we build a deep learning model that integrates DenseNet and Yolov3 to automatically segment and identify X-ray security inspection images, use convolutional neural networks and FPN networks to extract features, and combine with non-maximization suppression algorithms to detect dangerous items identification and early warning.
It realizes automated identification and early warning of dangerous goods, improves the efficiency and accuracy of security inspections, reduces labor costs, enhances the safety of public places, and reduces the risk of misdetection and missed inspections.
Smart Images

Figure CN111815616B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of security inspection dangerous goods detection, and specifically relates to a dangerous goods detection method in X-ray security inspection images based on deep learning. Background Art
[0002] In the field of public security, such as airports, subway stations, railway stations, bus stations and other public places, security inspectors mainly use X-ray security inspection machines to check passengers' luggage, which can effectively improve the efficiency and accuracy of security inspections, so X-ray security inspection machines are widely used. For example, in stations and airports, explosives, chemicals, guns, knives and other dangerous items carried by terrorists are generally hidden in the interlayer of luggage or clothing, which are relatively secretive and difficult to find in manual inspections, and the efficiency is relatively low. During the inspection, the luggage enters the X-ray inspection channel to generate X-ray signals. The X-rays penetrate the luggage to produce different attenuations. The security inspection machine presents images of different colors on the screen according to the received signals, and then relies on manual analysis and inspection of the images to identify dangerous items and issue warnings.
[0003] In real-life scenarios, airports, subways, train stations, and other places that require security checks often have high population density and large freight traffic. Considering congestion, delays, and other issues, security checks in these public places generally have high real-time requirements and high accuracy requirements. However, current security checks mainly rely on security inspectors' active observation of X-ray images, and the security inspectors' ability to identify dangerous goods images directly affects the quality and efficiency of security checks. This method not only requires training for full-time personnel, but also is prone to human fatigue due to the monotony and boredom of the inspection process, resulting in missed inspections and false inspections, which poses a major safety hazard. Summary of the invention
[0004] The present invention overcomes the shortcomings of the prior art and provides a method for detecting dangerous goods in X-ray security inspection images based on deep learning, with the aim of improving security inspection efficiency and quality. Image recognition or target detection is used for automatic segmentation and recognition of X-ray security inspection images through big data methods.
[0005] In order to achieve the above object, the present invention is implemented through the following technical solutions.
[0006] A method for detecting dangerous goods in X-ray security inspection images based on deep learning includes the following specific steps:
[0007] Step S1: Use pytorch to build the Yolov3 model, whose feature extractor adopts Darknet, and integrates the dense connection in Densenet to build a deep learning model integrating DenseNet and Yolov3, and pre-train the model to obtain the weight;
[0008] Step S2: Load the pre-trained weights and load the processed X-ray security inspection video or image to be inspected into the model;
[0009] Step S3: using a convolutional neural network as a feature extractor, forward propagating the loaded image to extract features of the loaded image;
[0010] Step S4: Calculate the confidence level of the dangerous goods and the location information of the dangerous goods according to the extracted features;
[0011] Step S5: Use the non-maximum suppression algorithm to remove redundant prediction objects and output the prediction results. For images containing dangerous goods, the category and location information of the dangerous goods are marked.
[0012] Furthermore, the step S2 specifically includes:
[0013] Step S21: extracting video frames from the loaded video, converting them into images, and loading them;
[0014] Step S22: scaling the loaded image to a fixed size;
[0015] Step S23: converting the processed image into a digital signal for fusion model calculation, and inputting the digital signal into the fusion model;
[0016] Furthermore, the convolutional neural network is a Darknet convolutional neural network, and step S3 is specifically as follows:
[0017] Step S31: using a densely connected Darknet convolutional neural network as a feature extractor, continuously convolving and downsampling the loaded image, completing forward propagation, and extracting the original features of the input image at different scales;
[0018] Step S32: Using the FPN network, the original features at different scales extracted in step S31 are horizontally connected and up-sampled to obtain fused features of three different scales and sizes.
[0019] Convolutional neural networks have the advantages of high fault tolerance, strong self-learning ability, weight sharing, automatic feature extraction, etc. They have shown great advantages in the fields of image recognition and target detection.
[0020] Better yet, the Darknet convolutional neural network connects the original input of a layer directly to the output of that layer:
[0021] y=F(x)+x
[0022] Among them, y is the output of this layer, F is the function mapping of this layer, and x is the input of this layer.
[0023] This connection method reduces the loss of original information during transmission, and alleviates the gradient vanishing problem in deep neural networks to a certain extent. At the same time, it further integrates the idea of dense connection in DenseNet, that is, all layers in the network have direct connections:
[0024] x l =H l ([x0, x1, ..., x l-1 ])
[0025] Among them, x l is the output of the lth layer, H l is the convolution function of the lth layer, x0,x1,...,x l-1 It is the output of all neural network layers before the lth layer. This way of connecting layers reduces the loss of original information during the transmission process, which is conducive to maximizing the transmission of information, making full use of shallow feature information and enhancing feature reuse.
[0026] The FPN network is introduced in step S32. Through lateral connection and upsampling, different levels are fused to obtain fusion features of three different scales and sizes, so that it contains more semantic features, which is conducive to object recognition in the image, and at the same time has richer information about local details of the image, which is conducive to locating the position of the object in the image and enhancing the convolutional neural network's ability to express and output image information.
[0027] Further, the step S4 includes:
[0028] Step S41: evenly divide the extracted features into grids of the same size, each grid is a vector representing the features of the grid area, and each grid is responsible for detecting the object falling therein;
[0029] Step S42: extract the feature vector of each grid, calculate the confidence that the grid contains each dangerous article, set the threshold to 0.3, filter the predictions with confidence less than the threshold, and set the confidence of the prediction to zero;
[0030] Step S43: for each grid, three anchor frames of different shapes are allocated to fit dangerous goods of different shapes and sizes falling within the grid;
[0031] Step S44: extract the feature vector of each grid, calculate the offset of the object in the grid relative to the assigned anchor box, further calculate the position of the object, and finally obtain a set of bounding box lists.
[0032] Furthermore, the step S5 comprises:
[0033] Step S51: sorting according to the confidence score.
[0034] Step S52: Select the predicted bounding box with the highest confidence and add it to the final output list, and delete it from the bounding box list;
[0035] Step S53: Calculate the areas of all bounding boxes;
[0036] Step S54: Calculate the intersection over union (IoU) of the bounding box with the highest confidence and other candidate boxes:
[0037]
[0038] Among them, box a That is, a predicted box, in step S54, is the bounding box with the highest confidence, box b That is, other predicted bounding boxes;
[0039] Step S55: setting a threshold and deleting bounding boxes whose IoU is greater than the threshold;
[0040] Step S56: Repeat the above process until the bounding box list is empty;
[0041] Step S57: for images containing dangerous goods, the predicted category and location information of the dangerous goods are marked. If no dangerous goods are detected, the image is a normal security inspection image that does not contain dangerous goods.
[0042] The beneficial effects of the present invention compared with the prior art are as follows.
[0043] The present invention is mainly used in airports and other places where security checks are required. At present, these places still use manual methods to detect dangerous goods, which results in a large labor cost. The present invention can automatically complete the identification and early warning of dangerous goods, saving manpower and financial resources. At the same time, the present invention is of great significance for improving the level of security inspection technology, preventing and stopping terrorist and violent incidents, improving people's sense of security, and building and maintaining a national security image. At the same time, the research of this project can be applied to transportation hubs and important activity places such as railway stations and subway stations, and has great economic and social value. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a model diagram of dangerous goods detection in X-ray security inspection images based on deep learning according to an embodiment of the present invention.
[0045] Figure 2 This is an example diagram of dangerous goods detection in X-ray security inspection images according to an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the technical problems, technical solutions and beneficial effects to be solved by the present invention clearer, the present invention is further described in detail in conjunction with the embodiments and the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. The technical solutions of the present invention are described in detail below in conjunction with the embodiments and the accompanying drawings, but the scope of protection is not limited thereto.
[0047] like Figure 1-2 , is a method for detecting dangerous goods in X-ray security inspection images based on deep learning, which specifically includes the following steps:
[0048] During the security inspection process, the X-ray security inspection machine will continuously generate scanning videos during the scanning process. Therefore, the present invention can support the detection of videos as well as the detection of corresponding pictures.
[0049] Step S1: Load the X-ray security inspection image or video to be detected. Specifically:
[0050] Step S11: For the loaded video, extract the video frame, convert it into an image, and load it.
[0051] Step S12: Perform a certain scale transformation on the loaded image and scale it to a fixed size.
[0052] Step S13: For the processed image, convert it into a digital signal for model calculation, and input it into the deep learning model integrating Densenet and Yolov3.
[0053] Step S2: Implement the definition and loading of the above model, and load the pre-trained weights.
[0054] Yolov3 is a one-stage target detection model proposed in recent years. Under the premise of ensuring a relatively fast detection speed, it improves the classification accuracy by improving the classification algorithm and the main structure of the feature extraction network. It achieves higher detection accuracy by refining the grid division and using a multi-scale prediction mechanism to make up for the shortcomings of small object detection, and meets the real-time and accuracy requirements of X-ray security dangerous goods detection.
[0055] Step S3: Use the convolutional neural network as a feature extractor to perform forward propagation on the loaded image to extract the features of the loaded image. Specifically:
[0056] Step S31: Using the Darknet convolutional neural network integrated with dense connections as a feature extractor, the loaded image is continuously convolved and downsampled to complete forward propagation and extract the original features of the input image at different scales.
[0057] Step S32: Using the FPN network, the original features at different scales extracted in step S31 are horizontally connected and up-sampled to obtain fused features of three different scales and sizes.
[0058] Step S41: Evenly divide the extracted features into grids of the same size, each grid is a vector representing the features of the grid area. Each grid is responsible for detecting the object falling into it;
[0059] Step S42: extract the feature vector of each grid, calculate the confidence that the grid contains each dangerous goods, and set the threshold to 0.7 to filter out predictions with too low confidence;
[0060] Step S43: For each grid, three anchor boxes of different shapes are allocated to fit dangerous goods of different shapes and sizes falling within the grid.
[0061] Step S44: extract the feature vector of each grid, calculate the offset of the object in the grid relative to the assigned anchor frame, and further calculate the position of the object (b x , b y , b w , b h )
[0062] b x =σ(t x )+c x
[0063] b y =σ(t y )+c y
[0064]
[0065]
[0066] Among them, (b x , b y ) are the center coordinates of the bounding box of the predicted object in the image, (b w , b h ) is the width and height of the predicted object bounding box, (t x , t y ) are the offsets of the predicted object’s bounding box relative to the center coordinates of the anchor box, (t w , t h ) are the offsets of the predicted object’s bounding box relative to the width and height of the anchor box. (c x , c y ) is the coordinate of the bounding box of the predicted object relative to the upper left corner of the grid, (p w , p h) are the width and height of the assigned anchor box.
[0067] Finally, we get a list of bounding boxes.
[0068] Step S5: Output the prediction results, and for images containing dangerous goods, label the category and location information of the dangerous goods contained; specifically:
[0069] Step S51: Use the non-maximum suppression (NMS) algorithm to remove redundant prediction objects.
[0070] The idea of the non-maximum suppression (NMS) algorithm is to search for local maxima and suppress maxima. For example, in the process of dangerous goods detection, a large number of prediction boxes will be generated at the same target location, and these prediction boxes may overlap with each other. In this case, we need to use non-maximum suppression to find the best object bounding box and eliminate redundant prediction boxes.
[0071] Step S52: sorting according to the confidence scores.
[0072] Step S53: Select the predicted bounding box with the highest confidence and add it to the final output list, and delete it from the bounding box list.
[0073] Step S54: Calculate the areas of all bounding boxes.
[0074] Step S55: Calculate the intersection over union (IoU) of the bounding box with the highest confidence and other candidate boxes:
[0075]
[0076] Among them, box a That is, a predicted box, in step S55, is the bounding box with the highest confidence, box b That is, the other predicted bounding boxes.
[0077] Step S56: Set the threshold to 0.5 and delete the bounding boxes whose IoU is greater than the threshold.
[0078] Step S57: Repeat the above process until the bounding box list is empty.
[0079] Step S58: For images containing dangerous goods, the predicted category and location information of the dangerous goods are marked. If no dangerous goods are detected, the image is a normal security inspection image that does not contain dangerous goods.
[0080] The above content is a further detailed description of the present invention in combination with a specific preferred embodiment. It cannot be determined that the specific embodiments of the present invention are limited to this. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the present invention, which should be regarded as belonging to the present invention and the scope of patent protection determined by the submitted claims.
Claims
1. A method for detecting dangerous goods in X-ray security inspection images based on deep learning, characterized in that: The specific steps include: Step S1: Load the X-ray security inspection image or video to be detected: Step S11: extracting video frames from the loaded video, converting them into images, and loading them; Step S12: performing a certain scale transformation on the loaded image and scaling it to a fixed size; Step S13: For the processed image, convert it into a digital signal for model calculation, and input it into a deep learning model integrating Densenet and Yolov3; Step S2: define and load the above model, and load the pre-trained weights; Step S3: Use the convolutional neural network as a feature extractor to perform forward propagation on the loaded image to extract the features of the loaded image: Step S31: using a densely connected Darknet convolutional neural network as a feature extractor, continuously convolving and downsampling the loaded image, completing forward propagation, and extracting the original features of the loaded image at different scales; Step S32: Using the FPN network, the original features at different scales extracted in step S31 are horizontally connected and up-sampled to obtain fused features of three different scales and sizes; Step S41: evenly divide the extracted features into grids of the same size, each grid being a vector representing the features of the grid area; each grid is responsible for detecting the object falling therein; Step S42: extract the feature vector of each grid, calculate the confidence that the grid contains each dangerous goods, and set the threshold to 0.7 to filter out predictions with too low confidence; Step S43: for each grid, three anchor frames of different shapes are allocated to fit dangerous goods of different shapes and sizes falling within the grid; Step S44: extract the feature vector of each grid, calculate the offset of the object in the grid relative to the assigned anchor frame, and further calculate the position of the object (b x , b y , b w , b h ) b x =σ(t x )+c x b y =σ(t y )+c y Among them, (b x , b y ) are the center coordinates of the bounding box of the predicted object in the image, (b w , b h ) is the width and height of the predicted object bounding box, (t x , t y ) are the offsets of the predicted object’s bounding box relative to the center coordinates of the anchor box, (t w , t h ) are the offsets of the predicted object’s bounding box relative to the width and height of the anchor box respectively; (c x , c y ) is the coordinate of the bounding box of the predicted object relative to the upper left corner of the grid, (p w , p h ) are the width and height of the assigned anchor box; Finally, we get a list of bounding boxes; Step S5: Output the prediction results, and for images containing dangerous goods, label the category and location information of the dangerous goods contained: Step S51: using the non-maximum suppression (NMS) algorithm to remove redundant prediction objects; Step S52: sorting according to confidence scores; Step S53: Select the predicted bounding box with the highest confidence and add it to the final output list, and delete it from the bounding box list; Step S54: Calculate the areas of all bounding boxes; Step S55: Calculate the intersection over union (IoU) of the bounding box with the highest confidence and other candidate boxes: Among them, box a That is, a predicted box, in step S55, is the bounding box with the highest confidence, box b That is, other predicted bounding boxes; Step S56: Set the threshold to 0.5 and delete the bounding boxes whose IoU is greater than the threshold; Step S57: Repeat the above process until the bounding box list is empty; Step S58: for images containing dangerous goods, the predicted category and location information of the dangerous goods are marked; if no dangerous goods are detected, the image is a normal security inspection image that does not contain dangerous goods.
