Railway foreign matter invasion small target detection method and system based on improved YOLO-v5s model

By improving the YOLO-v5s model and using Focal EIOU loss function, M-SimAM attention mechanism and dynamic detection head DyHead, the accuracy and speed problems of small target detection in railway scenes are solved, achieving high accuracy and low false alarm rate. Foreign object intrusion detection.

CN118628713APending Publication Date: 2024-09-10SHANGHAI INST OF TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410701689.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In complex railway scenarios, it is difficult for traditional detection methods to accurately identify small target foreign objects, resulting in a high missed detection rate, and the existing technology is insufficient in speed and accuracy when detecting small targets.

Method used

By improving the YOLO-v5s model, the Focal EIOU loss function, M-SimAM attention mechanism and dynamic detection head DyHead are used to enhance the model's performance in small target detection.

Benefits of technology

It significantly improves the accuracy and speed of small target detection, reduces the false alarm rate, and is suitable for foreign object intrusion detection in complex railway environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628713A
    Figure CN118628713A
Patent Text Reader

Abstract

The invention discloses a railway foreign matter invasion small target detection method and system based on an improved YOLO-v5s model. The method comprises the following steps: acquiring and constructing a data set of railway foreign matters with labels; a CIOU loss function in the YOLOv5s model is modified into a Focal EIOU loss function; the YOLOv5s model is improved, and an improved non-parametric attention mechanism M-SimAM module is added behind the SPPF module; replacing a detection head part of the YOLOv5s model with a dynamic detection head DyHead; and detecting the attempt image to be detected, and evaluating the detection result. According to the method, the detection precision of the model can be improved, the feature extraction capability is enhanced, and the safety and monitoring capability of a railway system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a method and system for detecting small targets of railway foreign object intrusion based on an improved YOLO-v5s model. Background Art

[0002] In 2023, the length of global rail transit lines will reach 1.1527 million kilometers. Railways play an increasingly important role in supporting economic development. The huge railway transportation network has promoted the development of the country's economy and society, but the resulting safety issues have become the focus of social attention and the key to the development of high-speed railways. Therefore, the automation and intelligence of high-speed railway safety monitoring systems and abnormal situation detection methods are of great significance to ensuring the safe operation of high-speed railways. With the trend of higher and higher carrying capacity and faster and faster operating speeds, foreign body intrusion is more likely to cause irreversible damage.

[0003] At present, target detection algorithms can be divided into two categories: two-stage detection algorithms and one-stage detection algorithms. Two-stage detection algorithms include convolutional neural networks, CNN, and R-CNN, which generate candidate boxes containing potential targets and then use regional classifiers to predict them. One-stage detection algorithms, such as SSD and YOLO series, directly classify and predict the target at each position on the feature map, with faster detection speed and stronger practicality.

[0004] There are two main methods for railway intrusion detection: contact detection and non-contact detection. Contact detection requires a lot of hardware support, is troublesome to install, and is not suitable for large-scale use. Computer vision is an effective non-contact intrusion detection method. With the development of deep learning algorithms, it can achieve high detection accuracy and low false alarm rate to a certain extent. However, in railway foreign object intrusion detection, small target detection has always been a technical difficulty due to its small size, low contrast, and easy background interference. Traditional detection methods often have difficulty in accurately identifying these small targets, resulting in a high missed detection rate. Therefore, in complex railway scenarios, a railway intrusion detection method with high accuracy, low false alarm rate, and fast speed is needed. Summary of the invention

[0005] The purpose of this section is to summarize some aspects of embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.

[0006] In view of the above existing problems, the present invention is proposed. Therefore, the present invention provides a railway foreign object intrusion small target detection method based on an improved YOLO-v5s model to solve the problem of how to detect railway intrusion with high accuracy, low false alarm rate and high speed.

[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0008] In a first aspect, the present invention provides a method for detecting small targets of railway foreign body intrusion based on an improved YOLO-v5s model, comprising:

[0009] Acquire and construct a dataset of railway foreign objects with annotations;

[0010] The CIOU loss function in the YOLOv5s model is modified to the Focal EIOU loss function to balance the weights of different target sizes;

