Urban governance method, system and equipment based on YOLO network and medium

By designing the filter base and replacing the convolutional layer in the YOLO network, the compression of the YOLO model is solved, and the problem of excessive storage and computing demand in urban governance applications is improved, and detection efficiency and model adaptability are improved.

CN119762798AActive Publication Date: 2025-04-04浪潮智慧城市科技有限公司
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202411824130.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-04
Estimated Expiration
2044-12-12

AI Technical Summary

Technical Problem

YOLO network has the problem of excessive storage and computing demand in urban governance applications, which is difficult to directly deploy on platforms with limited resources, and the scale of the model affects the response speed.

Method used

By designing the filter basis and linear combination, a new convolution filter is constructed, and the convolution layer in the original C3 module in YOLOv5 is replaced to realize the compression of the YOLO model.

Benefits of technology

It effectively reduces the amount of parameters and calculations of the YOLO network, improves detection efficiency, and significantly reduces the model size while maintaining a high detection accuracy, making it more suitable for application in urban governance scenarios with resource-constrained.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119762798A_ABST
    Figure CN119762798A_ABST
Patent Text Reader

Abstract

The invention discloses an urban governance method, system and device based on a YOLO network and a medium, belongs to the technical fields of artificial intelligence, computer vision, target detection and the like, and aims to solve the technical problems of how to improve the detection efficiency of the YOLO network and enhance the actual application effect in urban governance. According to the technical scheme, the method comprises the following steps: data collection and preprocessing: selecting three urban governance representative scenes of traffic accident detection, road surface detection and safety helmet and safety clothing detection, collecting image or video data of each scene, and preprocessing and marking the collected image or video data of each scene, the method is used for subsequent compression network training and evaluation; convolution filter reconstruction: designing a group of filter bases, and constructing a new convolution filter through different linear combinations of the group of filter bases; wherein the number of the filter bases is lower than the number of original convolution filters; the invention relates to network architecture replacement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical fields of artificial intelligence, computer vision, target detection, and the like, and specifically to a city governance method, system, device, and medium based on a YOLO network. Background Art

[0002] With the development of artificial intelligence technology, target detection technology plays an increasingly important role in the field of smart city governance, which can automatically identify and classify different objects in images or videos. As an efficient algorithm for target detection, the YOLO series network is widely used in many fields such as traffic management, security monitoring and environmental monitoring due to its fast and accurate detection capabilities. By processing video streams in real time, the YOLO network can detect targets such as vehicles and pedestrians, providing data support for traffic flow monitoring and road safety. At the same time, it can also conduct real-time monitoring in crowded areas to enhance the safety of the city. Despite these advantages, the storage and computing requirements of the YOLO network pose challenges to its deployment on resource-limited platforms in many practical applications.

[0003] Although YOLO performs well in various smart city scenarios, there are still some challenges in actual deployment. On the one hand, many applications need to run models or algorithms on edge devices, which usually have limited computing and memory resources, and the original scale of the YOLO model may not be suitable for direct deployment on such resource-constrained devices in some cases. In addition, the application scenarios of urban governance are usually diverse, with different requirements for the performance and resource consumption of detection models. This requires the model to better adapt to such diverse needs. On the other hand, the scale of the model, including parameters and computational complexity, also affects the response speed. Reducing the model size can help the model process and respond to data in urban operations faster.

[0004] Therefore, how to improve the detection efficiency of the YOLO network and enhance its actual application effect in urban governance is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The technical task of the present invention is to provide a city governance method, system, device and medium based on the YOLO network to solve the problem of how to improve the detection efficiency of the YOLO network and enhance the actual application effect in urban governance.

[0006] The technical task of the present invention is achieved in the following way: a city governance method based on the YOLO network, the method is as follows:

[0007] Data collection and preprocessing: Select three representative scenes of urban governance: traffic accident detection, road surface detection, and helmet and safety clothing detection, collect image or video data of each scene, and preprocess and annotate the collected image or video data of each scene for subsequent compression network training and evaluation;

[0008] Convolution filter reconstruction: design a set of filter bases and construct new convolution filters through different linear combinations of the set of filter bases; the number of filter bases is less than the number of original convolution filters;

