[System & Source Code] Rail train dangerous area intrusion alarm system: Improved YOLOv7

1.Research background

The development of high-speed railways has brought great convenience. While the railway industry is developing rapidly, railway safety issues also deserve attention. The existing railway safety in China mainly relies on a combination of video surveillance and manual inspection. Because China's railway tracks are complex and widely distributed, trains travel at high speeds. At the same time, staff lack professionalism, operate improperly, and are careless. However, my country's railway network is large-scale, and it is difficult to judge whether there are illegal intrusions and stays on all lines through manual detection. Therefore, in order to improve railway safety and reliability while saving labor costs, the track video surveillance system urgently needs comprehensive technical upgrades and large-scale application. However, traditional algorithms often have problems such as poor real-time performance and low accuracy.

2. Picture demonstration

1.png

2.png

3. Video demonstration

Improved YOLOv7's rail train dangerous area intrusion alarm system (system & source code)_bilibili_bilibili

4. Current research status at home and abroad

In recent years, the development and widespread application of high-speed rail technology in the world has made railway traffic safety not only a problem for our country, but a problem for the world, especially for developed countries with advanced railway technology, led by Europe, the United States, and Japan. nation. Countries are also paying more and more attention to railway safety issues, and the financial, material and human resources devoted to railway safety are also increasing year by year. With the modernization and intelligent construction of cities, various countries are currently seeking technological breakthroughs and fundamental innovations in railway safety. Developed countries have built railway operation guarantee systems based on Railway Intelligent Transportation System. The development of railway safety towards intelligence and efficiency has become an inevitable trend.
As a close neighbor of China and a developed country in Asia, Japan is also the first country in the world to build practical high-speed rail and conduct commercial operations. Its system construction and technical support in the direction of high-speed rail safety are also worthy of our reference and study. Although Japan is a small country, it is an island country with complex terrain and is in an earthquake zone, making it an earthquake-prone area. However, Japan's high-speed railway "Shinkansen" is world-famous for its safety. It has never happened since it was built in 1964. experienced major passenger safety incidents. Therefore, Japan’s railway safety technology is worthy of our study and research. The foreign object detection technology used in Japan is mainly distributed optical cable monitoring technology15], which is composed of several sensors. When the optical cable sends out a signal and propagates outward through regional nodes, the signal is attenuated during the propagation process. Finally, the attenuated signal passes through The optical cable returns to the light source. When there is a foreign object in the detection area, the signal attenuation amplitude will change. Finally, the attenuation amplitude of the return signal is used to determine whether there is a foreign object. If there are foreign objects, the system will also evaluate the hazard level of the foreign objects. When a certain standard is reached, the system will immediately alarm and control the train speed to avoid disasters and ensure railway safety.
The vast land area of ​​the United States and the nationwide railway network are highly similar to China’s railway situation. The United States also has relatively good responses to railway safety issues. Its developed economy and advanced science and technology have provided guarantees for U.S. traffic safety. Therefore, the American railway safety system also has important reference value for my country's railway safety construction. The United States has also invested considerable costs in railway safety. It has divided the safety detection system into many modules and consists of many sensors. When there is a foreign object intrusion limit, many sensors will feedback the sensed information to the system, and the system will perform fusion calculations based on the feedback information. When it is judged that there is a safety hazard, the system will automatically convey the alarm to the monitoring room and the video surveillance module will mobilize the road section. of video surveillance, with further measures decided manually.
image.png

5. Research content of this article

This article proposes a method for detecting obstacles in dangerous areas of tracks based on the improved YOLOv7 network, which includes shooting and obtaining video information of the track in front of the train, cutting out the key parts containing obstacles in the video, and filtering and cutting out the key part pictures as sample images. , used to establish a data set for obstacle detection in dangerous areas of railway tracks; perform data enhancement processing on the obtained sample images, and divide the obtained data set into a training set and a test set; build a model for obstacle detection in dangerous areas of railway tracks, features The training set prepared by extracting the network model is trained using a convolutional neural network to detect whether the obstacles are in the dangerous area of ​​​​the track, and whether there are obstacles in the dangerous area by judging whether they overlap. The invention can realize intelligent detection of obstacles in dangerous areas of train tracks, has high accuracy, low false detection rate, fast detection speed, good real-time performance, and has broad application potential.

6.YOLOv7 algorithm

YOLO is the abbreviation of You Only Look Once. The network structure of YOLO is similar to CNN, consisting of convolutional layer, pooling layer and fully connected layer. But unlike CNN, the output layer of YOLO is no longer a Softmax function, but a tensor. As can be seen from the RCNN and FAST RCNN introduced earlier, in order to obtain candidate frames that may contain objects, rcnn and fast renn use a selective search method that is independent of the network to separate modules. The training process is therefore divided into multiple modules. The detection process is divided into two parts: classification problem and regression problem. These steps of YOLO are completely carried out in an independent network. In the process of obtaining candidate areas, YOLO also transforms the detection problem into a regression problem to solve. Since YOLO's model is a separate end-to-end network, the network can detect the location of the object and the category of the object by inputting the image once.
image.png