[0011] Improve the YOLOv5s model by adding an improved non-parametric attention mechanism M-SimAM module after the SPPF module to process channel or spatial features at the same time;

[0012] Replace the detection head of the YOLOv5s model with the dynamic detection head DyHead to dynamically adjust the feature representation of target detection;

[0013] Based on the improved YOLOv5s model, a small target detection model for railway foreign object intrusion is obtained, the detection image is detected, and the detection results are evaluated.

[0014] As a preferred solution of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model described in the present invention, obtaining and constructing a data set of railway foreign objects with annotations includes:

[0015] Obtain railway foreign body dataset and create foreign body labels using labelme;

[0016] The prepared foreign body number labels are subjected to data enhancement, and the data enhancement includes rotation, translation, mirroring, image brightness transformation and Gaussian blur processing.

[0017] As a preferred solution of the railway foreign body intrusion small target detection method based on the improved YOLO-v5s model described in the present invention, wherein: constructing the data set also includes:

[0018] Label the railway foreign body dataset and divide it into image dataset files and image corresponding label files;

[0019] Classify the labeled data set, including pedestrians, animals, debris flow, falling rocks, and rolling logs;

[0020] The processed data set is preprocessed and divided into training set, validation set and test set in a ratio of 7:1:2. Data enhancement is performed through rotation, translation, mirroring, image brightness transformation and Gaussian blur to increase the number of training samples.

[0021] As a preferred solution of the railway foreign body intrusion small target detection method based on the improved YOLO-v5s model described in the present invention, the Focal EIOU loss function is expressed as:

[0022] L Focal-EIOU =IOU γ L EIOU

[0023]

[0024] Among them, γ is a hyperparameter used to control the curve, L IOU represents the IOU loss, L dis Represents the distance loss, L asp is the edge length loss, ρ 2 (b,b gt ) represents the center coordinates b of the predicted box and the center coordinates b of the real box gt The Euclidean distance between 2 (w,w gt ) represents the width w of the prediction box and the width w of the solid line box gt The square of the difference, ρ 2 (h,h gt ) represents the height h of the predicted box and the height h of the real box gt The square of the difference, c w and c h They represent the width and height of the minimum bounding rectangle of the prediction box and the target box respectively, and c represents the diagonal length of the minimum bounding rectangle.

[0025] As a preferred solution of the railway foreign body intrusion small target detection method based on the improved YOLO-v5s model described in the present invention, the M-SimAM module includes:

[0026] The mish activation function is introduced to replace the sigmoid activation function in the SimAM module to generate a new M-SimAM module. The feature map calculation of the M-SimAM attention mechanism is expressed as:

[0027]

[0028] Among them, X represents the original eigenvalue input to the M-SimAM module, Represents the feature output value after enhancement by the M-SimAM module.

[0029] As a preferred solution of the railway foreign body intrusion small target detection method based on the improved YOLO-v5s model described in the present invention, the dynamic detection head DyHead includes:

[0030] Modify the detection head of the YOLOv5s model to a dynamic detection head DyHead, and introduce an attention mechanism on each specific dimension of the feature tensor, that is, give a three-dimensional feature tensor F∈R on the detection layer L×S×C , the attention function of the dynamic detection detection head is expressed as:

[0031] W(F)=π C (π S (π L (F)·F)·F)·F

[0032] Among them, π L (·),π S (·),π C (·) represent three different attention functions applied on dimensions L, S, and C respectively.

[0033] As a preferred solution of the railway foreign body intrusion small target detection method based on the improved YOLO-v5s model described in the present invention, the detection and evaluation include:

[0034] Configure environment variables, set epoch to 300, batch size to 16, and image size to 416*416;

[0035] Train the railway foreign body intrusion small target detection model, and detect the image to be detected to obtain the detection result;

[0036] Based on the detection results, the evaluation index mAP is obtained by calculating the average precision of the model at the IoU threshold, which is expressed as:

[0037]

[0038]

[0039] Among them, p represents precision, R represents recall, TP represents the number of positive classes that are actually predicted to be positive, FP represents the number of negative classes that are actually predicted to be positive, and FN represents the number of negative classes that are actually predicted to be positive.