[0009] Network architecture replacement: Build a new convolutional layer through a new convolutional filter and replace the convolutional layer in the original C3 module in YOLOv5 to obtain the YOLO model and realize YOLOv5 compression.

[0010] As a preferred method, data collection and preprocessing are as follows:

[0011] Data collection: Collect image or video data related to traffic accident detection, road surface detection, and helmet and safety clothing detection from public data sets or web crawler technology; for traffic accident detection, collect images and video data containing traffic accident scenes; video data includes accident or non-accident videos captured from fixed traffic cameras; for road surface detection, collect images of road cracks, potholes, manhole covers, and drains on the street; for helmet and safety clothing detection, collect scene images of wearing helmets, not wearing helmets, wearing safety clothing, and not wearing safety clothing at construction sites or workshops;

[0012] Image preprocessing and importing: Use OpenCV's image processing function to preprocess the collected images to unify the image size and orientation; after preprocessing, import the images into LabelImg and LabelMe annotation tools to prepare for subsequent processing;

[0013] Video frame processing: For video data, use OpenCV basic commands to extract frames in order to convert raw video data into an image format suitable for model input;

[0014] Target recognition and labeling: Identify the target to be located and draw a bounding box around it. Use LabelImg and LabelMe labeling tools to adjust the size and position of the labeling box to ensure that the labeling box can accurately cover the target object. And assign a category to each bounding box according to the different categories contained in the collected image to identify the type of target in the box; for example, for traffic accident detection, there are two categories: "accident" and "non-accident";

[0015] Data enhancement: Use OpenCV’s image processing functions to enhance the data and increase the diversity of the data set. Specifically, perform geometric transformations such as rotating, flipping, translating, and scaling the image to help the model learn how objects behave in different positions, scales, and directions. At the same time, add random noise to the image to simulate different shooting environments and qualities.

[0016] Data format conversion: Convert the labeled data into YOLO training format to facilitate network training;

[0017] Data normalization: Use OpenCV to standardize and normalize images for easy model processing;

[0018] Dataset division: Divide the processed and annotated image data and corresponding labels into training set, validation set and test set.

[0019] Preferably, the YOLO training format requires the dataset to have a specific directory structure, which includes two main folders: images and labels;

[0020] Among them, the images folder stores image files, and the labels folder stores the corresponding label files; each image file corresponds to a label file, and the name of the label file should correspond to the image file, for example, image 1.jpg corresponds to label file 1.txt; YOLO's label file is a plain text file (usually in .txt format), and each line represents the annotation information of an object; for each object, the label file contains five values, namely the category index (class), the x-coordinate of the object center (x_center), the y-coordinate of the object center (y_center), the width (width) and height (height) of the object.

[0021] As a preference, a set of filter bases are designed as follows:

[0022] Define a set of n filter bases F = {F1, F2, ..., F n};in

[0023] To simplify the problem, let n = N / k; where k>1 is a preset hyperparameter;

[0024] A convolutional layer contains N = c out A complete filter is formed by linearly combining the defined filter bases. Only n filter bases are stored to construct all filters in a given layer;

[0025] In order to determine the coefficients of the linear combination, a coefficient matrix is ​​introduced Then each filter is expressed as:

[0026]

[0027] Among them, the coefficient matrix Each parameter represents the coefficient of a linear combination; t represents the total number of filters required, t∈{1,…,N}.

[0028] Preferably, the convolution filter is reconstructed as follows:

[0029] Parameter setting: predefine the ratio of the filter basis and the original output channel, i.e. k;

[0030] Initialization: Initialize n = N / k filter bases and coefficient matrix D;

[0031] Convolution operation definition: Use the filter basis and coefficient matrix to perform linear combination to construct a new filter W t , and redefine the convolution operation;

[0032] Convolutional layer definition: Add normalization BatchNorm and SiLU activation function to define a new complete convolutional layer.

[0033] Preferably, the network architecture is replaced as follows:

