Shell structure crack detection method based on deep learning
By randomly disrupting the data and setting the device, combining the deep learning model and the loss function for unbalanced data, the problem of poor crack detection accuracy in shell structures in the prior art is solved, and high-precision crack detection and efficiency improvement are achieved.
Patent Information
- Application Number
- CN202411596492.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-28
AI Technical Summary
Existing deep learning methods have poor identification accuracy in shell structure crack detection, especially in the case of complex backgrounds and low contrast.
By preparing data, including random disruption of data, and fully setting the device, the model is trained by using the deep learning model to learn the feature representation of the cracks, combined with the loss function for unbalanced data, the model performance is optimized to improve detection accuracy.
High-precision crack detection is achieved, the need for manual detection is reduced, the detection efficiency is improved, the crack can be accurately detected under complex backgrounds and low contrast, and the problem of crack pixels far less than background pixels is solved.
Smart Images

Figure CN119540178A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of architectural design, and in particular to a shell structure crack detection method based on deep learning. Background Art
[0002] Architectural design is gradually developing in a complex and diversified direction, which poses many challenges to structural design. Especially in free-form surface large-span spatial structures, the rationality of structural mechanical performance plays a decisive role in determining the success or failure of the plan. To achieve a free-form surface building that meets the architectural intention, on the one hand, it is necessary to ensure the rationality of structural mechanical performance, and on the other hand, it is necessary to minimize the construction difficulty and minimize the construction cost.
[0003] In response to the needs that may exist in actual engineering, the generation method of multiple wires for creating ruled surfaces using B-spline curves, as well as the connection and branching methods of wires of different orders are given. On this basis, the arrangement scheme of wires and wire control points of combined ruled surfaces, the setting of different orders, and the means of opening holes according to wire branches are discussed, and the generation method of initial shell structures of different forms of complex ruled surfaces is further studied.
[0004] Most of the existing shell structure crack detection methods based on deep learning use AlexNet to identify model cracks, but the accuracy of crack identification is poor. Therefore, there is an urgent need for a shell structure crack detection method based on deep learning. Summary of the invention
[0005] The purpose of this section is to summarize some aspects of the embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the specification abstract and the invention title of this application to avoid blurring the purpose of this section, the specification abstract and the invention title, and such simplifications or omissions cannot be used to limit the scope of the present invention.
[0006] In view of the above-mentioned and / or existing problems in a shell structure crack detection method based on deep learning, the present invention is proposed.
[0007] Therefore, the purpose of the present invention is to provide a shell structure crack detection method based on deep learning. By performing data preparation to randomly shuffle the data and performing model training after fully setting up the equipment, high-precision crack detection can be achieved by learning the characteristic representation of the cracks, reducing the need for manual detection, and improving detection efficiency. Even in difficult situations such as complex backgrounds and low contrast, cracks can be accurately detected. The deep learning model can use a loss function for unbalanced data to solve the problem that crack pixels are far less than background pixels, thereby improving the accuracy of crack detection.
[0008] To solve the above technical problems, according to one aspect of the present invention, the present invention provides the following technical solutions:
[0009] A shell structure crack detection method based on deep learning, comprising:
[0010] S1. Perform data preparation and create training and validation data sets, including assigning samples to training and validation sets and randomly shuffling the data;
[0011] S2, load and modify the model to adapt to specific application scenarios and optimize model performance;
[0012] S3. Perform device settings, determine the device on which the model runs, and give priority to using GPU to accelerate the training and reasoning process, including optimizer and loss function settings and data loader configuration;
[0013] S4, perform model training, including forward propagation, loss calculation, back propagation and optimizer steps. After each epoch, save the best model weights based on the performance on the validation set and perform crack detection on new images. Use the trained model to make predictions and output the crack category.
[0014] S5. Use the validation set to evaluate model performance, calculate indicators such as precision and recall, visualize model prediction results and make model improvements.
[0015] As a preferred solution of the shell structure crack detection method based on deep learning described in the present invention, in the step S1, the data to be prepared include image data set, data annotation, data preprocessing, image pixel normalization processing, data set division, data loading, data set category mapping and pre-trained model weights.
[0016] As a preferred solution of the shell structure crack detection method based on deep learning described in the present invention, in step S3, the setting of the optimizer and the loss function includes defining the loss function and the optimizer, and setting the learning rate scheduler to adjust the learning rate during the training process.
[0017] As a preferred solution of the shell structure crack detection method based on deep learning described in the present invention, in the step S3, the data loader configuration includes configuring DataLoader to load data in batches and setting appropriate parameters, such as batch size and whether to shuffle the data.
[0018] As a preferred solution of the shell structure crack detection method based on deep learning described in the present invention, in the step S5, the model reasoning step includes loading the model and performing image preprocessing, entering the evaluation mode, inputting the preprocessed image data into the model for reasoning and outputting analysis, and displaying the reasoning results after post-processing the output of the model as needed.
[0019] As a preferred solution of the shell structure crack detection method based on deep learning described in the present invention, in the step S5, the model improvement includes improving the performance of crack detection by improving the network structure, removing the fully connected layer and the average pooling layer, introducing a hybrid dilated convolution, adding a spatial channel attention mechanism between different layers, and using multi-scale feature fusion.
[0020] Compared with the existing technology: by randomly shuffling the data during data preparation and fully setting up the equipment for model training, it is possible to achieve high-precision crack detection by learning the characteristic representation of cracks, reduce the need for manual inspection, and improve detection efficiency. Even in difficult situations such as complex backgrounds and low contrast, cracks can be accurately detected. The deep learning model can use a loss function for unbalanced data to solve the problem that crack pixels are far less than background pixels, thereby improving the accuracy of crack detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the present invention will be described in detail below in combination with the accompanying drawings and detailed embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. Among them:
[0022] Figure 1 This is a schematic flow chart of a shell structure crack detection method based on deep learning in the present invention. DETAILED DESCRIPTION
[0023] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0024] Secondly, the present invention is described in detail with reference to schematic diagrams. When describing the embodiments of the present invention in detail, for the sake of convenience, the cross-sectional diagrams showing the device structure will not be partially enlarged according to the general scale, and the schematic diagrams are only examples, which should not limit the scope of protection of the present invention. In addition, in actual production, the three-dimensional dimensions of length, width and depth should be included.
[0025] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0026] The present invention provides a shell structure crack detection method based on deep learning. By performing data preparation to randomly shuffle the data and performing model training after fully setting up the equipment, high-precision crack detection can be achieved by learning the characteristic representation of the cracks, reducing the need for manual detection and improving detection efficiency. Even in difficult situations such as complex backgrounds and low contrast, cracks can be accurately detected. The deep learning model can use a loss function for unbalanced data to solve the problem that crack pixels are far less than background pixels, thereby improving the accuracy of crack detection.
[0027] Figure 1 The figure shows a schematic diagram of a process for implementing a shell structure crack detection method based on deep learning of the present invention. Figure 1 , a shell structure crack detection method based on deep learning in this embodiment includes the following steps:
[0028] Perform data preparation and create training and validation data sets, including assigning samples to training and validation sets and randomly shuffling the data. The data that needs to be prepared include image data sets, data annotation, data preprocessing, image pixel normalization, data set partitioning, data loading, data set category mapping, and pre-trained model weights:
[0029] ① It is necessary to collect image datasets containing shell structure cracks: these datasets can be specially collected for crack detection or publicly available datasets, such as CrackTree260, CRKWH100, CrackLS315, and Stone331;
[0030] ② Data labeling: For supervised learning, image data needs to be labeled to identify the location and category of cracks, which may include characteristics such as crack type, length, and width;
[0031] ③ Data preprocessing: 1. Resize the image to meet the model input requirements, such as resizing it to 224x224 pixels; 2. Perform data enhancement, such as random cropping, flipping, rotation, etc., to increase the diversity of the data set and prevent model overfitting;
[0032] ④ Normalization: Normalize the image pixel values to fit a specific range, such as [0,1] or [-1,1], to ensure the stability of model training;
[0033] ⑤ Dataset division: Divide the dataset into training set and validation set, with a common ratio of 80% training set and 20% validation set;
[0034] ⑥Data loading: Use DataLoader to load the dataset, set the batch size (batch size) and the number of worker threads (num_workers);
[0035] ⑦Dataset category mapping: Map the category name of the dataset to an integer index for easy model processing;
[0036] ⑧Preprocess model weights: If you use a pre-trained ResNet-50 model, you need to download the corresponding training model and load the parameters in the pre-trained model into the network.
[0037] Load and modify the model to adapt to specific application scenarios and optimize model performance. Load the pre-trained ResNet-50 model and freeze the model parameters to take advantage of its pre-training capabilities in image recognition. Modify the fully connected layer of the ResNet-50 model to adapt to the classification task of crack detection. This usually involves replacing the last fully connected layer to match the number of categories for crack detection. The specific steps are as follows:
[0038] ① Load the pre-trained ResNet-50 model: Using the PyTorch framework, you can load the pre-trained ResNet-50 model through the torchvision.models module. The code is as follows:
[0039] resnet50=models.resnet50(pretrained=True)
[0040] This will download and load the pre-trained ResNet-50 model, where pretrained=True means loading pre-trained weights;
[0041] ② Freeze model parameters: In order to perform transfer learning, it is usually necessary to freeze the parameters of the pre-trained model and only train the last few layers. The code is as follows:
[0042] for paramin resnet50.parameters():
[0043] param.requires_grad = False
[0044] This will set the requires_grad attribute of all parameters to False, meaning that the gradients of these parameters will not be calculated and updated during training;
[0045] ③Modify the fully connected layer of the model: According to the specific number of categories of the shell crack detection task, the fully connected layer of the ResNet-50 model needs to be modified. For example, if there are two categories (normal and crack), it can be modified as follows:
[0046] fc_inputs=resnet50.fc.in_features
[0047] resnet50.fc = nn.Sequential(
[0048] nn.Linear(fc_inputs,128),
[0049] nn.ReLU(),
[0050] nn.Dropout(0.4),
[0051] nn.Linear(128,2))
[0052] Here, the last fully connected layer is replaced with a new sequence consisting of a linear layer, a ReLU activation function, a Dropout layer, and another linear layer to accommodate two output categories;
[0053] ④ Transfer the model to the GPU: If available, transfer the model to the GPU to speed up the training process. The code is as follows:
[0054] resnet50=resnet50.to(device)
[0055] Where device is a PyTorch device object, which can be a CPU or GPU;
[0056] ⑤Set optimizer and loss function: Define the optimizer and loss function, for example, use the Adam optimizer and cross entropy loss function:
[0057] criterion=nn.CrossEntropyLoss()
[0058] optimizer=optim.Adam(resnet50.parameters())
[0059] You can also use the learning rate scheduler to adjust the learning rate during training;
[0060] ⑥Data loading and batch processing: Use DataLoader to load training and validation data sets and perform batch processing:
[0061] dataloaders={"train":DataLoader(TrainDataset,shuffle=True,batc h_size=batch_size,num_workers=num_workers,pin_memory=True,drop_las t=True),
[0062] "val":DataLoader(ValidationDataset,shuffle=True,batch_size=bat ch_size,num_workers=num_workers,pin_memory=True,drop_last=True)}
[0063] TrainDataset and ValidationDataset are custom dataset classes, batch_size and num_workers are the batch size and the number of worker threads.
[0064] Perform device settings, determine the device on which the model runs, and give priority to using GPUs to accelerate the training and inference process, including optimizer and loss function settings and data loader configuration. The settings of optimizers and loss functions include defining loss functions and optimizers, and setting learning rate schedulers to adjust the learning rate during training. Data loader configuration includes configuring DataLoader to load data in batches and setting appropriate parameters, such as batch size and whether to shuffle the data.
[0065] Use the validation set to evaluate the model performance, calculate indicators such as precision and recall, and visualize the model prediction results and improve the model. The model reasoning steps include loading the model and performing image preprocessing, entering the evaluation mode, inputting the preprocessed image data into the model for reasoning and output analysis, and post-processing the model output as needed to display the reasoning results. The specific steps of model reasoning are as follows:
[0066] ① Load the model: First, you need to load the trained ResNet-50 model. If you are using PyTorch, you can load the pre-trained model and replace the last fully connected layer to adapt to the number of categories for crack detection. For example, use torch.load to load the model weights;
[0067] ② Image preprocessing: Preprocess the input crack image to match the input requirements during model training. This usually includes steps such as resizing and normalizing the image. You can use transforms in torchvision for processing;
[0068] ③Model evaluation mode: Set the model to evaluation mode, turning off training-specific behaviors such as dropout and batch normalization. In PyTorch, this can be achieved by calling model.eval();
[0069] ④ Inference: Input the preprocessed image data into the model for inference. In PyTorch, this usually involves encapsulating the data into a torch.Tensor object and using torch.no_grad() to avoid calculating gradients;
[0070] ⑤ Output analysis: Model output is usually the logits or probability distribution of the category. These outputs need to be converted into specific category labels. In PyTorch, you can use torch.max to get the category index with the maximum probability;
[0071] ⑦ Post-processing: Post-process the output of the model as needed, such as non-maximum suppression (NMS) to remove overlapping detection boxes, or filter out detection results below the probability threshold;
[0072] ⑧Result display and resource release: Display the inference results, which can be printing out the crack category or drawing the detected crack box on the image. After the inference is completed, make sure to release all occupied resources, such as destroying dataset resources, uninstalling the model, etc.
[0073] Model improvements include improving the performance of crack detection by improving the network structure, removing fully connected layers and average pooling layers, introducing hybrid dilated convolutions, adding spatial channel attention mechanisms between different layers, and using multi-scale feature fusion.
[0074] Although the present invention has been described above with reference to the embodiments, various modifications may be made thereto and parts thereof may be replaced by equivalents without departing from the scope of the present invention. In particular, as long as there is no structural conflict, the various features in the embodiments disclosed in the present invention may be used in combination with each other in any manner, and the fact that these combinations are not exhaustively described in this specification is only for the sake of omitting space and saving resources. Therefore, the present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
Claims
1. A shell structure crack detection method based on deep learning, characterized in that: include: S1. Perform data preparation and create training and validation data sets, including assigning samples to training and validation sets and randomly shuffling the data; S2, load and modify the model to adapt to specific application scenarios and optimize model performance; S3. Perform device settings, determine the device on which the model runs, and give priority to using GPU to accelerate the training and reasoning process, including optimizer and loss function settings and data loader configuration; S4, perform model training, including forward propagation, loss calculation, back propagation and optimizer steps. After each epoch, save the best model weights based on the performance on the validation set and perform crack detection on new images. Use the trained model to make predictions and output the crack category. S5. Use the validation set to evaluate model performance, calculate indicators such as precision and recall, visualize model prediction results and make model improvements.
2. The shell structure crack detection method based on deep learning according to claim 1 is characterized in that: In step S1, the data that need to be prepared include image data set, data annotation, data preprocessing, image pixel normalization processing, data set partitioning, data loading, data set category mapping and pre-trained model weights.
3. The shell structure crack detection method based on deep learning according to claim 1 is characterized in that: In step S3, the setting of the optimizer and the loss function includes defining the loss function and the optimizer, and setting a learning rate scheduler to adjust the learning rate during the training process.
4. The shell structure crack detection method based on deep learning according to claim 1, characterized in that: In step S3, the data loader configuration includes configuring DataLoader to load data in batches and setting appropriate parameters, such as batch size and whether to shuffle the data.
5. The shell structure crack detection method based on deep learning according to claim 1, characterized in that: In step S5, the model reasoning step includes loading the model and performing image preprocessing, entering the evaluation mode, inputting the preprocessed image data into the model for reasoning and outputting analysis, and displaying the reasoning results after post-processing the output of the model as needed.
6. The shell structure crack detection method based on deep learning according to claim 1, characterized in that: In step S5, the model improvement includes improving the performance of crack detection by improving the network structure, removing the fully connected layer and the average pooling layer, introducing a hybrid dilated convolution, adding a spatial channel attention mechanism between different layers, and using multi-scale feature fusion.