[0040] In a second aspect, the present invention provides a railway foreign object intrusion small target detection system based on an improved YOLO-v5s model, comprising:

[0041] The collection module is used to obtain and construct a dataset of railway foreign objects with annotations;

[0042] The first improvement module is used to modify the CIOU loss function in the YOLOv5s model to the Focal EIOU loss function, which balances the weights of different target sizes;

[0043] The second improvement module is used to improve the YOLOv5s model, adding an improved non-parametric attention mechanism M-SimAM module after the SPPF module, and processing channel or spatial features at the same time;

[0044] The third improvement module is used to replace the detection head of the YOLOv5s model with the dynamic detection head DyHead to dynamically adjust the feature representation of target detection;

[0045] The evaluation module is used to obtain a railway foreign object intrusion small target detection model based on the improved YOLOv5s model, detect the image to be detected, and evaluate the detection results.

[0046] In a third aspect, the present invention provides an electronic device, comprising:

[0047] Memory and processor;

[0048] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model are implemented.

[0049] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, can implement the steps of the method for detecting small targets of railway foreign object intrusion based on the improved YOLO-v5s model.

[0050] Compared with the prior art, the present invention has the following beneficial effects: the present invention aims at the problem of slow network convergence and low regression accuracy when identifying small sample foreign bodies. The present invention introduces the Focal EIoU loss function. Compared with CIoU, the EIoU loss function has a faster calculation speed and is more suitable for processing small target frames and overlapping occluded target frames, which is particularly beneficial for small target detection. In addition, in the regression process, Focal loss focuses more on high-quality anchor frames, thereby further improving the detection performance; in order to solve the problem of failing to capture key information when identifying small sample foreign bodies, the present invention introduces the M-SimAM module based on the non-parametric attention mechanism SimAM and integrates it into the backbone network. The module is used to highlight the key information in the current task, reduce or filter the interference of other irrelevant information, thereby improving the detection performance; in order to solve the problem of serious loss of feature information after multiple downsampling of the feature map, the present invention introduces the replacement of the target detection head of the original model with a detection head (Dynamic Head, DyHead) with a self-attention mechanism, thereby improving the representation ability of the model detection layer and allowing the detection head to have a stronger representation ability, thereby improving the detection effect of the algorithm on small target foreign bodies. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:

[0052] Figure 1 It is a schematic diagram of the overall process of a method for detecting small targets of railway foreign body intrusion based on an improved YOLO-v5s model according to an embodiment of the present invention;

[0053] Figure 2 A schematic diagram of the structure of a conventional YOLO-v5s model of a railway foreign object intrusion small target detection method based on an improved YOLO-v5s model according to an embodiment of the present invention;

[0054] Figure 3 A schematic diagram of the structure of a SimAM module of a railway foreign object intrusion small target detection method based on an improved YOLO-v5s model according to an embodiment of the present invention;

[0055] Figure 4 A schematic diagram of the structure of a Dyhead module of a railway foreign body intrusion small target detection method based on an improved YOLO-v5s model according to an embodiment of the present invention;

[0056] Figure 5The schematic diagram of the improved YOLO-v5s model structure of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model described in an embodiment of the present invention. DETAILED DESCRIPTION

[0057] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in the art without creative work should fall within the scope of protection of the present invention.

[0058] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0059] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0060] The present invention is described in detail with reference to schematic diagrams. When describing the embodiments of the present invention, for the sake of convenience, the cross-sectional diagrams showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the scope of protection of the present invention. In addition, in actual production, the three-dimensional dimensions of length, width and depth should be included.

[0061] At the same time, in the description of the present invention, it should be noted that the directions or positional relationships indicated by the terms "upper, lower, inner and outer" are based on the directions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as limiting the present invention. In addition, the terms "first, second or third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0062] In the present invention, unless otherwise clearly specified and limited, the terms "install, connect, connect" should be understood in a broad sense, for example: it can be a fixed connection, a detachable connection or an integral connection; it can also be a mechanical connection, an electrical connection or a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0063] Example 1