[0034] Replacement strategy setting: flexibly set different replacement strategies to adapt to different resource requirements; specifically: each C3 module contains multiple convolutional layers "Conv", and replace "Conv" in different positions with newly defined convolutional layers; in addition, YOLOv5 also contains multiple C3 modules in the head and backbone, and choose to replace the convolutional layers of the C3 modules in the head or backbone to achieve different compression effects; in general, the more convolutional layers are replaced, the fewer parameters and calculations of the YOLOv5 model; for example, when the application scenario has greater restrictions on storage and computing resources, you can choose to replace more convolutional modules to achieve a greater degree of compression and save resources; when the application scenario has higher requirements for accuracy, you can choose to replace a small number of convolutional modules to maintain accuracy. This flexible replacement strategy can help optimize the balance between model scale and detection accuracy;

[0035] Convolutional layer replacement: Integrate the newly defined convolutional layer into the YOLOv5 model definition to replace the original convolutional layer;

[0036] Adjust network parameters: According to the characteristics of the newly defined convolutional layer, adjust the learning rate, batch size and other parameters of the network to ensure the stability and convergence of the model training;

[0037] Recompile the model: Recompile the YOLO model to ensure that the newly defined convolutional layers are integrated correctly;

[0038] Training and validation: Train the YOLO model using the prepared dataset;

[0039] Performance evaluation: Compare the performance of the YOLO model before and after the replacement, and test key indicators including accuracy, mAP, as well as the number of network parameters and computational complexity on three actual application datasets to ensure the compression effectiveness of the new convolutional layer;

[0040] Adjustment and optimization: Based on the results of performance evaluation, further adjust parameters and strategies, and iterate multiple times to achieve the best results.

[0041] Preferably, the training and validation are as follows:

[0042] Create a new dataset configuration YAML file to configure the dataset path, number of categories, and category list. At the same time, modify the nc parameter in the YOLO model configuration file according to the number of categories in the dataset.

[0043] Use the Ultralytics command line to train the YOLO model, and adjust the script parameters to set the number of epochs and batch size;

[0044] After the training is completed, the trained YOLO model is used to test the test set to evaluate the performance of the YOLO model.

[0045] A city governance system based on a YOLO network, the system is used to implement the above-mentioned city governance method based on a YOLO network; the system comprises:

[0046] The data collection and preprocessing module is used to select three representative scenes of urban governance, namely traffic accident detection, road surface detection and helmet and safety clothing detection, and collect image or video data of each scene through field shooting and network search; the collected image or video data is preprocessed by denoising, normalization and resizing to meet the input requirements of the model; and the generalization ability of the model is improved through data enhancement techniques such as random cropping, flipping and rotation; finally, the processed images are annotated in YOLO format to provide accurate training labels for the model so that the model can learn to identify and locate target objects;

[0047] The convolution filter reconstruction module is used to design a set of filter bases, construct new convolution filters through different linear combinations of the filter bases, and use the newly constructed convolution filters to define new convolution operations, and reorganize the newly defined convolution operations, batch normalization and activation functions into new convolution layers; the new convolution layer is used to capture various visual features such as contours and patterns in the image, which are crucial for identifying objects in the image; at the same time, by merging feature maps at different levels, feature fusion is achieved, which helps the network integrate information at different scales and improve recognition accuracy; and by reconstructing the filter, the feature extraction capability is enhanced while also improving computational efficiency; the number of filter bases is lower than the number of original convolution filters;

[0048] The network architecture replacement module is used to replace the convolutional layer in the original C3 module in YOLOv5 with a new convolutional layer, obtain the YOLO model, and realize the compression of YOLOv5.

[0049] An electronic device comprising: a memory and at least one processor;

[0050] Wherein, the memory stores a computer program;

[0051] The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the urban governance method based on the YOLO network as described above.

[0052] A computer-readable storage medium having a computer program stored therein, wherein the computer program can be executed by a processor to implement the urban governance method based on the YOLO network as described above.

[0053] The city governance method, system, device and medium based on the YOLO network of the present invention have the following advantages:

[0054] (i) The present invention constructs a new target detection network and algorithm with fewer parameters and computational complexity, which can optimize the use of storage and computing resources and improve the practical application performance and efficiency of target detection in urban governance;

