Contraband detection method and device, computer equipment and storage medium
Through multi-scale contour mapping and hybrid network extraction, combined with incremental learning mode, the problem of low performance of contraband detection technology in occlusion and overlapping item processing and susceptibility to feature learning is solved, and the accuracy of detection is improved and the accuracy of detection is It is awesome and enhances the generalization ability of the model.
Patent Information
- Application Number
- CN202411134846.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-06
AI Technical Summary
Existing contraband detection technology has low performance when dealing with occluded and overlapping items, feature learning is susceptible to contraband thickness and density, and batch learning-based models have low generalization ability and poor robustness when facing unseen categories.
Multi-scale contour mapping and hybrid network extract features, build and incremental training detection models by acquiring and preprocessing X-ray images, using convolutional encoder and attention mechanism modules to extract features, and improve the model through incremental task FC nodes. generalization ability.
It improves the accuracy and robustness of contraband detection, can accurately identify threatening items in complex scenarios, reduces the cost of repeated training, and enhances the generalization ability of the model.
Smart Images

Figure CN119091160A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image detection technology, and in particular to a method, device, computer equipment and storage medium for detecting contraband. Background Art
[0002] Nowadays, baggage inspection based on X-ray imaging has become the standard for ensuring the safety of transportation and other public places. X-ray imaging systems enable security personnel to identify contraband in luggage. Current security inspections mostly rely on manual operations, in which the interpretation of X-ray images depends on the operator's experience and judgment. Since operators may be affected by factors such as time pressure or fatigue, they may misjudge or omit potential threatening items, which poses a risk of misjudgment. Therefore, automated contraband detection technology urgently needs to be studied.
[0003] With the rapid development of computer vision technology, many supervised and unsupervised intelligent detection methods have been proposed to deal with the above problems. Although these methods have reduced misjudgment to a certain extent, they still have some shortcomings:
[0004] 1. The models show remarkable ability in detecting isolated objects, but their performance degrades when recognizing extremely cluttered, occluded, and overlapping items;
[0005] 2. Since the color of X-ray imaging is related to the material, when the thickness and density of the background and the contraband are similar, it will interfere with the feature learning of the model, thereby reducing the detection performance;
[0006] 3. Currently, most of these methods are based on the batch learning mode. Most models are put into use after a one-time batch training. They are powerless when faced with categories that have never appeared before, which greatly reduces the credibility of the prediction and shows problems such as low generalization ability and poor robustness. If more samples are added for retraining, the training cost and labor cost will be greatly increased.
[0007] Therefore, there is an urgent need to propose a contraband detection method, apparatus, computer equipment and storage medium that can solve the problems of low performance when dealing with occluded and overlapping objects, and feature learning being easily affected by the thickness and density of contraband. Summary of the invention
[0008] Based on this, it is necessary to provide a contraband detection method, device, computer equipment and storage medium that can solve the problems of low performance when processing occluded and overlapping objects, and feature learning being easily affected by the thickness and density of contraband, in response to the above-mentioned technical problems.
[0009] In a first aspect, a method for detecting contraband is provided, the method comprising:
[0010] Acquire a first image set and a second image set;
[0011] Preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0012] Constructing a first contraband detection model, and training the first contraband detection model using the first target image set to obtain a second contraband detection model;
[0013] Based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model;
[0014] The collected real-time image is input into the fourth contraband detection model to obtain an instance segmentation map, and the location information of the contraband is determined according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0015] Optionally, the image preprocessing method includes:
[0016] Acquire an initial image, and scale the initial image to obtain multiple target images of different scales;
[0017] Selecting a first target image from a plurality of target images of different scales, converting the first target image into a grayscale image, and performing binarization processing on the grayscale image to obtain a binary image;
[0018] Performing an erosion operation on the binary image to obtain an eroded image, and performing an expansion operation on the eroded image to obtain an expanded image;
[0019] A subtraction operation is performed on the eroded image and the dilated image to obtain a first edge image B1.
[0020] Optionally, the image preprocessing method also includes:
[0021] Selecting a second target image from a plurality of target images of different scales, performing a downsampling operation on the first edge image B1 based on a size value of the second target image, and fusing the first edge image B1 after the downsampling operation with the second target image to obtain a fused image;
[0022] The fused image is subjected to binarization, corrosion and dilation operations in sequence, and a second edge image B2 is obtained based on the fused image subjected to the binarization, corrosion and dilation operations;
[0023] And so on, until edge images corresponding to multiple target images of different scales are obtained;
[0024] Based on the image fusion function, multiple edge images are fused to obtain the target edge image, and the image fusion function includes:
[0025] X E =Upsample(B n )+…+Upsample(B3)+Upsample(B2)+B1
[0026] Among them, X E represents the target edge image, Upsample represents upsampling, B m =B1, B2, B3, ..., B n represents an edge image;
[0027] The target edge image is mapped onto the initial image to obtain a preprocessed image, and the calculation formula is:
[0028] I E (x, y) = (1 - C (x, y)) · X b (x, y) + C (x, y) · X E (x, y)
[0029] Among them, I E (x, y) represents the preprocessed image I E The pixel value at pixel (x, y), C(x, y)∈[0, 1], C(x, y) represents the pixel weight, X b (x, y) represents the initial image X b The pixel value at pixel (x, y).
[0030] Optionally, the first contraband detection model includes at least a backbone network and a basic task FC node, the backbone network includes a convolution encoder, an attention mechanism module and a decoder, and the first contraband detection model is trained based on the first target image set to obtain the second contraband detection model including:
[0031] Performing feature extraction on the images in the first target image set based on a convolutional encoder to obtain a first feature map;
[0032] Extract features from images in the first target image set based on a block attention mechanism to obtain a second feature map;
[0033] Perform a learnable convolution fusion on the first feature map and the second feature map, and input the fusion into a decoder to obtain a pixel-level full-scale feature map;
[0034] Input the pixel-level full-scale feature map into the basic task FC node and perform learnable convolution fusion to obtain a basic category mapping feature map;
[0035] Performing pixel-level classification score judgment on the basic category mapping feature map, and calculating the loss value of the first contraband detection model;
[0036] In response to detecting that the loss value of the first contraband detection model meets a preset standard, a second contraband detection model is obtained.
[0037] Optionally, the method for calculating the loss value of the first contraband detection model includes:
[0038]
[0039] in, Indicates the true probability distribution of the target sample pixels. Indicates the pixel-level probability distribution of the target sample predicted by the first contraband detection model, Loss b Represents the loss value of the first contraband detection model.
[0040] Optionally, based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model, including:
[0041] Adding at least one incremental task FC node on the basis of the second contraband detection model to generate the third contraband detection model;
[0042] performing incremental training on the third contraband detection model using images in the second target image set, and calculating a loss value of the third contraband detection model;
[0043] In response to detecting that the loss value of the third contraband detection model meets a preset standard, a fourth contraband detection model is obtained.
[0044] Optionally, the method for calculating the loss value of the third contraband detection model includes:
[0045] L total =βL kd +L ce
[0046]
[0047] Among them, L total represents the loss value of the third contraband detection model, β represents the hyperparameter, and L kd Represents the distillation loss value, L ce represents the cross entropy loss value, Indicates the true probability distribution of the target sample pixels. Indicates the incremental task output value, represents the pixel-level probability of the images in the second target image set obtained based on the second contraband detection model, Indicates the output value of the basic task output.
[0048] In a second aspect, a contraband detection device is provided, the device comprising:
[0049] An image set acquisition module, used to acquire a first image set and a second image set;
[0050] A preprocessing module, used to preprocess the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0051] A model building and training module, used to build a first contraband detection model, and train the first contraband detection model using the first target image set to obtain a second contraband detection model;
[0052] an incremental training module, configured to construct a third contraband detection model based on the second contraband detection model, and perform incremental training on the third contraband detection model using the second target image set to obtain a fourth contraband detection model;
[0053] The detection module is used to input the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determine the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0054] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:
[0055] Acquire a first image set and a second image set;
[0056] Preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0057] Constructing a first contraband detection model, and training the first contraband detection model using the first target image set to obtain a second contraband detection model;
[0058] Based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model;
[0059] The collected real-time image is input into the fourth contraband detection model to obtain an instance segmentation map, and the location information of the contraband is determined according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0060] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0061] Acquire a first image set and a second image set;
[0062] Preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0063] Constructing a first contraband detection model, and training the first contraband detection model using the first target image set to obtain a second contraband detection model;
[0064] Based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model;
[0065] The collected real-time image is input into the fourth contraband detection model to obtain an instance segmentation map, and the location information of the contraband is determined according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0066] The above-mentioned contraband detection method, device, computer equipment and storage medium, the method includes: acquiring a first image set and a second image set; preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set; constructing a first contraband detection model, and using the first target image set to train the first contraband detection model to obtain a second contraband detection model; based on the second contraband detection model, constructing a third contraband detection model, and using the second target image set to incrementally train the third contraband detection model to obtain a fourth contraband detection model; inputting the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determining the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map. The present application detects contraband in an image based on the constructed contraband detection model, which can solve the problems of low detection accuracy and insensitive recognition of contraband in the image, thereby realizing accurate detection of contraband in complex scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 is an application environment diagram of a contraband detection method in one embodiment;
[0068] Figure 2 A schematic diagram of a process of detecting contraband in one embodiment;
[0069] Figure 3 It is a schematic diagram of the fusion process of feature images of different scales in a method for detecting contraband in one embodiment;
[0070] Figure 4 A schematic diagram of a basic sample training process of a contraband detection method in one embodiment;
[0071] Figure 5 A schematic diagram of a backbone network structure of a contraband detection method in one embodiment;
[0072] Figure 6 A schematic diagram of an incremental sample training process of a contraband detection method in one embodiment;
[0073] Figure 7 A schematic diagram of an algorithm testing process of a contraband detection method in one embodiment;
[0074] Figure 8 is a structural block diagram of a contraband detection device in one embodiment;
[0075] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0077] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like throughout the specification should be interpreted as inclusive rather than exclusive or exhaustive; that is, the meaning of "including but not limited to".
[0078] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.
[0079] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.
[0080] According to the background technology, with the rapid development of computer vision technology, many supervised and unsupervised intelligent detection methods have been proposed to deal with the problems caused by manual operation, that is, using models based on deep learning, such as RetinaNet, YOLO and Faster R-CNN. These intelligent detection methods use a large amount of training data and complex neural network structures to automatically learn and identify the characteristics of dangerous goods. They can quickly analyze X-ray images and provide prediction results of possible dangerous goods. This automated detection method can reduce the burden on operators and reduce the possibility of human misjudgment and omissions to a certain extent, but there are still some shortcomings.
[0081] In order to solve the above technical problems, the present application provides a contraband detection method, apparatus, computer equipment and storage medium, which combine multi-scale contour mapping and hybrid network feature extraction to detect contraband in X-ray images, so as to solve the problems of low performance when processing occluded and overlapping objects, and feature learning being easily affected by the thickness and density of contraband, so as to improve the accuracy of contraband detection.
[0082] like Figure 1 FIG. 1 is a schematic diagram of a contraband detection system provided in an embodiment of the present application. The contraband detection system may include a computer device 100, in which a contraband detection device is integrated. Figure 1 Computer equipment in.
[0083] In the embodiment of the present application, the computer device 100 is mainly used to: construct and acquire a first image set and a second image set; preprocess the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set; construct a first contraband detection model, and train the first contraband detection model using the first target image set to obtain a second contraband detection model; construct a third contraband detection model based on the second contraband detection model, and perform incremental training on the third contraband detection model using the second target image set to obtain a fourth contraband detection model; input the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determine the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0084] In the embodiment of the present application, the computer device 100 may be an independent server, or a server network or server cluster composed of servers. For example, the computer device 100 described in the embodiment of the present application includes but is not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of a plurality of servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.
[0085] It is understandable that the computer device 100 in the embodiment of the present application may also be a terminal, and the terminal may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link, and such a device may include: a cellular or other communication device having a single-line display or a multi-line display or a cellular or other communication device without a multi-line display. The specific terminal may be a desktop terminal or a mobile terminal, and the terminal may also be one of a tablet computer, a laptop computer, etc.
[0086] In an embodiment of the present application, the computer device 100 may be a computer device that is communicatively connected to one or more X-ray machines (also known as security inspection machines), and images scanned by one or more X-ray machines may be input into the computer device 100 as images to be detected for contraband image detection.
[0087] Those skilled in the art will understand that Figure 1 The application environment shown in the figure is only one application scenario of the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or less computer equipment as shown in Figure 1 Only one computer device is shown in the figure. It can be understood that the contraband detection system can also include one or more other services, which are not specifically limited here.
[0088] In addition, if Figure 1 As shown, the contraband detection system may further include a memory 200 for storing the first image set and the second image set, such as contraband-related image information scanned by an X-ray machine.
[0089] It should be noted that Figure 1 The scenario diagram of the contraband detection system shown is merely an example. The contraband detection system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the contraband detection system and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is equally applicable to similar technical problems.
[0090] In one embodiment, Figure 2 As shown, it is a schematic diagram of an embodiment of the method for detecting an article component in the embodiment of the present application. The method for detecting an article component includes steps S1 to S5, which are specifically as follows:
[0091] S1: Acquire a first image set and a second image set.
[0092] It should be noted that the images in the first image set are historical sample images of prohibited items, which can be used as basic samples for basic training of the constructed contraband detection model; the images in the second image set are newly added sample images of prohibited items, which are used for incremental learning of the contraband detection model; the images in the image set can be X-ray images obtained by scanning with an X-ray machine, or they can be images obtained from other channels, such as databases on the Internet.
[0093] S2: Preprocess the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set.
[0094] In some specific embodiments, the image preprocessing method includes:
[0095] The initial image is obtained, and the initial image is scaled to obtain multiple target images of different scales. Image scaling refers to adjusting the size of a digital image, and the number of scaling times can be set according to actual needs. For example, the original X-ray image is read and recorded as X b , perform a scaling operation on it to obtain three X-ray images of different scales
[0096] A first target image is selected from a plurality of target images of different scales, the first target image is converted into a grayscale image, and the grayscale image is binarized to obtain a binary image. Exemplarily, the selected first target image is defined as Will Convert it into the corresponding grayscale image, perform binarization on the grayscale image to get X'1, divide the image into two parts: foreground edge and background. After getting the binary image, set the foreground pixels to 1 and the background pixels to 0;
[0097] Performing an erosion operation on the binary image to obtain an eroded image, and performing an expansion operation on the eroded image after the erosion operation to obtain an expanded image. Specifically, performing an erosion operation on the binary image X'1, the erosion operation is to erode the background pixels around the foreground pixels to reduce the foreground area. The erosion operation can be achieved by performing a logical AND operation on each pixel and the pixels around it. This is a common method and will not be described in detail here. Performing an expansion operation on the eroded image, the expansion operation is to expand the background pixels around the foreground pixels to increase the foreground area.
[0098] Performing a subtraction operation on the eroded image and the dilated image, that is, performing a subtraction operation on the eroded image and the dilated image, to obtain an extracted first edge image B1;
[0099] Next, a second target image is selected from a plurality of target images of different scales, and based on the size value of the second target image, a downsampling operation is performed on the first edge image B1, and the first edge image B1 after the downsampling operation is fused with the second target image to obtain a fused image. For example, B1 is downsampled to size, and with Fusion, to obtain a fused image;
[0100] The fused image is subjected to binarization, corrosion and dilation operations in sequence, and a second edge image B2 is obtained based on the fused image subjected to the binarization, corrosion and dilation operations;
[0101] Again, downsample B2 to size, and with After fusion, the above operation is performed again to obtain a third edge image B3, and so on, until edge images corresponding to multiple target images of different scales are obtained;
[0102] Based on the image fusion function, multiple edge images are fused to obtain the target edge image, and the image fusion function includes:
[0103] X E =Upsample(B n )+…+Upsample(B3)+Upsample(B2)+B1
[0104] Among them, X E represents the target edge image, Upsample represents upsampling, B m=B1, B2, B3, ..., B n represents an edge image;
[0105] For example, Figure 3 As shown in That is, scale 1, scale 2 and scale 3, extract the contour, and get the corresponding contour map, that is, the corresponding edge image is B1, B2, B3, and B1, B2, B3 are fused to get the fused contour map, that is, the final edge image X E , the fusion formula is as follows:
[0106] X E =Upsample(B3)+Upsample(B2)+B1
[0107] The target edge image is mapped onto the initial image to obtain a preprocessed image, that is, the X E Mapped on the X-ray image X b The calculation formula is:
[0108] I E (x, y) = (1 - C (x, y)) · X b (x, y) + C (x, y) · X E (x, y)
[0109] Among them, I E (x, y) represents the preprocessed image I E The pixel value at pixel (x, y), C(x, y)∈[0, 1], C(x, y) represents the pixel weight, X b (x, y) represents the initial image X b The pixel value at pixel (x, y);
[0110] Based on the above steps, we can get the image I after contour enhancement. E .
[0111] S3: construct a first contraband detection model, and use the first target image set to train the first contraband detection model to obtain a second contraband detection model.
[0112] It should be noted that if Figure 4 As shown, the first contraband detection model includes at least a backbone network and a basic task FC node, wherein the backbone network includes a convolutional encoder, an attention mechanism module (Swin Transformer module) and a decoder.
[0113] In some specific implementations, the first contraband detection model is trained based on the first target image set, that is, the contour-enhanced image IE Input into the first contraband detection model for basic sample training, and obtain the second contraband detection model including:
[0114] Based on the convolution encoder, features are extracted from the images in the first target image set to obtain a first feature map, specifically, Figure 5 As shown, the contour enhanced image I E Input convolutional encoder, which consists of five hybrid blocks (E1, E2, E3, E4, E5), responsible for extracting features of different scales of the image, and learning the feature distribution of deep semantics layer by layer from shallow to deep, and finally obtain 5 semantic feature maps of different scales and depths. Each hybrid module consists of a convolutional block and a residual block, where the convolutional block consists of a convolutional layer, a batch normalization layer, and an activation layer; the residual block consists of a convolutional layer, a batch normalization layer, an activation layer, and a residual structure; the first feature map obtained by the encoder after E5 convolution is called f e ,Right now Represents the final result of deep semantic learning of features by the overall encoder, where the main function of the encoding in this step is to use convolution operations to learn the relationship between local features of the input image at different scales and semantic information at different depths;
[0115] Based on the block attention mechanism, feature extraction is performed on the image in the first target image set to obtain a second feature map. Specifically, while the convolution encoder is used to extract features, the contour-enhanced image I E Input into SwinTransformer module, such as Figure 5 As shown in Figure 1, the module consists of three Swin Transformer blocks, denoted as T1, T2, and T3. Each Swin Transformer block consists of a Patch partition module, a Swin TransformerBlock module, and a Patch Merging module. The function of the Patch partition module is to transform the input image I E(H×W×3) blocks are used to divide the image into 4×4 blocks to obtain W / 4×H / 4 image blocks. The purpose of this process is to convert the spatial information of the input image into channel information and input it into the subsequent SwinTransformer Block module in a serialized form. The Swin Transformer Block module uses a moving window multi-head self-attention to learn the global context spatial feature information and channel information; before all feature learning, the layer normalization operation is used to prevent the gradient from disappearing during the feature learning process. After all learning, the LN operation (normalization operation) is also performed, and then the multi-layer perceptron operation is performed to further fit the learned global spatial features and channel features; Patch Merging is mainly for Swin Transformer The global contextual spatial information and channel information obtained by the Block module are downsampled by 2 times, so as to learn the deep global spatial and channel semantic information of different scales and depths. Based on this, the input image is processed by T1 to obtain the feature map S1, and the feature map S1 is sent to T2 to obtain the feature map S2, and then the feature map S2 is sent to T3 to obtain the feature map S3. The feature map S3 containing the deepest global spatial and channel semantic information is used as the output of the Swin Transformer module, that is, the second feature map, and is named S t ;
[0116] The first feature map and the second feature map are subjected to a learnable convolution fusion and input into the decoder to obtain a pixel-level full-scale feature map. Specifically, f e and S t Perform learnable convolution fusion and input it into the decoder. The decoder consists of five decoding blocks (D1, D2, D3, D4, D5), each of which contains an upsampling layer and a convolution layer. In addition, a jump connection is established between the convolution encoder and the decoder to overcome the degradation problem of the model in the process of contraband object segmentation. Through 5 consecutive decoding operations, the distribution of all spatial and channel features of the pixel level of the input image can be obtained, thereby improving the pixel-level learning ability and modeling the feature distribution of the input image, which is conducive to the final judgment and positioning of the contraband pixels.
[0117] The pixel-level full-scale feature map is input into the basic task FC node, and a learnable convolution fusion is performed to obtain a basic category mapping feature map, that is, the pixel-level full-scale feature map output by the backbone network is used as the input of the basic task FC node, and a learnable convolution operation is performed to obtain a basic category mapping feature map;
[0118] The basic category mapping feature map is subjected to pixel-level classification score judgment, and the loss value of the first contraband detection model is calculated. Specifically, the basic category mapping feature map obtained above is subjected to pixel-level softmax score judgment to obtain This variable contains the probability that each pixel in the image belongs to each category. At this time, the first contraband detection model trained based on the basic sample is recorded as W b , which is composed of the backbone network weight and basic task FC node weight It consists of two parts, and its loss value is calculated by the cross entropy loss function. The formula is as follows:
[0119]
[0120] in, Indicates the true probability distribution of the target sample pixels, Indicates the pixel-level probability distribution of the target sample predicted by the first contraband detection model, Loss b represents the loss value of the first contraband detection model;
[0121] In response to detecting that the loss value of the first contraband detection model meets a preset standard, a second contraband detection model is obtained, wherein the preset standard may be that when the model training reaches a preset number of iterations, the model weight with the smallest loss value is selected as the optimal solution of the first contraband detection model to generate the second contraband detection model.
[0122] S4: Based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model.
[0123] It should be noted that the third contraband detection model is composed of the second contraband detection model and incremental task FC nodes. The number of incremental task FC nodes is equal to the number of new incremental sample categories. The second contraband detection model is composed of a backbone network and basic task FC nodes. Both the incremental task FC nodes and the basic task FC nodes are parameter networks. The second target image set includes multiple new sample images of prohibited items categories.
[0124] In some specific implementations, based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model, including:
[0125] Adding at least one incremental task FC node on the basis of the second contraband detection model to generate the third contraband detection model;
[0126] Using the images in the second target image set, incrementally training the third contraband detection model, and calculating the loss value of the third contraband detection model, wherein the calculation method of the loss value of the third contraband detection model includes:
[0127] L total =βL kd +L ce
[0128]
[0129] Among them, l total represents the loss value of the third contraband detection model, β represents the hyperparameter, and L kd Represents the distillation loss value, L ce represents the cross entropy loss value, Indicates the true probability distribution of the target sample pixels, Indicates the incremental task output value, represents the pixel-level probability of the images in the second target image set obtained based on the second contraband detection model, Indicates the output value of the basic task output;
[0130] Specifically, Figure 6 As shown, the new prohibited items category sample image X n Input to the trained second contraband detection model W b In the above example, we get the pixel-level probability output At the same time, the new prohibited items category sample image X n Input into the third contraband detection model for training. At this time, the weight parameter of the backbone network is Use the weights obtained from basic sample training Network weight of basic task FC nodes The weights obtained from basic sample training are used At the same time, a new incremental task FC node parameter network is randomly initialized Based on this, the output of the third contraband detection model is divided into two parts: incremental prediction output Basic task output At this time, the third contraband detection model is recorded as W n , which is caused by and composition.
[0131] Furthermore, the loss during incremental training is calculated by the loss value calculation method of the third contraband detection model, where L ce The loss can ensure that the third contraband detection model W n New contraband category samples can be learned, Lkd The loss can ensure that the third contraband detection model W n Remember its existing knowledge, β is used as a hyperparameter to control the memory capacity of the network during incremental training;
[0132] In response to detecting that the loss value of the third contraband detection model meets the preset standard, a fourth contraband detection model is obtained, and Figure 7 As shown, by testing sample X test Test the fourth contraband detection model and output the contraband detection results To evaluate the test accuracy, wherein the preset standard in this step is the same as the preset standard definition in step S3, and will not be repeated here;
[0133] Furthermore, if there are new incremental sample categories that need to be learned, the above incremental training process will be executed in a loop. At this time, the previously trained contraband detection model will be used as the basic training model, and the incremental task FC node parameter network will be added to perform overall network training to obtain the incremental training model.
[0134] S5: Inputting the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determining the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0135] It should be noted that this step specifically includes:
[0136] Use the fourth contraband detection model to detect the real-time image and generate an instance segmentation map
[0137] The minimum circumscribed rectangle of each area is calculated based on the segmented pixel-level features to obtain the location information of the contraband, and the coordinate information corresponding to the location information is drawn in the input image to form a contraband detection effect diagram.
[0138] In the above contraband detection method, since the object contour in the X-ray image contains too much noise, it will cause certain obstacles to the detection. Therefore, the multi-scale contour mapping proposed in this application can extract accurate edge features by analyzing the structure and gradient of the image, and map the extracted contour to the X-ray image, thereby highlighting the edge and shape of the target object, which is helpful for subsequent feature extraction and analysis. Furthermore, the mapped image is sent to the convolution and Transformer hybrid network to extract local, full-channel and global accurate features, and then combined with the classifier to judge the category information of the contraband pixels, the semantic segmentation of the contraband is realized, thereby achieving Contraband target detection is now carried out. Further, in response to the problems of low robustness, poor generalization ability, and high training cost of the current batch learning method, a contraband detection method for X-ray images based on an incremental learning model is proposed. The contraband detection model is constructed using the idea of batch learning, so that the model has the ability to continuously update and learn new samples, which helps to improve the generalization ability of the model and reduce the overhead caused by repeated training. Based on this, the present application can not only improve the model's ability to accurately identify threats in complex spaces, but also be applicable to various scenarios. While improving the accuracy of contraband detection, it also improves the generalization ability of the algorithm to a certain extent.
[0139] It should be understood that although Figure 2-Figure 7 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 7 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0140] In one embodiment, Figure 8 As shown, a contraband detection device is provided, including: an image set acquisition module, a preprocessing module, a model building and training module, an incremental training module and a detection module, wherein:
[0141] An image set acquisition module, used to acquire a first image set and a second image set;
[0142] A preprocessing module, used to preprocess the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0143] A model building and training module, used to build a first contraband detection model, and train the first contraband detection model using the first target image set to obtain a second contraband detection model;
[0144] an incremental training module, configured to construct a third contraband detection model based on the second contraband detection model, and perform incremental training on the third contraband detection model using the second target image set to obtain a fourth contraband detection model;
[0145] The detection module is used to input the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determine the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0146] As a preferred implementation, in the embodiment of the present invention, the preprocessing module is specifically used for:
[0147] Acquire an initial image, and scale the initial image to obtain multiple target images of different scales;
[0148] Selecting a first target image from a plurality of target images of different scales, converting the first target image into a grayscale image, and performing binarization processing on the grayscale image to obtain a binary image;
[0149] Performing an erosion operation on the binary image to obtain an eroded image, and performing an expansion operation on the eroded image to obtain an expanded image;
[0150] A subtraction operation is performed on the eroded image and the dilated image to obtain a first edge image B1.
[0151] As a preferred implementation, in the embodiment of the present invention, the preprocessing module is further used for:
[0152] Selecting a second target image from a plurality of target images of different scales, performing a downsampling operation on the first edge image B1 based on a size value of the second target image, and fusing the first edge image B1 after the downsampling operation with the second target image to obtain a fused image;
[0153] The fused image is subjected to binarization, corrosion and dilation operations in sequence, and a second edge image B2 is obtained based on the fused image subjected to the binarization, corrosion and dilation operations;
[0154] And so on, until edge images corresponding to multiple target images of different scales are obtained;
[0155] Based on the image fusion function, multiple edge images are fused to obtain the target edge image, and the image fusion function includes:
[0156] X E =Upsample(B n )+…+Upsample(B3)+Upsample(B2)+B1
[0157] Among them, X E represents the target edge image, Upsample represents upsampling, B m =B1, B2, B3, ..., B n represents an edge image;
[0158] The target edge image is mapped onto the initial image to obtain a preprocessed image, and the calculation formula is:
[0159] I E (x, y) = (1vC(x, y))·X b (x, y) + C (x, y) · X E (x, y)
[0160] Among them, I E (x, y) represents the preprocessed image I E The pixel value at pixel (x, y), C(x, y)∈[0, 1], C(x, y) represents the pixel weight, X b (x, y) represents the initial image X b The pixel value at pixel (x, y).
[0161] As a preferred implementation, in the embodiment of the present invention, the model building and training module is specifically used for:
[0162] Performing feature extraction on the images in the first target image set based on a convolutional encoder to obtain a first feature map;
[0163] Extract features from images in the first target image set based on a block attention mechanism to obtain a second feature map;
[0164] Perform a learnable convolution fusion on the first feature map and the second feature map, and input the fusion into a decoder to obtain a pixel-level full-scale feature map;
[0165] Input the pixel-level full-scale feature map into the basic task FC node and perform learnable convolution fusion to obtain a basic category mapping feature map;
[0166] Performing pixel-level classification score judgment on the basic category mapping feature map and calculating the loss value of the first contraband detection model;
[0167] In response to detecting that the loss value of the first contraband detection model meets a preset standard, a second contraband detection model is obtained.
[0168] As a preferred implementation, in the embodiment of the present invention, the model building and training module is also specifically used for:
[0169] The calculation method of the loss value of the first contraband detection model includes:
[0170]
[0171] in, Indicates the true probability distribution of the target sample pixels. Indicates the pixel-level probability distribution of the target sample predicted by the first contraband detection model, Loss b Represents the loss value of the first contraband detection model.
[0172] As a preferred implementation, in the embodiment of the present invention, the incremental training module is specifically used for:
[0173] Adding at least one incremental task FC node on the basis of the second contraband detection model to generate the third contraband detection model;
[0174] performing incremental training on the third contraband detection model using images in the second target image set, and calculating a loss value of the third contraband detection model;
[0175] In response to detecting that the loss value of the third contraband detection model meets a preset standard, a fourth contraband detection model is obtained.
[0176] As a preferred implementation, in the embodiment of the present invention, the incremental training module is further used for:
[0177] L total =βL kd +L ce
[0178]
[0179] Among them, L total represents the loss value of the third contraband detection model, β represents the hyperparameter, and L kd Represents the distillation loss value, L ce represents the cross entropy loss value, Indicates the true probability distribution of the target sample pixels. Indicates the incremental task output value, represents the pixel-level probability of the images in the second target image set obtained based on the second contraband detection model, Indicates the output value of the basic task output.
[0180] For the specific definition of the prohibited items detection device, please refer to the definition of the prohibited items detection method above, which will not be repeated here. Each module in the above-mentioned prohibited items detection device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0181] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a contraband detection method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0182] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0183] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0184] S1: Acquire a first image set and a second image set;
[0185] S2: preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0186] S3: constructing a first contraband detection model, and using the first target image set to train the first contraband detection model to obtain a second contraband detection model;
[0187] S4: constructing a third contraband detection model based on the second contraband detection model, and performing incremental training on the third contraband detection model using the second target image set to obtain a fourth contraband detection model;
[0188] S5: Inputting the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determining the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0189] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0190] Acquire an initial image, and scale the initial image to obtain multiple target images of different scales;
[0191] Selecting a first target image from a plurality of target images of different scales, converting the first target image into a grayscale image, and performing binarization processing on the grayscale image to obtain a binary image;
[0192] Performing an erosion operation on the binary image to obtain an eroded image, and performing an expansion operation on the eroded image to obtain an expanded image;
[0193] A subtraction operation is performed on the eroded image and the dilated image to obtain a first edge image B1.
[0194] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0195] Selecting a second target image from a plurality of target images of different scales, performing a downsampling operation on the first edge image B1 based on a size value of the second target image, and fusing the first edge image B1 after the downsampling operation with the second target image to obtain a fused image;
[0196] The fused image is subjected to binarization, corrosion and dilation operations in sequence, and a second edge image B2 is obtained based on the fused image subjected to the binarization, corrosion and dilation operations;
[0197] And so on, until edge images corresponding to multiple target images of different scales are obtained;
[0198] Based on the image fusion function, multiple edge images are fused to obtain the target edge image, and the image fusion function includes:
[0199] X E =Upsample(B n )+…+Upsample(B3)+Upsample(B2)+B1
[0200] Among them, X E represents the target edge image, Upsample represents upsampling, B m =B1, B2, B3, ..., B n represents an edge image;
[0201] The target edge image is mapped onto the initial image to obtain a preprocessed image, and the calculation formula is:
[0202] I E (x, y) = (1 - C (x, y)) · X b (x, y) + C (x, y) · X E (x, y)
[0203] Among them, I E (x, y) represents the preprocessed image I E The pixel value at pixel (x, y), C(x, y)∈[0, 1], C(x, y) represents the pixel weight, X b (x, y) represents the initial image X b The pixel value at pixel (x, y).
[0204] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0205] Performing feature extraction on the images in the first target image set based on a convolutional encoder to obtain a first feature map;
[0206] Extract features from images in the first target image set based on a block attention mechanism to obtain a second feature map;
[0207] Perform a learnable convolution fusion on the first feature map and the second feature map, and input the fusion into a decoder to obtain a pixel-level full-scale feature map;
[0208] Input the pixel-level full-scale feature map into the basic task FC node and perform learnable convolution fusion to obtain a basic category mapping feature map;
[0209] Performing pixel-level classification score judgment on the basic category mapping feature map and calculating the loss value of the first contraband detection model;
[0210] In response to detecting that the loss value of the first contraband detection model meets a preset standard, a second contraband detection model is obtained.
[0211] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0212] The calculation method for defining the loss value of the first contraband detection model includes:
[0213]
[0214] in, Indicates the true probability distribution of the target sample pixels, Indicates the pixel-level probability distribution of the target sample predicted by the first contraband detection model, Loss b Represents the loss value of the first contraband detection model.
[0215] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0216] Adding at least one incremental task FC node on the basis of the second contraband detection model to generate the third contraband detection model;
[0217] performing incremental training on the third contraband detection model using images in the second target image set, and calculating a loss value of the third contraband detection model;
[0218] In response to detecting that the loss value of the third contraband detection model meets a preset standard, a fourth contraband detection model is obtained.
[0219] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0220] The calculation method for defining the loss value of the third contraband detection model includes:
[0221] L total =βL kd +L ce
[0222]
[0223] Among them, L total represents the loss value of the third contraband detection model, β represents the hyperparameter, and L kd Represents the distillation loss value, L ce represents the cross entropy loss value, Indicates the true probability distribution of the target sample pixels, Indicates the incremental task output value, represents the pixel-level probability of the images in the second target image set obtained based on the second contraband detection model, Indicates the output value of the basic task output.
[0224] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0225] S1: Acquire a first image set and a second image set;
[0226] S2: preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set;
[0227] S3: constructing a first contraband detection model, and using the first target image set to train the first contraband detection model to obtain a second contraband detection model;
[0228] S4: constructing a third contraband detection model based on the second contraband detection model, and performing incremental training on the third contraband detection model using the second target image set to obtain a fourth contraband detection model;
[0229] S5: Inputting the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determining the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
[0230] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0231] Acquire an initial image, and scale the initial image to obtain multiple target images of different scales;
[0232] Selecting a first target image from a plurality of target images of different scales, converting the first target image into a grayscale image, and performing binarization processing on the grayscale image to obtain a binary image;
[0233] Performing an erosion operation on the binary image to obtain an eroded image, and performing an expansion operation on the eroded image to obtain an expanded image;
[0234] A subtraction operation is performed on the eroded image and the dilated image to obtain a first edge image B1.
[0235] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0236] Selecting a second target image from a plurality of target images of different scales, performing a downsampling operation on the first edge image B1 based on a size value of the second target image, and fusing the first edge image B1 after the downsampling operation with the second target image to obtain a fused image;
[0237] The fused image is subjected to binarization, corrosion and dilation operations in sequence, and a second edge image B2 is obtained based on the fused image subjected to the binarization, corrosion and dilation operations;
[0238] And so on, until edge images corresponding to multiple target images of different scales are obtained;
[0239] Based on the image fusion function, multiple edge images are fused to obtain the target edge image, and the image fusion function includes:
[0240] X E =Upsample(B n )+…+Upsample(B3)+Upsample(B2)+B1
[0241] Among them, X E represents the target edge image, Upsample represents upsampling, B m =B1, B2, B3, ..., B n represents an edge image;
[0242] The target edge image is mapped onto the initial image to obtain a preprocessed image, and the calculation formula is:
[0243] I E (x, y) = (1 - C (x, y)) · X b (x, y) + C (x, y) · X E (x, y)
[0244] Among them, I E (x, y) represents the preprocessed image I E The pixel value at pixel (x, y), C(x, y)∈[0, 1], C(x, y) represents the pixel weight, X b (x, y) represents the initial image X b The pixel value at pixel (x, y).
[0245] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0246] Performing feature extraction on the images in the first target image set based on a convolutional encoder to obtain a first feature map;
[0247] Extract features from images in the first target image set based on a block attention mechanism to obtain a second feature map;
[0248] Perform a learnable convolution fusion on the first feature map and the second feature map, and input the fusion into a decoder to obtain a pixel-level full-scale feature map;
[0249] Input the pixel-level full-scale feature map into the basic task FC node and perform learnable convolution fusion to obtain a basic category mapping feature map;
[0250] Performing pixel-level classification score judgment on the basic category mapping feature map, and calculating the loss value of the first contraband detection model;
[0251] In response to detecting that the loss value of the first contraband detection model meets a preset standard, a second contraband detection model is obtained.
[0252] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0253] The calculation method of the loss value of the first contraband detection model includes:
[0254]
[0255] in, Indicates the true probability distribution of the target sample pixels. Indicates the pixel-level probability distribution of the target sample predicted by the first contraband detection model, Loss b Represents the loss value of the first contraband detection model.
[0256] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0257] Adding at least one incremental task FC node on the basis of the second contraband detection model to generate the third contraband detection model;
[0258] performing incremental training on the third contraband detection model using images in the second target image set, and calculating a loss value of the third contraband detection model;
[0259] In response to detecting that the loss value of the third contraband detection model meets a preset standard, a fourth contraband detection model is obtained.
[0260] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0261] The calculation method for defining the loss value of the third contraband detection model includes:
[0262] L total =βL kd +L ce
[0263]
[0264]
[0265] Among them, L total represents the loss value of the third contraband detection model, β represents the hyperparameter, and L kd Represents the distillation loss value, Lce represents the cross entropy loss value, Indicates the true probability distribution of the target sample pixels. Indicates the incremental task output value, represents the pixel-level probability of the images in the second target image set obtained based on the second contraband detection model, Indicates the output value of the basic task output.
[0266] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0267] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0268] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application.
Claims
1. A method for detecting contraband, characterized in that: The method comprises: Acquire a first image set and a second image set; Preprocessing the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set; Constructing a first contraband detection model, and training the first contraband detection model using the first target image set to obtain a second contraband detection model; Based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model; The collected real-time image is input into the fourth contraband detection model to obtain an instance segmentation map, and the location information of the contraband is determined according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
2. The contraband detection method according to claim 1, characterized in that: Image preprocessing methods include: Acquire an initial image, and scale the initial image to obtain multiple target images of different scales; Selecting a first target image from a plurality of target images of different scales, converting the first target image into a grayscale image, and performing binarization processing on the grayscale image to obtain a binary image; Performing an erosion operation on the binary image to obtain an eroded image, and performing an expansion operation on the eroded image to obtain an expanded image; A subtraction operation is performed on the eroded image and the dilated image to obtain a first edge image B1.
3. The contraband detection method according to claim 2, characterized in that: Image preprocessing methods also include: Selecting a second target image from a plurality of target images of different scales, performing a downsampling operation on the first edge image B1 based on a size value of the second target image, and fusing the first edge image B1 after the downsampling operation with the second target image to obtain a fused image; The fused image is subjected to binarization, corrosion and dilation operations in sequence, and a second edge image B2 is obtained based on the fused image subjected to the binarization, corrosion and dilation operations; And so on, until edge images corresponding to multiple target images of different scales are obtained; Based on the image fusion function, multiple edge images are fused to obtain the target edge image, and the image fusion function includes: X E =Upsample(B n )+...+Upsample(B3)+Upsample(B2)+B1 Among them, X E represents the target edge image, Upsample represents upsampling, B m =B1,B2,B3,...,B n represents an edge image; The target edge image is mapped onto the initial image to obtain a preprocessed image, and the calculation formula is: I E (x,y)=(1-C(x,y))·X b (x,y)+C(x,y)·X E (x,y) Among them, I E (x,y) represents the preprocessed image I E The pixel value at pixel (x, y), C(x, y)∈[0,1], C(x, y) represents the pixel weight, X b (x,y) represents the initial image X b The pixel value at pixel (x,y).
4. The contraband detection method according to claim 1, characterized in that: The first contraband detection model at least includes a backbone network and a basic task FC node, the backbone network includes a convolution encoder, an attention mechanism module and a decoder, and the first contraband detection model is trained based on the first target image set to obtain a second contraband detection model including: Extracting features from images in a first target image set based on a convolutional encoder to obtain a first feature map; Extract features from images in the first target image set based on a block attention mechanism to obtain a second feature map; Perform a learnable convolution fusion on the first feature map and the second feature map, and input the result into a decoder to obtain a pixel-level full-scale feature map; Input the pixel-level full-scale feature map into the basic task FC node and perform learnable convolution fusion to obtain a basic category mapping feature map; Performing pixel-level classification score judgment on the basic category mapping feature map, and calculating the loss value of the first contraband detection model; In response to detecting that the loss value of the first contraband detection model meets a preset standard, a second contraband detection model is obtained.
5. The method for detecting contraband according to claim 4, characterized in that: The calculation method of the loss value of the first contraband detection model includes: in, Indicates the true probability distribution of the target sample pixels. Indicates the pixel-level probability distribution of the target sample predicted by the first contraband detection model, Loss b Represents the loss value of the first contraband detection model.
6. The method for detecting contraband according to claim 1, characterized in that: Based on the second contraband detection model, a third contraband detection model is constructed, and the third contraband detection model is incrementally trained using the second target image set to obtain a fourth contraband detection model, including: Adding at least one incremental task FC node on the basis of the second contraband detection model to generate the third contraband detection model; performing incremental training on the third contraband detection model using images in the second target image set, and calculating a loss value of the third contraband detection model; In response to detecting that the loss value of the third contraband detection model meets a preset standard, a fourth contraband detection model is obtained.
7. The method for detecting contraband according to claim 6, characterized in that: The calculation method of the loss value of the third contraband detection model includes: L total =βL kd +L ce Among them, L total represents the loss value of the third contraband detection model, β represents the hyperparameter, and L kd Represents the distillation loss value, L ce represents the cross entropy loss value, Indicates the true probability distribution of the target sample pixels, Indicates the incremental task output value, represents the pixel-level probability of the images in the second target image set obtained based on the second contraband detection model, Indicates the output value of the basic task output.
8. A contraband detection device, characterized in that: The device comprises: An image set acquisition module, used to acquire a first image set and a second image set; A preprocessing module, used to preprocess the images in the first image set and the second image set respectively to obtain a first target image set and a second target image set; A model building and training module, used to build a first contraband detection model, and train the first contraband detection model using the first target image set to obtain a second contraband detection model; an incremental training module, configured to construct a third contraband detection model based on the second contraband detection model, and perform incremental training on the third contraband detection model using the second target image set to obtain a fourth contraband detection model; The detection module is used to input the collected real-time image into the fourth contraband detection model to obtain an instance segmentation map, and determine the location information of the contraband according to the pixel-level features of the instance segmentation map to generate a contraband detection effect map.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