[0064] Reference Figure 1-Figure 5 , which is an embodiment of the present invention, provides a railway foreign object intrusion small target detection method based on an improved YOLO-v5s model. By replacing the CIOU loss function used by the YOLO-v5s model with the Focal EIOU loss function, the detection accuracy of the model is increased. At the same time, an improved non-parametric attention mechanism module M-SimAM is added after the SPPF module to enhance the feature extraction capability. In addition, the detection head of the YOLO-v5s model is replaced with a dynamic detection head DyHead to dynamically adjust the feature representation of target detection. Finally, the image to be detected is detected by the modified railway foreign object intrusion small target detection model to obtain the detection result.

[0065] like Figure 1 As shown, the method of the present invention comprises:

[0066] S100, obtaining and constructing a dataset of railway foreign objects with annotations;

[0067] Furthermore, the specific steps of S100 are as follows:

[0068] Obtain railway foreign body dataset and create foreign body labels using labelme;

[0069] The prepared foreign body number labels are subjected to data enhancement, which includes rotation, translation, mirroring, image brightness transformation and Gaussian blur processing.

[0070] Specifically, the image rotation formula is expressed as:

[0071]

[0072] Where (x, y) represents the coordinates of the pixel in the original image, (x', y') represents the coordinates of the pixel in the output image after the corresponding pixel (x, y) is rotated, and θ is the rotation angle.

[0073] The image translation formula is specifically expressed as:

[0074]

[0075] Where (x0, y0) is the translation of the image along the x-axis and y-axis;

[0076] The image vertical mirror transformation formula is specifically expressed as:

[0077]

[0078] The image horizontal mirror transformation formula is specifically expressed as:

[0079]

[0080] Where N and M represent the length and width of the image, respectively, (x, y) is the original image coordinate, and (x', y') is the transformed coordinate;

[0081] The image brightness conversion formula is specifically expressed as:

[0082] g(x',y')=af(x,y)+β

[0083] Where f(x,y) is the original image pixel, g(x',y') is the output image pixel, x and y represent the pixel located in the xth row and yth column, and the parameters a>0 and β are the gain and bias parameters, which control the contrast and brightness respectively;

[0084] The Gaussian blur transformation formula is specifically expressed as:

[0085]

[0086] Where r is the blur radius and σ is the standard deviation of the normal distribution.

[0087] Furthermore, constructing the dataset also includes:

[0088] Label the railway foreign body dataset and divide it into image dataset files and image corresponding label files;

[0089] Classify the labeled data set into categories including pedestrians, animals, debris flow, falling rocks, and rolling logs;

[0090] The processed data set is preprocessed and divided into training set, validation set and test set in a ratio of 7:1:2. Data enhancement is performed through rotation, translation, mirroring, image brightness transformation and Gaussian blur to increase the number of training samples, thereby effectively improving model performance.

[0091] S200, the CIOU loss function in the YOLOv5s model is modified to the Focal EIOU loss function, which balances the weights of different target sizes;

[0092] It should be noted that the CIoU loss function is replaced by a more effective loss function, Focal EIoU, which replaces the CIoU loss function to improve the small object detection performance. Based on EIOU, Focal EIOU combines Focal loss to focus on better anchor boxes, thereby significantly improving the accuracy of detecting small objects.

[0093] Furthermore, the Focal EIOU loss function is expressed as:

[0094] L Focal-EIOU =IOU γ L EIOU

[0095]

[0096] Among them, γ is a hyperparameter used to control the curve, L IOU represents the IOU loss, L dis Represents the distance loss, L asp is the edge length loss, ρ 2 (b,b gt ) represents the center coordinates b of the predicted box and the center coordinates b of the real box gt The Euclidean distance between 2 (w,w gt ) represents the width w of the prediction box and the width w of the solid line box gt The square of the difference, ρ 2 (h,h gt ) represents the height h of the predicted box and the height h of the real box gt The square of the difference, c w and c h They represent the width and height of the minimum bounding rectangle of the prediction box and the target box respectively, and c represents the diagonal length of the minimum bounding rectangle.

[0097] S300, improves the YOLOv5s model, adds an improved non-parametric attention mechanism M-SimAM module after the SPPF module, and processes channel or spatial features at the same time;