[0055] (ii) The present invention uses different replacement strategies and parameter settings to specifically influence model performance, optimizes the balance between model scale and detection accuracy, and flexibly adjusts the model scale to accommodate different resource requirements, which helps develop efficient target detection solutions for resource-constrained devices in smart city governance;

[0056] (III) The present invention can effectively reduce the number of parameters and computational complexity of the YOLO network and improve detection efficiency. At the same time, different settings can be used to flexibly adjust the model scale to meet different resource requirements;

[0057] (IV) Improve the detection efficiency of the YOLO network through model compression, strengthen the practical application effect in urban governance, and further improve the operational efficiency and practicality of urban governance;

[0058] (V) Through continuous optimization of three stages, namely data collection and processing, convolution filter reconstruction, and network architecture replacement, the YOLO model can significantly reduce the model size and accelerate model deployment while maintaining a high detection accuracy, making it more suitable for application in resource-constrained urban governance scenarios;

[0059] (VI) The present invention reconstructs the convolution filter by using the filter basis, thereby reducing the number of parameters and the amount of calculation of the convolution layer, and speeding up the training and reasoning of the network;

[0060] (VII) The detection model of the present invention is more lightweight, which speeds up information processing and decision-making, facilitates and quickly responds to problems in urban governance, and improves efficiency;

[0061] (VIII) The present invention provides flexible model scale selection by setting different compression parameters and strategies, and supports the deployment of the model on different resource-limited devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] The present invention is further described below in conjunction with the accompanying drawings.

[0063] Attached Figure 1 Schematic diagram of filter reconstruction;

[0064] Attached Figure 2 Schematic diagram of the C3 module structure (the new convolutional layer replaces the "Conv" layer). DETAILED DESCRIPTION

[0065] The following detailed description is made of the city governance method, system, device and medium based on the YOLO network of the present invention with reference to the drawings and specific embodiments of the specification.

[0066] Embodiment 1:

[0067] This embodiment provides a city governance method based on the YOLO network, and the method is specifically as follows:

[0068] S1. Data collection and preprocessing: Select three representative scenes of urban governance, namely traffic accident detection, road surface detection, and helmet and safety clothing detection, collect image or video data of each scene, and preprocess and annotate the collected image or video data of each scene for subsequent compression network training and evaluation;

[0069] S2, convolution filter reconstruction: design a set of filter bases, and construct new convolution filters through different linear combinations of the set of filter bases; wherein the number of filter bases is less than the number of original convolution filters;

[0070] S3, network architecture replacement: Build a new convolutional layer through a new convolutional filter, and replace the convolutional layer in the original C3 module in YOLOv5 to obtain the YOLO model and realize the compression of YOLOv5.

[0071] The data collection and preprocessing in step S1 of this embodiment are specifically as follows:

[0072] S101. Data collection: Collect image or video data related to traffic accident detection, road surface detection, and helmet and safety clothing detection from public data sets or web crawler technology; for traffic accident detection, collect images and video data containing traffic accident scenes; video data includes accident or non-accident videos captured from fixed traffic cameras; for road surface detection, collect images of road cracks, potholes, manhole covers, and drains on the street; for helmet and safety clothing detection, collect scene images of people wearing helmets, not wearing helmets, wearing safety clothing, and not wearing safety clothing at construction sites or workshops;

[0073] S102, image preprocessing and importing: preprocess the collected images with the help of OpenCV's image processing function to unify the image size and orientation; after preprocessing, import the images into LabelImg and LabelMe annotation tools to prepare for subsequent processing;

[0074] S103, video frame processing: for video data, frame extraction is performed using OpenCV basic commands to convert the original video data into an image format suitable for model input;

[0075] S104, target recognition and labeling: Identify the target to be located and draw a bounding box around the target to be located, use LabelImg and LabelMe labeling tools to adjust the size and position of the labeling box to ensure that the labeling box can accurately cover the target object; and assign a category to each bounding box according to the different categories contained in the collected image to identify the type of the target in the box; for example, for traffic accident detection, there are two categories of "accident" and "non-accident";

