Metal crack detection method, device, electronic equipment and storage medium
Through the feature extraction and analysis of metal crack detection through convolutional neural networks, feature maps are generated to identify metal cracks, which solves the problems of low recognition accuracy and high training difficulty of traditional methods, achieving higher recognition accuracy and lower Training costs.
Patent Information
- Application Number
- CN202210220084.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-03-08
AI Technical Summary
Traditional metal crack detection methods cannot effectively extract the characteristic information of cracks, have low recognition accuracy, are difficult to optimize and train, and cannot adapt to the characteristics of slender and angular cracks on the metal surface.
A feature extraction network based on a convolutional neural network is used to extract and analyze multiple features of the image to be inspected through the convolutional layer and the detection layer to generate features that represent the presence of the target object, center point offset, frame width, height, and tilt angle. Figure, improve recognition accuracy and reduce training difficulty.
It improves the recognition accuracy of metal cracks, reduces useless information, is suitable for slender and angular crack characteristics, and reduces the difficulty and cost of model optimization training.
Smart Images

Figure CN114757875B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image detection technology, and in particular to a metal crack detection method, device, electronic equipment and storage medium. Background Art
[0002] Due to the long-term alternating loads during the production process or use, some weak parts of metal components are more likely to produce fatigue cracks (local ruptures). Moreover, under certain load or environmental conditions, these fatigue cracks will gradually grow, and once they expand to a critical size, the component will be completely destroyed (broken).
[0003] In the field of infrastructure, most infrastructure (such as rails, bridges, etc.) is mainly composed of metal. In order to ensure the safe and stable operation of infrastructure, it is necessary to conduct structural health inspections on these metal components regularly or irregularly. Among them, one of the main inspection items in this structural health inspection is the detection of metal cracks.
[0004] Traditional metal crack detection basically detects cracks as rectangular frames without angles (such as Figure 1 However, since most of the cracks on the metal surface are long and thin with a certain angle, and most of the area inside the rectangular frame without angle is the background area, it cannot well characterize the crack characteristics. Therefore, the traditional metal crack detection method still has the problem of not being able to extract the characteristic information of the crack well, low recognition accuracy, and difficulty in optimization training. Summary of the invention
[0005] In view of this, the embodiments of the present disclosure provide a metal crack detection method, device, electronic device and storage medium to solve the problems that the existing metal crack detection method cannot extract the characteristic information of the crack well, has low recognition accuracy, and is difficult to optimize and train.
[0006] A first aspect of the embodiments of the present disclosure provides a metal crack detection method, comprising:
[0007] Obtain the image to be inspected, input the image to be inspected into a preset feature extraction network, and output a feature map after being processed by the convolution layer of the feature extraction network;
[0008] Using the detection layer of the feature extraction network to perform feature extraction and analysis on the feature map again, to obtain a metal crack detection result, the metal crack detection result includes a first feature map, a second feature map, a third feature map and a fourth feature map;
[0009] Among them, the first feature map is used to characterize whether there is a target object, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the inclination angle of the target frame.
[0010] A second aspect of the embodiments of the present disclosure provides a metal crack detection device, comprising:
[0011] The acquisition module is configured to acquire the image to be inspected, input the image to be inspected into a preset feature extraction network, and output a feature map after being processed by the convolution layer of the feature extraction network;
[0012] An analysis module is configured to use the detection layer of the feature extraction network to perform feature extraction and analysis on the feature map again to obtain a metal crack detection result, where the metal crack detection result includes a first feature map, a second feature map, a third feature map, and a fourth feature map;
[0013] Among them, the first feature map is used to characterize whether there is a target object, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the inclination angle of the target frame.
[0014] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0015] According to a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0016] Compared with the prior art, the embodiments of the present disclosure have at least the following beneficial effects: the embodiments of the present disclosure obtain the image to be inspected, input the image to be inspected into a preset feature extraction network, and output a feature map after being processed by the convolution layer of the feature extraction network; the detection layer of the feature extraction network is used to extract and analyze the feature map again to obtain the metal crack detection result, and the metal crack detection result includes a first feature map, a second feature map, a third feature map and a fourth feature map; wherein the first feature map is used to characterize whether there is a target object, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the tilt angle of the target frame. The feature extraction network in the present disclosure is more sensitive to the detailed feature information of the image, can identify more detailed feature information in the image, and can greatly reduce the useless information (image background) in the target frame. At the same time, the target frame can be a rectangular frame with a tilt angle, which is more in line with the slender and tilted characteristics of the metal crack, so that the recognition accuracy of the metal crack can be well improved, and the method can also reduce the difficulty of model optimization training, which is conducive to reducing the training cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 It is a schematic diagram of the non-angle target frame in the traditional metal crack detection method;
[0019] Figure 2 It is a schematic diagram of a process of a metal crack detection method provided by an embodiment of the present disclosure;
[0020] Figure 3 It is a structural schematic diagram of a feature extraction network in the metal crack detection method provided by an embodiment of the present disclosure;
[0021] Figure 4 is a schematic diagram of an angled target frame of a metal crack detection method provided by an embodiment of the present disclosure;
[0022] Figure 5 is a schematic diagram of the structure of a convolutional layer in a feature extraction network provided by an embodiment of the present disclosure;
[0023] Figure 6 is a schematic diagram of the structure of a detection layer in a feature extraction network provided by an embodiment of the present disclosure;
[0024] Figure 7 It is a schematic diagram of the overall process of a metal crack detection method provided by an embodiment of the present disclosure;
[0025] Figure 8 is a structural schematic diagram of a metal crack detection device provided by an embodiment of the present disclosure;
[0026] Fig. 9 It is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.
[0028] A metal crack detection method and device according to an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0029] Figure 2 FIG. 1 is a flow chart of a metal crack detection method provided by an embodiment of the present disclosure. Figure 2 As shown, the metal crack detection method includes:
[0030] Step S201, obtain the image to be inspected, input the image to be inspected into a preset feature extraction network, and output a feature map after being processed by the convolution layer of the feature extraction network.
[0031] The image to be inspected may be an image / photo obtained by inspecting and photographing a metal component using a photographing device (such as a camera, etc.) during production or use, or may be a detection video stream obtained by inspecting and photographing a metal component, and then the detection video stream is framed to obtain a framed image. For example, if the duration of the obtained detection video stream is 1 second, and the acquisition frequency is 25 frames per second, then the detection video stream can be framed at a frame interval of 0.04 seconds to obtain 25 frames of images, and then at least one frame of images can be selected as the image to be inspected.
[0032] Combination Figure 3In one embodiment, illustratively, the feature extraction network of the embodiment of the present disclosure can be a network obtained by improving an existing convolutional neural network (such as Resnet50). Specifically, the feature extraction network includes a convolution layer 301 and a detection layer 302. The difference between the feature extraction network of the present disclosure and the existing Resnet50 network is mainly that: an extraction module that is more sensitive to detail feature information is added to the convolution layer, and the network structure of the detection layer is improved, such as using multiple detection branches to detect the metal crack target frame and its related attributes in the image to be inspected.
[0033] Step S202, use the detection layer of the feature extraction network to perform feature extraction and analysis on the feature map again to obtain the metal crack detection result, which includes the first feature map, the second feature map, the third feature map and the fourth feature map. Among them, the first feature map is used to characterize whether there is a target object, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the tilt angle of the target frame.
[0034] The feature extraction network of the disclosed embodiment is more sensitive to the detailed feature information of the image, can identify more detailed feature information in the image, and can greatly reduce the useless information (image background) in the target frame. At the same time, the target frame can be a rectangular frame with an inclined angle (such as Figure 4 As shown in the figure, it is more in line with the slender and inclined characteristics of metal cracks, thereby greatly improving the recognition accuracy of metal cracks. In addition, this method can also reduce the difficulty of model optimization training, which is conducive to reducing training costs.
[0035] Figure 5 The figure shows a schematic diagram of the structure of a convolutional layer provided by an embodiment of the present disclosure. For the convenience of description, only the parts related to the present embodiment are shown in the figure.
[0036] In some embodiments, Figure 5 As shown, the convolution layer 301 includes a first convolution layer 501, a second convolution layer 502, a third convolution layer 503, a fourth convolution layer 504, a fifth convolution layer 505 and a deconvolution layer 506 which are connected in sequence. Among them, the first convolution layer 501 includes a first convolution module 5011; the second convolution layer 502 includes a second convolution module 5021 and a first detail feature extraction module 5022; the third convolution layer 503 includes a third convolution module 5031 and a second detail feature extraction module 5032; the fourth convolution layer 504 includes a fourth convolution module 5041 and a third feature extraction module 5042; the fifth convolution layer 505 includes a fifth convolution module 5051; and the deconvolution layer 506 includes at least three deconvolution modules 5061.
[0037] Exemplarily, the first convolution module 5011, the second convolution module 5021, the third convolution module 5031, the fourth convolution module 5041 and the fifth convolution module 5051 can be convolution network modules with the same structure (for example, they can be modules for changing the dimension of feature vectors). The first detail feature extraction module 5022, the second detail feature extraction module 5032, and the third feature extraction module 5042 can be extraction modules with the same structure (for example, they can be combination modules of a hole convolution module and a 1*1 convolution module). At least three deconvolution modules 5061 in the deconvolution layer 506 can be modules with the same structure (for example, transposed convolution modules).
[0038] Combination Figure 5 In some embodiments, the image to be inspected is input into a preset feature extraction network, and a feature map is output, which specifically includes:
[0039] Using the first convolution module to perform feature extraction on the image to be inspected to obtain a first image feature;
[0040] Using the second convolution module, the first detail feature extraction module and the third convolution module to extract the first image feature to obtain the second image feature;
[0041] Using the fourth convolution module and the second detail feature extraction module to extract the second image features to obtain third image features;
[0042] Using the fifth convolution module and the third detail feature extraction module to extract the third image feature to obtain a fourth image feature;
[0043] Deconvolute the fourth image feature using at least three deconvolution modules to obtain a feature map.
[0044] As an example, assume that the image to be inspected has a dimension of [512, 512, 3] (H, W, C), where H represents the image height, W represents the image width, and C represents the number of channels. The image to be inspected [512, 512, 3] (H, W, C) is input into the first convolution module 5011 for feature extraction, and a first image feature with a dimension of [256, 256, 64] (H, W, C) can be obtained.
[0045] Next, the first image feature is input into the second convolution module 5021, the third convolution module 5031, and the first detail feature extraction module 5022 for feature extraction to obtain the second image feature. Specifically, first, the second convolution module is used to extract the first image feature to obtain the first convolution extraction feature; then, the third convolution module is used to extract the first convolution extraction feature to obtain the second convolution extraction feature; the first detail feature extraction module is used to extract the first convolution extraction feature to obtain the detail extraction feature; finally, the second convolution extraction feature and the detail extraction feature are superimposed to obtain the second image feature.
[0046] Continuing with the above example, the first image feature with a dimension of [256, 256, 64] (H, W, C) is input into the second convolution module 5021 for feature extraction, and the first convolution extraction feature with a dimension of [128, 128, 256] (H, W, C) can be obtained. Then, the first convolution extraction feature with a dimension of [128, 128, 256] (H, W, C) is input into the third convolution module 5031 for feature extraction, and the second convolution extraction feature with a dimension of [64, 64, 512] (H, W, C) is obtained; then, the first convolution extraction feature with a dimension of [128, 128, 256] (H, W, C) is input into the first detail feature extraction module 5022 for feature extraction, and the detail extraction feature with a dimension of [64, 64, 512] (H, W, C) can be obtained. Finally, the second convolution extraction feature and the detail extraction feature are superimposed to obtain a second image feature with a dimension of [64, 64, 512] (H, W, C).
[0047] In some embodiments, a first detail feature extraction module is used to extract features of the first image features to obtain detail extraction features. Specifically, the first image features are first subjected to dilated convolution and downsampling processing to obtain dilated convolution features; and then the dilated convolution features are subjected to 1*1 convolution processing to obtain detail extraction features.
[0048] In the disclosed embodiment, by adding a first detail feature extraction module in the second convolution layer to extract features from the first image features, more detail features can be obtained, and the processing method of hole convolution and downsampling can retain more feature information compared to the processing method of direct pooling and downsampling, which is beneficial to improving the accuracy of detection and recognition. At the same time, by further performing 1*1 convolution processing on the hole convolution feature, its feature dimension is made consistent with the second convolution extraction feature, and the detail extraction feature is obtained. Then the second convolution extraction feature is added to the detail extraction feature to obtain the second image feature. The second image feature is more sensitive to space and position information than the second convolution extraction feature, and therefore, it is beneficial to improve the sensitivity of the feature extraction network to the position information and detail information of metal cracks (for example, metal cracks are generally small, thin, and long), thereby improving the accuracy of recognition.
[0049] Similarly, the fourth convolution module can be used to extract features of the second image features with a dimension of [64, 64, 512] (H, W, C) to obtain a third convolution extraction feature with a dimension of [32, 32, 1024] (H, W, C); then, the second detail feature extraction module is used to extract features of the second image features to obtain detail extraction features with a dimension of [32, 32, 1024] (H, W, C); then, the third convolution extraction feature and the detail extraction feature with a dimension of [32, 32, 1024] (H, W, C) are superimposed to obtain a third image feature map with a dimension of [32, 32, 1024] (H, W, C).
[0050] The fifth convolution module is used to extract features of the third image features with a dimension of [32, 32, 1024] (H, W, C) to obtain a fourth convolution extraction feature with a dimension of [16, 16, 2028] (H, W, C); then, the third detail feature extraction module is used to extract features of the third image features to obtain detail extraction features with a dimension of [16, 16, 2028] (H, W, C); then, the fourth convolution extraction feature and the detail extraction feature with a dimension of [16, 16, 2028] (H, W, C) are superimposed to obtain a fourth image feature map with a dimension of [16, 16, 2028] (H, W, C).
[0051] In one embodiment, the deconvolution layer includes a first deconvolution module, a second deconvolution module and a third deconvolution module. Using at least three deconvolution modules to deconvolve the fourth image feature to obtain a feature map includes the following steps:
[0052] Using the first deconvolution module to perform a deconvolution and upsampling on the fourth image feature to obtain a first deconvolution feature;
[0053] Using the second deconvolution module to perform secondary deconvolution and upsampling on the first deconvolution feature to obtain a second deconvolution feature;
[0054] The third deconvolution module is used to perform three deconvolutions and upsampling on the second deconvolution features to obtain a feature map.
[0055] In combination with the above example, the fourth image feature map with a dimension of [16,16,2028](H,W,C) is input into the first deconvolution module for one deconvolution and upsampling, and the first deconvolution feature with a dimension of [32,32,256](H,W,C) can be obtained. Then, the first deconvolution feature is input into the second deconvolution module for a second deconvolution and upsampling, and the second deconvolution feature with a dimension of [64,64,128](H,W,C) can be obtained. Finally, the second deconvolution feature is input into the third deconvolution module for a third deconvolution and upsampling, and the feature map with a dimension of [128,128,64](H,W,C) can be obtained.
[0056] In the disclosed embodiment, a higher resolution feature map can be obtained by deconvolution and upsampling processing of at least three deconvolution layers. Preferably, the number of deconvolution modules in the deconvolution layer is 3 to 5, and more preferably, the number of deconvolution modules in the deconvolution layer is 3. If the number of deconvolution modules is too small, the resolution of the obtained feature map is low, which is not conducive to improving the accuracy of subsequent detection. If the number of deconvolution modules is too large, the calculation amount of detection will increase and the calculation efficiency will be reduced.
[0057] Figure 6 The figure shows a schematic diagram of the structure of a detection layer provided by an embodiment of the present disclosure. For the convenience of description, only the parts related to the present embodiment are shown in the figure.
[0058] In some embodiments, Figure 6 The detection layer 302 shown includes a first detection branch 601, a second detection branch 602, a third detection branch 603 and a fourth detection branch 604. The detection layer of the feature extraction network is used to extract and analyze the feature map again to obtain the metal crack detection result, including the following steps:
[0059] Input the feature map into the first detection branch and output the first feature map;
[0060] Input the feature map into the second detection branch and output a second feature map;
[0061] Input the feature map into the third detection branch and output a third feature map;
[0062] Input the feature map into the fourth detection branch, and output a fourth feature map;
[0063] The metal crack detection result of the image to be inspected is determined according to the first characteristic map, the second characteristic map, the third characteristic map and the fourth characteristic map.
[0064] The first detection branch may be an algorithm model (such as a heat map prediction model) for identifying whether a target object exists in a feature map, that is, whether a metal crack exists. The second detection branch may be an algorithm model for calculating the distance value between the center point of the target object and the feature point of the first feature map. The third detection branch may be a prediction model for predicting the width and height of a target box corresponding to the target object. The fourth detection branch may be a prediction model for predicting the tilt angle of a target box.
[0065] As an example, suppose the dimension of the feature map is [128, 128, 64] (H, W, C). The feature map of dimension [128, 128, 64] (H, W, C) is input into the first detection branch. After a series of convolution, normalization and activation function operations, a first feature map of dimension [128, 128, 1] can be obtained. The first feature map represents whether there is a target object at each thermal point. The feature map of dimension [128, 128, 64] (H, W, C) is input into the second detection branch. After a series of convolution, normalization and activation function operations, a second feature map of dimension [128, 128, 2] can be obtained. The second feature map represents the offset of the center point of the target object from the thermal point (i.e., the feature point of the first feature map). The predicted value in the last dimension 2 represents the offset of the center point of the current target object from the thermal point. The feature map with dimensions of [128,128,64](H,W,C) is input into the third detection branch. After a series of convolution, normalization and activation function operations, a third feature map with dimensions of [128,128,2] is obtained. The third feature map represents the predicted values of the width and height of the target box corresponding to the target object. The predicted value in the last dimension 2 represents the width and height of the target box corresponding to the current feature point. The feature map with dimensions of [128,128,64](H,W,C) is input into the fourth detection branch. After a series of convolution, normalization and activation function operations, a fourth feature map with dimensions of [128,128,1] is obtained. The fourth feature map represents the tilt of the target box. The predicted value in the last dimension 1 represents the tilt angle of the current target box.
[0066] In some embodiments, the third detection branch can be trained by the following steps:
[0067] Obtain a training data set, which includes multiple training samples, each of which is marked with the actual width and height values of the target box;
[0068] Each time, a batch of training samples is extracted from the training data set, and the batch of training samples is input into the basic model for training, and the width and height prediction values of the target box are output;
[0069] Calculate the width and height loss of the target box based on the predicted width and height and the actual width and height values;
[0070] Calculate and update the loss value based on the width and height loss values and the preset weight coefficient;
[0071] The basic model is iteratively updated according to the updated loss value until a preset iteration end condition is reached to obtain the third detection branch.
[0072] The training samples may be pictures of some metal components, and the metal crack areas therein may be manually marked in advance, for example, by using a rectangular frame to mark the target frame and the actual width and height values of the target frame.
[0073] As an example, in each round of training, a batch of training samples for a round of training can be extracted from the training data set (for example, 4 pictures are extracted as batch training samples in a round of training). The batch training samples are input into the basic model (such as the initialization model of the third detection branch) for training, and the width and height prediction values of the target box are output.
[0074] In general, the difference between the length and width of metal cracks is relatively large in most cases. It is obviously unreasonable to treat the losses of length (height) and width in the same way. For example, the actual length and width of the target box are 50 and 8 respectively, and the predicted results are 54 and 4, then the penalty coefficients for length and width are both 4. For this case, when designing a detection scheme, it is usually expected that the penalty coefficient for width is larger than that for length. Therefore, in the disclosed embodiment, it is proposed to calculate the updated loss value based on the width and height loss values and the preset weight coefficient. Specifically, the preset loss function (such as the L1 loss function) is multiplied by the preset weight coefficient to obtain the updated loss value.
[0075] Among them, the calculation formula of specific gravity coefficient a is as follows: Where A is the area of the target box; p is the predicted value of length or width; r is the scaling factor (hyperparameter). Here, the empirical value of r can be set to 0.3.
[0076] Therefore, the updated loss value = L1*a.
[0077] Afterwards, the basic model is iteratively updated according to the above-mentioned updated loss value until the preset iteration end condition is reached (for example, the predicted model accuracy is reached, or the preset number of iteration rounds is reached, etc.), and the third detection branch is obtained.
[0078] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0079] Figure 7 This is the overall process of a specific example of the metal crack detection method provided in the embodiment of the present disclosure.
[0080] like Figure 7As shown, the image to be inspected with a dimension of [512,512,3](H,W,C) is input into the first convolution module C1, and the first image feature with a dimension of [256,256,64](H,W,C) is output; the first image feature is input into the second convolution module C2, and the first convolution extraction feature with a dimension of [128,128,256](H,W,C) is output; the first convolution extraction feature is input into the third convolution module C3, and the second convolution extraction feature with a dimension of [64,64,512](H,W,C) is output; the first convolution extraction feature is input into the first detail feature extraction module S1, and the first detail extraction feature with a dimension of [64,64,512](H,W,C) is output. feature; add the second convolution extraction feature and the first detail extraction feature to obtain a second image feature with a dimension of [64,64,512](H,W,C); the second image feature is input into the fourth convolution module C4, and the third convolution extraction feature with a dimension of [32,32,1024](H,W,C) is output; the second image feature is input into the second detail feature extraction module S2, and the second detail extraction feature with a dimension of [32,32,1024](H,W,C) is output; the third convolution extraction feature and the second detail extraction feature are added to obtain a third image feature with a dimension of [32,32,1024](H,W,C); the third image feature is input into the fifth convolution module C5, and the output The fourth convolution extraction feature with a dimension of [16, 16, 2028] (H, W, C) is output; the third image feature is input into the third detail feature extraction module S3, and the third detail extraction feature with a dimension of [16, 16, 2028] (H, W, C) is output; the fourth convolution extraction feature and the third detail extraction feature are added to obtain a fourth image feature with a dimension of [16, 16, 2028] (H, W, C); the fourth image feature is input into the first deconvolution module P4, and the first deconvolution feature with a dimension of [32, 32, 256] (H, W, C) is output; the first deconvolution feature is input into the second deconvolution module P3, and the output dimension is [64, 64, 128] (H, W, C ); the second deconvolution feature is input into the third deconvolution module P2, and the feature map of dimension [128,128,64](H,W,C) is output; the feature map is input into the first detection branch (heatmap), and the first feature map of dimension [128,128,1] is output; the feature map is input into the second detection branch ((x,y)offset), and the second feature map of dimension [128,128,2] is output; the feature map is input into the third detection branch (w,h), and the third feature map of dimension [128,128,2] is output; the feature map is input into the fourth detection branch (angle), and the fourth feature map of dimension [128,128,1] is output.
[0081] The present invention uses an anchor-free target detection mechanism to convert the prediction of the rectangular box into an estimate of the center point, and regresses the length, width, and tilt angle of the target rectangular box. The angled rectangular box is used to detect metal surface cracks, which effectively solves the problem of traditional anchor-based target detection algorithms, which contain a large amount of useless information (background) in the rectangular box and cause training difficulties. It can reduce the amount of calculation and improve the calculation efficiency. At the same time, in view of the characteristics of the slender cracks, the present invention designs a feature extraction network that is more sensitive to detail information, and optimizes the calculation of the regression loss of length and width, which can further improve the network's recognition accuracy of metal cracks.
[0082] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.
[0083] Figure 8 Schematic diagram of a metal crack detection device provided by an embodiment of the present disclosure. Figure 8 As shown, the metal crack detection device comprises:
[0084] The acquisition module 801 is configured to acquire the image to be inspected, input the image to be inspected into a preset feature extraction network, and output a feature map after being processed by the convolution layer of the feature extraction network;
[0085] The analysis module 802 is configured to use the detection layer of the feature extraction network to perform feature extraction and analysis on the feature map again to obtain a metal crack detection result, where the metal crack detection result includes a first feature map, a second feature map, a third feature map, and a fourth feature map;
[0086] Among them, the first feature map is used to characterize whether there is a target object, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the inclination angle of the target frame.
[0087] The feature extraction network provided by the embodiment of the present disclosure is more sensitive to the detailed feature information of the image, can identify more detailed feature information in the image, and can greatly reduce the useless information (image background) in the target frame. At the same time, the target frame can be a rectangular frame with an inclined angle, which is more in line with the slender and inclined characteristics of the metal crack, thereby greatly improving the recognition accuracy of the metal crack. The method can also reduce the difficulty of model optimization training, which is conducive to reducing training costs.
[0088] In some embodiments, the convolution layer includes a first convolution layer, a second convolution layer, a third convolution layer, a fourth convolution layer, a fifth convolution layer and a deconvolution layer connected in sequence. The first convolution layer includes a first convolution module; the second convolution layer includes a second convolution module and a first detail feature extraction module; the third convolution layer includes a third convolution module and a second detail feature extraction module; the fourth convolution layer includes a fourth convolution module and a third detail feature extraction module; the fifth convolution layer includes a fifth convolution module; and the deconvolution layer includes at least three deconvolution modules.
[0089] In some embodiments, the acquisition module 801 includes:
[0090] A first extraction unit is configured to use a first convolution module to perform feature extraction on the image to be inspected to obtain a first image feature;
[0091] A second extraction unit is configured to extract the first image feature using the second convolution module, the first detail feature extraction module and the third convolution module to obtain a second image feature;
[0092] A third extraction unit is configured to extract the second image feature using the fourth convolution module and the second detail feature extraction module to obtain a third image feature;
[0093] a fourth extraction unit configured to extract the third image feature using the fifth convolution module and the third detail feature extraction module to obtain a fourth image feature;
[0094] The deconvolution unit is configured to use at least three deconvolution modules to deconvolve the fourth image feature to obtain a feature map.
[0095] In some embodiments, the second extraction unit may be specifically configured as follows:
[0096] Using the second convolution module to perform feature extraction on the first image feature to obtain a first convolution extraction feature;
[0097] Using the third convolution module to perform feature extraction on the first convolution extraction feature to obtain a second convolution extraction feature;
[0098] Using a first detail feature extraction module to perform feature extraction on the first convolution extraction feature to obtain a detail extraction feature;
[0099] The second convolution extraction feature and the detail extraction feature are superimposed to obtain a second image feature.
[0100] In some embodiments, using a first detail feature extraction module to extract features from the first image features to obtain detail extraction features includes:
[0101] Performing dilated convolution and downsampling processing on the first image feature to obtain a dilated convolution feature;
[0102] Perform 1*1 convolution processing on the hole convolution feature to obtain the detail extraction feature.
[0103] In some embodiments, the deconvolution layer includes a first deconvolution module, a second deconvolution module, and a third deconvolution module.
[0104] The above deconvolution unit can be specifically configured as follows:
[0105] Using the first deconvolution module to perform a deconvolution and upsampling on the fourth image feature to obtain a first deconvolution feature;
[0106] Using the second deconvolution module to perform secondary deconvolution and upsampling on the first deconvolution feature to obtain a second deconvolution feature;
[0107] The third deconvolution module is used to perform three deconvolutions and upsampling on the second deconvolution features to obtain a feature map.
[0108] In some embodiments, the detection layer includes a first detection branch, a second detection branch, a third detection branch, and a fourth detection branch.
[0109] The above analysis module 802 includes:
[0110] A first analysis unit is configured to input the feature map into the first detection branch and output a first feature map;
[0111] A second analysis unit is configured to input the feature map into the second detection branch and output a second feature map;
[0112] A third analysis unit is configured to input the feature map into the third detection branch and output a third feature map;
[0113] a fourth analysis unit, configured to input the feature map into a fourth detection branch and output a fourth feature map;
[0114] The determination unit is configured to determine the metal crack detection result of the image to be inspected according to the first feature map, the second feature map, the third feature map and the fourth feature map.
[0115] In some embodiments, the third detection branch is trained by the following steps:
[0116] Obtain a training data set, which includes multiple training samples, each of which is marked with the actual width and height values of the target box;
[0117] Each time, a batch of training samples is extracted from the training data set, and the batch of training samples is input into the basic model for training, and the width and height prediction values of the target box are output;
[0118] Calculate the width and height loss of the target box based on the predicted width and height and the actual width and height values;
[0119] Calculate and update the loss value based on the width and height loss values and the preset weight coefficient;
[0120] The basic model is iteratively updated according to the updated loss value until a preset iteration end condition is reached to obtain the third detection branch.
[0121] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0122] Fig. 9 is a schematic diagram of an electronic device 900 provided in an embodiment of the present disclosure. Fig. 9 As shown, the electronic device 900 of this embodiment includes: a processor 901, a memory 902, and a computer program 903 stored in the memory 902 and executable on the processor 901. When the processor 901 executes the computer program 903, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 901 executes the computer program 903, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0123] Exemplarily, the computer program 903 may be divided into one or more modules / units, which are stored in the memory 902 and executed by the processor 901 to complete the present disclosure. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 903 in the electronic device 900.
[0124] The electronic device 900 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 900 may include, but is not limited to, a processor 901 and a memory 902. Those skilled in the art will appreciate that Fig. 9 It is only an example of the electronic device 900 and does not constitute a limitation of the electronic device 900. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0125] The processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0126] The memory 902 may be an internal storage unit of the electronic device 900, for example, a hard disk or memory of the electronic device 900. The memory 902 may also be an external storage device of the electronic device 900, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 900. Further, the memory 902 may also include both an internal storage unit of the electronic device 900 and an external storage device. The memory 902 is used to store computer programs and other programs and data required by the electronic device. The memory 902 may also be used to temporarily store data that has been output or is to be output.
[0127] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0128] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0129] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. 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 this disclosure.
[0130] In the embodiments provided in the present disclosure, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of devices or units, which may be electrical, mechanical or other forms.
[0131] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0132] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0133] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0134] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should all be included in the protection scope of the present disclosure.
Claims
1. A metal crack detection method, characterized in that: include: Obtaining a picture to be inspected, inputting the picture to be inspected into a preset feature extraction network, and outputting a feature map after being processed by a convolutional layer of the feature extraction network; Using the detection layer of the feature extraction network to perform feature extraction and analysis on the feature map again, to obtain a metal crack detection result, wherein the metal crack detection result includes a first feature map, a second feature map, a third feature map, and a fourth feature map; The first feature map is used to characterize whether a target object exists, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the tilt angle of the target frame; The image to be inspected is input into a preset feature extraction network, and after being processed by the convolution layer of the feature extraction network, a feature map is output, including: Input the image to be inspected into a first convolution module, and output a first image feature; Input the first image feature into a second convolution module, and output the first convolution extracted feature; Input the first convolution extracted features into a third convolution module, and output the second convolution extracted features; Inputting the first convolution extraction feature into a first detail feature extraction module, and outputting a first detail extraction feature; Adding the second convolution extraction feature and the first detail extraction feature to obtain a second image feature; Input the second image feature into a fourth convolution module, and output a third convolution extraction feature; Inputting the second image feature into a second detail feature extraction module, and outputting a second detail extraction feature; Adding the third convolution extraction feature and the second detail extraction feature to obtain a third image feature; Input the third image feature into a fifth convolution module, and output a fourth convolution extraction feature; Inputting the third image feature into a third detail feature extraction module, and outputting a third detail extraction feature; Adding the fourth convolution extraction feature and the third detail extraction feature to obtain a fourth image feature; Inputting the fourth image feature into a first deconvolution module, and outputting a first deconvolution feature; Inputting the first deconvolution feature into a second deconvolution module, and outputting a second deconvolution feature; Inputting the second deconvolution feature into a third deconvolution module, and outputting a feature map; The feature map is subjected to feature extraction and analysis again using the detection layer of the feature extraction network to obtain metal crack detection results, including: Input the feature map into a first detection branch, and output a first feature map; Inputting the feature map into a second detection branch, and outputting a second feature map; Inputting the feature map into a third detection branch, and outputting a third feature map; Inputting the feature map into a fourth detection branch, and outputting a fourth feature map; Inputting the first convolution extraction feature into a first detail feature extraction module and outputting the first detail extraction feature includes: Performing dilated convolution and downsampling processing on the first image feature to obtain a dilated convolution feature; Perform 1*1 convolution processing on the hole convolution feature to obtain a first detail extraction feature.
2. The method according to claim 1, characterized in that The third detection branch is trained by the following steps: Acquire a training data set, wherein the training data set includes a plurality of training samples, each of the training samples is marked with actual width and height values of a target box; Each time, a batch of training samples is extracted from the training data set, the batch of training samples is input into the basic model for training, and the width and height prediction values of the target box are output; Calculate the width and height loss value of the target frame according to the predicted width and height values and the actual width and height values; Calculate and update the loss value according to the width and height loss value and the preset weight coefficient; The basic model is iteratively updated according to the updated loss value until a preset iteration end condition is reached to obtain a third detection branch.
3. A metal crack detection device, characterized in that: include: An acquisition module is configured to acquire a picture to be inspected, input the picture to be inspected into a preset feature extraction network, and output a feature map after being processed by a convolutional layer of the feature extraction network; An analysis module is configured to use the detection layer of the feature extraction network to perform feature extraction and analysis on the feature map again to obtain a metal crack detection result, wherein the metal crack detection result includes a first feature map, a second feature map, a third feature map, and a fourth feature map; The first feature map is used to characterize whether a target object exists, the second feature map is used to characterize the offset of the center point of the target object compared to the feature point of the first feature map, the third feature map is used to characterize the width and height of the target frame corresponding to the target object, and the fourth feature map is used to characterize the tilt angle of the target frame; The image to be inspected is input into a preset feature extraction network, and after being processed by the convolution layer of the feature extraction network, a feature map is output, including: Input the image to be inspected into a first convolution module, and output a first image feature; Input the first image feature into a second convolution module, and output the first convolution extracted feature; Input the first convolution extracted features into a third convolution module, and output the second convolution extracted features; Inputting the first convolution extraction feature into a first detail feature extraction module, and outputting a first detail extraction feature; Adding the second convolution extraction feature and the first detail extraction feature to obtain a second image feature; Input the second image feature into a fourth convolution module, and output the third convolution extracted feature; Inputting the second image feature into a second detail feature extraction module, and outputting a second detail extraction feature; Adding the third convolution extraction feature and the second detail extraction feature to obtain a third image feature; Input the third image feature into a fifth convolution module, and output a fourth convolution extraction feature; Inputting the third image feature into a third detail feature extraction module, and outputting a third detail extraction feature; Adding the fourth convolution extraction feature and the third detail extraction feature to obtain a fourth image feature; Inputting the fourth image feature into a first deconvolution module, and outputting a first deconvolution feature; Inputting the first deconvolution feature into a second deconvolution module, and outputting a second deconvolution feature; Inputting the second deconvolution feature into a third deconvolution module, and outputting a feature map; The feature map is subjected to feature extraction and analysis again using the detection layer of the feature extraction network to obtain metal crack detection results, including: Input the feature map into a first detection branch, and output a first feature map; Inputting the feature map into a second detection branch, and outputting a second feature map; Inputting the feature map into a third detection branch, and outputting a third feature map; Inputting the feature map into a fourth detection branch, and outputting a fourth feature map; Inputting the first convolution extraction feature into a first detail feature extraction module and outputting the first detail extraction feature includes: Performing dilated convolution and downsampling processing on the first image feature to obtain a dilated convolution feature; Perform 1*1 convolution processing on the hole convolution feature to obtain a first detail extraction feature.
4. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 2 are implemented.
5. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 2 are implemented.
