Dial center contraband identification method, device and equipment and storage medium
The contraband identification model is constructed through the Efficientdet network, which solves the problem of high resolution and false alarm rates in X-ray scanning technology, and achieves rapid and accurate identification of contraband and improves logistics safety.
Patent Information
- Application Number
- CN202411168766.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-11-12
AI Technical Summary
Existing methods for identifying contraband through X-ray scanning technology are limited by the high resolution and false alarm rate, which makes it difficult to meet the growing logistics security needs.
The Efficientdet network is used to build a contraband identification model. By annotating and classifying the X-ray-wrapped images, the training set and test set are divided, the initial recognition model is trained, the parameters are adjusted, and the model is optimized to improve the recognition accuracy.
It realizes the rapid and accurate identification of contraband, reduces the dependence on manual inspection, reduces the risk of misjudgment and missed inspection caused by human factors, and improves the safety of package security inspection.
Smart Images

Figure CN118942041A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent identification technology, and in particular to a method, device, equipment and storage medium for identifying prohibited items in a distribution center. Background Art
[0002] Logistics companies usually use manual inspection and some basic X-ray scanning technology to identify contraband. Manual inspection is inefficient and easily affected by factors such as operator fatigue and distraction. Especially during peak logistics periods, manual inspection cannot quickly process large quantities of goods, resulting in cargo backlogs and reduced logistics efficiency. Although X-ray scanning technology can improve the efficiency of identifying contraband to a certain extent, it is usually limited by its high resolution and false alarm rate, making it difficult to meet the growing demand for logistics safety.
[0003] Therefore, the prior art still needs to be improved and developed. Summary of the invention
[0004] The main purpose of the present invention is to solve the problem that the existing method of identifying contraband by X-ray scanning technology is limited by high resolution and false alarm rate, and is difficult to meet the growing demand for logistics safety.
[0005] The first aspect of the present invention provides a method for identifying contraband in a distribution center, comprising:
[0006] The collected X-ray package images are labeled and classified to obtain an X-ray package image data set; the X-ray package images are divided into a training set and a test set according to a predetermined ratio, and the training set and the test set both include contraband image samples and non-contraband image samples; an initial recognition model is constructed based on an Efficientdet network; the initial recognition model is trained by the training set, the parameters of the initial recognition model are adjusted, and a contraband recognition model is obtained after being tested by the test set; the real-time acquired X-ray package image to be recognized is input into the contraband recognition model, a detection result is output, and whether to issue an alarm is determined according to the detection result.
[0007] Optionally, in a first implementation manner of the first aspect of the present invention, the collected X-ray package images are annotated and classified to obtain an X-ray package image dataset, including the steps of: scanning the package at the outlet and the distribution center by an X-ray imaging device to obtain the X-ray package image; performing data amplification processing on the X-ray package image to obtain an expanded image sample; and annotating and classifying the expanded image sample to obtain the X-ray package image dataset.
[0008] Optionally, in a second implementation of the first aspect of the present invention, data augmentation processing is performed on the X-ray package image to obtain an expanded picture sample, including the steps of: mirroring, rotating, scaling, cropping, translating or Gaussian noise processing on the X-ray package image to obtain a deformed picture sample; performing Mosaic processing and / or shearing and fusion processing on the X-ray package image and the deformed picture sample to obtain an expanded picture sample.
[0009] Optionally, in a third implementation of the first aspect of the present invention, the extended image samples are labeled and classified to obtain an X-ray package image dataset, including the steps of: performing feature labeling on the contraband areas in the extended image samples using the Labelme tool to obtain image samples labeled with feature information; classifying the image samples according to the feature information to obtain image samples containing contraband and image samples not containing contraband, wherein the image samples containing contraband and the image samples not containing contraband constitute the X-ray package image dataset.
[0010] Optionally, in a fourth implementation manner of the first aspect of the present invention, an initial recognition model is constructed based on an Efficientdet network, including the steps of: building an Efficientdet network framework, the Efficientdet network framework including an EfficientNet backbone network, a bidirectional feature pyramid network, a classification and bounding box regression network, and a loss function module, wherein the EfficientNet backbone network includes a Stem convolution layer for adjusting the number of channels and 16 stacked MBConvBlocks; introducing a spatial pyramid pooling module at different levels of the bidirectional feature pyramid network, performing multi-scale pooling operations on feature maps from different scales, and splicing or fusing the pooled feature maps to construct an initial recognition model.
[0011] Optionally, in a fifth implementation of the first aspect of the present invention, the initial recognition model is trained using the training set, the parameters of the initial recognition model are adjusted, and after being tested using the test set, a contraband recognition model is obtained, including the steps of: assigning initial values to all parameters in the initial recognition model using a random initialization method; randomly selecting image samples from the training set and inputting them into the initial recognition model for training, calculating prediction results through forward propagation, and then calculating loss values according to a Focal Loss function; updating the parameters of the network using a back propagation algorithm so that the loss values gradually decrease; repeating the above training steps until a predetermined number of training rounds is reached to obtain a trained initial recognition model; evaluating the trained initial recognition model using a test set, adjusting hyperparameters based on the evaluation results, and obtaining an optimized contraband recognition model.
[0012] Optionally, in a sixth implementation of the first aspect of the present invention, the loss value is calculated according to the Focal Loss function, including the steps of: using focal loss as the classification loss function, and measuring the difference between the category probability predicted by the initial recognition model and the true category through the classification loss function, and the calculation formula of Focal loss is as follows: L_cls = -α(1-p_t)^γlog(p_t), wherein p_t is the category probability predicted by the initial recognition model, α and γ are hyperparameters used to adjust the weights of samples of different difficulty levels, when p_t is close to 1, (1-p_t)^γ will become smaller, so that the loss value of the sample becomes smaller; conversely, when p_t is close to 0, (1-p_t)^γ will become larger, so that the loss value of the sample becomes larger; using smooth L1 loss as the regression loss function, and measuring the difference between the bounding box position predicted by the initial recognition model and the true bounding box position through the regression loss function, Smooth The calculation formula of L1 loss is as follows: L_reg = 0.5*(IoU-1)^2*1if|IoU-1|<1, otherwise L_reg = |IoU-1|-0.5, where IoU represents the IOU value of the predicted bounding box and the true bounding box. When the IoU value is close to 1, it means that the predicted box is very close to the true box, and the loss value is small at this time; when the IoU value deviates from 1, the loss value will gradually increase.
[0013] The second aspect of the present invention provides a distribution center contraband identification device, comprising: a labeling and classification module, used to label and classify the collected X-ray package images to obtain an X-ray package image data set; a data division module, used to divide the X-ray package images into a training set and a test set according to a predetermined ratio, and the training set and the test set both include contraband image samples and non-contraband image samples; a model construction module, used to construct an initial recognition model based on an Efficientdet network; a training module, used to train the initial recognition model through the training set, adjust the parameters of the initial recognition model, and obtain a contraband recognition model after testing with the test set; a recognition module, used to input the real-time acquired X-ray package image to be identified into the contraband recognition model, output a detection result, and determine whether to issue an alarm based on the detection result.
[0014] Optionally, in a first implementation manner of the second aspect of the present invention, the labeling and classification module includes: an acquisition unit, used to scan the package at the outlets and distribution centers through X-ray imaging equipment to acquire X-ray package images; an amplification unit, used to perform data amplification processing on the X-ray package images to obtain expanded image samples; and a classification unit, used to label and classify the expanded image samples to obtain an X-ray package image data set.
[0015] Optionally, in a second implementation of the second aspect of the present invention, the amplification unit includes: a deformation subunit, used to mirror, rotate, scale, crop, translate or Gaussian noise process the X-ray package image to obtain a deformed picture sample; a transformation subunit, used to perform Mosaic processing and / or shearing and fusion processing on the X-ray package image and the deformed picture sample to obtain an expanded picture sample.
[0016] Optionally, in a third implementation of the second aspect of the present invention, the classification unit includes: a labeling subunit, used to perform feature labeling on the prohibited items area in the expanded image sample through the Labelme tool to obtain image samples labeled with feature information; a classification subunit, used to classify the image samples according to the feature information to obtain image samples containing contraband and image samples containing non-contraband, and the image samples containing contraband and non-contraband constitute the X-ray package image data set.
[0017] Optionally, in a fourth implementation manner of the second aspect of the present invention, the model building module includes: a building unit for building an Efficientdet network framework, the Efficientdet network framework including an EfficientNet backbone network, a bidirectional feature pyramid network, a classification and bounding box regression network, and a loss function module, wherein the EfficientNet backbone network includes a Stem convolution layer for adjusting the number of channels and 16 stacked MBConvBlocks; an introduction unit for introducing a spatial pyramid pooling module at different levels of the bidirectional feature pyramid network, performing multi-scale pooling operations on feature maps from different scales, and splicing or fusing the pooled feature maps to construct an initial recognition model.
[0018] Optionally, in a fifth implementation of the second aspect of the present invention, the training module includes: an initialization unit, used to assign initial values to all parameters in the initial recognition model using a random initialization method; a calculation unit, used to randomly select image samples from the training set and input them into the initial recognition model for training, calculate the prediction results through forward propagation, and then calculate the loss value according to the Focal Loss function; an updating unit, used to update the parameters of the network using a back propagation algorithm so that the loss value gradually decreases; a repetition unit, used to repeat the above training steps until a predetermined number of training rounds is reached to obtain a trained initial recognition model; an evaluation unit, used to evaluate the trained initial recognition model using a test set, adjust the hyperparameters according to the evaluation results, and obtain an optimized contraband recognition model.
[0019] Optionally, in a sixth implementation manner of the second aspect of the present invention, the calculation unit includes: a classification loss calculation subunit, used to adopt focal loss as a classification loss function, and to measure the difference between the category probability predicted by the initial recognition model and the true category through the classification loss function, and the calculation formula of focal loss is as follows: L_cls = -α(1-p_t)^γlog(p_t), wherein p_t is the category probability predicted by the initial recognition model, α and γ are hyperparameters used to adjust the weights of samples of different difficulty levels, and when p_t is close to 1, (1-p_t)^γ will become smaller, so that the loss value of the sample becomes smaller; conversely, when p_t is close to 0, (1-p_t)^γ will become larger, so that the loss value of the sample becomes larger; a regression loss calculation subunit, used to adopt smooth L1 loss as a regression loss function, and to measure the difference between the bounding box position predicted by the initial recognition model and the true bounding box position through the regression loss function, Smooth The calculation formula of L1 loss is as follows: L_reg = 0.5*(IoU-1)^2*1if|IoU-1|<1, otherwise L_reg = |IoU-1|-0.5, where IoU represents the IOU value of the predicted bounding box and the true bounding box. When the IoU value is close to 1, it means that the predicted box is very close to the true box, and the loss value is small at this time; when the IoU value deviates from 1, the loss value will gradually increase.
[0020] The third aspect of the present invention provides a distribution center contraband identification device, comprising: a memory and at least one processor, wherein the memory stores computer-readable instructions, and the memory and the at least one processor are interconnected via a line; the at least one processor calls the computer-readable instructions in the memory so that the distribution center contraband identification device executes each step of the distribution center contraband identification method as described above.
[0021] A fourth aspect of the present invention provides a computer-readable storage medium, in which computer-readable instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the various steps of the distribution center contraband identification method as described above.
[0022] Beneficial effects: In the technical solution of the present invention, the collected X-ray package images are annotated and classified to obtain an X-ray package image data set; the X-ray package images are divided into a training set and a test set according to a predetermined ratio, and the training set and the test set both include samples of images containing contraband and samples of non-contraband images; an initial recognition model is constructed based on the Efficientdet network; the initial recognition model is trained by the training set, the parameters of the initial recognition model are adjusted, and after being tested by the test set, a contraband recognition model is obtained; the X-ray package images to be recognized acquired in real time are input into the contraband recognition model, the detection results are output, and it is determined whether to issue an alarm based on the detection results. The present invention constructs a contraband recognition model based on the Efficientdet network, and based on the contraband recognition model, contraband can be quickly and accurately identified, thereby reducing dependence on manual inspection. The visual recognition system reduces the risk of misjudgment and missed detection caused by human factors, and improves the overall safety of package inspection. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A first flow chart of a method for identifying contraband in a distribution center provided by an embodiment of the present invention;
[0024] Figure 2 A second flow chart of the method for identifying contraband in a distribution center provided by an embodiment of the present invention;
[0025] Figure 3 A third flow chart of the method for identifying contraband in a distribution center provided by an embodiment of the present invention;
[0026] Figure 4 A fourth flow chart of the method for identifying contraband in a distribution center provided by an embodiment of the present invention;
[0027] Figure 5 A fifth flow chart of the method for identifying contraband in a distribution center provided by an embodiment of the present invention;
[0028] Figure 6 A sixth flow chart of the method for identifying contraband in a distribution center provided by an embodiment of the present invention;
[0029] Figure 7 A schematic diagram of a structure of a prohibited goods identification device for a distribution center provided by an embodiment of the present invention;
[0030] Figure 8 Another structural schematic diagram of the prohibited goods identification device for a distribution center provided by an embodiment of the present invention;
[0031] Fig. 9 A schematic diagram of the structure of a prohibited article identification device for a distribution center provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The embodiment of the present invention provides a method, device, equipment and storage medium for identifying contraband in a distribution center, which labels and classifies the collected X-ray package images to obtain an X-ray package image data set; divides the X-ray package images into a training set and a test set according to a predetermined ratio, and the training set and the test set both include samples of images containing contraband and samples of images containing non-contraband; constructs an initial recognition model based on an Efficientdet network; trains the initial recognition model through the training set, adjusts the parameters of the initial recognition model, and obtains a contraband recognition model after testing the test set; inputs the real-time acquired X-ray package image to be identified into the contraband recognition model, outputs the detection result, and determines whether to issue an alarm based on the detection result. The present invention constructs a contraband recognition model based on the Efficientdet network, and based on the contraband recognition model, it can quickly and accurately identify contraband, thereby reducing the reliance on manual inspection, and the visual recognition system reduces the risk of misjudgment and missed detection caused by human factors, and improves the overall security of package inspection.
[0033] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first embodiment of the method for identifying contraband in a distribution center in the embodiment of the present invention includes:
[0035] S100: labeling and classifying the collected X-ray package images to obtain an X-ray package image dataset.
[0036] Specifically, in this embodiment, X-ray imaging equipment is deployed at key locations of outlets and distribution centers to ensure that packages can be easily scanned during circulation, and the X-ray imaging equipment is integrated with the existing logistics management system to achieve real-time transmission and storage of scanned data, while configuring equipment parameters such as scanning speed, image resolution, etc. to accommodate packages of different sizes and types; during the scanning process, Xray sample images are automatically or manually acquired and stored in a designated database, and these Xray sample images can be used to train machine learning models to achieve automatic recognition and classification of package contents. After acquiring the X-ray package images, the collected X-ray package images can be annotated and classified manually or by machine, thereby obtaining an X-ray package image data set, including original images, annotation information, classification labels, etc., so as to ensure the quality and diversity of the data set so as to train a more accurate model later.
[0037] S200, dividing the X-ray package image into a training set and a test set according to a predetermined ratio, wherein the training set and the test set both include contraband image samples and non-contraband image samples.
[0038] In this embodiment, since the initial recognition model initially constructed needs to be trained with a large amount of data and verified before an accurate contraband recognition model can be obtained. Therefore, in this embodiment, the X-ray package image needs to be divided into a training set and a test set according to a predetermined ratio. In order to ensure that there are enough sample data sets to train the initial recognition model, the number of the training set should be greater than the number of the test set. Preferably, the ratio of the number of the training set to the test set is 8:2-6:4, wherein the training set and the test set both include samples of images containing contraband and samples of images containing non-contraband.
[0039] S300, build an initial recognition model based on the Efficientdet network.
[0040] Specifically, EfficientDet is an efficient target detection network that is extended and optimized on the basis of EfficientNet, combining a weighted bidirectional feature pyramid network (BiFPN) and a compound scaling method, aiming to improve the efficiency of multi-scale feature fusion and maintain high precision. EfficientDet uses a compound scaling method to balance the depth, width and resolution of the model. This method allows the model parameters to be adjusted under different resource constraints to achieve optimal performance. Specifically, EfficientDet generates models of different complexity by adjusting the scaling factors of EfficientNet (such as depth coefficient, width coefficient and resolution coefficient) and the number of repetitions and width of BiFPN. This embodiment has the following advantages in constructing an initial recognition model based on the Efficientdet network: EfficientDet performs well in maintaining high precision and can reach or exceed the performance of existing target detection models on multiple data sets; by optimizing the feature fusion network and adopting a compound scaling method, EfficientDet reduces the number of parameters and the amount of calculation while maintaining a high detection speed. This makes it more efficient in practical applications; EfficientDet provides a variety of model versions with different complexities (D0 to D7), and users can choose the appropriate model for training and deployment according to actual needs and resource constraints; EfficientDet's architectural design has good scalability and can be easily combined with other technologies (such as attention mechanism, lightweight network, etc.) to further improve performance.
[0041] S400, training the initial recognition model through the training set, adjusting the parameters of the initial recognition model, and obtaining a contraband recognition model after testing with the test set.
[0042] S500: Input the real-time acquired X-ray package image to be identified into the contraband identification model, output the detection result, and determine whether to issue an alarm according to the detection result.
[0043] In this embodiment, after the initial recognition model is trained and tested by the training set and the test set, a contraband recognition model is obtained. Based on the model, the X-ray package image to be identified can be detected in real time and quickly, so as to determine whether the X-ray package image to be identified is a sample containing contraband images. If the detection result is an image containing contraband, an alarm is issued to remind the corresponding staff to detain the package and perform special treatments such as seizing the package. If the detection result is a non-contraband image, no alarm is issued and the package is transported normally. The present invention constructs a contraband recognition model based on the Efficientdet network. Based on the contraband recognition model, contraband can be quickly and accurately identified, thereby reducing dependence on manual inspection. The visual recognition system reduces the risk of misjudgment and missed inspection caused by human factors, and improves the overall security of package inspection.
[0044] See also Figure 2 The second embodiment of the method for identifying contraband in a distribution center in the embodiment of the present invention includes:
[0045] S110, scanning the package at the outlet and the distribution center by using an X-ray imaging device to obtain an X-ray package image;
[0046] S120, performing data amplification processing on the X-ray package image to obtain an expanded image sample;
[0047] S130: labeling and classifying the expanded image samples to obtain an X-ray package image dataset.
[0048] Specifically, in this embodiment, X-ray imaging equipment can be installed in express delivery outlets and distribution centers to ensure that the equipment can clearly capture X-ray images of the internal structure of the package. Whenever the package passes through the scanning area, the equipment automatically or manually triggers the shooting to obtain the X-ray package image; since the number of X-ray package images initially obtained is limited, it is not conducive to training the constructed network, so it is necessary to perform data amplification processing on the obtained X-ray package images by data amplification to obtain more expanded image samples; then these expanded image samples are annotated and classified with special marks, and the processed expanded image samples are placed in the corresponding directory to form an X-ray package image data set. In this embodiment, by training a machine learning or deep learning model with a large amount of annotated and classified X-ray image data, the recognition accuracy of the package content can be significantly improved, and false positives and false negatives can be reduced; at the same time, the data amplification processing enables the model to be exposed to more diverse image samples during the training process, so that it can maintain a high recognition ability when facing various complex situations in practical applications.
[0049] See also Figure 3 The third embodiment of the method for identifying contraband in a distribution center in the embodiment of the present invention includes:
[0050] S121, performing mirroring, rotation, scaling, cropping, translation or Gaussian noise processing on the X-ray package image to obtain a deformed image sample;
[0051] S122, performing mosaic processing and / or cutting and fusion processing on the X-ray package image and the deformed image sample to obtain an expanded image sample.
[0052] Specifically, in this embodiment, the original X-ray package image is first processed by mirroring, rotating, scaling, cropping, translating or Gaussian noise by commonly used data augmentation means to generate a new image. Although this processing method is a brand new image for the network model and can achieve the purpose of expanding the data set, the deformed image sample after such processing does not change the label of the original image, and the training effect is not good. Therefore, this embodiment further performs Mosaic processing and / or shear fusion processing on these deformed image samples and the original X-ray package image, so that the label of the expanded image sample obtained may be different from the label of the original image, which is conducive to the training of the network model and obtains a network model with better prediction effect. Specifically, Mosaic is a data augmentation technology that can create new training samples by combining two or more images together. As an example: randomly select four images; perform data augmentation operations on each image, including flipping, scaling, color gamut change, etc.; splice these four images together to form a new image, and ensure that the size of each image is equal to the size of the final output image, thereby obtaining a new expanded image sample. The cutting and fusion processing of the image includes the following steps: randomly deleting part of the area of one of the images in the extended image sample; intercepting an area of the same size from another image in the extended image sample to fill the deleted part of the area of the previous image, and performing full-image soft fusion to generate a new image to achieve data augmentation. This embodiment uses the CutMix method to achieve data enhancement. CutMix combines CutOut and Mixup. Compared with Cutout, CutMix changes the area deletion operation into intercepting an area of the same size as another image to fill the area, and changes the label of the new image at the same time; mixup performs full-image soft fusion of the two images, and also soft fusion of the labels of the two images, thereby utilizing the information of the full image. Cutout only drops the image, so it cannot utilize the full image information, and of course does not change the label. Cutmix performs hard fusion of the two images, and adopts the label soft fusion strategy of mixup. Such processing ensures that CutMix does not change the distribution of the entire data set. This embodiment can obtain a more diverse and rich extended image sample set by performing deformation processing and Mosaic / cut fusion processing on the X-ray package image. This not only helps to improve the generalization and robustness of the model, but also provides strong support for more complex analysis tasks.
[0053] See also Figure 4 The fourth embodiment of the method for identifying prohibited items in a distribution center of express mail in the embodiment of the present invention includes:
[0054] S131, using the Labelme tool to perform feature labeling on the prohibited items area in the expanded image sample to obtain an image sample labeled with feature information;
[0055] S132. Classify the image samples according to the feature information to obtain image samples containing contraband and image samples containing non-contraband, wherein the image samples containing contraband and the image samples containing non-contraband constitute the X-ray package image dataset.
[0056] The extended image samples described in this embodiment should include contraband (such as guns, knives, explosives, etc.) and non-contraband (such as clothing, books, electronic products, etc.). Labelme is an open source image annotation tool that supports multiple annotation methods such as polygons, rectangles, circles, etc., and is suitable for complex image annotation tasks. In this embodiment, the labeling software Labelme is used to feature the contraband area on the image in the extended image sample. The feature annotation can be a frame selection of different shapes. For example, a special shape such as a pentagram is used to frame the contraband area and use it as feature information. A corresponding label (such as "gun", "knife", etc.) is added to each annotated area, and the annotation result is saved; then the image samples can be classified according to the feature information, that is, the image samples marked with a pentagram frame selection are contraband image samples, and the image samples not marked with a pentagram frame selection are non-contraband image samples. The contraband image samples and non-contraband image samples constitute the X-ray package image data set. This embodiment can significantly improve the image recognition speed and accuracy in the security inspection process through automatic or semi-automatic image annotation and classification technology, and reduce manual intervention and misjudgment.
[0057] See also Figure 5 The fifth embodiment of the prohibited items identification in the distribution center in the embodiment of the present invention includes:
[0058] S310, building an Efficientdet network framework, wherein the Efficientdet network framework includes an EfficientNet backbone network, a bidirectional feature pyramid network, a classification and bounding box regression network, and a loss function module, wherein the EfficientNet backbone network includes a Stem convolution layer for adjusting the number of channels and 16 stacked MBConvBlocks;
[0059] S320, introducing a spatial pyramid pooling module at different levels of the bidirectional feature pyramid network, performing a multi-scale pooling operation on feature maps from different scales, and concatenating or fusing the pooled feature maps to construct an initial recognition model.
[0060] Specifically, EfficientNet, as the backbone network of the Efficientdet network framework, includes a Stem convolution layer for adjusting the number of channels and 16 stacked MBConvBlocks, where the Stem convolution layer (usually a 3x3 convolution with a step size of 2) reduces the dimension of the input image (for example, from 224x224 to 112x112) and adjusts the number of channels to match the requirements of subsequent MBConvBlocks; MBConvBlock (bottleneck convolution block in MobileNetV3) is the basic building block of EfficientNet. You need to stack these blocks according to the specific configuration of EfficientNet (such as EfficientNet-B0, B1,..., B7). Each MBConvBlock includes a depth-separable convolution, an optional SE (Squeeze-and-Excitation) block, and a point convolution to expand and compress the feature dimension. A total of 16 MBConvBlocks are stacked, and the depth and width of each Block can be adjusted according to the scaling rule of EfficientNet. In this embodiment, the bidirectional feature pyramid network is mainly used to extract features from multiple levels of the EfficientNet backbone network (such as feature maps of different scales), and then the feature maps of different scales are upsampled or downsampled to the same resolution, and then weighted fusion is performed. This embodiment introduces SPP (Spatial Pyramid Pooling) at each level, captures multi-scale information through pooling operations of different scales (such as 1x1, 3x3, 5x5, etc.), and then splices or fuses these pooled feature maps. In order to improve the effect of feature fusion, multiple BiFPN layers can be stacked, and each layer performs cross-scale weighted fusion and SPP operations; in this embodiment, the classification and bounding box regression network first selects a feature map of a specific scale from the top layer of the BiFPN network as the final feature representation, passes the selected feature map through a series of convolutional layers (usually 1x1 convolution), and then connects it to a classifier (such as a softmax classifier) to predict the category of each anchor point. Similarly, the feature map is used to pass through a series of convolutional layers and then connected to a bounding box regressor to predict the offset of the anchor point, thereby obtaining a more accurate bounding box; in this embodiment, the loss function module combines the classification loss (commonly used cross entropy loss) and the bounding box regression loss (commonly used Smooth L1 loss) to obtain the total loss by weighted summation.
[0061] This embodiment uses EfficientNet as the backbone network, provides efficient feature extraction capabilities, and optimizes performance through a composite scaling method (adjusting depth, width, and resolution at the same time); BiFPN can more effectively fuse multi-scale features through bidirectional weighted fusion and SPP modules to improve target detection performance; this embodiment can also adjust the configuration of EfficientNet and BiFPN according to different application scenarios to achieve optimal detection performance and computational efficiency; this embodiment can more accurately locate and classify targets through a carefully designed feature fusion and bounding box regression network.
[0062] See also Figure 6 The sixth embodiment of the identification of contraband in the distribution center in the embodiment of the present invention includes:
[0063] S410, using a random initialization method to assign initial values to all parameters in the initial recognition model;
[0064] S420, randomly selecting image samples from the training set and inputting them into the initial recognition model for training, calculating the prediction results through forward propagation, and then calculating the loss value according to the Focal Loss function;
[0065] S430, using the back propagation algorithm to update the parameters of the network so that the loss value gradually decreases;
[0066] S440, repeating the above training steps until a predetermined training round is reached to obtain a trained initial recognition model;
[0067] S450. Use the test set to evaluate the trained initial recognition model, adjust the hyperparameters according to the evaluation results, and obtain an optimized contraband recognition model.
[0068] Specifically, before model training, a random initialization method is used to assign initial values to all parameters in the initial recognition model, such as setting the initial number of iterations (such as 5000 times), the initial learning rate (such as 10-5) and batch_size (such as 300), as well as setting the data set path parameters and category parameters, and using a parallel GPU for training; a batch of images and corresponding bounding box annotation data are randomly selected from the training set and input into the model for training; after feature extraction and prediction branch processing, the predicted category probability and bounding box position are obtained; according to the prediction results and the true annotations, the classification loss and regression loss are calculated, the classification loss uses focal loss, and the regression loss uses smooth L1 loss. Among them, focal loss is used as a classification loss function, and the classification loss function is used to measure the difference between the category probability predicted by the initial recognition model and the actual category. The calculation formula of focal loss is as follows: L_cls = -α(1-p_t)^γlog(p_t), where p_t is the category probability predicted by the initial recognition model, α and γ are hyperparameters used to adjust the weights of samples of different difficulty levels. When p_t is close to 1, (1-p_t)^γ will become smaller, making the loss value of the sample smaller; conversely, when p_t is close to 0, (1-p_t)^γ will become larger, making the loss value of the sample larger; smooth L1 loss is used as a regression loss function, and the regression loss function is used to measure the difference between the bounding box position predicted by the initial recognition model and the actual bounding box position. The calculation formula of smooth L1 loss is as follows: L_reg = 0.5*(IoU-1)^2*1if|IoU-1|<1, otherwise L_reg = |IoU-1|-0.5, where IoU represents the IoU value between the predicted bounding box and the true bounding box. When the IoU value is close to 1, it means that the predicted box is very close to the true box, and the loss value is small at this time; when the IoU value deviates from 1, the loss value will gradually increase.
[0069] Then, according to the gradient of the loss function, backpropagate to all parameters of the model, update the parameter values, and repeat the training until the preset number of training rounds is reached; use the test set to evaluate the performance of the trained model, calculate indicators such as accuracy, recall rate, mAP, etc. to evaluate the performance of the model; finally, test and verify the results, adjust hyperparameters such as learning rate and batch size to optimize the performance of the model and obtain an optimized contraband recognition model.
[0070] The present invention inputs the real-time acquired X-ray package image to be identified into the contraband identification model, outputs the detection result, and determines whether to issue an alarm based on the detection result. The present invention constructs a contraband identification model based on the Efficientdet network. Based on the contraband identification model, contraband can be identified quickly and accurately, thereby reducing the dependence on manual inspection. The visual recognition system reduces the risk of misjudgment and missed inspection caused by human factors, and improves the overall safety of package security inspection.
[0071] The above describes the method for identifying contraband in a distribution center according to an embodiment of the present invention. The following describes the device for identifying contraband in a distribution center according to an embodiment of the present invention. Figure 7 In one embodiment of the present invention, a device for identifying prohibited items in a distribution center includes:
[0072] The labeling and classification module 10 is used to label and classify the collected X-ray package images to obtain an X-ray package image data set;
[0073] A data partitioning module 20, for partitioning the X-ray package image into a training set and a test set according to a predetermined ratio, wherein the training set and the test set both include contraband image samples and non-contraband image samples;
[0074] A model building module 30 is used to build an initial recognition model based on the Efficientdet network;
[0075] A training module 40, used to train the initial recognition model through the training set, adjust the parameters of the initial recognition model, and obtain a contraband recognition model after testing with the test set;
[0076] The identification module 50 is used to input the real-time acquired X-ray package image to be identified into the contraband identification model, output the detection result, and determine whether to issue an alarm based on the detection result.
[0077] The present invention constructs a contraband identification model based on the Efficientdet network. Based on the contraband identification model, contraband can be identified quickly and accurately, thereby reducing dependence on manual inspection. The visual recognition system reduces the risk of misjudgment and missed inspection due to human factors, and improves the overall safety of package security inspection.
[0078] See also Figure 8 Another embodiment of the contraband identification device of the distribution center in the embodiment of the present invention includes:
[0079] The labeling and classification module 10 is used to label and classify the collected X-ray package images to obtain an X-ray package image data set;
[0080] A data partitioning module 20, for partitioning the X-ray package image into a training set and a test set according to a predetermined ratio, wherein the training set and the test set both include contraband image samples and non-contraband image samples;
[0081] A model building module 30 is used to build an initial recognition model based on the Efficientdet network;
[0082] A training module 40, used to train the initial recognition model through the training set, adjust the parameters of the initial recognition model, and obtain a contraband recognition model after testing with the test set;
[0083] The identification module 50 is used to input the real-time acquired X-ray package image to be identified into the contraband identification model, output the detection result, and determine whether to issue an alarm based on the detection result.
[0084] In this embodiment, the labeling classification module 10 includes:
[0085] An acquisition unit 11 is used to scan the package at the outlet and the distribution center through an X-ray imaging device to acquire an X-ray package image;
[0086] An amplification unit 12 is used to perform data amplification processing on the X-ray package image to obtain an expanded image sample;
[0087] The classification unit 13 is used to label and classify the extended image samples to obtain an X-ray package image data set.
[0088] In this embodiment, the amplification unit 12 includes:
[0089] The deformation subunit 121 is used to perform mirroring, rotation, scaling, cropping, translation or Gaussian noise processing on the X-ray package image to obtain a deformed image sample;
[0090] The transformation subunit 122 is used to perform mosaic processing and / or shearing and fusion processing on the X-ray package image and the deformed picture sample to obtain an expanded picture sample.
[0091] In this embodiment, the classification unit 13 includes:
[0092] The labeling subunit 131 is used to perform feature labeling on the contraband area in the expanded image sample by using the Labelme tool to obtain an image sample labeled with feature information;
[0093] The classification subunit 132 is used to classify the image samples according to the feature information to obtain the image samples containing contraband and the image samples without contraband, wherein the image samples containing contraband and the image samples without contraband constitute the X-ray package image data set.
[0094] In this embodiment, the model building module 30 includes:
[0095] A building unit 31 is used to build an Efficientdet network framework, wherein the Efficientdet network framework includes an EfficientNet backbone network, a bidirectional feature pyramid network, a classification and bounding box regression network, and a loss function module, wherein the EfficientNet backbone network includes a Stem convolution layer for adjusting the number of channels and 16 stacked MBConvBlocks;
[0096] The introducing unit 32 is used to introduce the spatial pyramid pooling module at different levels of the bidirectional feature pyramid network, perform multi-scale pooling operations on feature maps from different scales, and splice or fuse the pooled feature maps to construct an initial recognition model.
[0097] In this embodiment, the training module 40 includes:
[0098] An initialization unit 41 is used to assign initial values to all parameters in the initial recognition model using a random initialization method;
[0099] A calculation unit 42 is used to randomly select image samples from the training set and input them into the initial recognition model for training, calculate the prediction results through forward propagation, and then calculate the loss value according to the Focal Loss function;
[0100] An updating unit 43 is used to update the parameters of the network using a back propagation algorithm so that the loss value gradually decreases;
[0101] A repeating unit 44 is used to repeat the above training steps until a predetermined training round is reached to obtain a trained initial recognition model;
[0102] The evaluation unit 45 is used to evaluate the trained initial recognition model using the test set, and adjust the hyperparameters according to the evaluation results to obtain an optimized contraband recognition model.
[0103] In this embodiment, the loss calculation unit 43 includes:
[0104] The classification loss calculation subunit 431 is used to use focal loss as a classification loss function, and the classification loss function is used to measure the difference between the category probability predicted by the initial recognition model and the actual category. The calculation formula of focal loss is as follows: L_cls = -α(1-p_t)^γlog(p_t), where p_t is the category probability predicted by the initial recognition model, α and γ are hyperparameters used to adjust the weights of samples of different difficulty levels. When p_t is close to 1, (1-p_t)^γ will become smaller, so that the loss value of the sample becomes smaller; conversely, when p_t is close to 0, (1-p_t)^γ will become larger, so that the loss value of the sample becomes larger;
[0105] The regression loss calculation subunit 432 is used to use smooth L1 loss as the regression loss function, and the difference between the bounding box position predicted by the initial recognition model and the real bounding box position is measured by the regression loss function. The calculation formula of SmoothL1 loss is as follows: L_reg=0.5*(IoU-1)^2*1if|IoU-1|<1,otherwise L_reg=|IoU-1|-0.5, wherein IoU represents the IOU value of the predicted bounding box and the real bounding box. When the IoU value is close to 1, it means that the predicted box is very close to the real box, and the loss value is small at this time; when the IoU value deviates from 1, the loss value will gradually increase.
[0106] above Figure 7 and Figure 8 The distribution center contraband identification device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The distribution center contraband identification device in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0107] Fig. 9 1 is a schematic diagram of the structure of a distribution center contraband identification device provided by an embodiment of the present invention. The distribution center contraband identification device 100 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 11 (for example, one or more processors) and a memory 12, and one or more storage media 13 (for example, one or more mass storage devices) storing application programs 133 or data 132. Among them, the memory 12 and the storage medium 13 can be short-term storage or permanent storage. The program stored in the storage medium 13 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the distribution center contraband identification device 100. Furthermore, the processor 11 can be configured to communicate with the storage medium 13 to execute a series of instruction operations in the storage medium 13 on the distribution center contraband identification device 100.
[0108] The distribution center contraband identification device 100 may also include one or more power supplies 14, one or more wired or wireless network interfaces 15, one or more input and output interfaces 16, and / or one or more operating systems 131, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that Figure 8 The device structure shown does not constitute a limitation on the distribution center contraband identification device 100, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0109] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the method for identifying contraband in a distribution center.
[0110] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device, or unit can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0111] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0112] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for identifying contraband in a distribution center, characterized in that: The distribution center contraband identification method comprises: Annotate and classify the collected X-ray package images to obtain an X-ray package image dataset; Dividing the X-ray package image into a training set and a test set according to a predetermined ratio, wherein the training set and the test set both include contraband image samples and non-contraband image samples; Build an initial recognition model based on the Efficientdet network; The initial recognition model is trained by the training set, the parameters of the initial recognition model are adjusted, and after being tested by the test set, a contraband recognition model is obtained; The X-ray package image to be identified acquired in real time is input into the contraband identification model, and the detection result is output, and it is determined whether to issue an alarm according to the detection result.
2. The method for identifying prohibited items in a distribution center according to claim 1, characterized in that: The collected X-ray package images are labeled and classified to obtain an X-ray package image dataset, including the following steps: Scan the parcels at outlets and distribution centers using X-ray imaging equipment to obtain X-ray parcel images; Performing data augmentation processing on the X-ray package image to obtain an augmented image sample; The expanded image samples are labeled and classified to obtain an X-ray package image dataset.
3. The method for identifying contraband in a distribution center according to claim 2, characterized in that: Performing data augmentation processing on the X-ray package image to obtain an augmented image sample includes the following steps: Mirroring, rotating, scaling, cropping, translating or Gaussian noise processing are performed on the X-ray package image to obtain a deformed image sample; Mosaic processing and / or shearing and fusion processing are performed on the X-ray package image and the deformed picture sample to obtain an expanded picture sample.
4. The method for identifying prohibited items in a distribution center according to claim 2, characterized in that: The expanded image samples are labeled and classified to obtain an X-ray package image dataset, including the following steps: Use the Labelme tool to perform feature labeling on the prohibited items area in the expanded image sample to obtain an image sample labeled with feature information; The image samples are classified according to the feature information to obtain the image samples containing contraband and the image samples not containing contraband, and the image samples containing contraband and the image samples not containing contraband constitute the X-ray package image data set.
5. The method for identifying prohibited items in a distribution center according to claim 1, characterized in that: Building an initial recognition model based on the Efficientdet network includes the following steps: Build an Efficientdet network framework, which includes an EfficientNet backbone network, a bidirectional feature pyramid network, a classification and bounding box regression network, and a loss function module, wherein the EfficientNet backbone network includes a Stem convolution layer for adjusting the number of channels and 16 stacked MBConvBlocks; A spatial pyramid pooling module is introduced at different levels of the bidirectional feature pyramid network to perform multi-scale pooling operations on feature maps from different scales, and the pooled feature maps are spliced or fused to construct an initial recognition model.
6. The method for identifying contraband in a distribution center according to claim 1, characterized in that: The initial recognition model is trained by the training set, the parameters of the initial recognition model are adjusted, and after being tested by the test set, a contraband recognition model is obtained, including the steps of: Using a random initialization method to assign initial values to all parameters in the initial identification model; Randomly select image samples from the training set and input them into the initial recognition model for training, calculate the prediction results through forward propagation, and then calculate the loss value according to the Focal Loss function; Use the back propagation algorithm to update the parameters of the network so that the loss value gradually decreases; Repeat the above training steps until the predetermined training rounds are reached to obtain a trained initial recognition model; The trained initial recognition model is evaluated using the test set, and the hyperparameters are adjusted according to the evaluation results to obtain an optimized contraband recognition model.
7. The method for identifying contraband in a distribution center according to claim 6, characterized in that: Calculate the loss value according to the Focal Loss function, including the following steps: Focal loss is used as the classification loss function, and the classification loss function is used to measure the difference between the category probability predicted by the initial recognition model and the actual category. The calculation formula of focal loss is as follows: L_cls = -α(1-p_t)^γlog(p_t), where p_t is the category probability predicted by the initial recognition model, α and γ are hyperparameters used to adjust the weights of samples of different difficulty levels. When p_t is close to 1, (1-p_t)^γ will become smaller, making the loss value of the sample smaller; conversely, when p_t is close to 0, (1-p_t)^γ will become larger, making the loss value of the sample larger; Smooth L1 loss is used as the regression loss function. The regression loss function is used to measure the difference between the bounding box position predicted by the initial recognition model and the true bounding box position. The calculation formula of Smooth L1 loss is as follows: L_reg=0.5*(IoU-1)^2*1if|IoU-1|<1,otherwise L_reg=|IoU-1|-0.5, where IoU represents the IOU value of the predicted bounding box and the true bounding box. When the IoU value is close to 1, it means that the predicted box is very close to the true box, and the loss value is small at this time; when the IoU value deviates from 1, the loss value will gradually increase.
8. A device for identifying prohibited items in a distribution center, characterized in that: include: The labeling and classification module is used to label and classify the collected X-ray package images to obtain an X-ray package image data set; A data division module, used for dividing the X-ray package image into a training set and a test set according to a predetermined ratio, wherein the training set and the test set both include contraband image samples and non-contraband image samples; Model building module, used to build the initial recognition model based on the Efficientdet network; A training module, used to train the initial recognition model through the training set, adjust the parameters of the initial recognition model, and obtain a contraband recognition model after testing with the test set; The identification module is used to input the real-time acquired X-ray package image to be identified into the contraband identification model, output the detection result, and determine whether to issue an alarm based on the detection result.
9. A distribution center contraband identification device, characterized in that: comprising a memory and at least one processor, wherein the memory has computer-readable instructions stored therein; The at least one processor calls the computer-readable instructions in the memory to execute the various steps of the method for identifying contraband in a distribution center as described in any one of claims 1-7.
10. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the various steps of the method for identifying contraband in a distribution center as described in any one of claims 1-7 are implemented.