[0076] S105, Data Enhancement: Use OpenCV's image processing functions to enhance the data and increase the diversity of the data set; specifically, perform geometric transformations such as rotating, flipping, translating, and scaling the image to help the model learn how objects behave in different positions, scales, and directions; and add random noise to the image to simulate different shooting environments and qualities.

[0077] S106, data format conversion: convert the labeled data into YOLO training format to facilitate network training;

[0078] S107, Data normalization: Use OpenCV to standardize and normalize the image for model processing;

[0079] S108, data set division: divide the processed and annotated image data and corresponding labels into a training set, a validation set and a test set.

[0080] The YOLO training format in step S106 of this embodiment requires that the data set has a specific directory structure, which includes two main folders: images and labels;

[0081] Among them, the images folder stores image files, and the labels folder stores the corresponding label files; each image file corresponds to a label file, and the name of the label file should correspond to the image file, for example, image 1.jpg corresponds to label file 1.txt; YOLO's label file is a plain text file (usually in .txt format), and each line represents the annotation information of an object; for each object, the label file contains five values, namely the category index (class), the x-coordinate of the object center (x_center), the y-coordinate of the object center (y_center), the width (width) and height (height) of the object.

[0082] For a standard convolutional layer, w and h represent the width and height of the input and output tensors respectively, and the number of input and output channels is c. in and c out The input and output tensors can be represented as and The weight tensor of the convolutional layer can be expressed as Where d is the convolution kernel size. The number of convolution filters N in the convolution layer is equal to the number of output channels, that is, N = c out .

[0083] In order to reduce the memory and computational cost of the convolutional layer, the design of a set of filter bases in step S2 of this embodiment is as follows:

[0084] ① Define a set of n filter bases F = {F1, F2, ..., F n};in

[0085] ② To simplify the problem, let n = N / k; k>1 is a preset hyperparameter;

[0086] ③A convolutional layer contains N=c outA complete filter is formed by linearly combining the defined filter bases. Only n filter bases are stored to construct all filters in a given layer;

[0087] ④In order to determine the coefficients of the linear combination, a coefficient matrix is ​​introduced Then each filter is expressed as:

[0088]

[0089] Among them, the coefficient matrix Each parameter represents the coefficient of a linear combination; t represents the total number of filters required, t∈{1,…,N}.

[0090] As attached Figure 1 As shown, the convolution filter reconstruction in step S2 of this embodiment is specifically as follows:

[0091] S201, parameter setting: predefine the ratio of the filter basis and the original output channel, i.e., k;

[0092] S202, initialization: initializing n=N / k filter bases and coefficient matrix D;

[0093] S203, convolution operation definition: Use the filter basis and coefficient matrix to perform linear combination to construct a new filter W t , and redefine the convolution operation;

[0094] S204, convolution layer definition: Add normalized BatchNorm and SiLU activation function to define a new complete convolution layer.

[0095] After reconstructing the convolution filter, the original convolution layer in YOLO is replaced with a new convolution layer containing the reconstruction filter. Taking YOLOv5 as an example, the C3 module is a key component of the network structure and plays an important role in feature extraction and model performance enhancement. The C3 module consists of three convolution layers and multiple BottleNeck modules, each of which also contains two convolution layers. The number of these BottleNeck modules is determined by preset parameters. The C3 module includes two branches, one of which performs deep feature extraction through multiple BottleNecks, while the other only passes through the basic convolution module, and the outputs of the last two branches are connected to achieve feature fusion. Since the C3 module occupies an important parameter share in YOLOv5, this embodiment replaces the original convolution layer with a convolution layer containing the reconstruction filter at this stage to compress the C3 module, while retaining the original batch normalization and SiLU activation function settings, and only replacing the convolution operation.

[0096] The network architecture replacement in step S3 of this embodiment is specifically as follows:

[0097] S301, replacement strategy setting: flexibly set different replacement strategies to adapt to different resource requirements; specifically: as shown in the attached Figure 2 As shown in the figure, each C3 module contains multiple convolutional layers "Conv", and "Conv" in different positions is replaced with a newly defined convolutional layer; in addition, YOLOv5 also contains multiple C3 modules in the head and backbone, and the convolutional layers of the C3 modules in the head or backbone are replaced to achieve different compression effects; in general, the more convolutional layers are replaced, the fewer parameters and calculations of the YOLOv5 model; for example, when the application scenario has greater restrictions on storage and computing resources, more convolutional modules can be replaced to achieve a greater degree of compression and save resources; when the application scenario has higher requirements on accuracy, a small number of convolutional modules can be replaced to maintain accuracy. This flexible replacement strategy can help optimize the balance between model scale and detection accuracy;

[0098] S302, convolution layer replacement: integrate the newly defined convolution layer into the YOLOv5 model definition, replacing the original convolution layer;

[0099] S303, adjusting network parameters: according to the characteristics of the newly defined convolutional layer, adjusting other parameters of the network such as learning rate and batch size to ensure the stability and convergence of model training;

[0100] S304, recompile model: recompile the YOLO model to ensure that the newly defined convolutional layer is correctly integrated;

[0101] S305, training and verification: training the YOLO model using the prepared data set;

[0102] S306, Performance Evaluation: Compare the performance of the YOLO model before and after the replacement, test key indicators including accuracy, mAP, as well as the number of network parameters and the amount of calculation on three practical application data sets to ensure the compression effectiveness of the new convolutional layer;

[0103] S307, Adjustment and Optimization: Based on the results of performance evaluation, further adjust parameters and strategies, and iterate multiple times to achieve the best results.

[0104] The training and verification in step S305 of this embodiment are specifically as follows:

[0105] S30501. Create a new dataset configuration YAML file to configure the dataset path, number of categories, and category list. At the same time, modify the nc parameter in the YOLO model configuration file according to the number of categories in the dataset.

[0106] S30502. Use the Ultralytics command line to train the YOLO model, and set the number of epochs and batch size by adjusting the script parameters;

[0107] S30503. After the training is completed, the trained YOLO model is used to test the test set to evaluate the performance of the YOLO model.

[0108] Embodiment 2:

[0109] This embodiment provides a city governance system based on a YOLO network, which is used to implement the city governance method based on a YOLO network in Embodiment 1; the system includes:

[0110] The data collection and preprocessing module is used to select three representative scenes of urban governance, namely traffic accident detection, road surface detection and helmet and safety clothing detection, and collect image or video data of each scene through field shooting and network search; the collected image or video data is preprocessed by denoising, normalization and resizing to meet the input requirements of the model; and the generalization ability of the model is improved through data enhancement techniques such as random cropping, flipping and rotation; finally, the processed images are annotated in YOLO format to provide accurate training labels for the model so that the model can learn to identify and locate target objects;

[0111] The convolution filter reconstruction module is used to design a set of filter bases, construct new convolution filters through different linear combinations of the filter bases, and use the newly constructed convolution filters to define new convolution operations, and reorganize the newly defined convolution operations, batch normalization and activation functions into new convolution layers; the new convolution layer is used to capture various visual features such as contours and patterns in the image, which are crucial for identifying objects in the image; at the same time, by merging feature maps at different levels, feature fusion is achieved, which helps the network integrate information at different scales and improve recognition accuracy; and by reconstructing the filter, the feature extraction capability is enhanced while also improving computational efficiency; the number of filter bases is lower than the number of original convolution filters;

[0112] The network architecture replacement module is used to replace the convolutional layer in the original C3 module in YOLOv5 with a new convolutional layer, obtain the YOLO model, and realize the compression of YOLOv5.

[0113] Embodiment 3:

[0114] This embodiment also provides an electronic device, including: a memory and a processor;

[0115] Wherein, the memory stores computer-executable instructions;

[0116] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the urban governance method based on the YOLO network in any embodiment of the present invention.

[0117] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or any conventional processor, etc.

[0118] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory can also include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, at least one disk storage period, a flash memory device, or other volatile solid-state storage devices.

[0119] Embodiment 4:

[0120] This embodiment also provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions are loaded by a processor, so that the processor executes the urban governance method based on the YOLO network in any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code that implements the functions of any of the above embodiments is stored, and a computer (or CPU or GPU) of the system or device reads and executes the program code stored in the storage medium.

[0121] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.

[0122] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RYM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer via a communication network.

