Model construction method, electronic device, storage medium and computer program product
By constructing an image recognition model marked with directional rotating frames, the problem of low manual inspection efficiency in building construction is solved, automated and high-precision building defect detection is realized, and intelligent recognition of various building defects is suitable.
Patent Information
- Application Number
- CN202510480423.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-04-17
AI Technical Summary
Defect inspections in construction rely on manual inspections, resulting in low efficiency, easy omissions or misjudgment of details, and difficult to fully cover hidden projects in large and complex projects, posing potential safety hazards.
By constructing an image recognition model based on directed rotary box annotation, receiving the labeled original image sample set, training the preset initial image recognition model, adjusting model parameters using feature enhancement and gradient backpropagation algorithms, and building a target recognition model that recognizes building defect features.
It realizes automated and intelligent building defect detection, improves detection accuracy and efficiency, reduces missed inspection and false inspection rates, and is suitable for defect inspection in different building construction scenarios.
Smart Images

Figure CN119992260B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of model construction, and particularly relates to a model construction method, system, electronic device, storage medium and computer program product. Background Art
[0002] In the field of construction, quality inspection, as a key link to ensure project safety and compliance, its efficiency and accuracy directly affect the overall project progress and cost control. For a long time, construction quality inspection has mainly relied on traditional manual inspection methods, which are not only time-consuming and laborious, but also prone to details omission or misjudgment due to subjective judgment, experience level and physical limitations of people. Especially in large and complex projects, in the face of a huge number of inspection points and concealed works, it is often difficult for manual inspection to achieve full coverage and in-depth inspection, which poses potential safety hazards for subsequent use. Therefore, there is a problem of poor inspection effect of building defects in current construction quality inspection. Summary of the Invention
[0003] The main purpose of the present application is to provide a model construction method, system, electronic device, storage medium and computer program product, aiming to solve the technical problem of poor inspection effect of building defects.
[0004] To achieve the above purpose, the present application proposes a model construction method, and the model construction method includes:
[0005] Receiving an original image sample set marked with directed rotation boxes for building defect features of the original image samples in the original image sample set;
[0006] Training a preset initial image recognition model based on the original image sample set to construct a target recognition model for recognizing building defect features.
[0007] In one embodiment, the step of training the preset initial image recognition model based on the original image sample set includes:
[0008] Performing feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set;
[0009] For any enhanced image sample in the enhanced image sample set, inputting the enhanced image sample into the preset initial image recognition model to obtain a sample recognition result of the enhanced image sample;
[0010] Calculating a prediction loss value of the preset initial image recognition model according to the difference between the sample recognition result and the enhanced image sample;
[0011] Based on the predicted loss value, the model parameters of the preset initial image recognition model are adjusted using the gradient backpropagation algorithm;
[0012] After the preset initial image recognition model reaches the preset training conditions, the target recognition model is obtained.
[0013] In one embodiment, the step of performing feature enhancement on the original image samples in the original image sample set includes:
[0014] Extract the defect edges of the building defect features to obtain the coordinate distribution of the edge points of the defect edges;
[0015] Determine the distribution direction of the building defect features according to the coordinate distribution of the edge points, where the distribution direction represents the best tilt angle of the oriented rotation box;
[0016] Adjust the oriented rotation box based on the distribution direction to obtain a target rotation box, and the coverage rate of the target rotation box for the coordinate distribution of the edge points reaches a preset threshold;
[0017] Crop the part of the original image sample other than the target rotation box, and use the area surrounded by the target rotation box as the enhanced image sample.
[0018] In one embodiment, the step of extracting the defect edges of the defect features to obtain the coordinate distribution of the edge points of the defect edges includes:
[0019] Perform frequency domain decomposition on the target content selected by the oriented rotation box in the original image sample through filters of each preset scale, and extract the frequency domain responses of the target content in each preset direction and each preset wavelength, where the filters of each preset scale cover each preset direction and each preset wavelength;
[0020] Calculate the phase consistency value of each pixel point in the target content based on the frequency domain response, and mark the pixel points with a phase consistency value higher than the preset phase consistency threshold as valid edge points;
[0021] Perform morphological closing operation on the valid edge points to connect the valid edge points into continuous contour lines to obtain a connected edge area;
[0022] Convert the connected edge area into a coordinate set to obtain the coordinate distribution of the edge points, where the coordinate distribution of the edge points represents the geometric contour of the building defect features.
[0023] In one embodiment, the step of determining the distribution direction of the building defect features according to the coordinate distribution of the edge points includes:
[0024] Determine the edge point weights of each edge point coordinate in the edge point coordinate distribution;
[0025] Calculate the weighted mean center coordinate of the edge point coordinate distribution based on the respective edge point coordinates and the corresponding edge point weights;
[0026] Construct a covariance matrix of the edge point coordinate distribution based on the respective edge point coordinates, the edge point weights corresponding to the respective edge point coordinates, and the weighted mean center coordinate;
[0027] Determine the vector direction corresponding to the maximum eigenvalue of the covariance matrix, and the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect features.
[0028] In one embodiment, the step of determining the edge point weights of each edge point coordinate in the edge point coordinate distribution includes:
[0029] For any one edge point coordinate in the edge point coordinate distribution, calculate the gradient magnitude of the edge point coordinate;
[0030] Take the ratio of the gradient magnitude to the maximum gradient magnitude among all edge point coordinates as the clarity weight of the edge point coordinate;
[0031] Determine the curvature of the edge point coordinate, and determine the bending weight of the edge point coordinate according to the curvature and the maximum curvature among all edge point coordinates;
[0032] Obtain the edge point weight of the edge point coordinate based on the clarity weight and the bending weight.
[0033] In one embodiment, the step of adjusting the oriented rotation box based on the distribution direction includes:
[0034] Denote the intersection line of the weighted mean center coordinate and the distribution direction as the horizontal reference axis, and denote the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis as the vertical reference axis;
[0035] Expand the horizontal length based on the horizontal reference axis to both sides perpendicular to the horizontal reference axis, and expand the vertical length based on the vertical reference axis to both sides perpendicular to the vertical reference axis. The horizontal length and the vertical length respectively represent the length and width of the oriented rotation box.
[0036] In addition, to achieve the above object, the present application also proposes a model construction system, and the model construction system includes:
[0037] A data receiving module, configured to receive an original image sample set that is labeled, wherein the building defect features of the original image samples in the original image sample set are selected by an oriented rotation box;
[0038] A model training module for training a preset initial image recognition model based on the original image sample set to construct a target recognition model for recognizing building defect features.
[0039] In addition, to achieve the above object, the present application also provides an electronic device, which includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the model construction method as described above.
[0040] In addition, to achieve the above object, the present application also provides a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the model construction method as described above are implemented.
[0041] In addition, to achieve the above object, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the model construction method as described above are implemented.
[0042] The present application provides a model construction method, which includes: receiving an annotated original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by oriented rotated bounding boxes; training a preset initial image recognition model based on the original image sample set to construct a target recognition model for recognizing building defect features.
[0043] By obtaining a pre-annotated original image sample set, in which building defects are framed by oriented rotated bounding boxes, compared with traditional horizontal bounding boxes that cover too many invalid feature regions when annotating cracks and inclined objects, resulting in relatively mixed target feature data and unable to converge quickly and effectively, using oriented rotated bounding boxes to frame building defects is applicable to direction-sensitive problems such as concrete cracks, plaster layer cracks, floor cracks, and beam waist cracks, which can improve the quality of the model training sample set. Training the initial model based on the annotated data set can make the trained model have better effects. After training is completed, a target model for specifically recognizing building defects is obtained. Compared with the related solutions that rely on manual inspections, which are not only time-consuming and laborious but also affected by subjective experience, the present application constructs an image recognition model for building defects, solves the problems of traditional quality inspections relying on manual experience and low efficiency, and realizes automated and intelligent building defect detection. Description of the Drawings
[0044] The drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0045] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0046] Figure 1 It is a schematic flowchart provided for the first embodiment of the model construction method of the present application;
[0047] Figure 2 It is a schematic flowchart provided for the second embodiment of the model construction method of the present application;
[0048] Figure 3 It is a schematic diagram of the scenario of directed rotation box adjustment provided for the model construction method of the present application;
[0049] Figure 4 It is a schematic diagram of the module structure of the model construction system in the embodiment of the present application;
[0050] Figure 5 It is a schematic diagram of the device structure of the hardware operating environment involved in the model construction method in the embodiment of the present application.
[0051] The realization of the purpose, functional characteristics and advantages of the present application will be further described with reference to the embodiments and the drawings. Specific Embodiments
[0052] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0053] To better understand the technical solutions of the present application, the following will be described in detail in combination with the drawings of the specification and the specific embodiments.
[0054] The main solution of the embodiment of the present application is: receiving a set of original image samples marked with labels, where the building defect features of the original image samples in the set of original image samples are selected by a directed rotation box; training a preset initial image recognition model based on the set of original image samples to construct a target recognition model for recognizing building defect features.
[0055] In this embodiment, for the convenience of description, the following will be described with the model construction system as the execution subject.
[0056] Since the prior art relies on traditional manual inspection methods, it is not only time-consuming and laborious, but also prone to details being missed or misjudged due to human subjective judgment, experience level and physical limitations. Especially in large and complex projects, in the face of a large number of inspection points and concealed works, it is often difficult for manual inspection to achieve full coverage and in-depth inspection, which poses potential safety hazards for subsequent use.
[0057] This application provides a solution. By constructing an image recognition model for building defects, it solves the problems of traditional quality inspection relying on manual experience and low efficiency, and realizes automated and intelligent building defect detection.
[0058] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a model construction system, etc. that can implement the above functions. Hereinafter, taking the model construction system as an example, this embodiment and the following embodiments will be described.
[0059] Based on this, the embodiments of this application provide a model construction method, referring to Figure 1 , Figure 1 which is a schematic flowchart of the first embodiment of the model construction method of this application.
[0060] In this embodiment, the model construction method includes steps S01 to S02:
[0061] Step S01, receiving the original image sample set marked, where the building defect features of the original image samples in the original image sample set are selected by an oriented bounding box;
[0062] It should be noted that the original image sample set that has been manually marked is collected and received, which contains multiple original image samples. Each original image sample directly comes from the building construction site, covering various building states, especially the defective parts, and may include building defect features such as concrete cracks, plaster layer cracks, floor cracks, beam waist cracks, exposed reinforcement / tubes, and door and window gaps. The building defect features in these images have been accurately marked by an oriented bounding box (OBB).
[0063] In addition, it should be noted that OBB adds a dimension of θ (rotation angle), that is, (x, y, w, h, θ), where x and y are the center point coordinates of the oriented bounding box, w is the width of the oriented bounding box, h is the height of the oriented bounding box, and θ is the rotation angle of the oriented bounding box relative to the coordinate axis. The traditional horizontal bounding box (HBB) does not introduce the rotation angle θ parameter, that is, (x, y, w, h). Compared with HBB, OBB can more accurately describe the target direction, reduce the coverage of invalid feature regions, improve the accuracy of marking, and enable the model to more accurately detect non-horizontal target detection problems, such as cracks (concrete cracks, floor cracks, plaster layer cracks, concrete beam waist cracks, etc.), exposed reinforcement / tubes, and door and window gaps.
[0064] In addition, it should be noted that before model training, the original image samples in the original image sample set will also be scene-labeled. Through the scene recognition model, the construction building scene corresponding to the original image sample can be quickly determined, such as the ground, wall, glass, etc. The scene recognition model is a lightweight model pre-trained for identifying different construction building scenes and can be trained using the MobileNetV3 architecture. For construction buildings, since different building defect features vary due to different scenes, such as cracks on glass and cracks on walls being significantly different, by labeling the scenes of the original image samples, targeted training can be carried out for the building defect features of different scenes in subsequent training, so as to accurately identify the building defect features in that scene and improve the pertinence and accuracy of recognition.
[0065] It can be understood that since traditional image annotation methods (such as horizontal bounding box HBB) often have difficulty accurately describing the building defect features with irregular shapes and directions, resulting in mixed target feature data during subsequent model training and affecting the convergence speed and detection accuracy of the model, step S01 is carried out. By receiving the original image sample set annotated by OBB (Oriented Bounding Box), the problem of mixed target feature data under the traditional annotation method is solved. The OBB annotation method can more accurately describe the direction and shape of irregular targets by adding a parameter of rotation angle θ, reducing the interference of invalid feature regions, providing more accurate and rich feature data for subsequent model training, and helping to improve the detection accuracy and generalization ability of the model.
[0066] Step S02, training a preset initial image recognition model based on the original image sample set to construct a target recognition model for identifying building defect features.
[0067] It should be noted that after receiving the annotated original image sample set, these data are used to train the preset initial image recognition model. The preset initial image recognition model is a pre-designed image recognition model framework, which can be YOLOv8-OBB. Since YOLOv8-OBB already has certain image recognition capabilities and is particularly suitable for processing data annotated by OBB, the preset initial image recognition model can learn how to extract useful features from images and classify and locate these features, so as to accurately identify the building defect features and finally obtain the target recognition model. The target recognition model can quickly and accurately detect the building defect features in the image in practical applications, providing strong support for building construction quality inspection.
[0068] It can be understood that due to the diversity and complexity of building defect features, traditional image recognition models often have difficulty achieving accurate detection and classification of these defects, resulting in relatively high rates of missed detection and false detection. Therefore, step S02 is carried out. By training a preset initial image recognition model with an original image sample set based on OBB annotation, a target recognition model capable of accurately recognizing and classifying building defect features is constructed. This model can make full use of the precise feature data provided by OBB annotation to achieve efficient detection and classification of irregular building defect features, not only improving the detection accuracy, but also significantly shortening the detection time and reducing the rates of missed detection and false detection.
[0069] In a feasible implementation manner, in step S02, the step of training the preset initial image recognition model based on the original image sample set includes steps A01 to A05:
[0070] Step A01, perform feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set;
[0071] It should be noted that feature enhancement techniques can include adjusting the size, brightness, contrast, color saturation, etc. of the image, applying sharpening filters to enhance edge features, or generating more diverse image samples through data augmentation techniques (such as rotation, scaling, cropping, flipping, etc.). These operations together constitute the feature enhancement process, which is applied to each image in the original image sample set to obtain enhanced image samples, thereby generating an enhanced image sample set containing more significant features.
[0072] Step A02, for any enhanced image sample in the enhanced image sample set, input the enhanced image sample into the preset initial image recognition model to obtain the sample recognition result of the enhanced image sample;
[0073] It should be noted that the images in the enhanced image sample set are input into the preset initial image recognition model one by one. The preset initial image recognition model is a neural network that has been designed but not fully trained and has preliminary image recognition capabilities. The model will process the input images and output the corresponding sample recognition results, which include key information such as the location, size, type, etc. of building defect features.
[0074] Step A03, calculate the prediction loss value of the preset initial image recognition model according to the difference between the sample recognition result and the enhanced image sample;
[0075] It should be noted that the differences between the comparison sample recognition results and the actual building defect features in the enhanced image samples are measured by calculating loss functions (such as cross-entropy loss, mean square error, etc.) to obtain the predicted loss value. The predicted loss value reflects the gap between the current recognition result of the model and the real situation, and is an important basis for subsequent training and adjustment of the model.
[0076] Step A04: Based on the predicted loss value, adjust the model parameters of the preset initial image recognition model using the gradient backpropagation algorithm.
[0077] It should be noted that based on the predicted loss value, the model parameters of the preset initial image recognition model are adjusted using the gradient backpropagation algorithm. The gradient backpropagation algorithm calculates the gradient of the loss function with respect to the model parameters and updates the parameter values along the opposite direction of the gradient, thereby gradually reducing the predicted loss value. This process is the core of model training. By continuously iteratively adjusting the model parameters (such as the weights and biases of the convolutional layer), the model can better learn the building defect features.
[0078] Step A05: After the preset initial image recognition model reaches the preset training conditions, obtain the target recognition model.
[0079] It should be noted that when the preset initial image recognition model reaches the preset training conditions (which can be after a sufficient number of iterative trainings or the predicted loss value is reduced below the preset threshold), it is determined that the model has fully learned the building defect features and is used as the target recognition model. At this time, the target recognition model already has high recognition accuracy and generalization ability and can be applied to actual building construction quality inspections.
[0080] In this embodiment, through the feature enhancement technology, the key features in the image can be highlighted, making the building defect features more clearly visible. This not only improves the image quality but also provides higher-quality data support for model training. By inputting the enhanced image samples and obtaining the recognition results, the recognition performance and existing problems of the model can be initially understood, providing a basis for subsequent training and adjustment. By calculating the predicted loss value, the current performance level of the model can be intuitively understood, providing a clear direction for model optimization. By using the gradient backpropagation algorithm, the network parameters can be automatically adjusted to make the model better fit the features in the enhanced image samples, thereby improving the recognition accuracy. By setting the preset training conditions, it can be ensured that the model maintains good generalization ability while fully learning the features, enabling the model to be applicable to defect inspection tasks in different building construction scenarios, thus improving the efficiency and accuracy of quality inspection.
[0081] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar content as in the above-mentioned first embodiment can be referred to the above introduction and will not be repeated hereinafter. On this basis, please refer toFigure 2 , in step A01, the steps of feature enhancement for the original image samples in the original image sample set include steps S11 to S14:
[0082] Step S11, extract the defect edges of the building defect features to obtain the coordinate distribution of the edge points of the defect edges;
[0083] It should be noted that using image processing techniques (such as edge detection algorithms) to identify the defect edges of building defect features in images, the edge detection algorithm can identify the places where the brightness or color changes most violently in the image, and these places usually correspond to the boundaries or defects of objects. In the original image sample, the defect edge is the boundary line between defects such as cracks and breakages and the surrounding normal areas. Through the edge detection algorithm, the defect edges are extracted, and the coordinate information of each point on these edges is recorded to form the coordinate distribution of edge points. These coordinate points constitute a discrete representation of the defect edge, providing basic data for subsequent steps.
[0084] Step S12, determine the distribution direction of the building defect features according to the coordinate distribution of the edge points, where the distribution direction represents the best tilt angle of the oriented rotation box;
[0085] It should be noted that by analyzing the coordinate distribution of the edge points, the main distribution direction of the building defect features can be determined through calculation or statistical methods. The main distribution direction is the main extension direction of the building defect features in the image, representing the best tilt angle of the oriented rotation box, that is, the rotation angle that can cover the defect edge to the greatest extent. By determining the distribution direction, it can provide guidance for the subsequent adjustment of the oriented rotation box to ensure that the rotation box can accurately cover the defect area.
[0086] Exemplarily, if the building defect feature is a concrete crack, if the crack mainly extends along the horizontal direction, then the distribution direction is the horizontal direction, and the best tilt angle is 0 degrees (or a multiple of 360 degrees). If the crack is inclined, then the best tilt angle is an angle that matches the crack direction.
[0087] Step S13, adjust the oriented rotation box based on the distribution direction to obtain the target rotation box, and the coverage rate of the target rotation box for the coordinate distribution of the edge points reaches a preset threshold;
[0088] It should be noted that adjust the position, size, and tilt angle of the oriented rotation box according to the distribution direction, and continuously calculate the coverage rate of the oriented rotation box for the coordinate distribution of the edge points, that is, the ratio of the number of edge points contained in the rotation box to the total number of edge points. When this ratio reaches the preset threshold (such as 95%), stop the adjustment, generate the target rotation box, and consider that the target rotation box can already cover the area corresponding to the building defect feature at this time.
[0089] Step S14, crop the part of the original image sample other than the target rotated bounding box, and use the area enclosed by the target rotated bounding box as the enhanced image sample.
[0090] It should be noted that by cropping the part of the original image sample other than the target rotated bounding box and only retaining the area enclosed by the rotated bounding box, this area contains the most significant defect features and is important data for subsequent model training. Through cropping, the algorithm can remove irrelevant information in the image, highlight the defect features, and thus improve the recognition accuracy of the model.
[0091] In this embodiment, by extracting the edge features of the building defect features and generating the edge point coordinate distribution, irrelevant information in the image is effectively removed, the building defect features are highlighted, providing an accurate data basis for the subsequent steps. By statistically analyzing the edge point coordinate distribution, the main distribution direction of the building defect features is determined, providing guidance for the subsequent adjustment of the directed rotated bounding box, ensuring that the rotated bounding box can accurately cover the defect area and improving the recognition accuracy. By adjusting the position, size, and tilt angle of the directed rotated bounding box, ensuring that the coverage rate of the rotated bounding box for the edge point coordinate distribution reaches the preset threshold, irrelevant information in the image is effectively removed while retaining the complete defect features, providing high-quality data for the subsequent model training. By cropping the part of the original image sample other than the target rotated bounding box, enhanced image samples containing only defect features can be obtained, and these samples provide clear and accurate data support for the subsequent model training, helping to improve the recognition accuracy and generalization ability of the model.
[0092] In a feasible embodiment, in step S11, the steps of extracting the defect edges of the defect features and obtaining the edge point coordinate distribution of the defect edges include steps B01 to B04:
[0093] Step B01, perform frequency domain decomposition on the target content selected by the directed rotated bounding box in the original image sample through filters of each preset scale, and extract the frequency domain responses of the target content in each preset direction and each preset wavelength, where the filters of each preset scale cover each preset direction and each preset wavelength;
[0094] It should be noted that a set of filters with preset scales is used to perform frequency-domain decomposition on the target content selected by the oriented rotated bounding box in the original image sample. The target content includes images with building defect features. These filters cover different directions (i.e., preset directions) and wavelengths (i.e., preset wavelengths), and can capture the detailed information of different scales and directions in the image, and are used to extract the information of the image at different frequencies and directions. Among them, the preset directions can be 0°, 30°, 60°, 90°, 120°, 150°, etc., which are used to cover the possible multi-angle extension characteristics of building defect features. The preset wavelengths can be filter wavelengths such as 3px, 6px, 12px, etc., which correspond to the characteristic sizes of fine cracks, medium holes, and large cracks respectively. The preset directions and preset wavelengths constitute the preset scales, and each preset scale includes a specific combination of direction and wavelength. For example: preset scale 1: direction 0°, wavelength 3px; preset scale 2: direction 30°, wavelength 6px; preset scale 3: direction 60°, wavelength 12px, etc.
[0095] Exemplarily, for an original image sample containing multiple building defect features, including both fine cracks and large cracks, in order to extract the edge features of these defects, the following preset scales can be selected: preset scale 1: direction 0°, wavelength 3px (used to capture fine cracks), preset scale 2: direction 90°, wavelength 6px (used to capture medium-sized cracks), preset scale 3: direction 45°, wavelength 12px (used to capture large cracks).
[0096] In addition, it should be noted that frequency-domain decomposition refers to the process of converting the original image sample from the spatial domain (i.e., the distribution of pixel values) to the frequency domain (i.e., the distribution of frequency components). Frequency-domain decomposition helps to analyze the frequency components in the image, so as to extract the features of interest. Through frequency-domain decomposition, the frequency-domain response can be obtained. The frequency-domain response refers to the output result of the target content in the frequency domain after being processed by the filter, indicating the energy distribution of the target content at different frequencies and directions.
[0097] Step B02, calculate the phase consistency value of each pixel point in the target content based on the frequency-domain response, and mark the pixel points with the phase consistency value higher than the preset phase consistency threshold as valid edge points;
[0098] It should be noted that the phase consistency value of each pixel point in the target content is calculated based on the frequency domain response. Phase consistency is an index for measuring the stability of local features in an image, used to quantify the phase alignment degree in different frequencies and directions in the local area of the image, which can highlight the edge and texture information in the image. In edge detection, pixel points with high phase consistency values often correspond to edge or texture features in the image. By comparing the phase consistency value with a preset phase consistency threshold (such as 0.8), the pixel points higher than the threshold are marked as valid edge points, and these valid edge points constitute the edge features in the image, providing a basis for subsequent edge connection and contour extraction.
[0099] In addition, it should be noted that for the preset phase consistency threshold, it can also be set proportionally according to the maximum phase consistency value in the original image sample, which is applicable to scenes with uniform illumination, such as , where is the preset phase consistency threshold, is an empirical coefficient, usually taken as 0.4, is the maximum phase consistency value.
[0100] Step B03: Perform a morphological closing operation on the valid edge points to connect the valid edge points into a continuous contour line, obtaining a connected edge region;
[0101] It should be noted that a morphological closing operation is performed on the pixel points marked as valid edge points. The morphological closing operation is an image processing technique. Through the operations of dilation first and then erosion, it can fill the small gaps between edge points and connect the broken edges. The closing operation helps to generate a continuous contour line and improve the accuracy of edge detection. Through the morphological closing operation, a connected edge region composed of valid edge points is obtained, which characterizes the edge features in the image.
[0102] Step B04: Convert the connected edge region into a coordinate set to obtain the edge point coordinate distribution, where the edge point coordinate distribution characterizes the geometric contour of the building defect feature.
[0103] It should be noted that each edge point in the connected edge region is converted into a coordinate form, and a set containing all edge point coordinates is generated to describe the geometric contour of the edge features in the image. This coordinate set is the edge point coordinate distribution. The edge point coordinate distribution reflects information such as the shape, size, and position of the edge features in the image, and can be used for subsequent analysis, processing, and visualization.
[0104] In this embodiment, by performing frequency-domain decomposition on the original image samples using filters of each preset scale, the frequency-domain responses of the image at different scales and directions can be extracted, effectively suppressing noise and highlighting the edge and texture information in the image. At the same time, since the filters cover each preset direction and each preset wavelength, the possible multi-angle extension characteristics of building defect features and the detail information of different sizes can be captured, providing a more accurate and reliable basis for subsequent edge detection and feature extraction. By calculating the phase consistency value of each pixel point in the original image sample based on the frequency-domain response, the edge and texture information in the image is highlighted. Pixel points with a phase consistency value higher than the preset phase consistency threshold are marked as valid edge points, and the edge features in the image can be accurately identified, providing a more accurate basis for subsequent edge connection and contour extraction. By performing a morphological closing operation on the valid edge points, the problems of fracture and misconnection in edge connection are effectively solved, and a more accurate and complete connected edge region is obtained.
[0105] In a feasible embodiment, in step S12, the steps of determining the distribution direction of building defect features according to the edge point coordinate distribution include steps B11 to B14:
[0106] Step B11, determining the edge point weight of each edge point coordinate in the edge point coordinate distribution;
[0107] It should be noted that an edge point weight is assigned to each edge point, and this weight reflects the importance of the edge point in describing the building defect features. The determination of the weight can be based on various factors, such as the gradient intensity, phase consistency value, local contrast, etc. The larger the weight value, the more important the edge point is in describing the defect features.
[0108] Step B12, calculating the weighted mean center coordinate of the edge point coordinate distribution based on each edge point coordinate and the corresponding edge point weight;
[0109] It should be noted that after determining the edge point weight, the weighted mean center coordinate is calculated. This coordinate is the "center of gravity" of the edge point coordinate distribution, considering the position and weight of each edge point. The calculation formula for the weighted mean center coordinate is:
[0110]
[0111] Where, is the abscissa of the weighted mean center, is the ordinate of the weighted mean center, is the th edge point weight, reflecting the importance of this point in the defect features, is the th edge point abscissa, is the The ordinate of an edge point, is the sum of all weights, used for normalizing the weighted mean to ensure that the calculation result is not affected by the magnitude of the absolute value of the weights.
[0112] Step B13: Construct a covariance matrix of the edge point coordinate distribution based on each edge point coordinate, the edge point weight corresponding to each edge point coordinate, and the weighted mean center coordinate;
[0113] It should be noted that the covariance matrix is used to describe the linear relationship between variables, to describe the deviation and correlation between the edge point coordinates and the weighted mean center coordinate. The construction formula of the covariance matrix is:
[0114]
[0115] where, represents the covariance matrix, and is the deviation between the edge point coordinate and the weighted mean center coordinate, indicating the position offset of the point relative to the centroid.
[0116] Step B14: Determine the vector direction corresponding to the maximum eigenvalue of the covariance matrix. The vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect features.
[0117] It should be noted that after constructing the covariance matrix, calculate its maximum eigenvalue. The vector direction corresponding to the maximum eigenvalue is the main direction of the edge point coordinate distribution and also the most significant direction of the building defect features.
[0118] In this embodiment, by assigning weights to each edge point, the importance of different edge points in describing the building defect features can be distinguished, which helps to reduce noise interference and improve the accuracy of defect feature description. By considering the weights of the edge points and calculating the weighted mean center coordinate, the central position of the defect features can be more realistically reflected, providing a reliable basis for subsequent analysis. At the same time, the calculation of the weighted mean center coordinate also helps to reduce errors caused by uneven edge point distribution or noise interference. By constructing the covariance matrix, the directional information of the edge point coordinate distribution can be captured. The elements in the covariance matrix reflect the dispersion degree and correlation of the edge point coordinates in each direction. By analyzing the eigenvalues and eigenvectors of the covariance matrix, the extension direction of the defect features can be accurately judged. By determining the vector direction corresponding to the maximum eigenvalue of the covariance matrix, the distribution direction of the defect features can be objectively judged. This direction reflects the main trend and form of the edge point coordinate distribution and is of great significance for subsequent analysis and processing.
[0119] In a feasible implementation manner, in step B11, the steps of determining the edge point weights of each edge point coordinate in the edge point coordinate distribution include steps B21 to B24:
[0120] Step B21, for any edge point coordinate in the edge point coordinate distribution, calculate the gradient magnitude of the edge point coordinate;
[0121] It should be noted that the horizontal gradient of each edge point coordinate is calculated through the Sobel operator (3×3 convolution kernel) and the vertical gradient , the horizontal gradient and the vertical gradient The calculation formulas are:
[0122]
[0123]
[0124]
[0125]
[0126] Among them, represents the pixel value of the image at the position . In a grayscale image, is an integer value between 0 (black) and 255 (white), represents the edge point coordinate, is the horizontal gradient convolution kernel, is the vertical gradient convolution kernel, represents the offset of the convolution kernel in the vertical direction, and the value range is -1, 0, 1, represents the offset of the convolution kernel in the horizontal direction, and the value range is -1, 0, 1, and map the offset to the index of the convolution kernel. Since the index of the convolution kernel starts from 0, is the weight in the horizontal gradient convolution kernel, is the weight in the vertical gradient convolution kernel.
[0127] Through the horizontal gradient and the vertical gradient the gradient magnitude of the edge point coordinate can be calculated, and the calculation formula is:
[0128]
[0129] The gradient amplitude reflects the rate of change of the image at that point, that is, how fast the image brightness or color intensity changes. The larger the gradient amplitude, the more drastic the image change at the edge point, and therefore the more important the edge point may be. In the quality inspection of construction, edge points with large gradient amplitudes often correspond to the edges of defects, and these edges are crucial for describing the characteristics of defects.
[0130] Step B22, taking the ratio of the gradient amplitude to the maximum gradient amplitude in each edge point coordinate as the clarity weight of the edge point coordinate;
[0131] It should be noted that the maximum gradient amplitude in the coordinates of all edge points is found , calculate the clarity weight of each edge point coordinate , the calculation formula is:
[0132]
[0133] The clarity weight is used to measure the clarity or significance of edge points. In construction quality inspection, edge points with high clarity are more likely to represent real defect edges, so they should be given higher weights.
[0134] Step B23, determining the curvature of the edge point coordinates, and determining the bending weight of the edge point coordinates according to the curvature and the maximum curvature among the edge point coordinates;
[0135] It should be noted that for each edge point coordinate, the coordinates of the two adjacent points are taken , , , the curvature calculation formula of the edge point coordinates is:
[0136]
[0137] in, is the curvature, is the coordinate before the current edge point coordinate, is the coordinate after the current edge point coordinate, is the average step length between coordinate points.
[0138] The maximum curvature in determining the coordinates of each edge point After that, calculate the bending weight of the edge point coordinates , the calculation formula is:
[0139]
[0140] The curvature weight is used to measure the curvature of edge points. In construction quality inspection, edge points with large curvatures may correspond to complex defects or irregularities of edges. By assigning these edge points higher curvature weights, the complex characteristics of defects can be described more accurately.
[0141] Step B24: Obtain the edge point weight of the edge point coordinates based on the clarity weight and the curvature weight.
[0142] It should be noted that after obtaining the clarity weight and the curvature weight, calculate the edge point weight of the edge point coordinates. , and the calculation formula is:
[0143]
[0144] In this embodiment, by calculating the gradient amplitude of each edge point, the change rate of the image at this point is accurately measured, so as to identify those edge points with significant image changes. By calculating the ratio of the gradient amplitude to the maximum gradient amplitude, a clarity weight is assigned to each edge point, which helps to reduce noise interference and improve the accuracy of defect feature description. At the same time, by assigning higher weights to edge points with higher clarity, the real defect edges can be more prominently displayed, providing clearer image information for subsequent analysis and processing. By determining the curvature of each edge point and calculating the curvature weight according to the ratio of the curvature to the maximum curvature, the bending degree of the edge point is accurately measured, which helps to more accurately capture the complex shape and bending degree of the defect. At the same time, by assigning higher weights to edge points with larger bending degrees, the complex features of the defect can be more prominently displayed, providing richer image information for subsequent analysis and processing. By calculating the edge point weight based on the clarity weight and the curvature weight, comprehensively considering the clarity and bending degree of the edge point, a reasonable weight is assigned to each edge point, which helps to more accurately describe the distribution and shape of the defect. At the same time, by paying more attention to edge points with higher weights, building defects can be more effectively identified and processed, improving the accuracy and efficiency of building construction quality inspection.
[0145] In a feasible embodiment, in step S13, the steps of adjusting the oriented rotation box based on the distribution direction include steps B31 to B32:
[0146] Step B31: Denote the intersection line of the weighted mean center coordinate and the distribution direction as the horizontal reference axis, and denote the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis as the vertical reference axis;
[0147] It should be noted that the intersection line of the weighted mean center coordinates and the distribution direction is denoted as the horizontal reference axis, which represents the main direction of the defect extension. The intersection line that intersects with the weighted mean center coordinates and is perpendicular to the horizontal reference axis is denoted as the vertical reference axis. This axis is perpendicular to the horizontal reference axis and together they form the reference coordinate system of the oriented rotation box. The horizontal reference axis represents the main direction of the defect extension and is an important reference when constructing the oriented rotation box. It determines the rotation angle of the box so that it can closely fit the shape of the defect. The vertical reference axis is perpendicular to the horizontal reference axis and together they form the reference coordinate system of the oriented rotation box, which is used to determine the width of the box, that is, the dimension perpendicular to the defect extension direction.
[0148] Step B32, expand the horizontal length based on the horizontal reference axis to both sides perpendicular to the horizontal reference axis, and expand the vertical length based on the vertical reference axis to both sides perpendicular to the vertical reference axis. The horizontal length and the vertical length respectively represent the length and width of the oriented rotation box.
[0149] It should be noted that based on the horizontal reference axis, expand a certain length to both sides perpendicular to the horizontal reference axis. This length represents the length of the oriented rotation box and it needs to meet the requirement of covering the entire range of the building defect characteristics in the main extension direction. At the same time, based on the vertical reference axis, expand a certain length to both sides perpendicular to the vertical reference axis. This length represents the width of the oriented rotation box and it needs to meet the requirement of being able to cover the entire range of the defect perpendicular to the main extension direction.
[0150] Exemplarily, for the purpose of facilitating the understanding of the technical concept or technical principle of the present application, please refer to Figure 3 , Figure 3 A schematic diagram of the scenario for adjusting the oriented rotation box is provided. Among them, o is the weighted mean center coordinates, a is the distribution direction, the x-axis corresponds to the horizontal reference axis, and y corresponds to the vertical reference axis. For the horizontal reference axis x, when adjusting, expand the horizontal length from the weighted mean center coordinates o to the directions of x1 and x2 to both sides. For the vertical reference axis y, when adjusting, expand the vertical length from the weighted mean center coordinates o to the directions of y1 and y2 to both sides, and finally obtain the oriented rotation box C.
[0151] In this embodiment, by calculating the intersection line of the weighted mean center coordinates and the distribution direction to determine the horizontal reference axis, and then determining the vertical reference axis perpendicular to it, the self-adaptive adjustment of the direction of the marking box is realized, enabling it to closely fit the actual extension direction of the defect. This not only improves the matching degree between the marking box and the defect shape, but also reduces the misjudgment and omission caused by the direction mismatch. By self-adaptively adjusting the size of the marking box, it is ensured that the marking box can closely cover the key part of the defect, while avoiding the interference of unnecessary background information, which helps to solve the problem of poor building defect inspection effect caused by the mismatch of the marking box size in building construction quality inspection, and improves the accuracy and efficiency of defect recognition.
[0152] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the model construction method of this application. Based on this technical concept, more forms of simple transformations are within the protection scope of this application.
[0153] This application also provides a model construction system. Please refer to Figure 4 , the model construction system includes:
[0154] A data receiving module 10, configured to receive an original image sample set with annotations, wherein the building defect features of the original image samples in the original image sample set are selected by oriented rotation boxes;
[0155] A model training module 20, configured to train a preset initial image recognition model based on the original image sample set to construct a target recognition model for recognizing building defect features.
[0156] Optionally, the model training module 20 is further configured to:
[0157] Perform feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set;
[0158] For any enhanced image sample in the enhanced image sample set, input the enhanced image sample into the preset initial image recognition model to obtain a sample recognition result of the enhanced image sample;
[0159] Calculate a prediction loss value of the preset initial image recognition model according to the difference between the sample recognition result and the enhanced image sample;
[0160] Based on the prediction loss value, use the gradient backpropagation algorithm to adjust the model parameters of the preset initial image recognition model;
[0161] After the preset initial image recognition model reaches the preset training conditions, obtain the target recognition model.
[0162] Optionally, the model training module 20 is further configured to:
[0163] Extract the defect edges of the building defect features to obtain the edge point coordinate distribution of the defect edges;
[0164] Determine the distribution direction of the building defect features according to the edge point coordinate distribution, wherein the distribution direction represents the best tilt angle of the oriented rotation box;
[0165] Adjust the oriented rotation box based on the distribution direction to obtain a target rotation box, and the coverage rate of the target rotation box for the edge point coordinate distribution reaches a preset threshold;
[0166] Crop the part of the original image sample except the target rotation box, and use the area surrounded by the target rotation box as the enhanced image sample.
[0167] Optionally, the model training module 20 is further configured to:
[0168] Perform frequency domain decomposition on the target content selected by the oriented bounding box in the original image sample through filters of each preset scale, and extract the frequency domain responses of the target content in each preset direction and each preset wavelength, where the filters of each preset scale cover each preset direction and each preset wavelength;
[0169] Calculate the phase consistency value of each pixel point in the target content based on the frequency domain response, and mark the pixel points with the phase consistency value higher than the preset phase consistency threshold as valid edge points;
[0170] Perform morphological closing operation on the valid edge points to connect the valid edge points into continuous contour lines and obtain a connected edge region;
[0171] Convert the connected edge region into a coordinate set to obtain the edge point coordinate distribution, where the edge point coordinate distribution represents the geometric contour of the building defect feature.
[0172] Optionally, the model training module 20 is further configured to:
[0173] Determine the edge point weights of each edge point coordinate in the edge point coordinate distribution;
[0174] Calculate the weighted mean center coordinate of the edge point coordinate distribution based on each edge point coordinate and the corresponding edge point weight;
[0175] Construct the covariance matrix of the edge point coordinate distribution based on each edge point coordinate, the edge point weight corresponding to each edge point coordinate, and the weighted mean center coordinate;
[0176] Determine the vector direction corresponding to the maximum eigenvalue of the covariance matrix, and the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect feature.
[0177] Optionally, the model training module 20 is further configured to:
[0178] For any edge point coordinate in the edge point coordinate distribution, calculate the gradient magnitude of the edge point coordinate;
[0179] Use the ratio of the gradient magnitude to the maximum gradient magnitude among all edge point coordinates as the clarity weight of the edge point coordinate;
[0180] Determine the curvature of the edge point coordinate, and determine the bending weight of the edge point coordinate according to the curvature and the maximum curvature among all edge point coordinates;
[0181] Obtain the edge point weight of the edge point coordinate based on the clarity weight and the bending weight.
[0182] Optionally, the model training module 20 is further configured to:
[0183] The intersection line of the weighted mean center coordinates and the distribution direction is denoted as the horizontal reference axis, and the intersection line that intersects the weighted mean center coordinates and is perpendicular to the horizontal reference axis is denoted as the vertical reference axis;
[0184] Based on the horizontal reference axis, the horizontal length is extended to both sides perpendicular to the horizontal reference axis, and based on the vertical reference axis, the vertical length is extended to both sides perpendicular to the vertical reference axis. The horizontal length and the vertical length respectively represent the length and width of the oriented bounding box.
[0185] The model construction device provided by this application adopts the model construction method in the above-mentioned embodiment, and can solve the technical problem of poor building defect inspection effect. Compared with the prior art, the beneficial effects of the model construction device provided by this application are the same as those of the model construction method provided by the above-mentioned embodiment, and other technical features in the model construction device are the same as those disclosed in the method of the above-mentioned embodiment, which will not be elaborated here.
[0186] This application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the model construction method in the first embodiment above.
[0187] Next, refer to Figure 5 , which shows a schematic structural diagram of an electronic device suitable for implementing the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, PADs (Portable Application Description: tablet computers), and fixed terminals such as digital TVs, desktop computers, and the like. Figure 5 The electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of this application.
[0188] As Figure 5As shown, the electronic device may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which may perform various appropriate actions and processes according to a program stored in the read-only memory 1002 or a program loaded from the storage device 1003 into the random access memory 1004. In the random access memory 1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, the read-only memory 1002, and the random access memory 1004 are connected to each other through a bus 1005. The input / output interface 1006 is also connected to the bus. Generally, the following systems may be connected to the input / output interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the electronic device to communicate with other devices wirelessly or wiredly to exchange data. Although the figure shows an electronic device having various systems, it should be understood that it is not required to implement or have all the shown systems. More or fewer systems may be implemented or had alternatively.
[0189] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for performing the methods shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from the network through the communication device, or installed from the storage device 1003, or installed from the read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of the embodiments disclosed in the present application are executed.
[0190] The electronic device provided by the present application adopts the model construction method in the above-mentioned embodiment, and can solve the technical problem of poor building defect inspection effect. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as those of the model construction method provided by the above-mentioned embodiment, and other technical features in the electronic device are the same as those disclosed in the method of the previous embodiment, and will not be elaborated here.
[0191] It should be understood that the various parts disclosed in the present application may be implemented by hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in a suitable manner in any one or more embodiments or examples.
[0192] As described above, it is only the specific implementation manner of the present application. However, the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, and all of them should be covered by the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claimed rights.
[0193] The present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the model construction method in the above embodiments.
[0194] The computer-readable storage medium provided by the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM) or flash memory, optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system or device. The program code contained on the computer-readable storage medium can be transmitted by any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0195] The above computer-readable storage medium may be included in an electronic device; or it may exist separately without being assembled into the electronic device.
[0196] The above computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the model construction device is caused to: receive an original image sample set marked with labels, wherein the building defect features of the original image samples in the original image sample set are selected by an oriented bounding box; and train a preset initial image recognition model based on the original image sample set to construct a target recognition model for recognizing building defect features.
[0197] Computer program code for performing the operations of this application can be written in one or more programming languages or combinations thereof. The above-mentioned programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN: Local Area Network) or a wide area network (WAN: Wide Area Network), or it can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0198] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and this module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks can occur in a different order from that marked in the accompanying drawings. For example, two consecutively represented blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0199] The modules involved in the embodiments described in this application can be implemented in software or in hardware. Among them, the name of the module does not constitute a limitation on the unit itself in some cases.
[0200] The readable storage medium provided in this application is a computer-readable storage medium. The computer-readable storage medium stores computer-readable program instructions (i.e., computer programs) for performing the above-mentioned model construction method, and can solve the technical problem of poor building defect inspection effect. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the model construction method provided in the above embodiments, and will not be elaborated here.
[0201] The present application also provides a computer program product, including a computer program which, when executed by a processor, implements the steps of the model construction method as described above.
[0202] The computer program product provided by the present application can solve the technical problem of poor building defect inspection effect. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as those of the model construction method provided by the above embodiments, and will not be elaborated herein.
[0203] The above are only partial embodiments of the present application, and thus do not limit the patent scope of the present application. Any equivalent structural transformation made under the technical concept of the present application by using the content of the specification and drawings of the present application, or direct / indirect application in other related technical fields, is included in the patent protection scope of the present application.
Claims
1. A model building method, characterized in that, The model construction method includes: Receiving an original image sample set with annotations, where the building defect features of the original image samples in the original image sample set are selected by an oriented bounding box; Performing feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set, and training a preset initial image recognition model based on the enhanced image sample set to construct a target recognition model for recognizing building defect features. Among them, the step of performing feature enhancement on the original image samples in the original image sample set includes: Extracting the defect edge of the building defect feature to obtain the edge point coordinate distribution of the defect edge; Determining the distribution direction of the building defect feature according to the edge point coordinate distribution, where the distribution direction represents the best tilt angle of the oriented bounding box; Adjusting the oriented bounding box based on the distribution direction to obtain a target bounding box, and the coverage rate of the target bounding box for the edge point coordinate distribution reaches a preset threshold; Cropping the part of the original image sample except the target bounding box, and taking the area surrounded by the target bounding box as an enhanced image sample; The step of determining the distribution direction of the building defect feature according to the edge point coordinate distribution includes: Determining the edge point weights of each edge point coordinate in the edge point coordinate distribution; Calculating the weighted mean center coordinate of the edge point coordinate distribution based on the edge point coordinates and the corresponding edge point weights; Constructing a covariance matrix of the edge point coordinate distribution based on the edge point coordinates, the edge point weights corresponding to the edge point coordinates, and the weighted mean center coordinate; Determining the vector direction corresponding to the maximum eigenvalue of the covariance matrix, and the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect feature.
2. The model construction method according to claim 1, characterized in that The step of training the preset initial image recognition model based on the enhanced image sample set includes: For any enhanced image sample in the enhanced image sample set, inputting the enhanced image sample into the preset initial image recognition model to obtain the sample recognition result of the enhanced image sample; Calculating the prediction loss value of the preset initial image recognition model according to the difference between the sample recognition result and the enhanced image sample; Adjusting the model parameters of the preset initial image recognition model by using the gradient backpropagation algorithm based on the prediction loss value; After the preset initial image recognition model reaches the preset training conditions, obtaining the target recognition model.
3. The model construction method according to claim 1, wherein The step of extracting the defect edge of the building defect feature to obtain the edge point coordinate distribution of the defect edge includes: Performing frequency domain decomposition on the target content selected by the oriented bounding box in the original image sample through filters of each preset scale, and extracting the frequency domain responses of the target content in each preset direction and each preset wavelength, where the filters of each preset scale cover each preset direction and each preset wavelength; Calculating the phase consistency value of each pixel point in the target content based on the frequency domain response, and marking the pixel points with phase consistency values higher than the preset phase consistency threshold as valid edge points; Perform a morphological closing operation on the valid edge points to connect the valid edge points into a continuous contour line, obtaining a connected edge region; Convert the connected edge region into a coordinate set to obtain an edge point coordinate distribution, where the edge point coordinate distribution represents the geometric contour of the building defect feature.
4. The model construction method according to claim 1, characterized in that The step of determining the edge point weights of the edge point coordinates in the edge point coordinate distribution includes: For any edge point coordinate in the edge point coordinate distribution, calculate the gradient magnitude of the edge point coordinate; Take the ratio of the gradient magnitude to the maximum gradient magnitude among all edge point coordinates as the clarity weight of the edge point coordinate; Determine the curvature of the edge point coordinate, and determine the bending weight of the edge point coordinate according to the curvature and the maximum curvature among all edge point coordinates; Obtain the edge point weight of the edge point coordinate based on the clarity weight and the bending weight.
5. The model construction method according to claim 1, characterized in that The step of adjusting the directed rotation box based on the distribution direction includes: Denote the intersection line of the weighted mean center coordinate and the distribution direction as the horizontal reference axis, and denote the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis as the vertical reference axis; Expand the horizontal length based on the horizontal reference axis to both sides perpendicular to the horizontal reference axis, and expand the vertical length based on the vertical reference axis to both sides perpendicular to the vertical reference axis. The horizontal length and the vertical length respectively represent the length and width of the directed rotation box.
6. An electronic device, characterized in that, The device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor. The computer program is configured to implement the steps of the model construction method according to any one of claims 1 to 5.
7. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the model construction method according to any one of claims 1 to 5.
8. A computer program product, characterized in that, The computer program product includes a computer program. When the computer program is executed by a processor, it implements the steps of the model construction method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Detecting and error-correcting method capable of rapidly and accurately obtaining element center and deflection angle
CN104981105A
Concrete building outer wall detection method and system, computer equipment and storage medium
CN119360219A
Industrial pure iron metallographic specimen defect detection optimization method based on YOLOv8obb
CN119831964A