Traffic light detection method, system, device and medium based on improved yolov5
By introducing the Inception-ResNet v2 network into the YOLOv5 model, an improved traffic light detection method is constructed, which solves the problems of unreliability of the HSV color space and high error rate of the traditional YOLOv5 model, and achieves more efficient traffic light recognition.
Patent Information
- Application Number
- CN202310451669.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-25
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-04-25
AI Technical Summary
Traditional traffic light recognition methods are unreliable when applied to the HSV color space, and the traditional YOLOv5 model has a high error rate.
The backbone network of the original YOLOv5 model is replaced by the Inception-ResNet v2 network to construct an improved YOLOv5 model, which includes the Stem module, the Inception-ResNet-A module, the Reduction-A module, the Inception-ResNet-B module, and the Reduction-B module. The image feature extraction capability is improved through multiple convolution and pooling processes.
It improves the accuracy and speed of traffic light recognition, reduces the recognition error rate, and achieves higher recognition precision and reliability.
Smart Images

Figure CN116630934B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of image recognition, and particularly relates to a traffic light detection method, system, device and medium based on improved yolov5. BACKGROUND
[0002] A traditional traffic light recognition method based on vision is a method of combining an HSV color space with shape features of a traffic light to recognize the traffic light by processing an image. A paper entitled "Traffic Light Recognition Based on Vision" published on CNKI on May 25, 2021 records a method of using two features of a traffic light, i.e., a rectangular shape and a black backboard, using an edge detection algorithm to extract an area containing only the black backboard of the traffic light, converting the image from an RGB color space to an HSV color space, and using the HSV color space to recognize a color of the traffic light to obtain a recognition result.
[0003] This method uses the HSV color space to recognize the color of the traffic light, but the HSV color space itself has limitations. If the saturation S of the color of the image is very low, the calculated hue H is unreliable. Because according to the conversion formula from RGB to HSV, if the saturation S is smaller, V-min(R, G, B) is smaller while keeping the brightness V unchanged. At the same time, the denominator of the hue H is V-min(R, G, B), and the smaller denominator makes the hue H more sensitive to the change of the molecule, so when the saturation is small, the calculation of the hue H often has a large "jump". Therefore, the result of this recognition method is unreliable.
[0004] In addition, the backbone network (a network used to extract image features) used in the traditional yolov5 model is generally a ResNet network or a CSPDarknet53 network, and the image recognition of the model has a certain error rate. SUMMARY
[0005] The main purpose of the present application is to overcome the shortcomings and deficiencies of the prior art, and to provide a traffic light detection method, system, device and medium based on improved yolov5, which overcomes the unreliability of using the HSV color space for traffic light recognition, improves the accuracy and speed of traffic light recognition, and further reduces the error rate of the traditional yolov5 model recognition.
[0006] In order to achieve the above purpose, the present application adopts the following technical scheme:
[0007] In a first aspect, the present application provides a traffic light detection method based on improved yolov5, comprising the following steps:
[0008] Acquire the traffic light picture data and preprocess it to build a traffic light picture detection dataset;
[0009] Build an improved yolov5 model to train the traffic light picture detection dataset to obtain a trained improved yolov5 model; the improved yolov5 model replaces the original yolov5 backbone network with an Inception-ResNet v2 network; the backbone network of the improved yolov5 model includes a Stem module, an Inception-resnet-A module, a Reduction-A module, an Inception-resnet-B module, a Reduction-B module, and an Inception-resnet-C module; the Stem module is used to preprocess the data before entering the Inception module; the Inception-resnet-A module is used to perform 6 convolution operations on the input result and then stack the processing results; the Reduction-A module is used to perform 4 convolution operations and maximum pooling on the input from the previous layer; the Inception-resnet-B module is used to perform 4 convolution operations on the input from the previous layer and then stack the processing results; the Reduction-B module is used to perform 7 convolution operations and maximum pooling on the input from the previous layer; and the Inception-resnet-C module is used to perform 5 convolution operations on the input from the previous layer and then stack the processing results;
[0010] Input the traffic light picture to be detected into the trained improved yolov5 model for detection and output the detection result.
[0011] As a preferred technical solution, in the preprocessing process, the traffic light picture data is labeled to obtain the class label information of the target and is sorted and made into a traffic light picture detection dataset.
[0012] As a preferred technical solution, the improved yolov5 model is built to train the traffic light picture detection dataset to obtain the trained improved yolov5 model, specifically as follows:
[0013] Modify the original Input of the yolov5 model to 299x299x3;
[0014] The data of Input is processed by the Stem module, and the specific processing process is: first, the Input data is processed by two-dimensional convolution with a 3x3 convolution kernel three times, then maximum pooling is performed, and then two convolution processes are performed, then four branch processes are performed, and finally the four branches are stacked, the input image size is changed from the original 299x299x3 to 35x35x256;
[0015] After processing by the Stem module, the Inception-resnet-A module is entered for processing, and the specific processing process is: the structure of the Inception-resnet-A module is divided into four branches, which are direct output without processing, one-time 1x1 convolution processing with 32 channels, one-time 1x1 convolution processing with 32 channels and one-time 3x3 convolution processing with 32 channels, and one-time 1x1 convolution processing with 32 channels and one-time 3x3 convolution processing with 48 channels and one-time 3x3 convolution processing with 64 channels. The processing results of the last three branches are stacked and then convolved, and then added to the result of the first branch, and finally the processing result is obtained;
[0016] The Reduction-A module is entered for processing, and the Reduction-A module is divided into three branches of maximum pooling operation, one-time 3x3 convolution processing with a convolution kernel and three-time convolution processing. The results of the three branches are spliced according to the dimension 1, and the data after splicing is changed from the original 35x35x256 to 17x17x896;
[0017] The Inception-resnet-B module is entered for processing, and the Inception-resnet-B module is divided into three branches of direct output without processing, one-time 1x1 convolution processing with 192 channels, one-time 1x1 convolution processing with 128 channels, one-time 1x7 convolution processing with 160 channels and one-time 7x1 convolution processing with 192 channels. The processing results of the second branch and the third branch are stacked and then convolved, and then added to the processing result of the first branch;
[0018] Into the Reduction-B module processing, the Reduction-B module is divided into the maximum pooling operation, the 1x1 channel number is 256 once convolution operation and the 3x3 channel number is 384 once convolution operation, the 1x1 channel number is 256 once convolution operation and the 3x3 channel number is 288 once convolution operation, the 1x1 channel number is 256 once convolution operation, the 3x3 channel number is 288 once convolution operation and the 3x3 channel number is 320 once convolution operation 4 branches, the processing results obtained from this branch are spliced according to the dimension 1, and the data after splicing changes from the original 17x17x896 to 8x8x1792;
[0019] Into the Inception-resnet-C module processing, the Inception-resnet-C module is divided into the direct output without processing, the 1x1 channel number is 192 once convolution processing, the 1x1 channel number is 192 once convolution processing, the 1x3 channel number is 224 once convolution processing and the 3x1 channel number is 256 once convolution processing 3 branches, the processing results of the 2nd branch and the 3rd branch are stacked and then convolved, and then added to the processing result of the first branch.
[0020] After the above operation, the two-dimensional average pooling operation is carried out, the value of the kernel_size parameter is set to 8, and the output data after processing is 1792.
[0021] As a preferred technical solution, in the Stem module processing process, when the maximum pooling is carried out, the value of the kernel_size parameter is set to 3 and the value of the stride parameter is set to 2.
[0022] As a preferred technical solution, in the Reduction-A module processing process, the first time is the convolution kernel 1x1 convolution processing, and the convolution kernel of the 2nd and 3rd convolution operations is 3x3.
[0023] As a preferred technical solution, the Stem module processing process, the Inception-resnet-B module and the Inception-resnet-C module all need to be repeated multiple times.
[0024] As a preferred technical solution, after replacing the backbone network of the yolov5 model with an Inception-ResNet v2 network, modifying the depth_multiple parameter value in the yaml file under the models folder of the original yolov5 model to 0.5, the width_multiple parameter value to 1, and then modifying the backbone part to 7 layers, the 0th layer to the 6th layer are respectively a Stem module processing layer, an Inception-resnet-A module processing layer, a Reduction-A module processing layer, an Inception-resnet-B module processing layer, a Reduction-B module processing layer, an Inception-resnet-C module processing layer, and a two-dimensional average pooling operation layer.
[0025] In a second aspect, the application provides a traffic light detection system based on an improved yolov5, which is applied to the traffic light detection method based on the improved yolov5 and includes a data acquisition module, a model construction module, and a detection module.
[0026] The data acquisition module is configured to acquire traffic light picture data and perform preprocessing, and construct a traffic light picture detection dataset.
[0027] The model construction module is configured to construct an improved yolov5 model, train the traffic light picture detection dataset, and obtain a trained improved yolov5 model; the improved yolov5 model is obtained by replacing a backbone network of an original yolov5 with an Inception-ResNet v2 network; the backbone network of the improved yolov5 model includes a Stem module, an Inception-resnet-A module, a Reduction-A module, an Inception-resnet-B module, a Reduction-B module, and an Inception-resnet-C module; the Stem module is configured to pre-process data before entering the Inception module; the Inception-resnet-A module is configured to perform 6 convolution operations on input results and stack the processed results; the Reduction-A module is configured to perform 4 convolution operations and maximum pooling operations on input from a previous layer; the Inception-resnet-B module is configured to perform 4 convolution operations on input from the previous layer and stack the processed results; the Reduction-B module is configured to perform 7 convolution operations and maximum pooling operations on input from the previous layer; and the Inception-resnet-C module is configured to perform 5 convolution operations on input from the previous layer and stack the processed results.
[0028] The detection module is configured to input a traffic light picture to be detected into the trained improved yolov5 model for detection and output a detection result.
[0029] In a third aspect, the present application provides an electronic device, which comprises:
[0030] at least one processor; and
[0031] a memory in communication with the at least one processor; wherein
[0032] The memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to execute the improved yolov5-based traffic light detection method.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium storing a program, and the program is executed by a processor to implement the improved yolov5-based traffic light detection method.
[0034] Compared with the prior art, the present application has the following advantages and beneficial effects:
[0035] The Inception-ResNet v2 network used in the present application is a network that combines the advantages of the Inception network and the ResNet network. By replacing the original ResNet network and other backbone networks in the yolov5 model with the Inception-ResNet v2 network, compared with the original yolov5 model, the improved yolov5 model has the advantages of lower recognition error rate and higher efficiency. At the same time, compared with the traditional method of recognizing traffic lights using HSV color space, the method of the present application has the advantages of higher accuracy, more reliable recognition effect and smaller recognition error. BRIEF DESCRIPTION OF DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0037] Figure 1 The flowchart of the traffic light detection method based on the improved yolov5 of the embodiment of the present application;
[0038] Figure 2 The backbone network structure diagram of the improved yolov5 of the embodiment of the present application;
[0039] Figure 3 The block diagram of the traffic light detection system based on the improved yolov5 of the embodiment of the present application.
[0040] Figure 4 The structure diagram of the electronic device of the embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make those skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0042] Reference to“an embodiment” or“the embodiment” means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase“in one embodiment” or“in at least one embodiment” in various places in the specification are not necessarily all referring to the same embodiment, nor are they necessarily all directed to the same embodiment, or to a single alternative embodiment. It is expressly understood that any of the features, structures, or characteristics described in connection with an embodiment can be included in at least one implementation of the application. It is expressly understood that not all of the features, structures, or characteristics described in connection with an embodiment need be included in every implementation of the application.
[0043] Most of the activation values in deep networks are unnecessary (0) or redundant due to correlation. Therefore, the most efficient deep network architecture should be sparse connections between activations. Inception network uses dense structure to approximate a sparse CNN. In addition, Inception network also uses a bottleneck layer (actually 1x1 convolution) to reduce the number of input channels, thereby reducing the amount of calculation. The network uses global average pooling layer instead of fully connected layer after the last convolution layer, greatly reducing the total parameter amount of the model.
[0044] The advantage of ResNet network is that it can not only accelerate training, but also improve performance (prevent gradient dispersion).
[0045] Please refer to Figure 1 The embodiment provides a traffic light detection method based on an improved yolov5, which comprises the following steps:
[0046] S1, collect at least about 20,000 traffic light pictures (of which the training set is at least 16,000 pictures, and the test set is at least 4,000 pictures), use lableme software to label the pictures, obtain the class label information of the target, and make the data set for traffic light recognition.
[0047] S2, replace the backbone network of the yolov5 model with Inception-ResNet v2, and the specific implementation steps are as follows:
[0048] S21, modify the original Input of yolov5 to 299x299x3;
[0049] S22, the data of Input is processed through the Stem module, and the specific processing process is that: the Input data is first subjected to two-dimensional convolution with a convolution kernel of 3x3 three times, and then subjected to maximum pooling (when maximum pooling is performed, the value of the kernel_size parameter and the value of the stride parameter can be set to 3 and 2 respectively), and then subjected to two convolution processes (at this time, the number of channels is 64), and then subjected to four branch processes. The number of channels output after the four branch processes is 64, 96, 64 and 96 respectively, and finally the four branches are stacked, and the size of the input image changes from the original 299x299x3 to 35x35x256.
[0050] S23, after processing through the Stem module, the Inception-resnet-A module is entered for processing. The specific processing process is that: the structure of the Inception-resnet-A module is divided into four branches, which are direct output without processing, one convolution process with a 1x1 convolution kernel and 32 channels, one convolution process with a 1x1 convolution kernel and 32 channels and one convolution process with a 3x3 convolution kernel and 32 channels, and one convolution process with a 1x1 convolution kernel and 32 channels and one convolution process with a 3x3 convolution kernel and 48 channels and one convolution process with a 3x3 convolution kernel and 64 channels. The processing results of the last three branches are stacked and subjected to one convolution, and then added to the result of the first branch, and finally the processing result is obtained. This module needs to be operated 5 times.
[0051] S24, the Reduction-A module is entered for processing, and the module is divided into three branches: maximum pooling operation, one convolution process with a 3x3 convolution kernel and three convolution processes (the first convolution process is a convolution process with a 1x1 convolution kernel, and the second and third convolution processes are convolution processes with a 3x3 convolution kernel). The results of the three branches are spliced according to the dimension 1, and the data after splicing changes from the original 35x35x256 to 17x17x896.
[0052] S25, the Inception-resnet-B module is entered for processing, and the module is divided into three branches: direct output without processing, one convolution process with a 1x1 convolution kernel and 192 channels, and one convolution process with a 1x1 convolution kernel and 128 channels, one convolution process with a 1x7 convolution kernel and 160 channels, and one convolution process with a 7x1 convolution kernel and 192 channels. The processing results of the second branch and the third branch are stacked and subjected to one convolution, and then added to the processing result of the first branch. The operation of this module is repeated 10 times.
[0053] S26, enter the Reduction-B module processing, which is divided into four branches: maximum pooling operation, 1x1 convolution operation with 256 channels, 3x3 convolution operation with 384 channels, 1x1 convolution operation with 256 channels, 3x3 convolution operation with 288 channels, and 3x3 convolution operation with 320 channels. The processing results of this branch are spliced by dimension 1, and the data after splicing changes from the original 17x17x896 to 8x8x1792.
[0054] S27, enter the Inception-resnet-C module processing, which is divided into three branches: direct output without processing, 1x1 convolution processing with 192 channels, and 1x1 convolution processing with 192 channels, 1x3 convolution processing with 224 channels, and 3x1 convolution processing with 256 channels. The processing results of the second and third branches are stacked and then convolved, and then added to the processing result of the first branch. This module is repeated 5 times.
[0055] S28, after the above operations, perform two-dimensional average pooling operation, and set the value of the kernel_size parameter to 8. The output data after processing is 1792.
[0056] S3, after replacing the backbone network of yolov5 with Inception-ResNet v2 network, modify any yaml file under the models folder of the original yolov5 model. The value of the depth_multiple parameter in the yaml file can be modified to 0.5, and the value of the width_multiple parameter can be modified to 1. Then the backbone part can be modified to 7 layers, from the 0th layer to the 6th layer, which are Stem module processing layer, Inception-resnet-A module processing layer, Reduction-A module processing layer, Inception-resnet-B module processing layer, Reduction-B module processing layer, Inception-resnet-C module processing layer, and two-dimensional average pooling operation layer. The values of the number parameters of the 0th to 6th layers can be set to 2, 10, 2, 20, 2, and 10 respectively. After network calculation, the values of the number parameters of each layer (from the 0th layer to the 6th layer) are 2x 0.5=1, 10x 0.5=5, 2x 0.5=1, 20x 0.5=10, 2x 0.5=1, and 10x 0.5=5 respectively.
[0057] S4, other parts of the yolov5 model are kept unchanged.
[0058] S5, the improved yolov5 model is used to train the traffic light data set, and when the number of data sets is about 20,000, the training times can be selected as about 100 times to ensure that the training result can tend to fitting, the training effect is best, and overfitting does not occur.
[0059] It should be noted that for the foregoing method embodiments, in order to facilitate the description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the order of the described actions, because according to the present application, certain steps can be performed in other orders or simultaneously.
[0060] Based on the same idea as the yolov5-based traffic light detection method in the above embodiment, the present application also provides a yolov5-based traffic light detection system, which can be used to execute the yolov5-based traffic light detection method described above. In order to facilitate the description, in the structural diagram of the yolov5-based traffic light detection system embodiment, only the parts related to the embodiments of the present application are shown, and those skilled in the art can understand that the illustrated structure does not constitute a limitation on the device, and can include more or fewer components than the illustrated, or combine certain components, or different component arrangements.
[0061] Please refer to Figure 3 In another embodiment of the present application, a yolov5-based traffic light detection system 100 is provided, which comprises a data acquisition module 101, a model construction module 102 and a detection module 103;
[0062] The data acquisition module 101 is used to acquire traffic light picture data and pre-process it to construct a traffic light picture detection data set.
[0063] The model construction module 102 is configured to construct an improved yolov5 model, train the traffic light picture detection dataset, and obtain a trained improved yolov5 model; the improved yolov5 model is obtained by replacing the original yolov5 backbone network with an Inception-ResNet v2 network; the improved yolov5 model comprises a Stem module, an Inception-resnet-A module, a Reduction-A module, an Inception-resnet-B module, a Reduction-B module, and an Inception-resnet-C module; the Stem module is configured to pre-process data before entering the Inception module; the Inception-resnet-A module is configured to perform 6 convolution operations on the input result, and then stack the processing result; the Reduction-A module is configured to perform 4 convolution operations and maximum pooling processing on the input from the previous layer; the Inception-resnet-B module is configured to perform 4 convolution operations on the input from the previous layer, and then stack the processing result; the Reduction-B module is configured to perform 7 convolution operations and maximum pooling processing on the input from the previous layer; and the Inception-resnet-C module is configured to perform 5 convolution operations on the input from the previous layer, and then stack the processing result.
[0064] The detection module 103 is configured to input a traffic light picture to be detected into the trained improved yolov5 model for detection, and output a detection result.
[0065] It should be noted that the traffic light detection system based on the improved yolov5 of the present application corresponds to the traffic light detection method based on the improved yolov5 of the present application, and the technical features and advantages described in the embodiment of the traffic light detection method based on the improved yolov5 are applicable to the embodiment of the traffic light detection system based on the improved yolov5, and the specific content can be referred to the description in the method embodiment of the present application, which will not be repeated here.
[0066] In addition, in the embodiment of the traffic light detection system based on the improved yolov5 of the above embodiment, the logical division of each program module is only an example, and in actual application, the above functions can be completed by different program modules according to the needs, for example, the configuration requirements of the corresponding hardware or the convenience of software implementation, that is, the internal structure of the traffic light detection system based on the improved yolov5 is divided into different program modules to complete all or part of the functions described above.
[0067] Please refer to Figure 4In one embodiment, an electronic device implementing a traffic light detection method based on improved yolov5 is provided. The electronic device 200 can include a first processor 201, a first memory 202, and a bus, and can further include a computer program, such as a traffic light detection program based on improved yolov5 203, stored in the first memory 202 and executable on the first processor 201.
[0068] The first memory 202 includes at least one type of readable storage medium, including a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the first memory 202 can be an internal storage unit of the electronic device 200, such as a mobile hard disk of the electronic device 200. In other embodiments, the first memory 202 can also be an external storage device of the electronic device 200, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the first memory 202 can include both an internal storage unit and an external storage device of the electronic device 200. The first memory 202 can be used to store application software and various data installed in the electronic device 200, such as the code of the traffic light detection program based on improved yolov5 203, and can also be used to temporarily store data that has been output or will be output.
[0069] The first processor 201 can be composed of an integrated circuit in some embodiments, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more combinations of a central processing unit (CPU), a microprocessor, a digital processing chip, a graphics processor, and various control chips, etc. The first processor 201 is the control unit of the electronic device, which connects various components of the electronic device through various interfaces and lines, and executes or runs programs or modules stored in the first memory 202 and calls data stored in the first memory 202 to perform various functions and process data of the electronic device 200.
[0070] Figure 4 Only an electronic device with components is shown, and those skilled in the art can understand that, Figure 4The structure shown does not constitute a limitation on the electronic device 200, and can include fewer or more components than shown, or combine certain components, or different component arrangements.
[0071] The improved yolov5-based traffic light detection program 203 stored in the first memory 202 in the electronic device 200 is a combination of multiple instructions, which, when running in the first processor 201, can implement:
[0072] Obtain traffic light picture data and preprocess it to construct a traffic light picture detection dataset;
[0073] Construct an improved yolov5 model to train the traffic light picture detection dataset to obtain a trained improved yolov5 model; the improved yolov5 model replaces the original yolov5 backbone network with an Inception-ResNet v2 network; the improved yolov5 model includes a Stem module, an Inception-resnet-A module, a Reduction-A module, an Inception-resnet-B module, a Reduction-B module, and an Inception-resnet-C module; the Stem module is used to preprocess data before entering the Inception module; the Inception-resnet-A module is used to perform 6 convolution operations on the input result and then stack the processed results; the Reduction-A module is used to perform 4 convolution operations and maximum pooling on the input from the previous layer; the Inception-resnet-B module is used to perform 4 convolution operations on the input from the previous layer and then stack the processed results; the Reduction-B module is used to perform 7 convolution operations and maximum pooling on the input from the previous layer; and the Inception-resnet-C module is used to perform 5 convolution operations on the input from the previous layer and then stack the processed results;
[0074] Input the traffic light picture to be detected into the trained improved yolov5 model for detection and output the detection result.
[0075] Further, the modules / units of the electronic device 200, if implemented in the form of software function units and sold or used as independent products, can be stored in a non-volatile computer-readable storage medium. The computer-readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0076] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer readable storage medium, and when the program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, storage, database or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0077] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist, it should be considered as the scope of the present application.
[0078] The above embodiments are the preferred embodiments of the present application, but the embodiments of the present application are not limited by the above embodiments, and any changes, modifications, substitutions, combinations and simplifications made without departing from the spirit and principles of the present application shall be equivalent replacement methods and shall be within the scope of protection of the present application.
Claims
1. The traffic light detection method based on the improved yolov5 is characterized by: The steps include: Obtain traffic light image data and preprocess it to build a traffic light image detection dataset; Construct an improved yolov5 model to train the traffic light image detection dataset to obtain a trained improved yolov5 model; the improved yolov5 model is based on Inception-ResNet The v2 network replaces the backbone network of the original yolov5; the backbone network of the improved yolov5 model includes the Stem module, the Inception-resnet-A module, the Reduction-A module, the Inception-resnet-B module, the Reduction-B module and the Inception-resnet-C module, the Stem module is used to preprocess the data before entering the Inception module, the Inception-resnet-A module is used to perform 6 convolutions on the input result, and then stack the processing results; the Reduction-A module is used to perform 4 convolutions and maximum pooling on the input from the previous layer; the Inception-resnet-B module is used to perform 4 convolutions and maximum pooling on the input from the previous layer, and then stack the processing results, the Reduction-B module is used to perform 7 convolutions and maximum pooling on the input from the previous layer, and the Inception-resnet-C module is used to perform 5 convolutions on the input from the previous layer, and then stack the processing results; the backbone network of the yolov5 model is replaced with Inception-ResNet After the v2 network, modify any yaml file in the models folder of the original yolov5 model, change the value of the depth_multiple parameter in the yaml file to 0.5, the value of width_multiple to 1, and then change the backbone part to 7 layers, from layer 0 to layer 6 are the Stem module processing layer, Inception-resnet-A module processing layer, Reduction-A module processing layer, Inception-resnet-B module processing layer, Reduction-B module processing layer, Inception-resnet-C module processing layer and two-dimensional average pooling operation layer; The traffic light image to be detected is input into the trained improved yolov5 model for detection, and the detection result is output.
2. The traffic light detection method based on improved yolov5 according to claim 1, characterized in that: During the preprocessing process, the traffic light image data is labeled to obtain the target category label information, and then compiled into a traffic light image detection dataset.
3. The traffic light detection method based on improved yolov5 according to claim 1, characterized in that: The improved yolov5 model is constructed to train the traffic light image detection dataset to obtain a trained improved yolov5 model, specifically: Modify the original Input of the yolov5 model to 299x299x3; The input data is processed by the Stem module. The specific processing process is as follows: the input data is first subjected to three 3x3 two-dimensional convolutions, followed by maximum pooling. After maximum pooling, it is convolved twice, and then subjected to four branching processes. Finally, these four branches are stacked. The input image size is changed from the original 299x299x3 to 35x35x256; After being processed by the Stem module, it enters the Inception-resnet-A module for processing. The specific processing process is as follows: the structure of the Inception-resnet-A module is divided into four branches, namely, direct output without processing, a 1x1 32-channel convolution, a 1x1 32-channel convolution and a 3x3 32-channel convolution, a 1x1 32-channel convolution and a 3x3 48-channel and a 3x3 64-channel convolution. The processing results of the last three branches are stacked and convolved once, and then added with the result of the first branch to obtain the final processing result; Enter the Reduction-A module for processing. The Reduction-A module is divided into three branches: maximum pooling operation, convolution processing with a convolution kernel of 3x3, and convolution processing. The results of these three branches are concatenated according to the dimension of 1. After concatenation, the data is reduced from the original 35x35x256 to 17x17x896; Enter the Inception-resnet-B module for processing. The Inception-resnet-B module is divided into three branches: unprocessed direct output, a 1x1 192-channel convolution, a 1x1 128-channel convolution, a 1x7 160-channel convolution, and a 7x1 192-channel convolution. The processing results of the second and third branches are stacked and convolved once, and then added to the processing result of the first branch. Enter the Reduction-B module for processing. The Reduction-B module is divided into four branches: a maximum pooling operation, a 1x1 convolution operation with a channel number of 256 and a 3x3 convolution operation with a channel number of 384, a 1x1 convolution operation with a channel number of 256 and a 3x3 convolution operation with a channel number of 288, a 1x1 convolution operation with a channel number of 256, a 3x3 convolution operation with a channel number of 288, and a 3x3 convolution operation with a channel number of 320. The processing results obtained by this branch are spliced according to the dimension 1. After splicing, the data is changed from the original 17x17x896 to 8x8x1792; Enter the Inception-resnet-C module for processing. The Inception-resnet-C module is divided into three branches: unprocessed direct output, a 1x1 192-channel convolution, a 1x1 192-channel convolution, a 1x3 224-channel convolution, and a 3x1 256-channel convolution. The processing results of the second and third branches are stacked and convolved once, and then added to the processing result of the first branch; After the above operations, a two-dimensional average pooling operation is performed, and the value of the kernel_size parameter is set to 8. The output data after processing is 1792.
4. The traffic light detection method based on improved yolov5 according to claim 3 is characterized in that: During the Stem module processing, the kernel_size parameter value is set to 3 and the stride parameter value is set to 2 when performing maximum pooling.
5. The traffic light detection method based on improved yolov5 according to claim 3 is characterized in that: During the processing of the Reduction-A module, the first convolution operation is performed with a convolution kernel of 1x1, and the second and third convolution operations are performed with a convolution kernel of 3x3.
6. The traffic light detection method based on improved yolov5 according to claim 3, characterized in that: The Stem module processing process, Inception-resnet-B module, and Inception-resnet-C module need to be repeated multiple times.
7. The traffic light detection system based on the improved yolov5 is characterized by: The traffic light detection method based on the improved yolov5 applied to any one of claims 1-6 comprises a data acquisition module, a model building module and a detection module; The data acquisition module is used to acquire and preprocess traffic light image data to construct a traffic light image detection dataset; The model building module is used to build an improved yolov5 model to train the traffic light image detection dataset to obtain a trained improved yolov5 model; the improved yolov5 model is based on Inception-ResNet The v2 network replaces the backbone network of the original yolov5; the backbone network of the improved yolov5 model includes a Stem module, an Inception-resnet-A module, a Reduction-A module, an Inception-resnet-B module, a Reduction-B module and an Inception-resnet-C module, wherein the Stem module is used to preprocess the data before entering the Inception module, and the Inception-resnet-A module is used to perform 6 convolutions on the input result and then stack the processing results; the Reduction-A module is used to perform 4 convolutions and maximum pooling on the input from the previous layer; the Inception-resnet-B module is used to perform 4 convolutions and maximum pooling on the input from the previous layer and then stack the processing results; the Reduction-B module is used to perform 7 convolutions and maximum pooling on the input from the previous layer and the Inception-resnet-C module is used to perform 5 convolutions on the input from the previous layer and then stack the processing results; The detection module is used to input the traffic light image to be detected into the trained improved yolov5 model for detection and output the detection result.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the traffic light detection method based on the improved yolov5 as described in any one of claims 1-6.
9. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the traffic light detection method based on the improved yolov5 according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Doctor-nurse interaction gesture recognition method in operation process
CN112287843A
Online vehicle multi-target tracking method based on neural network
CN112561959A