[0123] In addition, it should be clear that the functions of any of the above embodiments can be implemented not only by executing the program code read by the computer, but also by enabling an operating system operating on the computer to complete part or all of the actual operations based on instructions from the program code.

[0124] In addition, it can be understood that the program code read from the storage medium is written to a memory provided in an expansion board inserted into the computer or written to a memory provided in an expansion unit connected to the computer, and then based on the instructions of the program code, a CPU installed on the expansion board or the expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above-mentioned embodiments.

[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A city governance method based on YOLO network, characterized in that: The method is as follows: Data collection and preprocessing: Select three representative scenes of urban governance: traffic accident detection, road surface detection, and helmet and safety clothing detection, collect image or video data of each scene, and preprocess and annotate the collected image or video data of each scene for subsequent compression network training and evaluation; Convolution filter reconstruction: design a set of filter bases and construct new convolution filters through different linear combinations of the set of filter bases; the number of filter bases is less than the number of original convolution filters; Network architecture replacement: Build a new convolutional layer through a new convolutional filter and replace the convolutional layer in the original C3 module in YOLOv5 to obtain the YOLO model and realize YOLOv5 compression.

2. The urban governance method based on the YOLO network according to claim 1 is characterized in that: The data collection and preprocessing are as follows: Data collection: Collect image or video data related to traffic accident detection, road surface detection, and helmet and safety clothing detection from public data sets or web crawler technology; for traffic accident detection, collect images and video data containing traffic accident scenes; video data includes accident or non-accident videos captured from fixed traffic cameras; for road surface detection, collect images of road cracks, potholes, manhole covers, and drains on the street; for helmet and safety clothing detection, collect scene images of wearing helmets, not wearing helmets, wearing safety clothing, and not wearing safety clothing at construction sites or workshops; Image preprocessing and importing: Use OpenCV's image processing function to preprocess the collected images to unify the image size and orientation; after preprocessing, import the images into LabelImg and LabelMe annotation tools to prepare for subsequent processing; Video frame processing: For video data, use OpenCV basic commands to extract frames in order to convert raw video data into an image format suitable for model input; Target recognition and labeling: Identify the target to be located and draw a bounding box around it. Use LabelImg and LabelMe labeling tools to adjust the size and position of the labeling box to ensure that the labeling box can accurately cover the target object. And assign a category to each bounding box based on the different categories contained in the collected image to identify the type of the target in the box. Data enhancement: Use OpenCV’s image processing functions to enhance the data and increase the diversity of the data set. Specifically, perform geometric transformations such as rotating, flipping, translating, and scaling the image to help the model learn how objects behave in different positions, scales, and directions. At the same time, add random noise to the image to simulate different shooting environments and qualities. Data format conversion: Convert the labeled data into YOLO training format to facilitate network training; Data normalization: Use OpenCV to standardize and normalize images for easy model processing; Dataset division: Divide the processed and annotated image data and corresponding labels into training set, validation set and test set.

3. The urban governance method based on the YOLO network according to claim 2 is characterized in that: The YOLO training format requires the dataset to have a specific directory structure, which includes two main folders: images and labels; Among them, the images folder stores image files, and the labels folder stores the corresponding label files; each image file corresponds to a label file, and the name of the label file should correspond to the image file; YOLO's label file is a plain text file, each line represents the annotation information of an object; for each object, the label file contains five values, namely the category index, the x-coordinate of the object center, the y-coordinate of the object center, and the width and height of the object.

4. The urban governance method based on the YOLO network according to claim 1 is characterized in that: Design a set of filter bases as follows: Define a set of n filter bases F = {F1, F2, ..., F n };in j∈{1,…,n}; Let n = N / k; where k>1 is a preset hyperparameter; A convolutional layer contains N = c out A complete filter is formed by linearly combining the defined filter bases. Only n filter bases are stored to construct all filters in a given layer; Introduce a coefficient matrix Then each filter is expressed as: Among them, the coefficient matrix Each parameter represents the coefficient of a linear combination; t represents the total number of filters required, t∈{1,…,N}.

5. The urban governance method based on the YOLO network according to claim 4 is characterized in that: The convolution filter reconstruction is as follows: Parameter setting: predefine the ratio of the filter basis and the original output channel, i.e. k; Initialization: Initialize n = N / k filter bases and coefficient matrix D; Convolution operation definition: Use the filter basis and coefficient matrix to perform linear combination to construct a new filter W t , and redefine the convolution operation; Convolutional layer definition: Add normalization BatchNorm and SiLU activation function to define a new complete convolutional layer.

6. The urban governance method based on the YOLO network according to claim 5 is characterized in that: The network architecture replacement is as follows: Replacement strategy setting: flexibly set different replacement strategies to adapt to different resource requirements; specifically: each C3 module contains multiple convolutional layers "Conv", and replace "Conv" at different positions with newly defined convolutional layers; Convolutional layer replacement: Integrate the newly defined convolutional layer into the YOLOv5 model definition to replace the original convolutional layer; Adjust network parameters: According to the characteristics of the newly defined convolutional layer, adjust the learning rate, batch size and other parameters of the network to ensure the stability and convergence of the model training; Recompile the model: Recompile the YOLO model to ensure that the newly defined convolutional layers are integrated correctly; Training and validation: Train the YOLO model using the prepared dataset; Performance evaluation: Compare the performance of the YOLO model before and after the replacement, and test key indicators including accuracy, mAP, as well as the number of network parameters and computational complexity on three actual application datasets to ensure the compression effectiveness of the new convolutional layer; Adjustment and optimization: Based on the results of performance evaluation, further adjust parameters and strategies, and iterate multiple times to achieve the best results.

7. The urban governance method based on the YOLO network according to claim 6 is characterized in that: The training and validation are as follows: Create a new dataset configuration YAML file to configure the dataset path, number of categories, and category list. At the same time, modify the nc parameter in the YOLO model configuration file according to the number of categories in the dataset. Use the Ultralytics command line to train the YOLO model, and adjust the script parameters to set the number of epochs and batch size; After the training is completed, the trained YOLO model is used to test the test set to evaluate the performance of the YOLO model.

8. A city governance system based on YOLO network, characterized in that: The system is used to implement the urban governance method based on the YOLO network as described in any one of claims 1 to 7; the system includes: The data collection and preprocessing module is used to select three representative scenes of urban governance, namely traffic accident detection, road surface detection and helmet and safety clothing detection, and collect image or video data of each scene through field shooting and network search; the collected image or video data is preprocessed by denoising, normalization and resizing to meet the input requirements of the model; and the generalization ability of the model is improved through data enhancement techniques such as random cropping, flipping and rotation; finally, the processed images are annotated in YOLO format to provide accurate training labels for the model so that the model can learn to identify and locate target objects; The convolution filter reconstruction module is used to design a set of filter bases, construct new convolution filters through different linear combinations of the filter bases, and use the newly constructed convolution filters to define new convolution operations, and reorganize the newly defined convolution operations, batch normalization and activation functions into new convolution layers; the new convolution layers are used to capture various visual features of contours and patterns in images; at the same time, by merging feature maps of different levels, feature fusion is achieved, which helps the network to integrate information of different scales and improve recognition accuracy; and by reconstructing filters, the feature extraction capability is enhanced while also improving computational efficiency; wherein, the number of filter bases is lower than the number of original convolution filters; The network architecture replacement module is used to replace the convolutional layer in the original C3 module in YOLOv5 with a new convolutional layer, obtain the YOLO model, and realize the compression of YOLOv5.

9. An electronic device, characterized in that: include: memory and at least one processor; Wherein, the memory stores a computer program; The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the urban governance method based on the YOLO network as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which can be executed by a processor to implement the urban governance method based on the YOLO network as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Remote sensing image target detection method based on deep evolution pruning convolutional network

    CN110532859A

  • Lightweight safety helmet wearing detection method based on YOLOv5

    CN115761645A

  • Improved YOLOv5 lightweight community scene pedestrian detection method

    CN115862066A

  • Embedded hardware-oriented face recognition method based on YOLOV7 model

    CN116229552A

  • Video stream target detection method and device based on modular lightweight network

    CN116403168A