7. YOLOv7 algorithm improvement

Convolutional neural networks (CNN) have achieved great success in many computer vision tasks such as image classification and object detection. However, their performance drops rapidly on more difficult tasks where the image resolution is low or the objects are small. In this paper, we show that this stems from the flawed but common design in existing CNN architectures, namely the use of strided convolution and/or pooling layers, which leads to the loss of fine-grained information and the detection of less effective features. Learning of representations. To this end, we propose a new CNN building block called SPD-Conv to replace each strided convolutional layer and each pooling layer (thus eliminating them completely). SPD-Conv consists of spatial-to-depth (SPD) layers followed by non-stride convolution (Conv) layers and can be applied to most (if not all) CNN architectures. We explain this new design under two of the most representative computer vision tasks: object detection and image classification. We then create new CNN architectures by applying SPD-Conv to YOLOv5 and ResNet, and empirically demonstrate that our method significantly outperforms state-of-the-art deep learning models, especially in higher resolution images with low-resolution images and small objects. On the difficult task.
image.png

Module structure

image.png

Space to Depth (SPD)

OurSPD component generalizes a (raw) image transformation technique [sajjadi2018frame] to characterize features within and across CNNs The graph is downsampled as shown below.
Consider any intermediate feature map X of size S×S×C1, cut a series of sub-feature maps into
f0,0=X[0:S :scale, :0S:s cale], f1,0=X[1: S cale, 0:S::SCALE],…,
fscale−1,0=X[scale− 1: S s c ale, 0:S:: s cale];
f0,1=X[0:S:scale, :1S:cale], f1,1,…, a>
fscale−1,1=X[scale−1: S s c ale, 1:S:: s cale];
f0,scale−1⋮ =X[ 0:S: s c a l e,scal e−1:S:SCALE],,f1,scale−1…,
fscale−1,scale−1=X[scale−1:S: s c a l e ,scal e−1:S:cale].
In general, given any (original) feature map X, a submap fx,y formed by all entries X(i,j) i+x and j+y is divisible by scale. Therefore, Each submap downsamples samples of X by a factor of scale. Figure4 (a) (b) (c) gives an example. When scale=2, we get four sub-mappings f0,0, f1,0,,f0,1,f1,1 each have shape (S2, S2, C1) and reduce the sampling rate of X by 2 times.
Next, we connect these sub-feature maps along the channel dimension to obtain a feature map X′ whose spatial dimension is reduced by scale and the channel size is increased by ScaLe2 multiples. In other words, SPD transforms the feature map X(S,S,)C1 into the intermediate feature map X′(Sscale,Sscalescale2C1).
YOLOv5-SPD. We apply the method described in Section 3 to YOLOv5 and obtain YOLOv5-SPD (Fig. 5), simply replace the YOLOv5 stride 2 convolution with our SPD-Conv building block. This replacement has 7 instances because YOLOv5 uses five stride-2 convolutional layers in the backbone to downsample the feature maps25, and two stride-2 convolutional layers in the neck. There is a connected layer after each strided convolution in the YOLOv5 neck; this does not change our approach, we just keep it between SPD and Conv.

Scalability. YOLOv5-SPD can be easily scaled up and down to meet different application or hardware needs in the same way as YOLOv5. Specifically, we can simply adjust (1) the number of filters in each non-stride convolutional layer and/or (2) the number of repetitions of the C3 module (as shown in the figure5< /span> is shown, where the selection of factor values ​​is the same as YOLOv5 for comparison in our later experiments. 2) to obtain different versions of YOLOv5-SPD. The first is called width scaling, which changes the original width nw (number of channels) to ⌈nw×width_factor⌉8 (rounded to the nearest multiple of 8). The second is called depth scaling, which scales the original depth nd (the number of times the C3 module is repeated; for example, the 9 9) Change to ⌈nd×dep t h_factor⌉. In this way, by choosing different width/depth factors, we obtain nano, small, medium and large versions of YOLOv5-SPD, as shown in Table

8. Core code implementation

class space_to_depth(nn.Module):
    # Changing the dimension of the Tensor
    def __init__(self, dimension=1):
        super().__init__()
        self.d = dimension

    def forward(self, x):
         return torch.cat([x[..., ::2, ::2], x[..., 1::2, ::2], x[..., ::2, 1::2], x[..., 1::2, 1::2]], 1)
......

9. System integration

The complete source code & environment deployment video tutorial & data set & custom UI interface shown below:
1.png
Reference blog "Improving the Danger of Rail Trains in YOLOv7 Regional intrusion alarm system (system & source code)》

Guess you like

Origin blog.csdn.net/cheng2333333/article/details/135018368