Model construction method, electronic equipment, storage medium and computer program product
By constructing a building defect identification model based on directed rotary frame marking, the problems of low efficiency and poor accuracy of defect inspection in building construction are solved, automated and intelligent building defect detection are realized, and the efficiency and accuracy of detection are improved.
Patent Information
- Application Number
- CN202510480423.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-04-17
AI Technical Summary
Defect inspections in construction rely on manual inspections, resulting in low efficiency, poor accuracy, and difficulty in comprehensive coverage and in-depth inspections, posing potential safety hazards.
A model construction method is proposed. By receiving the marked original image sample set, accurately annotating the building defect features using a directed rotating box, and training the initial image recognition model based on these data to build a target recognition model that recognizes building defect features.
Automatic and intelligent building defect detection is realized, the efficiency and accuracy of the inspection is improved, manual misjudgment and omissions are reduced, and the safety and compliance of building construction quality inspection is ensured.
Smart Images

Figure CN119992260A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of model building, and in particular to a model building method, system, electronic device, storage medium and computer program product. Background Art
[0002] In the field of construction, quality inspection is a key link to ensure project safety and compliance. Its efficiency and accuracy directly affect the overall progress and cost control of the project. For a long time, construction quality inspection has mainly relied on traditional manual inspection methods, which is not only time-consuming and laborious, but also prone to omissions or misjudgments of details due to subjective judgment, experience level and physical limitations. Especially in large and complex projects, facing a large number of checkpoints and hidden projects, manual inspections are often difficult to achieve comprehensive coverage and in-depth inspections, which bury potential safety hazards for subsequent use. Therefore, there is a problem of poor inspection results for building defects in current construction quality inspections. Summary of the invention
[0003] The main purpose of this application is to provide a model building method, system, electronic device, storage medium and computer program product, aiming to solve the technical problem of poor building defect inspection effect.
[0004] To achieve the above objectives, the present application proposes a model construction method, which includes: Receiving a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; A preset initial image recognition model is trained based on the original image sample set to construct a target recognition model for recognizing building defect features.
[0005] In one embodiment, the step of training a preset initial image recognition model based on the original image sample set includes: Performing feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set; For any one 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; Calculating a prediction loss value of the preset initial image recognition model according to a difference between the sample recognition result and the enhanced image sample; Based on the predicted loss value, a gradient back propagation algorithm is used to adjust the model parameters of the preset initial image recognition model; After the preset initial image recognition model reaches the preset training condition, the target recognition model is obtained.
[0006] In one embodiment, the step of performing feature enhancement on the original image samples in the original image sample set includes: Extracting defect edges of the building defect features to obtain edge point coordinate distribution of the defect edges; Determining a distribution direction of the building defect feature according to the edge point coordinate distribution, wherein the distribution direction represents an optimal tilt angle of the directed rotation frame; Adjusting the directed rotation frame based on the distribution direction to obtain a target rotation frame, wherein the coverage rate of the target rotation frame on the edge point coordinate distribution reaches a preset threshold; The portion of the original image sample other than the target rotation frame is cropped, and the area surrounded by the target rotation frame is used as the enhanced image sample.
[0007] In one embodiment, the step of extracting the defect edge of the defect feature and obtaining the coordinate distribution of edge points of the defect edge includes: Performing frequency domain decomposition on the target content selected by the directional rotation box in the original image sample through filters of each preset scale, and extracting the frequency domain response of the target content in each preset direction and each preset wavelength, wherein the filters of each preset scale cover each preset direction and each preset wavelength; Calculating a phase consistency value of each pixel in the target content based on the frequency domain response, and marking a pixel whose phase consistency value is higher than a preset phase consistency threshold as a valid edge point; Performing a morphological closing operation on the valid edge points to connect the valid edge points into a continuous contour line to obtain a connected edge region; The connected edge region is converted into a coordinate set to obtain an edge point coordinate distribution, wherein the edge point coordinate distribution represents a geometric outline of the building defect feature.
[0008] In one embodiment, the step of determining the distribution direction of the building defect feature according to the edge point coordinate distribution includes: Determine an edge point weight of each edge point coordinate in the edge point coordinate distribution; Calculating the weighted mean center coordinates 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 coordinates; The vector direction corresponding to the maximum eigenvalue of the covariance matrix is determined, and the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect feature.
[0009] In one embodiment, the step of determining the edge point weight of each edge point coordinate in the edge point coordinate distribution includes: For any edge point coordinate in the edge point coordinate distribution, calculating the gradient amplitude of the edge point coordinate; The ratio of the gradient amplitude to the maximum gradient amplitude in each edge point coordinate is used as the clarity weight of the edge point coordinate; Determine the curvature of the edge point coordinates, and determine the bending weight of the edge point coordinates according to the curvature and the maximum curvature among the edge point coordinates; The edge point weight of the edge point coordinate is obtained based on the clarity weight and the bending weight.
[0010] In one embodiment, the step of adjusting the directed rotation frame based on the distribution direction includes: The intersection line of the weighted mean center coordinate and the distribution direction is recorded as the horizontal reference axis, and the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis is recorded as the vertical reference axis; The horizontal length is extended on both sides perpendicular to the horizontal reference axis based on the horizontal reference axis, and the vertical length is extended on both sides perpendicular to the vertical reference axis based on the vertical reference axis. The horizontal length and the vertical length respectively represent the length and width of the directed rotation frame.
[0011] In addition, to achieve the above objectives, the present application also proposes a model building system, the model building system comprising: A data receiving module, used for receiving a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; The model training module is used to train a preset initial image recognition model based on the original image sample set to construct a target recognition model for identifying building defect features.
[0012] In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the model building method described above.
[0013] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which 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, the steps of the model building method described above are implemented.
[0014] In addition, to achieve the above-mentioned purpose, 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 building method described above are implemented.
[0015] The present application provides a model building method, which includes: receiving a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; and training a preset initial image recognition model based on the original image sample set to build a target recognition model for identifying building defect features.
[0016] This application obtains a pre-annotated original image sample set, in which building defects are framed by a directed rotating frame. Compared with the traditional horizontal frame, cracks and tilted objects will cover too many invalid feature areas when annotating, resulting in mixed target feature data and failure to converge quickly and effectively. The directed rotating frame is used to frame building defects, which is suitable for direction-sensitive problems such as concrete cracks, plaster cracks, floor cracks, and beam cracks. It can improve the quality of the model training sample set, and train the initial model based on the annotated data set, which can make the trained model more effective. After the training is completed, a target model specifically identifying building defects is obtained. Compared with related solutions that rely on manual inspections, which are not only time-consuming and labor-intensive, but also affected by subjective experience, this application solves the problem of traditional quality inspection relying on manual experience and low efficiency by constructing an image recognition model for building defects, and realizes automated and intelligent building defect detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0018] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0019] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the model building method of the present application; Figure 2 A flow chart of the second embodiment of the model building method of the present application is provided; Figure 3 A schematic diagram of a scene for adjusting a directional rotating frame provided for the model building method of this application; Figure 4 A schematic diagram of the module structure of the model building system of the embodiment of the present application; Figure 5 Schematic diagram of the device structure of the hardware operating environment involved in the model building method in the embodiment of the present application.
[0020] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0021] 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.
[0022] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0023] The main solution of the embodiment of the present application is: receiving a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; 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.
[0024] In this embodiment, for the convenience of description, the following description is made with the model building system as the execution subject.
[0025] Since existing technologies rely on traditional manual inspection methods, it is not only time-consuming and labor-intensive, but also very easy to miss details or misjudge due to people's subjective judgment, experience level and physical limitations. Especially in large and complex projects, faced with a large number of checkpoints and hidden projects, manual inspections are often difficult to achieve full coverage and in-depth inspections, which poses potential safety hazards to subsequent use.
[0026] This application provides a solution, which solves the problem of traditional quality inspection relying on manual experience and low efficiency by constructing an image recognition model for building defects, and realizes automated and intelligent building defect detection.
[0027] 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 capable of realizing the above functions, a model building system, etc. The following takes the model building system as an example to illustrate this embodiment and the following embodiments.
[0028] Based on this, the present application embodiment provides a model construction method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the model building method of the present application.
[0029] In this embodiment, the model building method includes steps S01-S02: Step S01, receiving a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; It should be noted that the manually annotated original image sample set is collected and received, which contains multiple original image samples. Each original image sample comes directly from the construction site, covering various building conditions, especially the defective parts, which may include concrete cracks, plaster cracks, floor cracks, beam cracks, exposed steel bars / pipes, door and window gaps and other building defect features. The building defect features in these images have been accurately annotated by the Oriented Bounding Box (OBB).
[0030] In addition, it should be noted that OBB adds the dimension θ (rotation angle), that is, (x, y, w, h, θ), where x and y are the coordinates of the center point of the directed rotation box, w is the width of the directed rotation box, h is the height of the directed rotation box, and θ is the rotation angle of the directed rotation box relative to the coordinate axis. The traditional horizontal bounding box (HBB) does not introduce the parameter of the rotation angle θ, that is, (x, y, w, h). Compared with HBB, OBB can more accurately describe the target direction, reduce the coverage of invalid feature areas, and improve the accuracy of annotation, so that the model can more accurately detect non-horizontal target detection problems, such as cracks (concrete cracks, floor cracks, plaster surface cracks, concrete beam waist cracks, etc.), exposed rebar / exposed pipes, door and window gaps, etc.
[0031] 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 scene corresponding to the original image sample can be quickly determined, such as the ground, wall, glass, etc. The scene recognition model is a pre-trained lightweight model for identifying different construction scenes, which can be trained using the MobileNetV3 architecture. For construction buildings, different building defect features will differ due to different scenes, such as cracks on glass and cracks on walls are obviously different. Therefore, by marking the scene of the original image sample, targeted training can be performed 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 identification.
[0032] It is understandable that, since traditional image annotation methods (such as horizontal bounding boxes HBB) are often difficult to accurately describe the characteristics of building defects with irregular shapes and directions, the target feature data is mixed during subsequent model training, which affects the convergence speed and detection accuracy of the model. Therefore, step S01 is performed to solve the problem of mixed target feature data under traditional annotation methods by receiving the original image sample set annotated by OBB (Oriented Bounding Box). The OBB annotation method can more accurately describe the direction and shape of irregular targets by adding the parameter of the rotation angle θ, reduce the interference of invalid feature areas, and provide more accurate and richer feature data for subsequent model training, which helps to improve the detection accuracy and generalization ability of the model.
[0033] 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.
[0034] It should be noted that after receiving the labeled original image sample set, the preset initial image recognition model is trained using these data. The preset initial image recognition model is a pre-designed image recognition model framework, which can be YOLOv8-OBB, because YOLOv8-OBB already has certain image recognition capabilities and is particularly suitable for processing OBB labeled data. The preset initial image recognition model can learn how to extract useful features from images, and classify and locate these features, thereby achieving accurate recognition of building defect features, and finally obtaining a target recognition model. The target recognition model can quickly and accurately detect building defect features in images in practical applications, and provide strong support for construction quality inspection.
[0035] It is understandable that due to the diversity and complexity of building defect features, traditional image recognition models often find it difficult to accurately detect and classify these defects, resulting in high missed detection and false detection rates. Therefore, step S02 is performed to train the preset initial image recognition model based on the original image sample set annotated by OBB, and to construct a target recognition model that can accurately identify and classify building defect features. This model can make full use of the precise feature data provided by OBB annotations to achieve efficient detection and classification of irregular building defect features, which not only improves the detection accuracy, but also significantly shortens the detection time and reduces missed detection and false detection rates.
[0036] In a feasible implementation manner, in step S02, the step of training a preset initial image recognition model based on the original image sample set includes steps A01 to A05: Step A01, performing feature enhancement on original image samples in an original image sample set to obtain an enhanced image sample set; It should be noted that feature enhancement techniques may 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 enhancement 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.
[0037] Step A02: for any enhanced image sample in the enhanced image sample set, input the enhanced image sample into a preset initial image recognition model to obtain a sample recognition result of the enhanced image sample; It should be noted that the images in the enhanced image sample set are input one by one into the preset initial image recognition model. The preset initial image recognition model is a neural network that has been designed but not fully trained. It has preliminary image recognition capabilities. The model will process the input image and output corresponding sample recognition results. These results include key information such as the location, size, and type of building defect features.
[0038] Step A03, 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; It should be noted that the difference between the sample recognition results and the actual building defect features in the enhanced image samples is measured by calculating the loss function (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 results of the model and the actual situation, and is an important basis for subsequent training and adjustment of the model.
[0039] Step A04, based on the predicted loss value, using a gradient back propagation algorithm to adjust the model parameters of the preset initial image recognition model; It should be noted that based on the predicted loss value, the gradient back propagation algorithm is used to adjust the model parameters of the preset initial image recognition model. The gradient back propagation algorithm calculates the gradient of the loss function with respect to the model parameters and updates the parameter values in 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 characteristics of building defects.
[0040] Step A05, after the preset initial image recognition model reaches the preset training condition, the target recognition model is obtained.
[0041] It should be noted that when the preset initial image recognition model reaches the preset training conditions (it can be a sufficient number of iterative training, or the predicted loss value is reduced to below the preset threshold), the judgment model has fully learned the building defect characteristics and uses it as the target recognition model. At this time, the target recognition model already has a high recognition accuracy and generalization ability, and can be applied to actual construction quality inspection.
[0042] In this embodiment, through feature enhancement technology, key features in the image can be highlighted, making the building defect features more clearly visible, which not only improves the image quality, but also provides higher quality data support for model training. By inputting enhanced image samples and obtaining recognition results, the recognition performance and existing problems of the model can be preliminarily 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. Through the gradient back propagation algorithm, the network parameters can be automatically adjusted so that the model better fits the features in the enhanced image samples, thereby improving the recognition accuracy. By presetting the training conditions, it can be ensured that the model maintains a good generalization ability while fully learning the features, so that the model can be applied to defect inspection tasks in different construction scenarios, thereby improving the efficiency and accuracy of quality inspection.
[0043] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 In step A01, the step of performing feature enhancement on the original image samples in the original image sample set includes steps S11 to S14: Step S11, extracting defect edges of building defect features to obtain edge point coordinate distribution of the defect edges; It should be noted that image processing technology (such as edge detection algorithm) is used to identify the defect edges of building defect features in the image. The edge detection algorithm can identify the places in the image where the brightness or color changes most dramatically. These places usually correspond to the boundaries or defects of the object. In the original image sample, the defect edge is the boundary between defects such as cracks and breakages and the surrounding normal area. The edge detection algorithm is used to extract the defect edge and record the coordinate information of each point on these edges to form the coordinate distribution of the edge points. These coordinate points constitute a discrete representation of the defect edge and provide basic data for subsequent steps.
[0044] Step S12, determining the distribution direction of the building defect feature according to the edge point coordinate distribution, wherein the distribution direction represents the optimal tilt angle of the directed rotation frame; It should be noted that by analyzing the coordinate distribution of 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, which represents the optimal tilt angle of the directed rotation frame, 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 subsequent adjustments to the directed rotation frame to ensure that the rotation frame can accurately cover the defect area.
[0045] For example, if the building defect feature is a concrete crack, if the crack mainly extends in the horizontal direction, then the distribution direction is the horizontal direction, and the optimal inclination angle is 0 degrees (or a multiple of 360 degrees); if the crack is inclined, then the optimal inclination angle is a certain angle that matches the crack direction.
[0046] Step S13, adjusting the directed rotation frame based on the distribution direction to obtain a target rotation frame, wherein the coverage rate of the target rotation frame on the edge point coordinate distribution reaches a preset threshold; It should be noted that the position, size and tilt angle of the directed rotating frame are adjusted according to the distribution direction, and the coverage rate of the directed rotating frame on the edge point coordinate distribution is continuously calculated, that is, the ratio of the number of edge points contained in the rotating frame to the total number of edge points. When this ratio reaches a preset threshold (for example, 95%), the adjustment is stopped, the target rotating frame is generated, and it is considered that the target rotating frame at this time can cover the corresponding area of the building defect features.
[0047] Step S14, cropping the portion of the original image sample except the target rotation frame, and taking the area surrounded by the target rotation frame as the enhanced image sample.
[0048] It should be noted that the part of the original image sample except the target rotation box is cropped, and only the area surrounded by the rotation box is retained. 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 and highlight the defect features, thereby improving the recognition accuracy of the model.
[0049] In this implementation, 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, and an accurate data basis is provided for subsequent steps. By performing statistical analysis on the edge point coordinate distribution, the main distribution direction of the building defect features is determined, providing guidance for subsequent directed rotation frame adjustment, ensuring that the rotation frame can accurately cover the defect area and improving the recognition accuracy. By adjusting the position, size and tilt angle of the directed rotation frame, ensuring that the coverage rate of the edge point coordinate distribution by the rotation frame reaches a preset threshold, irrelevant information in the image is effectively removed, while retaining the complete defect features, providing high-quality data for subsequent model training. By cropping the original image sample except the target rotation frame, an enhanced image sample containing only defect features can be obtained. These samples provide clear and accurate data support for subsequent model training, which helps to improve the recognition accuracy and generalization ability of the model.
[0050] In a feasible implementation manner, in step S11, the step of extracting the defect edge of the defect feature and obtaining the coordinate distribution of the edge points of the defect edge includes steps B01 to B04: Step B01, performing frequency domain decomposition on the target content selected by the directional rotating box in the original image sample through filters of various preset scales, and extracting the frequency domain response of the target content in various preset directions and various preset wavelengths, wherein the filters of various preset scales cover various preset directions and various preset wavelengths; It should be noted that a set of filters of preset scales are used to perform frequency domain decomposition on the target content selected by the directional rotating box in the original image sample. The target content includes images of building defect features. These filters cover different directions (i.e., preset directions) and wavelengths (i.e., preset wavelengths), and can capture detailed information of different scales and directions in the image, and are used to extract 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 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 direction and wavelength combination. For example: preset scale 1: direction 0°, wavelength 3px, preset scale 2: direction 30°, wavelength 6px, preset scale 3: direction 60°, wavelength 12px, etc.
[0051] Exemplarily, for an original image sample containing a variety of 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).
[0052] In addition, it should be noted that frequency domain decomposition refers to the process of converting the original image samples 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, thereby extracting 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, which indicates the energy distribution of the target content in different frequencies and directions.
[0053] Step B02, calculating the phase consistency value of each pixel in the target content based on the frequency domain response, and marking the pixel whose phase consistency value is higher than a preset phase consistency threshold as a valid edge point; It should be noted that the phase consistency value of each pixel in the target content is calculated based on the frequency domain response. Phase consistency is an indicator to measure the stability of local image features. It is used to quantify the degree of phase alignment at different frequencies and directions in the local area of the image, and can highlight the edge and texture information in the image. In edge detection, pixels with high phase consistency values often correspond to edges or texture features in the image. By comparing the phase consistency value with a preset phase consistency threshold (for example, 0.8), pixels above the threshold are marked as valid edge points. These valid edge points constitute the edge features in the image, providing a basis for subsequent edge connection and contour extraction.
[0054] In addition, it should be noted that for the preset phase consistency threshold, the threshold can also be set proportionally according to the maximum phase consistency value in the original image sample, which is suitable for scenes with uniform illumination, such as ,in, is the preset phase consistency threshold, is the empirical coefficient, usually taken as 0.4. is the maximum phase consistency value.
[0055] Step B03, performing a morphological closing operation on the valid edge points to connect the valid edge points as a continuous contour line to obtain a connected edge area; It should be noted that the morphological closing operation is performed on the pixel points marked as valid edge points. Morphological closing operation is an image processing technology. Through the operation of first dilation and then erosion, it can fill the small gaps between edge points and connect the broken edges. The closing operation helps to generate continuous contour lines and improve the accuracy of edge detection. Through the morphological closing operation, a connected edge area composed of valid edge points is obtained, which characterizes the edge features in the image.
[0056] Step B04, converting the connected edge area into a coordinate set to obtain the edge point coordinate distribution, wherein the edge point coordinate distribution represents the geometric outline of the building defect feature.
[0057] It should be noted that each edge point in the connected edge area is converted into coordinate form, and a set containing all edge point coordinates is generated to describe the geometric outline of the edge features in the image. This coordinate set is the edge point coordinate distribution. The edge point coordinate distribution reflects the shape, size, position and other information of the edge features in the image, which can be used for subsequent analysis, processing and visualization.
[0058] In this embodiment, the original image samples are decomposed in the frequency domain by filters of preset scales, so that the frequency domain responses of the image at different scales and directions can be extracted, noise can be effectively suppressed, and the edge and texture information in the image can be highlighted. At the same time, since the filter covers each preset direction and each preset wavelength, it can capture the possible multi-angle extension characteristics and detail information of the building defect features, 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, and the pixel points with phase consistency values higher than the preset phase consistency threshold are marked as valid edge points. The edge features in the image can be accurately identified, providing a more accurate basis for subsequent edge connection and contour extraction. By performing morphological closing operations on the valid edge points, the problems of breakage and incorrect connection in the edge connection are effectively solved, and a more accurate and complete connected edge area is obtained.
[0059] In a feasible implementation manner, in step S12, the step of determining the distribution direction of the building defect feature according to the edge point coordinate distribution includes steps B11 to B14: Step B11, determining the edge point weight of each edge point coordinate in the edge point coordinate distribution; It should be noted that an edge point weight is assigned to each edge point. This weight reflects the importance of the edge point in describing the characteristics of building defects. The weight can be determined based on a variety of factors, such as the gradient intensity, phase consistency value, local contrast, etc. of the edge point. The larger the weight value, the more important the edge point is in describing the defect characteristics.
[0060] Step B12, calculating the weighted mean center coordinates of the edge point coordinate distribution based on the edge point coordinates and the corresponding edge point weights; It should be noted that after determining the edge point weights, the weighted mean center coordinates are calculated. This coordinate is the "center of gravity" of the edge point coordinate distribution. Taking into account the position and weight of each edge point, the calculation formula for the weighted mean center coordinates is:
[0061] in, is the weighted mean center horizontal coordinate, is the weighted mean center ordinate, For the The weight of an edge point reflects the importance of the point in the defect feature. For the The horizontal coordinates of the edge points, For the The ordinate of the edge point, It is the sum of all weights and is used to normalize the weighted mean to ensure that the calculation result is not affected by the magnitude of the absolute value of the weight.
[0062] Step B13, constructing a covariance matrix of 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 coordinates; It should be noted that the covariance matrix is used to describe the linear relationship between variables, and is used to describe the deviation and correlation between the edge point coordinates and the weighted mean center coordinates. The construction formula of the covariance matrix is:
[0063] in, represents the covariance matrix, as well as It is the deviation between the edge point coordinates and the weighted mean center coordinates, indicating the position offset of the point relative to the center of mass.
[0064] Step B14, determining the vector direction corresponding to the maximum eigenvalue of the covariance matrix, where the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect characteristics.
[0065] It should be noted that after constructing the covariance matrix, its maximum eigenvalue is calculated. The vector direction corresponding to the maximum eigenvalue is the main direction of the edge point coordinate distribution and the direction in which the building defect characteristics are most significant.
[0066] In this implementation, by assigning weights to each edge point, the importance of different edge points in describing building defect characteristics 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 central coordinates, the center position of the defect feature can be more realistically reflected, providing a reliable basis for subsequent analysis. At the same time, the calculation of the weighted mean central coordinates also helps to reduce errors caused by uneven distribution of edge points or noise interference. By constructing a covariance matrix, the directional information of the edge point coordinate distribution can be captured. The elements in the covariance matrix reflect the discreteness and correlation of the edge point coordinates in various directions. By analyzing the eigenvalues and eigenvectors of the covariance matrix, the extension direction of the defect feature can be accurately determined. By determining the vector direction corresponding to the maximum eigenvalue of the covariance matrix, the distribution direction of the defect feature can be objectively determined. This direction reflects the main trend and form of the edge point coordinate distribution, which is of great significance for subsequent analysis and processing.
[0067] In a feasible implementation manner, in step B11, the step of determining the edge point weight of each edge point coordinate in the edge point coordinate distribution includes steps B21 to B24: Step B21, for any edge point coordinate in the edge point coordinate distribution, calculating the gradient amplitude of the edge point coordinate; It should be noted that the horizontal gradient of each edge point coordinate is calculated by the Sobel operator (3×3 convolution kernel) and vertical gradient , horizontal gradient and vertical gradient The calculation formula is:
[0068]
[0069]
[0070]
[0071] in, Indicates that the image is at position The pixel value of a grayscale image is is an integer value between 0 (black) and 255 (white). represents the edge point coordinates, is the horizontal gradient convolution kernel, is the vertical gradient convolution kernel, Indicates the vertical offset of the convolution kernel, with a value range of −1, 0, 1, Indicates the horizontal offset of the convolution kernel, the value range is −1, 0, 1, and is to map the offset to the index of the convolution kernel, because 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.
[0072] Through the horizontal gradient and vertical gradient The gradient magnitude of the edge point coordinates can be calculated , the calculation formula is:
[0073] 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.
[0074] 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; 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:
[0075] 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.
[0076] 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; 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:
[0077] 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.
[0078] The maximum curvature in determining the coordinates of each edge point Then, calculate the bending weight of the edge point coordinates , the calculation formula is:
[0079] 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.
[0080] Step B24, obtaining edge point weights of edge point coordinates based on the clarity weight and the curvature weight.
[0081] It should be noted that after obtaining the clarity weight and the bending weight, the edge point weight of the edge point coordinates is calculated. , the calculation formula is:
[0082] In this embodiment, by calculating the gradient amplitude of each edge point, the rate of change of the image at the point is accurately measured, so that those edge points with significant image changes are identified. 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 a higher weight to edge points with high clarity, the real defect edge 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 bending weight according to the ratio of the curvature to the maximum curvature, the degree of bending of the edge point is accurately measured, which helps to more accurately capture the complex morphology and degree of bending of the defect. At the same time, by assigning a higher weight to edge points with a large degree of bending, 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 bending weight, the clarity and degree of bending of the edge point are comprehensively considered, and a reasonable weight is assigned to each edge point, which helps to more accurately describe the distribution and morphology of the defect. At the same time, by assigning a higher degree of attention to edge points with high weights, building defects can be more effectively identified and processed, and the accuracy and efficiency of building construction quality inspection can be improved.
[0083] In a feasible implementation manner, in step S13, the step of adjusting the directed rotation frame based on the distribution direction includes steps B31-B32: Step B31, record the intersection line of the weighted mean center coordinate and the distribution direction as the horizontal reference axis, and record the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis as the vertical reference axis; It should be noted that the intersection of the weighted mean center coordinate and the distribution direction is recorded as the horizontal reference axis, which represents the main direction of defect extension. The intersection with the weighted mean center coordinate and perpendicular to the horizontal reference axis is recorded as the vertical reference axis. This axis is perpendicular to the horizontal reference axis and together constitutes the reference coordinate system of the directed rotation frame. The horizontal reference axis represents the main direction of defect extension and is an important reference when constructing a directed rotation frame. It determines the rotation angle of the frame so that it can fit the shape of the defect closely. The vertical reference axis is perpendicular to the horizontal reference axis and together constitutes the reference coordinate system of the directed rotation frame, which is used to determine the width of the frame, that is, the dimension perpendicular to the defect extension direction.
[0084] Step B32, 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, and the horizontal length and the vertical length represent the length and width of the directed rotation frame respectively.
[0085] It should be noted that based on the horizontal reference axis, a certain length is extended to both sides perpendicular to the horizontal reference axis. This length represents the length of the directional rotation frame, which must meet the requirement of covering the entire range of building defect features in the main extension direction. At the same time, based on the vertical reference axis, a certain length is extended to both sides perpendicular to the vertical reference axis. This length represents the width of the directional rotation frame, which must meet the requirement of covering the entire range of defects in the direction perpendicular to the main extension direction.
[0086] For example, to help understand the technical concept or technical principle of this application, please refer to Figure 3 , Figure 3 A schematic diagram of the scene of the directed rotating box adjustment is provided, wherein o is the weighted mean center coordinate, a is the distribution direction, the x-axis corresponds to the horizontal reference axis, and the y-axis corresponds to the vertical reference axis. For the horizontal reference axis x, when adjusting, the horizontal length is extended to both sides from the weighted mean center coordinate o in the direction of x1 and x2. For the vertical reference axis y, when adjusting, the vertical length is extended to both sides from the weighted mean center coordinate o in the direction of y1 and y2, and finally the directed rotating box C is obtained.
[0087] In this implementation, the horizontal reference axis is determined by calculating the intersection of the weighted mean center coordinates and the distribution direction, and then the vertical reference axis perpendicular to it is determined, thereby realizing adaptive adjustment of the marking frame direction so that it can closely fit the actual extension direction of the defect, which not only improves the matching degree between the marking frame and the defect morphology, but also reduces misjudgment and omission caused by direction mismatch. By adaptively adjusting the size of the marking frame, it is ensured that the marking frame can closely cover the key parts of the defect, while avoiding interference from unnecessary background information, which helps to solve the problem of poor building defect inspection effect caused by mismatch of marking frame size in construction quality inspection, and improves the accuracy and efficiency of defect identification.
[0088] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the model building method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0089] This application also provides a model building system, please refer to Figure 4 , the model building system comprises: The data receiving module 10 is used to receive a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by the directed rotation box; The model training module 20 is used to train a preset initial image recognition model based on the original image sample set to construct a target recognition model for identifying building defect features.
[0090] Optionally, the model training module 20 is further used to: Performing feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set; For any enhanced image sample in the enhanced image sample set, input the enhanced image sample into a preset initial image recognition model to obtain a sample recognition result of the enhanced image sample; 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; Based on the predicted loss value, the gradient back propagation algorithm is used to adjust the model parameters of the preset initial image recognition model; After the preset initial image recognition model reaches the preset training conditions, the target recognition model is obtained.
[0091] Optionally, the model training module 20 is further used to: Extract the defect edge of the building defect feature and obtain the edge point coordinate distribution of the defect edge; Determine the distribution direction of the building defect feature according to the edge point coordinate distribution, wherein the distribution direction represents the optimal tilt angle of the directed rotation frame; The directed rotation frame is adjusted based on the distribution direction to obtain a target rotation frame, and the coverage rate of the target rotation frame on the edge point coordinate distribution reaches a preset threshold; The part of the original image sample except the target rotation box is cropped, and the area surrounded by the target rotation box is used as the enhanced image sample.
[0092] Optionally, the model training module 20 is further used to: Performing frequency domain decomposition on the target content selected by the directional rotating box in the original image sample through filters of each preset scale, and extracting the frequency domain response of the target content in each preset direction and each preset wavelength, wherein the filters of each preset scale cover each preset direction and each preset wavelength; Calculate the phase consistency value of each pixel in the target content based on the frequency domain response, and mark the pixel points whose phase consistency value is higher than a preset phase consistency threshold as valid edge points; Perform morphological closing operation on valid edge points to connect the valid edge points as continuous contour lines to obtain connected edge areas; The connected edge area is converted into a coordinate set to obtain the edge point coordinate distribution, wherein the edge point coordinate distribution represents the geometric outline of the building defect characteristics.
[0093] Optionally, the model training module 20 is further used to: Determine the edge point weight of each edge point coordinate in the edge point coordinate distribution; Calculate the weighted mean center coordinates of the edge point coordinate distribution based on the edge point coordinates and the corresponding edge point weights; Constructing a covariance matrix of 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 coordinates; The vector direction corresponding to the maximum eigenvalue of the covariance matrix is determined, and the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect characteristics.
[0094] Optionally, the model training module 20 is further used to: For any edge point coordinate in the edge point coordinate distribution, calculate the gradient amplitude of the edge point coordinate; The ratio of the gradient amplitude to the maximum gradient amplitude in each edge point coordinate is used as the clarity weight of the edge point coordinate; Determine the curvature of the edge point coordinates, and determine the bending weight of the edge point coordinates according to the curvature and the maximum curvature among the edge point coordinates; The edge point weights of the edge point coordinates are obtained based on the clarity weight and the curvature weight.
[0095] Optionally, the model training module 20 is further used to: The intersection line of the weighted mean center coordinate and the distribution direction is recorded as the horizontal reference axis, and the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis is recorded as the vertical reference axis; 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 represent the length and width of the directed rotation frame respectively.
[0096] The model building device provided by the present application adopts the model building method in the above embodiment, which can solve the technical problem of poor building defect inspection effect. Compared with the prior art, the beneficial effects of the model building device provided by the present application are the same as the beneficial effects of the model building method provided by the above embodiment, and other technical features in the model building device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0097] The present 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 building method in the above-mentioned embodiment one.
[0098] Reference below Figure 5 , which shows a schematic diagram of the structure of an electronic device suitable for implementing an embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, notebook computers, PADs (Portable Application Description: tablet computers), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0099] like Figure 5 As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which may perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 to a 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 via a bus 1005. An 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 touch pad, 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 by wire to exchange data. Although the electronic device with various systems is shown in the figure, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have instead.
[0100] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. 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 includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a read-only memory 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0101] The electronic device provided by the present application adopts the model building method in the above embodiment to 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 the beneficial effects of the model building method provided by the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0102] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0103] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0104] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the model building method in the above-mentioned embodiment.
[0105] The computer-readable storage medium provided in 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 computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0106] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0107] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by an electronic device, the model building device: receives a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; and trains a preset initial image recognition model based on the original image sample set to build a target recognition model for identifying building defect features.
[0108] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate 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 may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0109] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0110] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0111] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned model building 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 the present application are the same as the beneficial effects of the model building method provided in the above-mentioned embodiment, and will not be repeated here.
[0112] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned model building method when executed by a processor.
[0113] The computer program product provided by this application can solve the technical problem of poor building defect inspection results. Compared with the prior art, the beneficial effects of the computer program product provided by this application are the same as the beneficial effects of the model building method provided by the above embodiment, which will not be repeated here.
[0114] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A model building method, characterized in that: The model building method comprises: Receiving a labeled original image sample set, wherein the building defect features of the original image samples in the original image sample set are selected by a directed rotation box; A preset initial image recognition model is trained based on the original image sample set to construct a target recognition model for recognizing building defect features.
2. The model building method according to claim 1, characterized in that: The step of training a preset initial image recognition model based on the original image sample set comprises: Performing feature enhancement on the original image samples in the original image sample set to obtain an enhanced image sample set; For any one 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; Calculating a prediction loss value of the preset initial image recognition model according to a difference between the sample recognition result and the enhanced image sample; Based on the predicted loss value, a gradient back propagation algorithm is used to adjust the model parameters of the preset initial image recognition model; After the preset initial image recognition model reaches the preset training condition, the target recognition model is obtained.
3. The model building method according to claim 2, characterized in that: The step of performing feature enhancement on the original image samples in the original image sample set comprises: Extracting defect edges of the building defect features to obtain edge point coordinate distribution of the defect edges; Determining a distribution direction of the building defect feature according to the edge point coordinate distribution, wherein the distribution direction represents an optimal tilt angle of the directed rotation frame; Adjusting the directed rotation frame based on the distribution direction to obtain a target rotation frame, wherein the coverage rate of the target rotation frame on the edge point coordinate distribution reaches a preset threshold; The portion of the original image sample other than the target rotation frame is cropped, and the area surrounded by the target rotation frame is used as the enhanced image sample.
4. The model building method according to claim 3, characterized in that: The step of extracting the defect edge of the defect feature and obtaining the coordinate distribution of the edge points of the defect edge comprises: Performing frequency domain decomposition on the target content selected by the directional rotation box in the original image sample through filters of each preset scale, and extracting the frequency domain response of the target content in each preset direction and each preset wavelength, wherein the filters of each preset scale cover each preset direction and each preset wavelength; Calculating a phase consistency value of each pixel in the target content based on the frequency domain response, and marking a pixel whose phase consistency value is higher than a preset phase consistency threshold as a valid edge point; Performing a morphological closing operation on the valid edge points to connect the valid edge points into a continuous contour line to obtain a connected edge region; The connected edge region is converted into a coordinate set to obtain an edge point coordinate distribution, wherein the edge point coordinate distribution represents a geometric outline of the building defect feature.
5. The model building method according to claim 3, characterized in that: The step of determining the distribution direction of the building defect feature according to the edge point coordinate distribution comprises: Determine an edge point weight of each edge point coordinate in the edge point coordinate distribution; Calculating the weighted mean center coordinates 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 coordinates; The vector direction corresponding to the maximum eigenvalue of the covariance matrix is determined, and the vector direction corresponding to the maximum eigenvalue represents the distribution direction of the building defect feature.
6. The model building method according to claim 5, characterized in that: The step of determining the edge point weight of each edge point coordinate in the edge point coordinate distribution comprises: For any edge point coordinate in the edge point coordinate distribution, calculating the gradient amplitude of the edge point coordinate; The ratio of the gradient amplitude to the maximum gradient amplitude in each edge point coordinate is used as the clarity weight of the edge point coordinate; Determine the curvature of the edge point coordinates, and determine the bending weight of the edge point coordinates according to the curvature and the maximum curvature among the edge point coordinates; The edge point weight of the edge point coordinate is obtained based on the clarity weight and the bending weight.
7. The model building method according to claim 5, characterized in that: The step of adjusting the directed rotation frame based on the distribution direction comprises: The intersection line of the weighted mean center coordinate and the distribution direction is recorded as the horizontal reference axis, and the intersection line that intersects the weighted mean center coordinate and is perpendicular to the horizontal reference axis is recorded as the vertical reference axis; The horizontal length is extended on both sides perpendicular to the horizontal reference axis based on the horizontal reference axis, and the vertical length is extended on both sides perpendicular to the vertical reference axis based on the vertical reference axis. The horizontal length and the vertical length respectively represent the length and width of the directed rotation frame.
8. An electronic device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the model building method according to any one of claims 1 to 7.
9. 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, the steps of the model building method according to any one of claims 1 to 7 are implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the model building method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Detecting and error-correcting method capable of rapidly and accurately obtaining element center and deflection angle
CN104981105A
Mobile phone cover plate glass defect detection method based on machine vision
CN112630222A
Power transmission line defect identification method and device, electronic equipment and storage medium
CN116342607A
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