Foreign matter intrusion detection method suitable for railway environment
Through data enhancement and artificial intelligence to generate content, combined with GhostNet and BiFPN networks, a lightweight target detection algorithm in the railway environment is designed, which solves the accuracy and real-time problems of obstacle detection in the railway environment and achieves high accuracy and rapid detection. Suitable for mobile deployment.
Patent Information
- Application Number
- CN202410231217.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-29
- Publication Date
- 2024-08-30
AI Technical Summary
In the railway environment, it is difficult for existing technologies to accurately detect obstacles that may threaten safety during train operation, such as pedestrians, animals, and falling rocks, in real time, especially when the number of data sets is insufficient and under poor lighting conditions, resulting in a decrease in recognition accuracy.
Use data enhancement technology and artificial intelligence to generate content, use MixUp method and Diffusion Model to generate virtual data sets, combine GhostNet and BiFPN networks, design a lightweight single-stage target detection algorithm, use CIoU loss function and model pruning technology to improve detection accuracy Accuracy and real-time.
It improves the robustness and generalization ability of the model, enhances the adaptability to different scenarios, achieves high-accuracy detection under conditions of insufficient data and light changes, reduces the amount of calculation and inference time, and is suitable for deployment on mobile terminals on the device.
Smart Images

Figure CN118570516A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent rail transit safety, and specifically is a system based on computer vision and deep learning technology suitable for railway environments, which uses corresponding equipment on the vehicle side or the road side to collect images, detect the vehicle ahead and obstacles that may pose a threat to the safety of railway operations, including pedestrians, animals, fallen rocks, etc., with good real-time and accuracy, and ensures the safe operation of trains. Background Art
[0002] Due to the vast territory and large population of my country, railway transportation is closely related to people's daily production activities. The railway industry is not only a basic and strategic supporting industry for the modernization of the country's society, but also plays an important role in the national economic development and material transportation. At the same time, it also alleviates the significant pressure of public transportation and plays a vital role in the development of the country. Compared with other transportation, railways have a large transportation capacity, short time and strong economic benefits. However, with the continuous increase in railway mileage, there are more and more difficulties and challenges in the operation of trains. In the process of all-weather railway transportation operation, foreign objects in the railway operation environment seriously threaten the safety of railway train operation. For example, factors such as people crossing the rails and highway motor vehicles passing through railway crossings are likely to cause railway traffic accidents, which increase the risks to the safety of people and national property. Therefore, ensuring the safety of trains running all-weather is important for the development of railway transportation.
[0003] The so-called railway foreign objects are objects that invade the operating limits of railway trains and pose a threat to train safety, such as pedestrians, vehicles, and falling rocks. In recent years, with the continuous expansion of monitoring coverage along the railway, railway foreign object target detection (OD) based on computer vision (CV) has become a hot research direction. This method converts image and video information into digital signals and realizes railway foreign object intrusion detection and tracking by extracting target features. This method has the advantages of high detection efficiency, high accuracy, and low cost, and provides important technical support for ensuring railway safety.
[0004] In order to more accurately extract the features of foreign objects from the background, there are currently two main mainstream methods. One is to use the traditional method to extract the target to be detected from the picture using the feature transformation method. The overall reliability of this method is low, the calculation amount is relatively complex, and it is easily affected by adverse factors such as light, which will reduce the recognition accuracy. Therefore, the present invention will use another method to extract features, which is a practical deep learning (DL) method, using a deep convolutional neural network to extract the detected object. This method has strong stability and accuracy. For the railway environment, the present invention, based on the classic single-stage detection algorithm framework, redesigns a new convolutional network module suitable for railway scenarios according to the "feature extraction + feature accumulation + output" structure, which can accurately identify invading foreign objects in the railway environment.
[0005] For the target detection algorithm based on deep learning, since the algorithm itself requires a large amount of data for fitting and learning, it is necessary to collect sample images containing foreign objects in the railway environment background. In the process of creating foreign object intrusion images in the railway environment, it is sometimes difficult to collect railway environment images containing intrusion targets in reality. For deep learning algorithms, the quality of intrusion sample images is directly related to the training effect of the algorithm and ultimately affects the final detection effect. Insufficient number of intrusion sample images may cause overfitting and other undesirable situations during the training process. Summary of the invention
[0006] In order to solve this problem, the technical purpose of the present invention is to expand the original data set using data augmentation technology. This method can well improve the robustness of the model during training and to a certain extent avoid the problem of overfitting during training. In addition, the present invention uses a large model and artificial intelligence generated content (AIGC), that is, using the "wensheng map" method to generate pictures containing foreign body intrusion in a virtual railway environment according to demand. This technology can well make up for the fact that there are no or few foreign body intrusion target pictures in reality, and the real effect of the picture can be comparable to the real world.
[0007] To achieve the above object, the present invention provides a technical solution: a foreign body intrusion detection method suitable for railway environment, the method comprising the following steps:
[0008] Step 1: Establish a railway foreign object intrusion sample set for deep learning training;
[0009] Combined with the intrusion targets in the railway environment, the railway foreign object intrusion sample data set was recreated by collecting, classifying and annotating massive video data of various railway scenes. Combined with the foreign object categories that may appear in the actual project, the foreign object detection categories are finally set in four categories, namely pedestrians, front vehicles, animals and falling rocks. The structure of the data set will be divided into "training set" and "validation set". According to the experience of deep learning training, the division ratio is 5:1. In addition, attention should be paid to the use of appropriate annotation methods during the annotation process. Generally speaking, the aspect ratio of the bounding box annotated with the sample image should be moderate. If the ratio is unbalanced, it will affect the training process and quality. The data annotation work is completed using Labeling software. The annotated xml file and the original image can be classified to form a training data set for the training of the deep learning model.
[0010] Furthermore, data enhancement is used to enrich railway foreign body intrusion samples, improve the richness of the data set, improve the model fitting effect, and enhance the model generalization ability. The MixUp method is used to create new training samples by linearly combining the input and labels of two or more samples. For the input data X and the corresponding category label Y, MixUp generates new samples through the following formula, as shown in equations (1) and (2):
[0011] Mixup(X1,X2,λ)=λ·X1+(1-λ)·X2 (1)
[0012] Mixup(Y1,Y2,λ)=λ·Y1+(1-λ)·Y2 (2)
[0013] Among them, X1, X2 are two input samples, Y1, Y2 are the corresponding category labels of the first two station images, and λ is a random number between 0 and 1. Mixup(X1, X2, λ) is the new sample image generated by the MixUp operation, and correspondingly, Mixup(Y1, Y2, λ) is the category label in the new sample. For image data, a new image is generated by linearly interpolating the pixel values of the image.
[0014] Furthermore, using the big model and AIGC technology, we use the famous Diffusion Model to generate sample images in the railway environment. The Diffusion Model has two processes. The first is the forward process, which is the process of adding noise to the image. The original image x0 is given in the form of probability distribution, x0~q(x). The forward process of the model adds Gaussian noise to it by T times to obtain new images x1, x2,…, x T , given a series of Gaussian distribution hyperparameters Since each moment t in the forward process is only related to the previous moment t-1, it is considered a Markov process, as shown in equations (3) and (4):
[0015]
[0016]
[0017] Among them, (3) represents the process of adding noise to the image for each x t is a is the mean, β t is obtained by Gauss distribution of variance. As t increases, x t is getting closer and closer to pure noise. When T→∞, x T is a complete Gauss noise, and in practice β t As t increases, it increases, that is, β1<β2<…<β T Then, (4) represents the process of generating an image, where Use standard normal distribution. Since each step of adding noise is independent and obeys normal distribution, let α t =1-β t So the final image x t The initial image x0 is given by (5),
[0018]
[0019] Among them, the addition of normal distributions is still a normal distribution, so ∈ t-1 is unified with ∈ and is denoted as ∈, so (5) continues to derive,
[0020]
[0021] Since the noise at each step is independently distributed, by iterating one step forward, we finally get:
[0022]
[0023] in,
[0024] The reverse process is the denoising inference process of Diffusion. If we can gradually obtain the reversed distribution q(x t-1 |x t ), we can completely get the standard Gauss distribution x T ~N(0,I) restores the original distribution, but cannot derive q(x t-1 |x t), use the deep learning model to predict the reverse distribution. The reverse denoising process is a reverse process: after the model is trained, sample and generate images. That is, train a neural network U-Net, start from pure noise and gradually denoise until a real image is obtained. Use a neural network with parameters to calculate its reverse process p θ (x t-1 |x t ), described as:
[0025]
[0026]
[0027] Although it is impossible to obtain the reversed distribution q(x t |x t-1 ), and by using the Bayesian formula at each step, we get q(x t-1 |x t ,x0),
[0028]
[0029] In essence, q(x t-1 |x t ,x0) still obeys the normal distribution, where:
[0030] Mean variance However, in formula (10), x0 on the right side of the equation is the target image to be generated, that is, the target solution, and the model is trained to obtain parameters to fit the target image.
[0031] The last step is the training phase of the Diffusion model, which constructs a new standard normal probability distribution p(x t-1 |x t ), the goal is to narrow the gap between this distribution and formula (10), so that its variance and posterior distribution q(x t-1 |x t ,x0) are consistent, let their mean be in, It is predicted by a deep learning model whose input is a noisy image x t With time step t, p(x t-1 |x t ) is written as The final objective function is written as in The simplified objective function is shown in formula (11):
[0032]
[0033] Step 2: Establish a deep learning detection network model;
[0034] The object detection algorithm based on deep learning can be divided into a single-stage One Stage detection algorithm and a two-stage Two Stage detection algorithm. Based on the framework of the single-stage object detection algorithm YOLO, that is, the structure of "feature extraction + feature stacking + output", combined with the characteristics of railway foreign objects, the single-stage object detection algorithm is redesigned.
[0035] 1) Input: To reduce input training parameters and speed up the training and reasoning process, all images will be scaled to 640×640 by default;
[0036] 2) Feature extraction network: Introduce the improved GhostNet as the feature extraction network;
[0037] 3) Feature fusion network: After feature extraction, the extracted features need to be fused and spliced. The BiFPN feature fusion network is introduced to complete the feature fusion work;
[0038] 4) Detection head: The detection head consists of a series of convolutional layers and a subsequent fully connected layer, which is responsible for generating bounding box predictions and class probabilities for object detection. The detection process will complete object detection based on three anchors of different scales. When the input image is 608×608, the feature maps of different scales are 76×76, 38×38, and 19×19. In this step, non-maximum suppression (NMS) is used to filter out redundant bounding boxes and select the most confident bounding box as the final detection. In addition, CIoU is introduced as a position loss function for training.
[0039] Step 3: Optimized network for target detection in railway scenes;
[0040] Step 3.1: Feature extraction network design
[0041] First, in order to adapt to the application of network models in embedded devices on trains, an improved GhostNet network structure is introduced, and linear operations are used to generate rich feature maps. In order to achieve lightweight network, the original ordinary convolution layer is replaced by the deep separable convolution GhostConv convolution module. In order to accurately obtain the feature map details and separate the multi-scale local feature information, 1×1 is first used to achieve deeper feature extraction, and then the output data is divided into several groups of features. The linear transformation is performed through the 5×5 convolution kernel to extract the features at a deeper level, and finally the transformation results are stacked and merged for output. The network balances the grouping effect and the number of convolutions by grouping convolutions.
[0042] Secondly, based on the original GhostNet, GC-Block is added. GC-Block is a method for capturing the dependencies between pixels in remote images.
[0043] Next, use the activation function Mish to replace the original ReLU in GhostNet.
[0044] Finally, the SPP structure is added between the feature extraction network and the feature fusion network. The main purpose of this structure is to perform pooling operations on the input feature maps at different scales to capture the features of objects at different sizes. The maximum pooling of 1×1, 5×5, 13×13 and 26×26 is selected to increase the receptive field of the feature map and enhance the model's detection ability for objects of different scales.
[0045] Finally, the above modules are spliced together to form a feature extraction network.
[0046] Step 3.2: Feature fusion network BiFPN;
[0047] The bidirectional feature pyramid network BiFPN integrates the characteristics of FPN, PANet and NAS-FPN. On the basis of FPN's one-way information from top to bottom, it adds additional bottom-up paths and cross paths based on the neural structure search method to form a weighted bidirectional feature pyramid network. This bidirectional feature pyramid network introduces learnable weights to learn the importance of different input features, and repeatedly applies top-down and bottom-up multi-scale feature fusion.
[0048] The weights are learned during the feature fusion process. BiFPN adopts a fast normalized feature fusion method, as shown in formula (12):
[0049]
[0050] This process is regarded as an optimization method using unrestricted fusion and softmax function fusion, where w i Representation feature I i The corresponding weights are ensured to be greater than or equal to 0 through ReLU, and then through I i The left side of the equation is normalized to between 0 and 1, and the denominator ∈ is taken as 0.0001.
[0051] The process of BiFPN is as follows. First, a mathematical formula is used to describe the fusion of multi-scale features. Given a series of features of different scales, the input-output relationship is shown in equations (13) and (14).
[0052]
[0053]
[0054] in Represents features of different scales. The purpose of multi-scale feature fusion is to find a conversion function f that can efficiently integrate features of different scales. Secondly, the mathematical process of FPN, whose input is the input features of level 3 to level 7, as shown in formula (15):
[0055]
[0056] in, The resolution of the feature is the input image resolution After feature fusion, as shown in formula (16),
[0057]
[0058] Where Conv represents the convolution operation, and Resize usually represents the upsampling or downsampling operation. Finally, BiFPN combines the bidirectional cross-scale connection and the fast normalization fusion method, which is given by equations (17) and (18):
[0059]
[0060]
[0061] in Indicates the output of a node at level 6. is the output of the second node of level 6. The input of the convolution operation is the fusion result obtained according to the fast normalization fusion method mentioned above. All other nodes are fused in this way, and in order to improve the efficiency of the model, when performing feature fusion, the convolution operation uses depthwise separable convolution, and each convolution layer is followed by a batch normalization and activation function layer.
[0062] Step 3.3: CIoU loss function;
[0063] The calculation method of CIoU is as follows. First, the expressions of IoU and CIoU are given as shown in equations (19) and (20).
[0064]
[0065]
[0066] Among them, A and B represent the real box and the predicted box respectively, ρ 2 (b,b gt) represents the Euclidean distance between the predicted box and the midpoint of the real box, and C is the diagonal length of the minimum bounding box between the predicted box and the real box. At the same time, the loss of the detection box scale is also added to the calculation of CIoU, that is, its width and height are included in the calculation. The specific implementation method is to add a correction term after CIoU. The specific calculation method is shown in formulas (21) and (22).
[0067]
[0068]
[0069] Finally, the loss function formula of CIoU is given, as shown in Equation 23.
[0070]
[0071] Step 4: Model pruning operation;
[0072] The model compression method used uses the γ parameter in the BN layer, an essential component of the convolutional neural network, to achieve end-to-end learning and pruning. At the same time, L1 regularization is applied to the scaling factor γ of the BN layer. Through sparse training, the scaling factor γ of the BN layer corresponding to the parameters that have little effect on train detection tends to 0. Since each scaling factor γ is associated with a specific convolution channel or a neuron in the fully connected layer, unimportant channels are automatically identified, and then the channels and layers below the threshold are deleted. The γ parameter of the BN layer is directly used to identify whether a channel of the output feature map of the previous Conv layer is important, and no additional expenses are incurred during this period. In this way, the amount of calculation can be reduced, the network can be reduced, and reasoning can be accelerated to obtain a compact model with almost no loss of accuracy. The process of pruning and compression is relatively complicated and is divided into the following 5 steps:
[0073] Step 1: Initialize the network and perform basic network training;
[0074] Step 2: Add channel sparse penalty term to compress the γ coefficient of BN layer;
[0075] Step 3: After the γ of most BN layers approaches 0, the channels are deleted by setting the threshold;
[0076] Step 4: Since the accuracy will decrease after deleting some channels, the network is fine-tuned and retrained after achieving the ideal pruning result;
[0077] Step 5: If the ideal accuracy is restored, the model compression ends; otherwise, continue;
[0078] After the basic training reaches the ideal accuracy, the sparse training of the model is carried out to reduce the weight parameter value of unimportant neurons to 0. After basic training, the γ of the BN layer basically obeys the normal distribution, and the transformation formula of the BN layer is shown in Equation (24) and Equation (25).
[0079]
[0080]
[0081] In formula (7), μ B and Represent the mean and variance of a feature map respectively, and update the scaling factor γ and shift factor β through back propagation, z in and z out Represent the input and output of the BN layer respectively. Apply L1 regularization to the scaling factor γ to penalize it so that its value tends to be 0. At this time, the objective function is finally designed as (26),
[0082]
[0083] Among them, the first term is the training loss function of the CNN network, x and y represent the input and target of the training respectively, W represents the training weight parameter, g(.) is the penalty term on the scaling factor, and λ is the balance factor to adjust these two terms. L1 regularization, that is, g(s) = |s|, is used for sparsification. During the sparse training process, continuous debugging is performed to find the sparse parameters suitable for the specified training set until most of the γ values of the BN layer are gradually compressed to close to 0. Channels close to 0 indicate that their output values are close to the constant and they are pruned. When the pruning combination is found, the model is pruned and then fine-tuned to achieve the same accuracy.
[0084] Compared with the prior art, the present invention has the following advantages:
[0085] 1. In terms of data sets, facing the problem of insufficient data sets, this invention is innovative and pioneering. In order to solve this problem, in addition to using traditional data enhancement solutions, this invention is the first to use a large model based on the text-based image method, using existing images, based on the semantic understanding and generation capabilities of the large model, to generate virtual images that are almost similar to the real world, enrich the existing data sets, and improve the training effect;
[0086] 2. The algorithm structure is closely integrated with the actual engineering background, and has both accuracy and real-time performance. Designed for the characteristics of railway intrusion targets, it can cope with most scenarios, has fast inference time, and has good real-time performance; in addition, the algorithm has fully considered the algorithm volume at the beginning of the design, and everything starts from a lightweight structure. At the same time, the algorithm pruning operation is added after basic training. Without losing the original accuracy, the model is further compressed, which provides feasibility for deployment and transplantation on the mobile terminal, and the algorithm can be deployed on devices with insufficient computing power to easily cope with it;
[0087] 3. The overall algorithm has a flexible algorithm structure, which is developmental and extensible. The algorithm can embed different modules in the algorithm network module according to different scenarios, and perform targeted optimization for different scenarios; BRIEF DESCRIPTION OF THE DRAWINGS
[0088] Figure 1 This is a diagram of MixUp data enhancement.
[0089] Figure 2 It is the Diffusion model diagram.
[0090] Figure 3 It is the forward and reverse process diagram of the Diffusion model.
[0091] Figure 4 This is a sample graph generated based on the Diffusion model.
[0092] Figure 5 This is the redesigned foreign object intrusion algorithm module diagram based on railway scenarios.
[0093] Figure 6 This is the GC-Block structure diagram and the improved GhostNet module schematic.
[0094] Figure 7 This is a schematic diagram of the BiFPN, FPN, PAN and NAS-FPN model structures.
[0095] Figure 8 It is the CIoU calculation representation diagram.
[0096] Fig. 9 These are the steps and schematic diagram of the pruning algorithm.
[0097] Figure 10-1 It is a basic training curve chart.
[0098] Figure 10-2 It is the loss function curve of basic training.
[0099] Figure 11-1 It is a sparse training curve under different sparsity rates.
[0100] Figure 11-2 It is the fine-tuning training curve of different pruning rates under the sparse rate of 0.020.
[0101] Fig.12 It is the PR curve of the pruned model.
[0102] Fig.13 This is the effect diagram of foreign body intrusion detection in a railway environment.
[0103] Fig.14 This is a diagram of the real-world effect of detecting categories trained using the dataset generated by the Diffusion model. DETAILED DESCRIPTION
[0104] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0105] A foreign body intrusion detection method applicable to a railway environment comprises the following steps:
[0106] Step 1: Establish a railway foreign object intrusion sample set for deep learning training;
[0107] Combined with the intrusion targets in the railway environment, the railway foreign object intrusion sample data set was recreated by collecting, classifying and annotating the massive video data of various railway scenes. Combined with the foreign object categories that may appear in the actual project, the foreign object detection categories are finally set in four categories, namely pedestrians, front vehicles, animals and falling rocks. The structure of the data set will be divided into "training set" and "validation set". According to the experience of deep learning training, the division ratio is 5:1. In addition, in the annotation process, attention should be paid to the use of appropriate annotation methods. Generally speaking, the aspect ratio of the bounding box annotated with the sample image should be moderate. If the ratio is unbalanced, it will affect the training process and quality. The data annotation work will be completed using Labeling software. The annotated xml file and the original image can be classified to form a training data set for the training of the deep learning model. The above is the whole process of data annotation.
[0108] In order to better enrich the railway foreign body intrusion samples and improve the richness of the data set, the model fitting effect will be improved and the model generalization ability will be enhanced. The present invention proposes two methods to solve this problem and use the existing data set for amplification.
[0109] First, the traditional data augmentation method (Data Augmentation) is used. Data augmentation is a technology used to train machine learning models. Its goal is to generate new training samples by performing a series of transformations on the original data set, thereby increasing the amount of training data for the model. Common methods include rotating, flipping, scaling, translating, adjusting brightness, shearing, and transforming sample images. The advantage of data augmentation is that it can simulate various situations in the real world by performing a variety of transformations on the original data, thereby improving the model's adaptability to various inputs. This is particularly important for training deep learning models with limited data. The present invention uses the MixUp method, the core idea of which is that it is a method for creating new training samples by linearly combining the inputs and labels of two or more samples. Specifically, for input data X and the corresponding category label Y, MixUp generates new samples through the following formula, as shown in equations (1) and (2):
[0110] Mixup(X1,X2,λ)=λ·X1+(1-λ)·X2 (1)
[0111] Mixup(Y1,Y2,λ)=λ·Y1+(1-λ)·Y2 (2)
[0112] Among them, X1, X2 are two input samples, Y1, Y2 are the corresponding category labels of the first two station images, and λ is a random number between 0 and 1. Mixup(X1, X2, λ) is the new sample image generated by the MixUp operation, and correspondingly, Mixup(Y1, Y2, λ) is the category label in the new sample. For image data, a new image can be generated by linearly interpolating the pixel values of the image. This allows the model to consider two samples at the same time in practice, thereby enhancing the generalization ability. Figure 1 , is an operation after mixing two pictures.
[0113] In addition to using data enhancement, the present invention also proposes a new method, which is to use a large model and artificial intelligence generated content (AIGC) technology, and use the famous diffusion model to generate sample images in a railway environment. Different from the previous image generation network technology, the image generation network based on AIGC has powerful semantic understanding and generation capabilities. In addition, it also has powerful cross-modal generation capabilities. Therefore, the sample images already in the data set can be input into its network, and then the expectations for the generated images can be proposed in a way similar to "conversation". The model will generate the expected sample images based on the semantic information.
[0114] The following is the principle of Diffusion Model. Diffusion Model has two processes. The first is the forward process, which is the process of adding noise to the image. Given the original image x0 in the form of probability distribution, x0~q(x), the model forward process adds Gaussian noise to it T times to get the new image x1,x2,…,x T , as shown in the following process, given a series of Gauss distribution hyperparameters Since each moment t in the forward process is only related to the previous moment t-1, it can be regarded as a Markov process, as shown in equations (3) and (4):
[0115]
[0116]
[0117] Among them, (3) represents the process of adding noise to the image, which can be understood as each x t is a is the mean, β t is obtained by Gauss distribution of variance. In this process, as t increases, x t is getting closer and closer to pure noise. When T→∞, x T is a complete Gauss noise, and in practice β t As t increases, it increases, that is, β1<β2<…<β T Then, (4) represents the process of generating the image, where Use standard normal distribution. Since each step of adding noise is independent and obeys normal distribution, let α t =1-β t So the final image x t It can be given by (5) from the initial image x0,
[0118]
[0119] Among them, the addition of normal distributions is still a normal distribution, so ∈ t-1 is unified with ∈ and is denoted as ∈, so (5) can be further derived.
[0120]
[0121] Since the noise at each step is independently distributed, by iterating one step forward, we can finally get:
[0122]
[0123] in,
[0124] Next is the reverse process, which is the denoising inference process of Diffusion. If we can gradually obtain the reversed distribution q(x t-1 |x t ), we can completely get the standard Gauss distribution x T ~N(0,I) restores the original distribution, but cannot derive q(x t-1 |x t ), use the deep learning model to predict the reverse distribution. The reverse denoising process is a reverse process: after the model is trained, sample and generate images. That is, train a neural network (U-Net), start from pure noise and gradually denoise until a real image is obtained. Use a neural network with parameters to calculate its reverse process p θ (x t-1 |x t ), the problem can be described as
[0125]
[0126]
[0127] Although it is impossible to obtain the reversed distribution q(x t |x t-1 ), we can use the Bayesian formula at each step to get q(x t-1 |x t ,x0),
[0128]
[0129] In essence, q(x t-1 |x t ,x0) still follows the normal distribution, where
[0130] Mean variance However, in (10), x0 on the right side is the target image to be generated, i.e., the target solution, so this equation cannot give the final result. The model needs to be trained to obtain parameters to fit the target image.
[0131] Finally, the Diffusion model training phase is to construct a new standard normal probability distribution p(x t-1 |x t ), the goal is to narrow the gap between this distribution and (10), so that its variance and the posterior distribution q(x t-1 |x t ,x0) are consistent, let their mean be in, It is predicted by a deep learning model whose input is a noisy image xt With time step t, therefore, p(x t-1 |x t ) can be written as Therefore, the final objective function can be written as in The simplified objective function is shown in (11),
[0132]
[0133] The above is the whole process of Diffusion. The whole process can be used Figure 2 and Figure 3 To express, Figure 4 It is a sample image generated using the Wensheng graph model.
[0134] Step 2: Initial establishment of deep learning detection network model
[0135] In this step, the algorithm model will be built. The target detection algorithm based on deep learning can be divided into a one-stage (One Stage) detection algorithm and a two-stage (Two Stage) detection algorithm. The difference between the two is whether there is a step to generate candidate areas. The two-stage detection algorithm needs to generate candidate areas first, while the one-stage algorithm models the target detection problem as a direct regression problem, and directly predicts the position and category of the target in the image through the network. Therefore, in terms of detection speed, the one-stage detection algorithm has more advantages. Combined with the characteristics of rail transit, the detection algorithm needs to be able to quickly identify foreign objects, and the one-stage detection algorithm can meet this requirement well. The YOLO (You Only Look Once) series is a representative one-stage detection algorithm, which shows high detection accuracy and fast reasoning time while ensuring the lightweight of the algorithm, and has achieved excellent results in engineering applications. With the continuous iteration of the algorithm itself, the algorithm after the third generation has formed a "modular" + "framework" layout, and the flexibility of its algorithm structure has been improved. The present invention will inherit the framework architecture of the single-stage target detection algorithm YOLO, that is, the structure of "feature extraction + feature stacking + output", and combine the characteristics of railway foreign objects to redesign the single-stage target detection algorithm. Next, we will introduce the redesigned detection algorithm framework, whose structure is as follows: Figure 5 As shown:
[0136] 1. Input: At the input, the image will be input and processed by different traditional enhancement methods (selectively), such as flipping, blurring, adding noise, or adding settings (such as adaptive anchors and adaptive image scaling). In order to reduce training parameters and speed up the training and inference process, all images will be scaled to a size of 640×640 by default;
[0137] 2. Feature extraction network: In actual application scenarios, the computing power of deep learning models is usually affected by the hardware environment and the spatial layout design of the device, and is thus greatly limited. In the target detection algorithm, the feature extraction network plays the role of feature extraction and plays a vital role in capturing low-level and high-level semantic information. It is the most important part of a target detection algorithm. A large network will occupy too many computing resources. Therefore, when constructing a feature extraction network, a lightweight network should be used as much as possible. In this part, the present invention will introduce the improved GhostNet as the feature extraction network of the present invention;
[0138] 3. Feature fusion network: After feature extraction, the extracted features need to be fused and spliced. Usually, when extracting features, a target detection network will extract layer by layer at different scales to maximize the extraction to meet information of different sizes and enhance the detection network. The high-level network has a large receptive field and strong semantic information representation ability, but the feature map resolution is relatively low and lacks spatial geometric features; although the low-level network has a small receptive field and weak semantic information expression ability, the feature map resolution is large and the spatial geometric details are sufficient. Therefore, it is more beneficial to the final detection network to fuse the features at each level. In order to better complete the feature fusion work, the present invention will introduce the BiFPN feature fusion network;
[0139] 4. Detection head: The detection head consists of a series of convolutional layers and a subsequent fully connected layer. This part is responsible for generating bounding box predictions and class probabilities for target detection. The detection process will complete object detection based on three anchors of different scales. When the input image is 608×608, the feature maps of different scales are 76×76, 38×38, and 19×19. In this step, non-maximum suppression (NMS) is used to filter out redundant bounding boxes and select the most confident bounding box as the final detection. In addition, CIoU is introduced as a position loss function for training, and its principle will be introduced in step 3.3.
[0140] Step 3: Optimizing the network for object detection in railway scenes
[0141] Step 3.1: Feature extraction network design
[0142] In order to adapt to the application of network models in embedded devices on trains, an improved GhostNet network structure is introduced, the core of which is to use linear operations to generate rich feature maps. In order to achieve lightweight network, the original ordinary convolution layer is replaced by the deep separable convolution GhostConv convolution module. In order to accurately obtain the feature map details and separate the multi-scale local feature information, 1×1 is first used to achieve deeper feature extraction, and then the output data is divided into several groups of features, and linear transformation is performed through the 5×5 convolution kernel to extract the features at a deeper level. Finally, the transformation results are stacked and merged for output. The network balances the grouping effect and the number of convolutions by grouping convolutions, which greatly reduces the complexity of the model, reduces the number of network parameters, and improves the model operation speed.
[0143] Secondly, based on the original GhostNet, GC-Block is added, which is a method for capturing dependencies between pixels in remote images. It has the ability to capture global capabilities. This shows that a lot of computation is redundant when the following methods calculate the attention map of each point in the non-local method. At the same time, inspired by SENet, GC-block is designed to be lightweight and effective to reduce computing resources and maintain accuracy.
[0144] Next, the present invention uses the activation function Mish to replace the ReLU in the original GhostNet. Mish has good performance in combining linear and nonlinear activations, and this performance can be used for gradient descent optimization in training. By combining GC-block with the original GhostNet and replacing the original activation function with Mish, a new optimized feature extraction network is obtained. The improved GhostNet network is as follows Figure 6 shown.
[0145] Finally, the present invention adds an SPP (Spatial Pyramid Pooling) structure between the feature extraction network and the feature fusion network. The main purpose of this structure is to perform pooling operations on the input feature maps at different scales to capture the features of objects at different sizes. The present invention uses maximum pooling of 1×1, 5×5, 13×13 and 26×26 to increase the receptive field of the feature map and enhance the model's detection ability for objects of different scales.
[0146] Finally, the above modules are spliced together to form the feature extraction network of the present invention.
[0147] Step 3.2: Feature Fusion Network BiFPN
[0148] BiFPN stands for Bidirectional Feature Pyramid Network, which is an extension of Feature Pyramid Network (FPN) to improve the efficiency and performance of feature extraction in deep neural networks. FPN has been widely used in multi-scale feature fusion. Although FPN has good performance, since these different input features have different resolutions, their contribution to the fused output features is usually uneven.
[0149] BiFPN combines the characteristics of FPN, PANet and NAS-FPN. On the basis of FPN which only has one-way information from top to bottom, it adds an additional bottom-up path and a cross path based on the neural structure search method to form a weighted bidirectional feature pyramid network. The network introduces learnable weights to learn the importance of different input features, and repeatedly applies multi-scale feature fusion from top to bottom and bottom to top. Its structure is as follows: Figure 7 As shown in Figure 2. Such a structure not only promotes the flow of information from high-resolution to low-resolution layers, but also allows information to flow in the opposite direction. This bidirectional flow helps to better integrate features of different scales and enhance the network's ability to handle objects of various sizes.
[0150] In the process of feature fusion, because of different resolutions, it is necessary to perform scaling operations on them. However, because different feature inputs have different resolutions, their contributions to the final feature network output should also be different, so the network needs to learn weights. BiFPN uses a fast normalized feature fusion method, as shown in formula (12):
[0151]
[0152] This process can be viewed as an optimization method using unrestricted fusion and softmax function fusion, where w i Representation feature I i The corresponding weights are ensured to be greater than or equal to 0 through ReLU, and then through I i The left side of the formula is normalized to between 0 and 1, and the denominator ∈ is taken as 0.0001 to avoid numerical instability. This method is faster and more accurate than softmax.
[0153] Therefore, the mathematical process of BiFPN can be given. First, a mathematical formula is used to describe the fusion of multi-scale features. Given a series of features of different scales, the input-output relationship is shown in equations (13) and (14).
[0154]
[0155]
[0156] in Represents features of different scales. The purpose of multi-scale feature fusion is to find a conversion function f that can efficiently integrate features of different scales. Secondly, the mathematical process of FPN, whose input is the input features of level 3 to level 7, as shown in formula (15):
[0157]
[0158] in, The resolution of the feature is the input image resolution After feature fusion, as shown in formula (16),
[0159]
[0160] Where Conv represents the convolution operation, and Resize usually represents the upsampling or downsampling operation. Finally, BiFPN combines the bidirectional cross-scale connection and the fast normalization fusion method, which can be given by equations (17) and (18):
[0161]
[0162]
[0163] in Indicates the output of a node at level 6. is the output of the second node of level 6. The input of the convolution operation is the fusion result obtained according to the fast normalization fusion method mentioned above. All other nodes are fused in this way, and in order to improve the efficiency of the model, when performing feature fusion, the convolution operation uses depthwise separable convolution, and each convolution layer is followed by a batch normalization and activation function layer.
[0164] Step 3.3: CIoU loss function
[0165] CIoU (Complete Intersection over Union) can more accurately capture the similarity between target bounding boxes. Unlike IoU, which uses the overlapping area of the predicted box and the real box for calculation, CIoU pays more attention to the center position of the two boxes, that is, the Euclidean distance between each detection box. This calculation method can make the training regression have a more stable convergence effect.
[0166] The calculation method of CIoU is as follows Figure 8As shown, firstly, the expressions of IoU and CIoU are given, as shown in equations (19) and (20).
[0167]
[0168]
[0169] Among them, A and B represent the real box and the predicted box respectively, ρ 2 (b,b gt ) represents the Euclidean distance between the predicted box and the midpoint of the real box, and C is the diagonal length of the minimum bounding box between the predicted box and the real box. At the same time, the loss of the detection box scale is also added to the calculation of CIoU, that is, its width and height are included in the calculation. The specific implementation method is to add a correction term after CIoU. The specific calculation method is shown in formulas (21) and (22).
[0170]
[0171]
[0172] Finally, the loss function formula of CIoU can be given, as shown in Formula 23.
[0173]
[0174] Step 4: Pruning
[0175] Large convolutional neural networks have stronger advantages in feature extraction and feature representation, but they consume more resources. If applied to single-category target detection and deployed on embedded platforms, they are still too complex and redundant. Among the huge parameters, not every parameter has a certain impact on the output, and there are many redundant and unimportant calculations that can be cut. If there are too many parameters, the demand for data will increase, the complexity of training and the amount of calculation will increase, and the detection speed of the network will be reduced. However, compression pruning can largely remove these redundant, unimportant parameters and calculations, reduce memory consumption and increase running speed. The core idea of the model compression method used in this study is to use the γ parameter in the BN layer, an essential component of the convolutional neural network, to achieve end-to-end learning and pruning. At the same time, L1 regularization is applied to the scaling factor γ of the BN layer. Through sparse training, the scaling factor γ of the BN layer corresponding to the parameters that have little effect on train detection is pushed to 0. Since each scaling factor γ is associated with a specific convolution channel (or a neuron in the fully connected layer), unimportant channels can be automatically identified, and then the channels and layers below the threshold are deleted. The characteristic is that the γ parameter of the BN layer is directly used to identify whether a channel of the output feature map of the previous Conv layer is important, and no additional cost is generated during this period. In this way, the amount of calculation can be reduced, the network can be reduced, and reasoning can be accelerated to obtain a compact model without almost any loss of accuracy. The process of cropping and compression is relatively complicated and can be roughly divided into the following 5 steps, such as Fig. 9 As shown:
[0176] Step 1: Initialize the network and perform basic network training;
[0177] Step 2: Add channel sparse penalty term to compress the γ coefficient of BN layer;
[0178] Step 3: After the γ of most BN layers approaches 0, the channels are deleted by setting the threshold;
[0179] Step 4: Since the accuracy will decrease after deleting some channels, the network is fine-tuned and retrained after achieving the ideal pruning result;
[0180] Step 5: If the ideal accuracy is restored, the model compression ends; otherwise, continue;
[0181] After the basic training reaches the ideal accuracy, the sparse training of the model can be started to reduce the weight parameter value of unimportant neurons to 0. After basic training, the γ of the BN layer basically obeys the normal distribution. The transformation formula of the BN layer is shown in Equation (24) and Equation (25).
[0182]
[0183]
[0184] In formula (7), μ B and Represent the mean and variance of a feature map respectively, and update the scaling factor γ and shift factor β through back propagation, z in and z out Represent the input and output of the BN layer respectively. Although it is possible to trim channels and layers whose scaling factor γ is close to 0, more often, only a small number of channels and layers have scaling factors γ close to 0. Therefore, it is necessary to apply L1 regularization to the scaling factor γ to penalize it so that its value tends to 0. At this time, the objective function is finally designed as (26),
[0185]
[0186] Among them, the first item is the training loss function of the CNN network, x and y represent the input and target of the training respectively, W represents the training weight parameter, g(.) is the penalty term on the scaling factor, and λ is the balance factor to adjust these two items. L1 regularization, that is, g(s) = |s|, is used for sparsification. In the process of sparse training, accuracy and sparsity rate compete with each other, and the two are contradictory. When the sparsity parameter is large, the sparsification speed is fast but the accuracy decreases greatly; when the sparsity parameter is small, the accuracy decreases less but the sparsification speed is slow. Therefore, in the process of sparse training, it is necessary to continuously debug and find the sparsity parameter suitable for the specified training set until most of the γ values of the BN layer are gradually compressed to close to 0. Channels close to 0 indicate that their output values are close to constants, so they can be pruned. After finding a suitable pruning combination, the model can be pruned and then fine-tuned to achieve the same accuracy.
[0187] After the above pruning steps, the original detection network can be further compressed and redundant neurons can be removed, so that the size of the algorithm can be compressed without losing detection accuracy, the portability of the algorithm can be improved, the reasoning speed of detection can be accelerated, and the subsequent deployment can be facilitated.
[0188] Optimization and training of detection models:
[0189] First, the basic training phase of the model is carried out. The created and labeled data set is trained under the detection network. The training parameters are set to Batch-size 16, the number of iterations 300, and the learning rate 0.001. In the basic training, the built detection network is used for training, and the optimal effect is achieved through continuous experiments. The basic model training curve is shown in Figure 10, where Figure 10-1 is the mAP curve, Figure 10-2is the loss function curve of training. The present invention performs well in terms of accuracy, reaching 0.955, and the model has good convergence.
[0190] After completing the basic training, the model is pruned by the algorithm in step 4 to further compress the original basic detection model. First, based on the algorithm pruning principle of 4, the original model is used to explore the pruning parameters. The accuracy of the original model is 0.955 and the algorithm size is 13.7MB. Through sparse training, pruning operations and fine-tuning training, the indicators after model pruning under different parameter combinations are compared to find the optimal pruning combination parameters. Through repeated experimental comparisons, it is found that when the sparsity rate and pruning rate are 0.020 and 40%, the compressed model has a faster inference time and maximized compression while maintaining the original accuracy level. The compressed volume is 66% of the original and the accuracy is only 0.015 lower than the original. Figure 11-1 As shown, the transformation of the original model after pruning at different sparsity rates is shown; Figure 11-2 The curves of the model accuracy change at different pruning rates under the sparsity rate of 20% are shown. Finally, through the pruning operation, the model accuracy can reach 0.951 after the optimization is performed using this parameter, and the algorithm size can be compressed to 6.44MB. Fig.12 As shown, the PR curve of the compressed model is shown.
[0191] Finally, the model parameters are as follows: mAP is 0.951, the model weight size is 6.44MB, and the inference time is 1.7ms, which has good real-time performance.
[0192] Next, the trained model is tested for target detection.
[0193] Model testing:
[0194] In this step, we first select pictures of railway scenes for testing, and the test results are shown in Figure 13. At the same time, in order to prove the dataset generated by the Diffusion model, we select pictures of animals in the real world for testing, and the results are shown in Figure 14.
[0195] In addition to the above advantages, the present invention uses a deep learning target detection algorithm, which not only has excellent accuracy and speed, but also has the stability to cope with the detection of intrusion objects under strong light, dim light and other conditions, thus ensuring the safe operation of the railway.
Claims
1. Foreign body intrusion detection method applicable to railway environment, It is characterized in that The method comprises the following steps, Step 1: Establish a railway foreign object intrusion sample set for deep learning training; Combined with the intrusion targets in the railway environment, the railway foreign object intrusion sample data set was recreated by collecting, classifying and annotating the massive video data of various railway scenes; combined with the possible foreign object categories that may appear in the actual project, the foreign object detection categories were finally set to four categories, namely pedestrians, preceding vehicles, animals and falling rocks; the structure of the data set will be divided into "training set" and "validation set", and the division ratio is 5:1 based on the experience of deep learning training; in addition, attention should be paid to the use of appropriate annotation methods during the annotation process; Generally speaking, the aspect ratio of the bounding box of the sample image annotation should be moderate. If the ratio is unbalanced, it will affect the training process and quality. The data annotation work is completed using Labeling software. The annotated XML file and the original image can form a training data set after classification for the training of the deep learning model. Step 2: Establish a deep learning detection network model; The object detection algorithm based on deep learning is divided into one-stage One Stage detection algorithm and two-stage Two Stage detection algorithm. Based on the framework of the one-stage object detection algorithm YOLO, that is, the structure of "feature extraction + feature stacking + output", combined with the characteristics of railway foreign objects, the one-stage object detection algorithm is redesigned; Step 3: Optimized network for target detection in railway scenes; Step 3.1: Feature extraction network design Firstly, in order to adapt to the application of network models in train embedded devices, an improved GhostNet network structure is introduced, and linear operations are used to generate feature maps. In order to achieve lightweight network, the depth-separable convolution GhostConv convolution module is used to replace the original ordinary convolution layer. In order to accurately obtain the detailed information of the feature map and separate the multi-scale local feature information, 1×1 is used to achieve deeper feature extraction, and then the output data is divided into several groups of features, which are linearly transformed through a 5×5 convolution kernel to extract the features at a deeper level, and the transformation results are stacked and merged for output. The network balances the grouping effect and the number of convolutions by means of group convolution. Secondly, add GC-Block based on GhostNet; Next, use the activation function Mish to replace the original ReLU in GhostNet; Finally, the SPP structure is added between the feature extraction network and the feature fusion network to perform pooling operations on the input feature maps at different scales to capture the features of objects at different sizes. The maximum pooling of 1×1, 5×5, 13×13 and 26×26 is selected to increase the receptive field of the feature map and enhance the model's detection ability for objects of different scales. Finally, the above modules are spliced together to form a feature extraction network; Step 3.2: Feature fusion network BiFPN; Bi-directional feature pyramid network BiFPN, which integrates the characteristics of FPN, PANet and NAS-FPN, adds additional bottom-up paths and cross paths based on neural structure search to form a weighted bi-directional feature pyramid network based on the top-down unidirectional information of FPN. This bi-directional feature pyramid network introduces learnable weights to learn the importance of different input features, and repeatedly applies multi-scale feature fusion from top to bottom and bottom to top. The weights are learned during the feature fusion process; BiFPN adopts a fast normalized feature fusion method, as shown in formula (12): This process is regarded as an optimization method using unrestricted fusion and softmax function fusion, where w i Representation feature I i The corresponding weights are ensured to be greater than or equal to 0 through ReLU, and then through I i The left side of the formula is normalized to between 0 and 1, and the denominator ∈ is taken as 0.0001; The process of BiFPN is as follows: First, a mathematical formula is used to describe the fusion of multi-scale features. Given a series of features of different scales, the input-output relationship is shown in equations (13) and (14). in Represents the features of different scales, as shown in formula (15): in, The resolution of the feature is the input image resolution After feature fusion, as shown in formula (16), Where Conv represents the convolution operation, and Resize usually represents the upsampling or downsampling operation. Finally, BiFPN combines the bidirectional cross-scale connection and the fast normalization fusion method, which is given by equations (17) and (18): in Indicates the output of a node at level 6. It is the output of the second node of level 6. When performing feature fusion, the convolution operation uses depthwise separable convolution, and each convolution layer is followed by a BatchNormalization and activation function layer. Step 3.3: CIoU loss function; The calculation method of CIoU is as follows. First, the expressions of IoU and CIoU are given as shown in equations (19) and (20). Among them, A and B represent the real box and the predicted box respectively, ρ 2 (b,b gt ) represents the Euclidean distance between the predicted box and the midpoint of the real box, and C is the diagonal length of the minimum bounding box between the predicted box and the real box. At the same time, the loss of the detection box scale is also added to the calculation of CIoU, that is, its width and height are included in the calculation. The specific implementation method is to add a correction term after CIoU. The specific calculation method is shown in formulas (21) and (22). Finally, the loss function formula of CIoU is given, as shown in Formula 23; Step 4: Model pruning operation; The model compression method adopted uses the γ parameter in the BN layer, an essential component of the convolutional neural network, to achieve end-to-end learning and pruning; at the same time, L1 regularization is applied to the scaling factor γ of the BN layer. Through sparse training, the scaling factor γ of the BN layer corresponding to the parameters that have little effect on train detection is made to tend to 0; since each scaling factor γ is associated with a specific convolution channel or a neuron in the fully connected layer, unimportant channels are automatically identified, and then these channels and layers below the threshold are deleted; the γ parameter of the BN layer is directly used to identify whether a channel of the output feature map of the previous Conv layer is important, and no additional expenses are incurred during this period.
2. The foreign body intrusion detection method applicable to a railway environment according to claim 1, It is characterized in that Data enhancement is used to enrich railway foreign body intrusion samples. The MixUp method is used to create new training samples by linearly combining the input and labels of two or more samples. For the input data X and the corresponding category label Y, MixUp generates new samples through the following formula, as shown in equations (1) and (2): Mixup(X 1 ,X 2 ,λ)=λ·X 1 +(1-λ)·X 2 (1) Mixup(Y 1 ,AND 2 ,λ)=λ·Y 1 +(1-λ)·Y 2 (2) Among them, X 1 ,X 2 are two input samples, Y 1 ,Y 2 is the corresponding category label of the first two station images, λ is a random number between 0 and 1; and Mixup(X 1 ,X 2 ,λ) is the new sample image generated by MixUp operation. Correspondingly, Mixup(Y 1 ,Y 2 ,λ) is the category label in the new sample; for image data, a new image is generated by linearly interpolating the pixel values of the image.
3. The foreign body intrusion detection method applicable to a railway environment according to claim 1, It is characterized in that Using the big model and AIGC technology, we can generate sample images in the railway environment using the famous Diffusion Model. The Diffusion Model has two processes. The first is the forward process, which is the process of adding noise to the image. The original image x is given in the form of probability distribution. 0 , x 0 ~q(x), the model forward process adds Gaussian noise to it by T times cumulatively to obtain a new image x 1 ,x 2 ,…,x T , given a series of Gaussian distribution hyperparameters Since each moment t in the forward process is only related to the previous moment t-1, it is considered a Markov process, as shown in equations (3) and (4): Among them, (3) represents the process of adding noise to the image for each x t is a is the mean, β t is obtained by Gauss distribution of variance; as t increases, x t It is getting closer and closer to pure noise; when T→∞, x T is a complete Gauss noise, and in practice β t As t increases, it increases, that is, β 1 <β 2 <…<β T ; Then, (4) represents the process of generating the image, where Use standard normal distribution; since the noise added at each step is independent and obeys normal distribution, let α t =1-β t So the final image x t From the original picture x 0 Given by (5), Among them, the addition of normal distributions is still a normal distribution, so ∈ t-1 is unified with ∈ and is denoted as ∈, so (5) continues to derive, Since the noise at each step is independently distributed, by iterating one step forward, we finally get: in, The reverse process is the denoising inference process of Diffusion. If we can gradually obtain the reversed distribution q(x t-1 |x t ), we can completely get the standard Gauss distribution x T ~N(0,I) restores the original distribution, but cannot derive q(x t-1 |x t ), use the deep learning model to predict the reverse distribution; the reverse denoising process is a reverse process: after the model is trained, sample and generate images; that is, train a neural network U-Net, start from pure noise and gradually denoise until a real image is obtained; use a neural network with parameters to calculate its reverse process p θ (x t-1 |x t ), described as: Although it is impossible to obtain the reversed distribution q(x t |x t-1 ), and obtain q(x by using the Bayes formula at each step t-1 |x t ,x 0 ), In essence, q(x t-1 |x t ,x 0 ) still follows a normal distribution, where: Mean variance However, in formula (10), the x on the right side of the equation is 0 is the target image to be generated, i.e. the target solution, and the model is trained to obtain parameters to fit the target image; The last step is the training phase of the Diffusion model, which constructs a new standard normal probability distribution p(x t-1 |x t ), the goal is to narrow the gap between this distribution and formula (10), so that its variance and posterior distribution q(x t-1 |x t ,x 0 ) are consistent, and their mean is set to in, It is predicted by a deep learning model whose input is a noisy image x t With time step t, p(x t-1 |x t ) is written as The final objective function is written as in The simplified objective function is shown in formula (11):
4. The foreign body intrusion detection method applicable to a railway environment according to claim 1, It is characterized in that The implementation process of step 2 is as follows: 1) Input: In order to reduce input training parameters and speed up the training and reasoning process, all images will be scaled to a size of 640×640 by default; 2) Feature extraction network: Introduce the improved GhostNet as the feature extraction network; 3) Feature fusion network: After feature extraction, the extracted features need to be fused and spliced; Introduce BiFPN feature fusion network to complete feature fusion; 4) Detection head: The detection head consists of a series of convolutional layers and a subsequent fully connected layer, which is responsible for generating bounding box predictions and class probabilities for target detection. The detection process will complete object detection based on three anchors of different scales. When the input image is 608×608, the feature maps of different scales are 76×76, 38×38, and 19×19. In this step, non-maximum suppression (NMS) is used to filter out redundant bounding boxes and select the most confident bounding box as the final detection. In addition, CIoU is introduced as the position loss function for training.
5. The foreign body intrusion detection method applicable to a railway environment according to claim 1, It is characterized in that Cropping and compression is divided into the following 5 steps: Step 1: Initialize the network and perform basic network training; Step 2: Add channel sparse penalty term to compress the γ coefficient of BN layer; Step 3: After the γ of most BN layers approaches 0, the channels are deleted by setting the threshold; Step 4: Since the accuracy will decrease after deleting some channels, the network is fine-tuned and retrained after achieving the ideal pruning result; Step 5: If the ideal accuracy is restored, the model compression ends; Otherwise continue; After the basic training reaches the ideal accuracy, the sparse training of the model is carried out to reduce the weight parameter value of unimportant neurons to 0; after the basic training, the γ of the BN layer basically obeys the normal distribution, and the transformation formula of the BN layer is shown in equations (24) and (25); In formula (7), μ B and Represent the mean and variance of a feature map respectively, and update the scaling factor γ and shift factor β through back propagation, z in and z out represent the input and output of the BN layer respectively; L1 regularization is applied to the scaling factor γ to penalize it so that its value tends to be 0; at this time, the objective function is finally designed as (26), Among them, the first item is the training loss function of the CNN network, x and y represent the input and target of the training respectively, W represents the training weight parameter, g(.) is the penalty term on the scaling factor, and λ is the balance factor for adjusting these two items; L1 regularization, that is, g(s) = |s|, is used for sparsification; during the sparse training process, continuous debugging is performed to find the sparse parameters suitable for the specified training set until most of the γ values of the BN layer are gradually compressed to close to 0.
Citation Information
Cited By
Power transmission line foreign matter detection method based on YOLOv9 and diffusion model
CN118799563A
Foreign object detection method for transmission lines based on YOLOv9 and diffusion model
CN118799563B