[0098] It should be noted that the M-SimAM module can help the network extract features and improve the detection performance of small objects without adding other parameters. SimAM is a 3D attention module. Its core idea is to use a similarity-based weighted method to focus attention on the most relevant parts. The mish activation function is introduced to replace the sigmoid activation function in SimAM. Due to its smoothness and better gradient performance, the mish activation function can enhance the model's ability to detect small objects and avoid problems such as gradient vanishing or gradient exploding, thereby improving the accuracy and stability of the model.

[0099] Furthermore, the mish activation function is introduced to replace the sigmoid activation function in the SimAM module to generate a new M-SimAM module. The feature map calculation of the M-SimAM attention mechanism is expressed as:

[0100]

[0101] Among them, X represents the original eigenvalue input to the M-SimAM module, Represents the feature output value after enhancement by the M-SimAM module.

[0102] S400, replaces the detection head of the YOLOv5s model with the dynamic detection head DyHead to dynamically adjust the feature representation of target detection;

[0103] It should be noted that in the YOLOv5s model, the backbone network outputs a three-dimensional tensor, which contains horizontal information, spatial information, and channel information about the object. In order to enhance the perception ability of the model, the detection head of the YOLOv5s model is replaced with a dynamic detection head DyHead (Dynamic Head). DyHead can introduce an attention mechanism on each specific dimension of the feature tensor, thereby achieving the unification of scale perception, spatial perception, and task perception.

[0104] Specifically, the dynamic detection head DyHead includes:

[0105] Modify the detection head of the YOLOv5s model to a dynamic detection head DyHead, and introduce an attention mechanism on each specific dimension of the feature tensor, that is, give a three-dimensional feature tensor F∈R on the detection layer L×S×C , the attention function of the dynamic detection detection head is expressed as:

[0106] W(F)=π C (π S (π L (F)·F)·F)·F

[0107] Among them, π L (·),π S (·),π C (·) represent three different attention functions applied on dimensions L, S, and C respectively. These three attention functions are applied sequentially to detect the head and can be superimposed multiple times.

[0108] S500, based on the improved YOLOv5s model, obtains the railway foreign object intrusion small target detection model, detects the detection image, and evaluates the detection results.

[0109] Specifically, configure environment variables, set epoch to 300, batch size to 16, and image size to 416*416;

[0110] Train the railway foreign body intrusion small target detection model, and detect the image to be detected to obtain the detection result;

[0111] The evaluation is based on the detection results. The evaluation index involved is mAP@0.5:0.95. The evaluation index mAP is obtained by calculating the average accuracy of the model at the IoU threshold, which is expressed as:

[0112]

[0113]

[0114] Among them, mAP represents mean average precision, p represents precision, R represents recall, TP represents the number of positive classes predicted as positive classes, FP represents the number of negative classes predicted as positive classes, and FN represents the number of negative classes predicted as negative classes. Preferably, the IoU threshold range is [0.5, 0.95].

[0115] It should be noted that in this embodiment, the CIOU loss function used by the YOLOv5s model is replaced by the Focal EIOU loss function in step S200. The Focal EIOU loss function takes into account the aspect ratio of the length and width of the target box when calculating the distance, so that it can better handle target boxes of different sizes and perform more balanced weighting of different target sizes in the loss function. In addition, Focal EIOU uses a more efficient calculation method for the distance between target boxes, making the network model more effective when training small targets. The focal spot loss gives targets of rare categories a greater weight, making it more sensitive to small target detection. By introducing a balancing factor, the problem of category imbalance can be alleviated to a certain extent. Based on EIOU, FocalEIOU combines Focal loss to focus on better anchor boxes, thereby significantly improving the accuracy of detection.

