Urban governance method, system, device and medium based on YOLO network
By collecting data, reconstructing convolutional filters, and replacing the network architecture, a lightweight YOLO model was constructed, which solved the problem of high resource demand of YOLO networks in urban governance and achieved efficient detection and rapid response.
Patent Information
- Application Number
- CN202411824130.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-12-12
AI Technical Summary
YOLO networks have high computational and storage resource requirements in urban governance, making them difficult to deploy effectively on resource-constrained devices. Furthermore, the model size affects response speed and makes it unable to adapt to diverse detection needs.
By collecting and preprocessing data, reconstructing convolutional filters, and replacing the network architecture, a new convolutional layer is designed to replace the C3 module in YOLOv5, thereby building a new YOLO model that reduces parameters and computational load and adapts to different resource requirements.
It has enabled efficient detection of the YOLO network in urban governance, improved detection efficiency and accuracy, adapted to resource-constrained equipment deployment, and improved the operational efficiency of urban governance.
Smart Images

Figure CN119762798B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to technical fields such as artificial intelligence, computer vision, and target detection, 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 (AI), object detection technology is playing an increasingly important role in smart city governance, enabling the automatic identification and classification of different objects in images or videos. As a highly efficient object detection algorithm, the YOLO family of networks, due to its fast and accurate detection capabilities, is widely used in various fields, including traffic management, security surveillance, and environmental monitoring. By processing video streams in real time, the YOLO network can detect objects such as vehicles and pedestrians, providing data support for traffic flow monitoring and road safety. It can also conduct real-time monitoring in crowded areas, enhancing urban safety. Despite these advantages, the storage and computing requirements of the YOLO network pose challenges for deployment on resource-constrained platforms in many real-world applications.
[0003] While YOLO performs well in various smart city scenarios, practical deployment still presents several challenges. For one thing, many applications require running models or algorithms on edge devices, which often have limited computing and memory resources. The original size of the YOLO model may, in some cases, be unsuitable for direct deployment on such resource-constrained devices. Furthermore, urban governance application scenarios are often diverse, placing varying demands on the performance and resource consumption of detection models. This requires models to better adapt to these diverse needs. Furthermore, the model's size, including parameters and computational complexity, also affects response speed. Reducing the model size can help it process and respond more quickly to data from urban operations.
[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 an urban 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 manner: a city governance method based on the YOLO network, the method is as follows:
[0007] Data collection and preprocessing: We selected three representative urban governance scenarios: traffic accident detection, road surface detection, and helmet and safety clothing detection. We collected image or video data for each scenario, preprocessed and annotated the collected image or video data 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 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 using a new convolutional filter and replace the convolutional layer in the original C3 module in YOLOv5 to obtain the YOLO model and implement YOLOv5 compression.
[0010] As a preference, data collection and preprocessing are specifically as follows:
[0011] Data Collection: Collect image or video data related to traffic accident detection, road surface detection, and safety helmet and safety clothing detection from public datasets or web crawler technology. For traffic accident detection, collect images and video data containing traffic accident scenes; video data includes accident and non-accident videos captured from fixed traffic cameras. For road surface detection, collect images of pavement cracks, potholes, manhole covers, and drains on the street. For safety helmet and safety clothing detection, collect images of scenes with and without safety helmets, safety clothing, and safety clothing worn at construction sites or workshops.
[0012] Image preprocessing and importing: Use OpenCV's image processing functions to preprocess the collected images to unify the image size and orientation; after preprocessing, import the images into the LabelImg and LabelMe annotation tools to prepare for subsequent processing;
[0013] Video frame processing: For video data, use OpenCV basic commands to extract frames to convert the 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 the LabelImg and LabelMe labeling tools to adjust the size and position of the labeling box to ensure that the labeling box accurately covers the target object. Each bounding box is assigned a category based on the different categories contained in the collected image to identify the type of object within the box. For example, for traffic accident detection, there are two categories: "accident" and "non-accident".
[0015] Data augmentation: We leverage OpenCV’s image processing capabilities to enhance the data and increase the diversity of the dataset. Specifically, we perform geometric transformations such as rotation, flipping, translation, and scaling on the image to help the model learn how objects behave at different positions, scales, and orientations. We also add random noise to the image to simulate different shooting environments and quality.
[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 the image to facilitate model processing;
[0018] Dataset division: Divide the processed and annotated image data and corresponding labels into training set, validation set and test set.
[0019] Better yet, the YOLO training format requires the dataset to have a specific directory structure, which includes two main folders: images and labels;
[0020] The images folder stores image files, and the labels folder stores 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: the class index (class), the x-coordinate of the object's center (x_center), the y-coordinate of the object's center (y_center), the width (width), and the height (height) of the object.
[0021] As a preference, a set of filter bases is 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] More optimally, 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 "Conv" in different positions are replaced with newly defined convolutional layers; in addition, YOLOv5 also contains multiple C3 modules in the head and backbone, and you can choose to replace the convolutional layers of the C3 modules in the head or backbone to achieve different compression effects; generally speaking, the more convolutional layers that are replaced, the fewer parameters and computational complexity 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 greater 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, replacing the original convolutional layer;
[0036] Adjust network parameters: Based on the characteristics of the newly defined convolutional layer, adjust the learning rate, batch size and other network parameters to ensure the stability and convergence of model training;
[0037] Recompile the model: Recompile the YOLO model to ensure that the newly defined convolutional layers are correctly integrated;
[0038] Training and validation: Use the prepared dataset to train the YOLO model;
[0039] Performance evaluation: We compared the performance of the YOLO model before and after the replacement, testing key metrics including accuracy and mean average prediction (MAP), as well as the number of network parameters and computational complexity on three real-world 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 steps 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, adjusting 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 includes:
[0046] The data collection and preprocessing module selects three representative urban governance scenarios: traffic accident detection, road surface detection, and helmet and safety clothing detection. It collects image or video data for each scenario through field photography and online searches. The collected image or video data undergoes preprocessing operations such as denoising, normalization, and resizing to meet the model's input requirements. Data augmentation techniques such as random cropping, flipping, and rotation are used to improve the model's generalization capabilities. Finally, the processed images are annotated in YOLO format to provide the model with accurate training labels so that it 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. The newly defined convolution operations, batch normalization, and activation functions are recombined into a new convolution layer. The new convolution layer is used to capture the contours, patterns, and various visual features in the image. Visual features 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. By reconstructing the filters, 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 layers in the original C3 module in YOLOv5 with new convolutional layers, obtain the YOLO model, and implement YOLOv5 compression.
[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 stores a computer program, which can be executed by a processor to implement the urban governance method based on the YOLO network as described above.
[0053] The YOLO network-based urban governance method, system, device, and medium of the present invention have the following advantages:
[0054] (1) This 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 performance and efficiency of target detection in practical applications of urban governance;
[0055] (2) This 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 model scale to accommodate different resource requirements, contributing to the development of efficient target detection solutions for resource-constrained devices in smart city governance;
[0056] (3) This invention can effectively reduce the number of parameters and computational complexity of the YOLO network, thereby improving detection efficiency. At the same time, different settings can be used to flexibly adjust the model scale to meet different resource requirements;
[0057] (4) 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] (5) Through continuous optimization of three stages, namely data collection and processing, convolution filter reconstruction, and network architecture replacement, the YOLO model can significantly reduce model size and accelerate model deployment while maintaining high detection accuracy, making it more suitable for application in resource-constrained urban governance scenarios;
[0059] (6) The present invention reconstructs the convolution filter by using a filter basis, which reduces the number of parameters and computational complexity of the convolution layer, and speeds up the training and reasoning of the network.
[0060] (7) 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] (8) The present invention provides flexible model scale selection by setting different compression parameters and strategies, supporting the deployment of the model on different resource-limited devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The present invention will be further described below with reference to the accompanying drawings.
[0063] Attachment Figure 1 Schematic diagram of filter reconstruction;
[0064] Attachment Figure 2 Schematic diagram of the C3 module structure (the new convolutional layer replaces the "Conv" layer). DETAILED DESCRIPTION
[0065] The following detailed description of the urban governance method, system, device and medium based on the YOLO network of the present invention is made with reference to the accompanying drawings and specific embodiments.
[0066] Example 1:
[0067] This embodiment provides a city governance method based on the YOLO network, which is specifically as follows:
[0068] S1. Data Collection and Preprocessing: We selected three representative scenarios for urban governance: traffic accident detection, road surface detection, and helmet and safety clothing detection. We collected image or video data for each scenario, and preprocessed and annotated the collected image or video data 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 using a new convolutional filter and replace the convolutional layer in the original C3 module in YOLOv5 to obtain the YOLO model and implement YOLOv5 compression.
[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 safety helmet and safety clothing detection from public datasets or web crawler technology. For traffic accident detection, collect images and video data containing traffic accident scenes; video data includes accident and non-accident videos captured from fixed traffic cameras. For road surface detection, collect images of pavement cracks, potholes, manhole covers, and drains on the street. For safety helmet and safety clothing detection, collect images of scenes with and without safety helmets, safety clothing, and safety clothing worn at construction sites or workshops.
[0073] S102, 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;
[0074] S103, video frame processing: For video data, use OpenCV basic commands to perform frame extraction to convert the original video data into an image format suitable for model input;
[0075] S104, Target Identification and Labeling: Identify the target to be located and draw a bounding box around it. Use the LabelImg and LabelMe annotation tools to adjust the size and position of the annotation box to ensure that the annotation box accurately covers the target object. Each bounding box is assigned a category based on the different categories contained in the collected image to identify the type of target within the box. For example, for traffic accident detection, there are two categories: "accident" and "non-accident".
[0076] S105, Data Augmentation: Use OpenCV's image processing capabilities to enhance the data and increase the diversity of the dataset. Specifically, geometric transformations such as rotation, flipping, translation, and scaling are performed on the image to help the model learn how objects behave in different positions, scales, and orientations. Random noise is also added to the image to simulate different shooting environments and quality.
[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 to facilitate model processing;
[0079] S108. Dataset 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 the dataset to have a specific directory structure, which includes two main folders: images and labels;
[0081] The images folder stores image files, and the labels folder stores 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: the class index (class), the x-coordinate of the object's center (x_center), the y-coordinate of the object's center (y_center), the width (width), and the 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, a set of filter bases are designed in step S2 of this embodiment 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; where 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: Initialize 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, convolutional layer definition: Add normalization BatchNorm and SiLU activation function to define a new complete convolutional 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, and each BottleNeck module 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. Finally, the outputs of the two branches are connected to achieve feature fusion. Since the C3 module occupies an important parameter share in YOLOv5, this embodiment compresses the C3 module at this stage by replacing the original convolution layer with a convolution layer containing the reconstruction filter, 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. You can 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 computational complexity 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 greater 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.
[0098] S302, convolutional layer replacement: Integrate the newly defined convolutional layer into the YOLOv5 model definition, replacing the original convolutional layer;
[0099] S303. Adjust network parameters: According to the characteristics of the newly defined convolutional layer, adjust the learning rate, batch size and other network parameters to ensure the stability and convergence of the 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 validation: using the prepared dataset to train the YOLO model;
[0102] S306, Performance Evaluation: Compare the performance of the YOLO model before and after the replacement, testing key indicators including accuracy, mAP, as well as the number of network parameters and computational complexity on three real-world application datasets 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, adjusting the script parameters to set the number of epochs and batch size.
[0107] S30503. After training is completed, the trained YOLO model is used to test the test set to evaluate the performance of the YOLO model.
[0108] Example 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 Example 1. The system includes:
[0110] The data collection and preprocessing module selects three representative urban governance scenarios: traffic accident detection, road surface detection, and helmet and safety clothing detection. It collects image or video data for each scenario through field photography and online searches. The collected image or video data undergoes preprocessing operations such as denoising, normalization, and resizing to meet the model's input requirements. Data augmentation techniques such as random cropping, flipping, and rotation are used to improve the model's generalization capabilities. Finally, the processed images are annotated in YOLO format to provide the model with accurate training labels so that it 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. The newly defined convolution operations, batch normalization, and activation functions are recombined into a new convolution layer. The new convolution layer is used to capture the contours, patterns, and various visual features in the image. Visual features 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. By reconstructing the filters, 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 layers in the original C3 module in YOLOv5 with new convolutional layers, obtain the YOLO model, and implement YOLOv5 compression.
[0113] Example 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), other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) 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 implements 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. 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 based on the use of the terminal, etc. In addition, the memory can also include high-speed random access memory and non-volatile memory, such as a hard disk, internal 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 memory devices.
[0119] Example 4:
[0120] This embodiment also provides a computer-readable storage medium storing a plurality of instructions, which are loaded by a processor to cause the processor to execute 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 software program code implementing the functions of any of the above embodiments is stored, and a computer (or CPU or GPU) of the system or device can be caused to read and execute 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 part of the present invention.
[0122] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (e.g., CD-ROMs, CD-Rs, CD-RWs, DVD-ROMs, DVD-RYMs, DVD-RWs, DVD+RWs), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer via a communications network.
[0123] In addition, it should be clear that the functions of any of the above embodiments can be achieved not only by executing the program code read by the computer, but also by enabling the operating system operating on the computer to complete part or all of the actual operations based on the instructions of the program code.
[0124] In addition, it can be understood that the program code read from the storage medium is written into the memory provided in the expansion board inserted into the computer or into the memory provided in the expansion unit connected to the computer, and then based on the instructions of the program code, the CPU installed on the expansion board or expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above 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 above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above 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: We selected three representative urban governance scenarios: traffic accident detection, road surface detection, and helmet and safety clothing detection. We collected image or video data for each scenario, preprocessed and annotated the collected image or video data 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 filter bases; the number of filter bases is less than the number of original convolution filters; Network architecture replacement: Build a new convolutional layer using a new convolutional filter and replace the convolutional layer in the original C3 module in YOLOv5 to obtain the YOLO model and implement YOLOv5 compression. Among them, designing a set of filter bases is as follows: Define a set n filter basis F={F 1 ,F 2 ,…,F n } ;in F j , j ∈{1,…, n }; make n=N / k ;in 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 to form the filter W t , only stores n filter basis 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 the linear combination; t represents the total number of filters required, t∈{1,…, N }; The convolution filter reconstruction is as follows: Parameter setting: predefine the ratio of filter basis and original output channel, i.e. k ; Initialization: Initialization n=N / k filter basis and coefficient matrix D; Convolution operation definition: Use the filter basis and coefficient matrix to perform linear combination to construct a new filter and redefine the convolution operation; Convolutional layer definition: Add normalization BatchNorm and SiLU activation function to define a new complete convolutional layer; 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 "Conv" in different positions are replaced with newly defined convolutional layers. Convolutional layer replacement: Integrate the newly defined convolutional layer into the YOLOv5 model definition, replacing the original convolutional layer; Adjust network parameters: Based on the characteristics of the newly defined convolutional layer, adjust the learning rate, batch size and other network parameters to ensure the stability and convergence of model training; Recompile the model: Recompile the YOLO model to ensure that the newly defined convolutional layers are correctly integrated; Training and validation: Use the prepared dataset to train the YOLO model; Performance evaluation: We compared the performance of the YOLO model before and after the replacement, testing key metrics including accuracy and mean average prediction (MAP), as well as the number of network parameters and computational complexity on three real-world 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.
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 safety helmet and safety clothing detection from public datasets or web crawler technology. For traffic accident detection, collect images and video data containing traffic accident scenes; video data includes accident and non-accident videos captured from fixed traffic cameras. For road surface detection, collect images of pavement cracks, potholes, manhole covers, and drains on the street. For safety helmet and safety clothing detection, collect images of scenes with and without safety helmets, safety clothing, and safety clothing worn at construction sites or workshops. Image preprocessing and importing: Use OpenCV's image processing functions to preprocess the collected images to unify the image size and orientation; after preprocessing, import the images into the LabelImg and LabelMe annotation tools to prepare for subsequent processing; Video frame processing: For video data, use OpenCV basic commands to extract frames to convert the 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 the LabelImg and LabelMe labeling tools to adjust the size and position of the labeling box to ensure that the labeling box accurately covers the target object. Each bounding box is assigned a category based on the different categories contained in the collected image to identify the type of target within the box. Data augmentation: We leverage OpenCV’s image processing capabilities to enhance the data and increase the diversity of the dataset. Specifically, we perform geometric transformations such as rotation, flipping, translation, and scaling on the image to help the model learn how objects behave at different positions, scales, and orientations. We also add random noise to the image to simulate different shooting environments and quality. Data format conversion: Convert the labeled data into YOLO training format to facilitate network training; Data normalization: Use OpenCV to standardize and normalize the image to facilitate 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; The images folder stores image files, and the labels folder stores 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, and each line represents the annotation information of an object. For each object, the label file contains five values: the category index, the x-coordinate of the object's center, the y-coordinate of the object's 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: The training and validation steps 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, adjusting 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.
5. A city governance system based on the 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 4; the system includes: The data collection and preprocessing module selects three representative urban governance scenarios: traffic accident detection, road surface detection, and helmet and safety clothing detection. It collects image or video data for each scenario through field photography and online searches. The collected image or video data undergoes preprocessing operations such as denoising, normalization, and resizing to meet the model's input requirements. Data augmentation techniques such as random cropping, flipping, and rotation are used to improve the model's generalization capabilities. Finally, the processed images are annotated in YOLO format to provide the model with accurate training labels so that it 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. The newly defined convolution operations, batch normalization, and activation functions are recombined into a new convolution layer. The new convolution layer is used to capture various visual features such as contours and patterns 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. By reconstructing the filters, 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. The network architecture replacement module is used to replace the convolutional layers in the original C3 module in YOLOv5 with new convolutional layers, obtain the YOLO model, and implement YOLOv5 compression.
6. 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 4.
7. 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 4.
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