Urban building earthquake damage prediction method and system based on neural network
By using the YOLOv3 neural network algorithm and Darknet-53 structure, the shortcomings in accuracy and efficiency of traditional building earthquake damage prediction methods are solved, more efficient building earthquake damage prediction is achieved, and a earthquake damage matrix is generated to support more effective emergency planning. .
Patent Information
- Application Number
- CN202410749146.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-10-01
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional building earthquake damage information prediction methods have problems such as low accuracy, low efficiency, high false detection rate and high missed detection rate in urban buildings, making it difficult to effectively respond to the challenges brought by earthquake disasters.
Using the YOLOv3 neural network algorithm and its Darknet-53 deep convolutional neural network structure, by collecting and preprocessing pre- and post-earthquake image data of buildings, a seismic damage matrix is generated to reflect the probability of building damage under different earthquake intensities. To improve the accuracy and efficiency of earthquake damage prediction.
It improves the accuracy and efficiency of building earthquake damage prediction, can more accurately identify the degree of earthquake damage of buildings, generates a earthquake damage matrix to help formulate disaster prevention and reduction strategies and emergency plans, enhances emergency response capabilities, and maximizes the protection of life and property. Safety.
Smart Images

Figure CN118736407A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of building parameter technology, specifically to the field of target prediction technology using a YOLOv3 neural network, and in particular to a method and system for predicting urban building earthquake damage based on a neural network. Background Art
[0002] Earthquake is a natural disaster with great destructive power, which poses a huge threat to human society, especially to urban buildings. Urban building earthquake damage prediction is one of the important means to mitigate earthquake disasters.
[0003] With the rapid development of the construction industry, the number and structural types of urban buildings are constantly being updated, which makes the traditional building earthquake damage information prediction method face many challenges, such as high difficulty, high false detection rate, high missed detection rate and low efficiency. These problems seriously affect the accuracy and timeliness of earthquake damage prediction, and restrict the effective implementation of disaster prevention and mitigation work.
[0004] YOLOv3 (You Only Look Once version 3) is an advanced real-time target detection algorithm. It uses a deep convolutional neural network structure called Darknet-53, which has powerful feature extraction capabilities. The YOLOv3 algorithm can better adapt to targets of different sizes by performing target detection at different scales, thereby improving detection accuracy and efficiency.
[0005] Although the YOLOv3 algorithm has taken a dominant position in the field of target detection, its application effect in urban building earthquake damage prediction is not the same. Urban building earthquake damage prediction is of great significance for mitigating earthquake disasters. As an efficient target detection algorithm, the YOLOv3 algorithm has broad application prospects in building earthquake damage prediction. By continuously optimizing and improving the YOLOv3 algorithm, we can better cope with the challenges brought by earthquake disasters and protect people's lives and property safety.
[0006] To this end, the present invention proposes a method and system for predicting urban building earthquake damage based on a neural network. Summary of the invention
[0007] In view of this, the embodiment of the present invention hopes to provide a method and system for predicting earthquake damage to urban buildings based on a neural network to solve or alleviate the technical problems existing in the prior art, that is, how to use the YOLOv3 algorithm to predict earthquake damage to urban buildings, and at least provide a beneficial option for this;
[0008] The technical solution of the embodiment of the present invention is achieved as follows:
[0009] First, a method for predicting earthquake damage to urban buildings based on neural networks:
[0010] 1. Overview:
[0011] The present invention aims to solve the above technical problems by using the YOLOv3 algorithm and its Darknet-53 deep convolutional neural network structure to obtain richer building information and earthquake data, thereby further improving the accuracy and efficiency of earthquake damage prediction. The number of buildings with different earthquake damage levels is counted, and an earthquake damage matrix is generated. This matrix can reflect the probability of different damage states of various types of buildings under different earthquake intensities. According to the prediction results, corresponding disaster prevention and mitigation strategies and emergency plans are formulated to reduce the impact of earthquakes on buildings.
[0012] (II) Technical solution:
[0013] To achieve the above technical goals, this solution needs to perform the following steps S1 to S4:
[0014] 2.1 Step S1, data preparation:
[0015] Collect historical earthquake damage data of the designated area, including images of buildings before and after the earthquake and label information of the damage degree, to form a dataset D. Its form is:
[0016]
[0017] in: Represents the image data of the building in the i-th sample before the earthquake. Represents the image data of the building after the earthquake in the i-th sample. i Represents the earthquake damage degree label of the building in the i-th sample. Each sample is a triple containing the pre-earthquake image, the post-earthquake image, and the earthquake damage degree label. In practical applications, image data is a high-dimensional pixel matrix, and label data is a discrete category identifier or a continuous earthquake damage degree score.
[0018] At the same time, the dataset D is divided into training set D train , test set D test , validation set D val . Use 70% of the data as the training set D train , 15% as validation set D val to adjust the model parameters, and the remaining 15% is used as the test set D test To evaluate the model performance.
[0019] At the same time, the collected image data can also be preprocessed, including conventional labeling, cropping and normalization processing techniques, to meet the input requirements of the YOLOv3 algorithm.
[0020] 2.2 Step S2, read the YOLOv3 algorithm:
[0021] Read the YOLOv3 algorithm framework, including using Darknet53 as the backbone network for forward propagation, loss calculation, and back propagation of the input data x. The input data x is equivalent to any sample in the data set D, and YOLOv3 uses Darknet53 as the backbone network for feature extraction.
[0022] 2.2.1 Step S200, forward propagation:
[0023] For input data x (it can be any sample in the dataset (D), i.e. an image), the Darknet53 network performs a series of convolution and residual connection operations to extract image features. This process can be formally expressed as:
[0024] f = Darknet53(x);
[0025] Among them, f is the feature map extracted from the input image x.
[0026] 2.2.2 Step S201, prediction output:
[0027] YOLOv3 makes predictions at multiple scales, usually at three different scales. For each scale, the network outputs a tensor containing the coordinates, width, height, confidence, and class probability of the bounding box. The prediction process is:
[0028] (b x , b y , b w , b h ,conf,p c )=PredictionHead(f);
[0029] Among them, (b x ,b y ,b w ,b h ) is the predicted bounding box position and size, conf is the predicted confidence, p c is the predicted class probability.
[0030] 2.2.3 Step S202, loss calculation:
[0031] The loss function of YOLOv3 includes bounding box coordinate loss, width and height loss, confidence loss, and classification loss. These losses are calculated using mean square error (MSE) or cross-entropy loss. The total loss is expressed as:
[0032] Loss=Losscoord+Losswidth-height+Lossconfidence+Lossclassification;
[0033] The specific calculation method of each loss depends on the specific implementation and configuration of YOLOv3.
[0034] 2.2.4 Step S203, back propagation:
[0035] After calculating the loss, the back-propagation algorithm is used to update the weights of the network. This process involves calculating the gradient of the loss function with respect to the network parameters and using these gradients to update the network parameters. One step of gradient descent can be expressed as:
[0036]
[0037] Among them, θ represents the parameters of the network (weights and biases), η is the learning rate, is the gradient of the loss function with respect to the parameters.
[0038] 2.3 Model training:
[0039] Based on the framework of the YOLOv3 algorithm in step S2, on the prepared training set D train By continuously adjusting the model parameters and optimizer settings, the model is trained on the training set D train A higher accuracy rate can be achieved on the validation set D val Validate the model to ensure that it is not overfitting and has good generalization ability.
[0040] In the test set D test The performance of the model is evaluated on the dataset, including the accuracy and recall indicators. According to the evaluation results, the model is enhanced with data to improve its predictive performance.
[0041] 2.3.1 Model training:
[0042] In the training set D train The model is trained using the YOLOv3 algorithm and the selected optimizer (Adam or SGD). The training goal is to minimize D train Loss function on train , the loss function includes classification loss and positioning loss. The training process is expressed as finding the optimal model parameter θ * The problem:
[0043] θ * =arg m θ Loss rain(θ;Dtrain);
[0044] Among them, θ represents the parameter set of the model, Loss train is the loss function on the training set.
[0045] 2.3.2 Model Validation:
[0046] On the validation set D val The performance of the model is evaluated on the validation set to ensure that there is no overfitting and that it has good generalization ability. val And accuracy to complete:
[0047]
[0048] Among them, M(x; θ^) represents the prediction result of the model using the optimal parameter θ^ for the input x, and y is the true label.
[0049] 2.3.3 Model testing and evaluation:
[0050] In the test set D test The final performance of the model is evaluated on , including accuracy (Precision) and recall (Recall):
[0051]
[0052] Among them, TP is true positive (actually positive and predicted as positive), FP is false positive (actually negative but predicted as positive), and FN is false negative (actually positive but predicted as negative).
[0053] 2.3.4 Data enhancement strategy:
[0054] If the model performs poorly on the test set, you can consider using a data augmentation strategy to improve the generalization ability of the model. Data augmentation can be represented as a series of transformation operations T on the original data set D to generate new training samples:
[0055] D augmented =T(x,y)|(x,y)∈D;
[0056] Among them, T includes rotation, scaling and translation operations. Then in the enhanced dataset D augmented Retrain the model on.
[0057] 2.4 Step S3, prediction and earthquake damage matrix generation:
[0058] The trained YOLOv3 model is used to predict the building images in the specified area and identify the earthquake damage degree of the buildings. According to the prediction results, the number of buildings with different earthquake damage degrees is counted and an earthquake damage matrix is generated. This matrix reflects the probability of different damage states of various types of buildings under different earthquake intensities.
[0059] 2.4.1 Step S300, prediction:
[0060] For the set of building images I in the specified area, i.e., the input x in step S2, the trained YOLOv3 model M is used for prediction. The prediction function is expressed as: P = M(I);
[0061] Among them, P is the model's prediction result of the earthquake damage degree of the building in each image, including the location, category and corresponding earthquake damage degree of the building.
[0062] 2.4.2 Step S301, counting the number of buildings with different earthquake damage levels:
[0063] According to the prediction result P, the number of buildings with different earthquake damage levels is counted. d represents the number of buildings with earthquake damage degree d, then the statistical process can be expressed as:
[0064] N d =∑ p∈P IIP damage =d;
[0065] Among them, p damage represents the earthquake damage degree in the prediction result p, and Ⅱ(·) is an indicator function, which takes 1 when the condition is true and 0 otherwise.
[0066] 2.4.3 Step S302, generate earthquake damage matrix:
[0067] Earthquake damage matrix M damage is a two-dimensional matrix, where the rows represent the earthquake intensity and the columns represent the damage status of the building. The element m in the matrix ij It represents the probability of a building in damage state j under earthquake intensity i. This probability can be estimated by statistically analyzing the distribution of building damage states under different earthquake intensities. However, due to the limitations of actual data, this probability may need to be estimated based on expert knowledge, historical data or other models. The earthquake damage matrix is expressed as:
[0068]
[0069] Where m is the number of earthquake intensity levels considered and n is the number of damage states of buildings. Each element m ij It represents the probability of a building being damaged in state j under earthquake intensity i.
[0070] (III) Mechanism for solving technical problems:
[0071] The YOLOv3 (You Only Look Once, version 3) algorithm, with its excellent target detection capabilities, has become a key component of our solution. The algorithm uses Darknet-53 as the backbone network, which is a 53-layer deep convolutional neural network that is particularly suitable for handling complex image recognition tasks. The powerful feature extraction capability of Darknet-53 enables our model to more accurately identify buildings and further determine their earthquake damage.
[0072] In the data preprocessing stage, the YOLOv3 algorithm is used to annotate and learn a large number of building images. This process not only includes the location information of the building, but also covers the type, structure and possible earthquake damage characteristics of the building. In this way, the model can learn more abundant building information during the training process, providing a solid foundation for subsequent earthquake damage prediction.
[0073] During the model training phase, we continuously adjusted the model parameters and optimizer settings to enable the YOLOv3 algorithm to achieve a high accuracy rate on the training set. At the same time, we also pay great attention to the generalization ability of the model, and use the validation set for multiple validations to ensure that the model can maintain stable performance when facing new data.
[0074] Once the model training is completed, it can be used to predict the extent of earthquake damage in building images in a specified area. In this process, the YOLOv3 algorithm can quickly and accurately identify the buildings in the image and determine their extent of earthquake damage based on the learned features. According to the prediction results, the number of buildings with different degrees of earthquake damage is counted and an earthquake damage matrix is generated. This can help us fully understand the damage status and probability distribution of various types of buildings under different earthquake intensities. In this way, the government and relevant departments can formulate emergency plans and rescue plans more specifically, thereby minimizing the losses caused by earthquakes.
[0075] Second, a neural network-based urban building earthquake damage prediction system:
[0076] like Figure 3 As shown, the system includes a processor and a memory connected to the processor, wherein the memory stores program instructions. When the program instructions are executed by the processor, the processor executes the urban building earthquake damage prediction method as described above and feeds back the results to a display screen.
[0077] Compared with the prior art, the present invention has the following beneficial effects:
[0078] 1. Improve prediction accuracy: This invention adopts the advanced YOLOv3 algorithm and the powerful Darknet-53 deep convolutional neural network structure to more accurately identify and classify buildings and accurately predict their earthquake damage. This high-precision prediction capability helps decision makers make more accurate decisions, optimize resource allocation, and thus improve the efficiency of emergency rescue.
[0079] 2. Enhance emergency response capabilities: The present invention generates an earthquake damage matrix, which enables decision makers to quickly understand the potential damage status of various types of buildings under different earthquake intensities. This foresight helps to formulate more effective emergency plans in advance, shorten the response time after the disaster occurs, and maximize the protection of people's lives and property.
[0080] 3. Improve the efficiency of disaster prevention and mitigation: With its efficient prediction model, the present invention can process a large amount of building image data in a short time, providing timely information support for disaster assessment and rescue work. This rapid information feedback mechanism helps relevant departments to respond quickly after a disaster occurs and reduce the losses caused by the disaster. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0082] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0083] Figure 2 It is a schematic diagram of the training method of the present invention;
[0084] Figure 3 It is a schematic diagram of the system composition of the present invention;
[0085] Figure 4 This is a schematic diagram of the Python execution program of step S1 of the present invention;
[0086] Figure 5 This is a schematic diagram of the Python framework program of step S2 of the present invention;
[0087] Figure 6 Schematic diagram of a training method according to Embodiment 2 of the present invention;
[0088] Figure 7 This is a schematic diagram of the Python execution program of step S3 of the present invention. DETAILED DESCRIPTION
[0089] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below;
[0090] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0091] Example 1: Please refer to Figure 1 This embodiment discloses a method for predicting urban building earthquake damage based on a neural network; it includes the following steps S1 to S3:
[0092] In this embodiment, regarding step S1, data preparation: the goal of this stage is to build a comprehensive and accurate data set in order to train an efficient neural network model for subsequent earthquake damage prediction. First, focus on collecting historical earthquake damage data in a specified area. These data include images of buildings before and after an earthquake, as well as corresponding earthquake damage degree label information. The construction method of data set D ensures that each data point contains a complete information triple: pre-earthquake image, post-earthquake image, and earthquake damage degree label. Formally, data set D can be represented as a series of triplets:
[0093]
[0094] in: Represents the image data of the building in the i-th sample before the earthquake. Represents the image data of the building after the earthquake in the i-th sample. i Represents the earthquake damage degree label of the building in the i-th sample. Each sample is a triple containing the pre-earthquake image, the post-earthquake image, and the earthquake damage degree label. In practical applications, image data is a high-dimensional pixel matrix, and label data is a discrete category identifier or a continuous earthquake damage degree score.
[0095] At the same time, the dataset D is divided into training set D train , test set D test , validation set D val . Use 70% of the data as the training set D train , 15% as validation set D valto adjust the model parameters, and the remaining 15% is used as the test set D test To evaluate the model performance.
[0096] In addition, in order to meet the input requirements of the YOLOv3 algorithm, we also need to preprocess the collected image data. This includes conventional image annotation, cropping, and normalization techniques. The annotation process ensures that the model can identify key features in the image; cropping helps remove irrelevant parts of the image, allowing the model to focus more on the earthquake damage characteristics of the building; and normalization can eliminate dimensional differences in image data and improve the training efficiency and accuracy of the model.
[0097] It is understandable that by preparing the dataset D, we can ensure that the neural network model can be exposed to a variety of earthquake damage scenarios during the training process, thereby improving its ability to identify different earthquake damage situations. At the same time, by dividing the dataset into three parts: training, validation, and testing, we can comprehensively evaluate the performance of the model and avoid overfitting or underfitting problems. In addition, the preprocessing step of the image data can further enhance the model's sensitivity to the characteristics of building earthquake damage, thereby improving the accuracy and reliability of the prediction. These measures work together to make our urban building earthquake damage prediction method more practical and accurate in practical applications.
[0098] Furthermore, the Python execution program of step S1 is as follows Figure 4 As shown in the figure, the principle is to set the directory of the original data and the directory of the processed data. The processed data will be divided into three subdirectories: training, validation, and testing. Each subdirectory has two folders, 'before' and 'after', for storing images before and after the earthquake. The os.listdir() function is used to obtain the list of image files before and after the earthquake in the original data directory, as well as the corresponding list of label files. An assertion is used to ensure that the number of images before and after the earthquake is the same and matches the number of label files. This is to ensure the integrity of the data. The data is divided into training, validation, and test sets using the train_test_split function from the sklearn.model_selection library. First, we divide the data into 70% training set and 30% temporary test set. Then, the 30% temporary test set is divided into two equal parts, as the validation set and the final test set. Finally, we use the shutil.copy2() function to copy the segmented images and label files to the corresponding processed data directory.
[0099] In this embodiment, regarding step S2, the YOLOv3 algorithm is read: the YOLOv3 algorithm framework is read, including using Darknet53 as the backbone network for forward propagation, loss calculation, and back propagation of the input data x. The input data x is equivalent to any sample in the data set D, and YOLOv3 uses Darknet53 as the backbone network for feature extraction.
[0100] Specifically, step S200, forward propagation: In this stage, Darknet53 is used as the backbone network of YOLOv3. For the input data x (it can be any sample in the data set D, that is, an image), the Darknet53 network will perform a series of complex convolution, residual connection and other operations to extract features in the image:
[0101] f = Darknet53(x);
[0102] Among them, f is the feature map extracted from the input image x. The design of the Darknet53 network structure enables it to efficiently extract multi-level features in the image and provide rich information for subsequent prediction steps.
[0103] Specifically, step S201, prediction output: The feature of the YOLOv3 algorithm is to make predictions at multiple scales, usually three different scales. For each scale, the network will output a tensor containing rich information, which covers the coordinates, width and height, confidence and category probability of the bounding box. The prediction process is:
[0104] (b x ,b y ,b w , b h ,conf,p c ) = PredictconHead(f);
[0105] Among them, (b x ,b y ,b w ,b h ) is the predicted bounding box position and size, conf is the predicted confidence, p c is the predicted category probability. This multi-scale prediction strategy enables YOLOv3 to detect objects of different sizes and positions, thereby improving the accuracy of earthquake damage prediction.
[0106] Specifically, step S202, loss calculation: The loss function of YOLOv3 includes bounding box coordinate loss, width and height loss, confidence loss and classification loss. These losses are calculated using mean square error (MSE) or cross-entropy loss. The total loss is expressed as:
[0107] Loss=Losscoord+Losswidth-height+Lossconfidence+Lossclassification;
[0108] The calculation details of each loss depend on the specific implementation and configuration of YOLOv3. By minimizing this total loss function, the network can gradually adjust its parameters to improve the accuracy of the prediction.
[0109] Specifically, step S203, back propagation: after calculating the loss, use the back propagation algorithm to update the weights of the network. This process involves calculating the gradient of the loss function with respect to the network parameters and using these gradients to update the network parameters. One step of gradient descent can be expressed as:
[0110]
[0111] Among them, θ represents the parameters of the network (including weights and biases), η is the learning rate, which is used to control the step size of parameter update, is the gradient of the loss function with respect to the parameters. By repeatedly performing this update step, the network can gradually learn an effective mapping from the input image to the predicted output, thereby improving its performance in the task of urban building earthquake damage prediction.
[0112] Furthermore, the python program of step S2 is as follows Figure 5As shown in the figure, the principle is as follows: first, the pre-trained YOLOv3 model is loaded. This model is usually trained on a large number of data sets and can recognize a variety of objects in images. A random input tensor x (representing an image) is passed to the backbone network of the model (i.e. Darknet53). This network extracts the features of the image through a series of convolution and residual connection operations. The extracted features will be used in the subsequent prediction steps. The extracted features are passed to the prediction heads, which generate prediction results at multiple scales. Each prediction result contains information such as the coordinates, size, confidence, and category probability of the bounding box. In the actual training process, we need to calculate the difference between the prediction result and the true label, that is, the loss. This loss function is a composite loss function that combines the bounding box coordinate loss, width and height loss, confidence loss, and classification loss. By minimizing this loss function, we can optimize the parameters of the model to improve the prediction accuracy. After calculating the loss, the back propagation algorithm is used to calculate the gradient of the loss function with respect to the model parameters, and these gradients are used to update the parameters of the model.
[0113] In this embodiment, regarding step S3, prediction and earthquake damage matrix generation: the trained YOLOv3 model is used to predict the building images in the specified area and identify the earthquake damage degree of the buildings. According to the prediction results, the number of buildings with different earthquake damage degrees is counted, and an earthquake damage matrix is generated. This matrix reflects the probability of different damage states of various types of buildings under different earthquake intensities.
[0114] Specifically, step S300, prediction: for the set of building images I in the specified area, i.e., the input x of step S2, use the trained YOLOv3 model M to make predictions. The prediction function is expressed as: P = M(I); where P is the model's prediction result of the earthquake damage degree of the building in each image. Including the location, category and corresponding earthquake damage degree of the building. These prediction results include not only the location and type of the building, but also the corresponding earthquake damage degree, thus providing us with detailed information about the damage to the building.
[0115] Specifically, in step S301, the number of buildings with different earthquake damage degrees is counted: according to the prediction result P, the number of buildings with different earthquake damage degrees is counted. Assume N d represents the number of buildings with earthquake damage degree d, then the statistical process can be expressed as:
[0116] N d =∑ p∈P Ip damage =d;
[0117] Among them, p damagerepresents the earthquake damage degree in the prediction result p, and Ⅱ(·) is an indicator function, which takes 1 when the condition is true and 0 otherwise. In this way, we can accurately understand the distribution of buildings under different earthquake damage degrees.
[0118] Specifically, in step S302, a damage matrix is generated: the damage matrix M damage is a two-dimensional matrix, where the rows represent the earthquake intensity and the columns represent the damage status of the building. The element m in the matrix ij It represents the probability of a building in damage state j under earthquake intensity i. This probability can be estimated by statistically analyzing the distribution of building damage states under different earthquake intensities. However, due to the limitations of actual data, this probability may need to be estimated based on expert knowledge, historical data or other models. The earthquake damage matrix is expressed as:
[0119]
[0120] Where m is the number of earthquake intensity levels considered and n is the number of damage states of buildings. Each element m ij It represents the probability of a building being damaged in state j under earthquake intensity i.
[0121] Furthermore, the python program of step S3 is as follows Figure 7 As shown in the figure, the principle is that the predict function accepts a trained model model and a dataset of building images to be predicted as input. Use the model's predict method to predict the image and return the prediction result. These results usually contain information such as the location, category, and degree of damage of the building. The count_damage_levels function traverses the prediction results and counts the number of buildings at each damage level. The prediction result contains a field ('damage_level') indicating the degree of damage, and the degree of damage is quantified into several discrete levels (5 levels). The function returns a dictionary, the key is the damage level, and the value is the number of buildings at the corresponding level.
[0122] The generate_damage_matrix function generates a damage matrix based on the number of statistical damage levels and the given earthquake intensity level. The rows of the matrix represent the earthquake intensity and the columns represent the damage level. Each element represents the probability of a building suffering a specific damage level under a specific earthquake intensity. The function finally returns a damage matrix represented by a NumPy array.
[0123] Example 2: Please refer to Figure 2 Based on the framework constructed in step S2 of the first embodiment, this embodiment further provides a training method for the YOLOv3 algorithm, including the following steps:
[0124] The first step is model training: Based on the framework of the YOLOv3 algorithm in step S2, on the prepared training set D train By continuously adjusting the model parameters and optimizer settings, the model is trained on the training set D train A higher accuracy rate can be achieved on the validation set D val Verify the model to ensure that it is not overfitting and has good generalization ability. test The performance of the model is evaluated on the dataset, including the accuracy and recall indicators. According to the evaluation results, the model is enhanced with data to improve its predictive performance.
[0125] The second step is model training: in the training set D train We use the YOLOv3 algorithm and select efficient optimizers such as Adam or stochastic gradient descent (SGD) to train the model. The core goal of training is to minimize the loss function Loss on the training set. train , this loss function takes into account the accuracy of classification and the accuracy of positioning. The entire training process can be regarded as finding a set of optimal model parameters θ * , so that under this set of parameters, the loss function on the training set reaches the minimum value:
[0126] θ * = arg m θ Loss rain(θ;Dtrain);
[0127] Among them, θ represents the parameter set of the model, Loss train is the loss function on the training set.
[0128] Step 3: Model validation: Model validation is a key step to ensure that the model is not overfitted and can perform well on unseen data. val The performance of the model is evaluated by calculating the average loss Loss on the validation set val And accuracy to quantify the generalization ability of the model. Here Loss val It is obtained by comparing the difference between the model prediction result M(x; θ^) and the true label y:
[0129]
[0130] Among them, M(x; θ^) represents the prediction result of the model using the optimal parameter θ^ for the input x, and y is the true label.
[0131] Step 4: Model testing and evaluation: After model training and verification, we use an independent test set Dtest to evaluate the final performance of the model. The test set contains data that the model has never seen during the training phase, so it can truly reflect the generalization performance of the model. The evaluation indicators mainly include accuracy (Precision) and recall (Recall), which can comprehensively measure the effectiveness of the model in identifying earthquake damage to urban buildings. The accuracy rate reflects the proportion of samples predicted by the model as positive examples that are truly positive; while the recall rate reflects the proportion of all samples that are truly positive examples that are correctly predicted by the model:
[0132]
[0133] Among them, TP is true positive (actually positive and predicted as positive), FP is false positive (actually negative but predicted as positive), and FN is false negative (actually positive but predicted as negative).
[0134] Step 5: Data enhancement strategy: If the model performs poorly on the test set, you can consider using a data enhancement strategy to improve the generalization ability of the model. Data enhancement can be represented as a series of transformation operations T on the original data set D to generate new training samples:
[0135] D augmented =T(x,y)|(x,y)∈D
[0136] Among them, T includes rotation, scaling and translation operations. Then in the enhanced dataset D augmented Retrain the model on.
[0137] Further, the puthon execution program of the training method of this embodiment is as follows Figure 6As shown: Load the data for the training set, validation set, and test set. These datasets contain images and corresponding labels (such as the location of the building and the degree of earthquake damage). DataLoader is used to load data in batches and shuffle it (only in the training set). Initialize the YOLOv3 model and select the optimizer (SGD) to update the parameters of the model. The optimizer is responsible for adjusting the weights of the model based on the calculated gradients. In the training loop, we iterate the training dataset, obtain the prediction results of the model through forward propagation, then calculate the loss function, and calculate the gradient through backpropagation. Finally, the optimizer is used to update the parameters of the model. This process is repeated until the preset number of training rounds (epochs) is reached. The performance of the model on the validation set is evaluated in the validation phase. The performance of the model is quantified by calculating the average loss on the validation set. This phase does not use gradient calculation, so the torch.no_grad() context manager is used to save memory and speed up calculations. In the testing phase, we use the test set to evaluate the final performance of the model. This includes calculating indicators such as accuracy and recall to comprehensively measure the model's ability to identify earthquake damage in urban buildings.
[0138] All the above embodiments only express the implementation methods of the relevant practical applications of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be based on the attached claims.
[0139] For those skilled in the art, it can be further appreciated that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0140] At the same time, those skilled in the art can understand that all or part of the processes in all the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media provided in this application and used in the embodiments may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
Claims
1. A method for predicting earthquake damage to urban buildings based on a neural network, characterized in that: The steps include: S1, data preparation: collect historical earthquake damage data of the designated area, including images of buildings before and after the earthquake and label information of the damage degree, to form the data set D; S2, read the YOLOv3 algorithm: including using Darknet53 as the backbone network for forward propagation, loss calculation, and back propagation of the input data x; S3, prediction and earthquake damage matrix generation: Use the trained YOLOv3 model to predict the building images in the specified area and identify the earthquake damage degree of the buildings; According to the prediction results, the number of buildings with different degrees of earthquake damage is counted and an earthquake damage matrix is generated.
2. The urban building earthquake damage prediction method according to claim 1, characterized in that: In S1, the data set D is: in: represents the image data of the building before the earthquake in the i-th sample; represents the image data of the building after the earthquake in the i-th sample; L i Represents the earthquake damage degree label of the building in the i-th sample.
3. The urban building earthquake damage prediction method according to claim 1 is characterized in that: In S2, the forward propagation method is: For the input data x, convolution and residual connection operations are performed to extract image features: f = Darknet53(x); Among them, f is the feature map extracted from the input image x.
4. The urban building earthquake damage prediction method according to claim 3 is characterized in that: In S2, for each scale, the YOLOv3 network outputs a tensor containing the coordinates, width, height, confidence, and category probability of the bounding box: (b x ,b y ,b w ,b h ,conf,p c )=PredictionHead(f); Among them, (b x ,b y ,b w ,b h ) is the predicted bounding box position and size, conf is the predicted confidence, p c is the predicted class probability.
5. The urban building earthquake damage prediction method according to claim 4 is characterized in that: In S2, loss calculation is performed, including bounding box coordinate loss, width and height loss, confidence loss and classification loss; and the mean square error MSE is used to calculate the total loss.
6. The urban building earthquake damage prediction method according to claim 3 is characterized in that: In S2, the back propagation method is: calculating the gradient of the loss function with respect to the network parameters, and using these gradients to update the network parameters: Among them, θ represents the parameters of the network (weights and biases), η is the learning rate, is the gradient of the loss function with respect to the parameters.
7. The urban building earthquake damage prediction method according to claim 1 is characterized in that: In S3, the prediction method is: for a set of building images I in a specified area, i.e., the input x of S2, a trained YOLOv3 model M is used for prediction; the prediction function is expressed as: P = M(I); Among them, P is the model's prediction result of the earthquake damage degree of the building in each image, including the location, category and corresponding earthquake damage degree of the building.
8. The urban building earthquake damage prediction method according to claim 7 is characterized in that: In S3, let N d It represents the number of buildings with earthquake damage degree d. According to the prediction result P, the number of buildings with different earthquake damage degrees is counted: N d =∑p∈PIIp damage =d; Among them, p damage represents the earthquake damage degree in the prediction result p, and Ⅱ(·) is an indicator function, which takes 1 when the condition is true and 0 otherwise.
9. The urban building earthquake damage prediction method according to claim 7, characterized in that: In S3, the damage matrix M damage is a two-dimensional matrix, where the rows represent the earthquake intensity and the columns represent the damage status of the building: Where m is the number of earthquake intensity levels considered, n is the number of damage states of buildings; each element m ij It represents the probability of a building being damaged in state j under earthquake intensity i.
10. A system for predicting earthquake damage to urban buildings based on a neural network, characterized in that: The system includes a processor and a memory connected to the processor, wherein program instructions are stored in the memory, and when the program instructions are executed by the processor, the processor executes the urban building earthquake damage prediction method as described in any one of claims 1-9.
Citation Information
Cited By
Two-stage underground station earthquake damage intelligent prediction method
CN122366787A
A two-stage underground station seismic damage intelligent prediction method
CN122366787B