[0116] In step S300, an improved non-parametric attention mechanism module M-SimAM is added after the SPPF module, aiming at the problem that most existing attention mechanisms can only focus on one-dimensional features of channels or spaces and lack the flexibility of processing space and channels at the same time. The present invention proposes an M-SimAM module based on the non-parametric attention mechanism module SimAM. The module can help the network extract features without adding other parameters and improve the detection performance of small targets. M-SimAM is a 3D attention module, and its core idea is to focus attention on the most relevant parts using a similarity-based weighting method. M-SimAM calculates attention weights by designing an energy function. Most of its operations are solutions based on energy functions, which can flexibly and effectively enhance the extraction of features in neural networks. The present invention introduces the mish activation function to replace the sigmoid activation function in SimAM. Due to its smoothness and better gradient performance, the mish activation function can enhance the model's ability to detect small targets, avoid problems such as gradient disappearance or gradient explosion, and thus improve the accuracy and stability of the model. In addition, the mish activation function can enhance the generalization ability of the model, so that it performs better in more challenging scenarios.

[0117] In step S400, the detection head of the YOLOv5s model is replaced with a dynamic detection head DyHead (DynamicHead), which can simultaneously realize the unification of scale-aware attention, spatial-aware attention and task-aware attention, that is, an attention mechanism is added to each specific dimension of the feature tensor to dynamically adjust the feature representation of target detection. In the design of the model of the present invention, four groups of π are used. L (·),π S (·),π C (·) The modules are stacked in sequence, which makes the detection head have stronger representation ability, thereby improving the detection effect of the algorithm on small targets.

[0118] The above is a schematic scheme of a railway foreign object intrusion small target detection method based on an improved YOLO-v5s model in this embodiment. It should be noted that the technical scheme of the railway foreign object intrusion small target detection system based on the improved YOLO-v5s model and the technical scheme of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model belong to the same concept. The details of the technical scheme of the railway foreign object intrusion small target detection system based on the improved YOLO-v5s model in this embodiment that are not described in detail can all be referred to the description of the technical scheme of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model.

[0119] The railway foreign object intrusion small target detection system based on the improved YOLO-v5s model in this embodiment includes:

[0120] The collection module is used to obtain and construct a dataset of railway foreign objects with annotations;

[0121] The first improvement module is used to modify the CIOU loss function in the YOLOv5s model to the Focal EIOU loss function, which balances the weights of different target sizes;

[0122] The second improved module is used to improve the YOLOv5s model. The improved non-parametric attention mechanism M-SimAM module is added after the SPPF module to process channel or spatial features at the same time.

[0123] The third improvement module is used to replace the detection head of the YOLOv5s model with the dynamic detection head DyHead to dynamically adjust the feature representation of target detection;

[0124] The evaluation module is used to obtain a railway foreign object intrusion small target detection model based on the improved YOLOv5s model, detect the image to be detected, and evaluate the detection results.

[0125] This embodiment also provides an electronic device, which is applicable to the case of detecting small targets of foreign objects intruding on railways based on the improved YOLO-v5s model, including:

[0126] Memory and processor; the memory is used to store computer executable instructions, and the processor is used to execute computer executable instructions to implement the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model as proposed in the above embodiment.

[0127] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, a method for detecting small targets of railway foreign object intrusion based on an improved YOLO-v5s model as proposed in the above embodiment is implemented.

[0128] The storage medium proposed in this embodiment and the method for detecting small targets of railway foreign object intrusion based on the improved YOLO-v5s model proposed in the above embodiment belong to the same inventive concept. The technical details not described in detail in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0129] Through the above description of the implementation mode, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course can also be implemented by hardware, but in many cases the former is a better implementation mode. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ReadOnly, Memory, ROM), random access memory (RandomAccess Memory, RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform the methods of various embodiments of the present invention.

[0130] Example 2

[0131] Referring to Table 1, an embodiment of the present invention provides a railway foreign object intrusion small target detection method based on the improved YOLO-v5s model. In order to verify its beneficial effects, the comparison results of two schemes are provided.

[0132] First, the experimental environment and parameter settings. The hardware configuration of this experiment is Nvidia RTX3060 GPU and Inteli7-127002.70GHz CPU, and the software environment is Pytorch deep learning framework under Windows11 system. The input image size is 640×640, and there are 200 training rounds in total. At the same time, in order to accelerate network convergence, the official pre-trained weights are used as the initial weights, and the initial learning rate of network training is set to 0.01.

[0133] Prepare the experimental data set. According to the needs of the experiment, establish a data set of foreign object target intrusion on the rail to simulate the intrusion in the real environment. This data set uses the 200-meter track of Shanghai University of Technology as the experimental site, collects all objects in the scene that may hinder the normal operation of the railway system from a long distance, and creates a railway foreign object small target detection data set. In the experiment, typical foreign objects such as pedestrians, cars, fallen rocks and animals are selected as research objects. These data sets will be used to train and test the railway foreign object detection model. The data set is divided into 5500 training sets, 1000 validation sets and 1000 test sets for experiments to evaluate the performance of each strategy.

[0134] The performance of the model is evaluated according to the following evaluation indicators: mean Average Precision (mAP) denoted as PmAP, frames per second (FPS) and computational overhead (GLOPs). The relevant formulas are as follows:

[0135]

[0136]

[0137]

[0138] Among them, T p The positive samples are correctly classified; T N Negative samples are correctly classified; F p Negative samples are misclassified; F N The positive samples are misclassified. n is the number of all categories; P A is the average precision of the target category.

[0139] Finally, the experimental results of small target detection of foreign object intrusion in railways were obtained. In order to verify the effectiveness and superiority of the algorithm, under the same training conditions and data, the method proposed in the present invention was experimentally compared with Mask R-CNN, YOLOv3-SPP, YOLOv5, YOLOX-S, YOLOv5X, YOLOv5s and other methods. Several models were tested on the data set and the average accuracy and processing speed detection results were compared. The experimental results are shown in Table 1.

[0140] Table 1: Comparative experimental results

[0141]

[0142] Comparing the experimental results of various target detection algorithms in Table 1, we can clearly see that the algorithm of the present invention has a higher average precision P mAP The indicators are significantly ahead of other mainstream algorithms, showing excellent detection accuracy. Compared with the original YOLOv5s algorithm, this algorithm has improved by 10%, compared with YOLOv5, it has improved by 12%, and compared with YOLOv3-SPP, it has improved by 12.9%. Compared with the Mask R-CNN, YOLOX-S and YOLO5X algorithms, the detection accuracy of the algorithm of the present invention has increased by 15.2%, 9.3% and 11.3% respectively. Compared with the YOLOv5s and YOLOv3-SPP algorithms with similar detection speeds, the detection accuracy of this algorithm is significantly superior; although YOLOv5X is faster, its detection accuracy is relatively low, and it is difficult to meet the needs of foreign body detection in complex railway environments.

[0143] The algorithm of the present invention is not only superior to the original YOLOv5s target detection algorithm in terms of average accuracy and detection speed, but also has a significant improvement in detection accuracy, with FPS increased by 15.85%, achieving a balance between speed and accuracy. In summary, the algorithm of the present invention is more in line with the real-time and accuracy requirements of target detection in complex road scenes than other mainstream algorithms.

[0144] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.

Claims

1. A railway foreign object intrusion small target detection method based on an improved YOLO-v5s model, characterized in that: include: Acquire and construct a dataset of railway foreign objects with annotations; The CIOU loss function in the YOLOv5s model is modified to the FocalEIOU loss function to balance the weights of different target sizes; Improve the YOLOv5s model by adding an improved non-parametric attention mechanism M-SimAM module after the SPPF module to process channel or spatial features at the same time; Replace the detection head of the YOLOv5s model with the dynamic detection head DyHead to dynamically adjust the feature representation of target detection; Based on the improved YOLOv5s model, a small target detection model for railway foreign object intrusion is obtained, the detection image is detected, and the detection results are evaluated.

2. The railway foreign body intrusion small target detection method based on the improved YOLO-v5s model as claimed in claim 1 is characterized in that: Acquiring and building a dataset of railway foreign objects with annotations includes: Obtain railway foreign body dataset and create foreign body labels using labelme; The prepared foreign body number labels are subjected to data enhancement, and the data enhancement includes rotation, translation, mirroring, image brightness transformation and Gaussian blur processing.

3. The railway foreign body intrusion small target detection method based on the improved YOLO-v5s model as claimed in claim 2 is characterized in that: Constructing the data set also includes: Label the railway foreign body dataset and divide it into image dataset files and image corresponding label files; Classify the labeled data set, including pedestrians, animals, debris flow, falling rocks, and rolling logs; The processed data set is preprocessed and divided into training set, validation set and test set in a ratio of 7:1:

2. Data enhancement is performed through rotation, translation, mirroring, image brightness transformation and Gaussian blur to increase the number of training samples.

4. The railway foreign body intrusion small target detection method based on the improved YOLO-v5s model as claimed in claim 3 is characterized in that: The FocalEIOU loss function is expressed as: L Focal-EIOU =IOU γ L EIOU Among them, γ is a hyperparameter used to control the curve, L IOU represents the IOU loss, L dis Represents the distance loss, L asp is the edge length loss, ρ 2 (b,b gt ) represents the center coordinates b of the predicted box and the center coordinates b of the real box gt The Euclidean distance between 2 (w,w gt ) represents the width w of the prediction box and the width w of the solid line box gt The square of the difference, ρ 2 (h,h gt ) represents the height h of the predicted box and the height h of the real box gt The square of the difference, c w and c h They represent the width and height of the minimum bounding rectangle of the prediction box and the target box respectively, and c represents the diagonal length of the minimum bounding rectangle.

5. The railway foreign body intrusion small target detection method based on the improved YOLO-v5s model as claimed in claim 4 is characterized in that: The M-SimAM module includes: The mish activation function is introduced to replace the sigmoid activation function in the SimAM module to generate a new M-SimAM module. The feature map calculation of the M-SimAM attention mechanism is expressed as: Among them, X represents the original eigenvalue input to the M-SimAM module, Represents the feature output value after enhancement by the M-SimAM module.

6. The railway foreign body intrusion small target detection method based on the improved YOLO-v5s model as claimed in claim 5 is characterized in that: The dynamic detection head DyHead comprises: Modify the detection head of the YOLOv5s model to a dynamic detection head DyHead, and introduce an attention mechanism on each specific dimension of the feature tensor, that is, give a three-dimensional feature tensor F∈R on the detection layer L×S×C , the attention function of the dynamic detection detection head is expressed as: W(F)=π C (p S (p L (F)·F)·F)·F Among them, π L (·),π S (·),π C (·) represent three different attention functions applied on dimensions L, S, and C respectively.

7. The railway foreign body intrusion small target detection method based on the improved YOLO-v5s model as claimed in claim 6 is characterized in that: The testing and evaluation include: Configure environment variables, set epoch to 300, batch size to 16, and image size to 416*416; Train the railway foreign body intrusion small target detection model, and detect the image to be detected to obtain the detection result; Based on the detection results, the evaluation index mAP is obtained by calculating the average precision of the model at the IoU threshold, which is expressed as: Among them, p represents precision, R represents recall, TP represents the number of positive classes that are actually predicted to be positive, FP represents the number of negative classes that are actually predicted to be positive, and FN represents the number of negative classes that are actually predicted to be positive.

8. A railway foreign object intrusion small target detection system based on the improved YOLO-v5s model, characterized in that: include, The collection module is used to obtain and construct a dataset of railway foreign objects with annotations; The first improvement module is used to modify the CIOU loss function in the YOLOv5s model to the Focal EIOU loss function, which balances the weights of different target sizes; The second improvement module is used to improve the YOLOv5s model, adding an improved non-parametric attention mechanism M-SimAM module after the SPPF module, and processing channel or spatial features at the same time; The third improvement module is used to replace the detection head of the YOLOv5s model with the dynamic detection head DyHead to dynamically adjust the feature representation of target detection; The evaluation module is used to obtain a railway foreign object intrusion small target detection model based on the improved YOLOv5s model, detect the image to be detected, and evaluate the detection results.

9. An electronic device, comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions. When the computer-executable instructions are executed by the processor, the steps of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the steps of the railway foreign object intrusion small target detection method based on the improved YOLO-v5s model as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Wild animal detection method based on feature fusion reconstruction and lightweight design

    CN119229474A

  • Substation small animal invasion monitoring and early warning method and system

    CN119251875A

  • Deep learning-based tomato maturity detection system and method

    CN119540944A