A method for predicting soil compaction quality based on image recognition
By using image recognition and an improved CNN neural network model, non-contact, efficient, and accurate detection of sand compaction quality is achieved, solving the problems of low detection efficiency and insufficient accuracy in existing technologies. It is suitable for large-area and continuous compaction quality detection in civil engineering.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHENGZHOU UNIV
- Filing Date
- 2026-04-29
- Publication Date
- 2026-06-23
AI Technical Summary
Existing methods for testing soil compaction quality suffer from problems such as cumbersome operation, low efficiency, destructiveness, and insufficient accuracy, making it difficult to achieve efficient testing over large areas and continuously.
By combining image recognition technology with an improved CNN neural network model, a sand compaction quality prediction model is constructed by collecting compaction images of the soil surface for preprocessing and model training. The pre-trained model is then fine-tuned to achieve non-contact, high-precision compaction degree prediction.
It improves detection efficiency and accuracy, reduces damage to the soil, enhances the model's adaptability and generalization ability, and meets the rapid detection needs of modern engineering.
Smart Images

Figure CN122265267A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of soil compaction prediction technology, specifically relating to a method for predicting soil compaction quality based on image recognition. Background Technology
[0002] In civil engineering construction such as roads, bridges, and dams, soil compaction quality is one of the key factors determining the stability, bearing capacity, and durability of the engineering structure. Sand, in particular, is widely used as backfill material and foundation pad material, and its compaction degree directly affects the construction quality and service life of the project. If the compaction quality of sand is substandard, it can easily lead to engineering defects such as roadbed settlement, pavement cracking, and dam seepage, causing huge economic losses and safety hazards.
[0003] Currently, methods for testing soil compaction quality are mainly divided into traditional testing methods and non-destructive testing methods. Traditional testing methods, such as the ring cutter method, sand cone method, and nuclear density meter method, have high testing accuracy, but they also have disadvantages such as cumbersome operation, time and labor consumption, low testing efficiency, and damage to the soil. Furthermore, they are difficult to achieve large-area, continuous, real-time testing, and cannot meet the needs of efficient construction in modern engineering projects.
[0004] Non-destructive testing methods, such as ultrasonic and radar methods, have solved the destructive problem of traditional methods, but their application is limited by drawbacks such as high equipment costs, susceptibility of test results to environmental factors, and high requirements for the professional skills of testing personnel. With the rapid development of image recognition and artificial intelligence technologies, their application to soil compaction quality testing has become a new research direction. This can achieve non-contact, rapid, and large-area testing. However, existing image recognition-based prediction methods suffer from poor preprocessing effects, weak model generalization ability, and insufficient prediction accuracy, making it difficult to accurately reflect the compaction quality of sand under different compaction conditions.
[0005] Therefore, developing an image recognition-based method for predicting soil compaction quality that is easy to operate, efficient in detection, highly accurate in prediction, and highly adaptable is of great engineering application value and practical significance in addressing the shortcomings of existing technologies. Summary of the Invention
[0006] To address the problems of cumbersome operation, low efficiency, destructive nature, and insufficient accuracy in existing soil compaction quality testing methods, this invention provides a method for predicting soil compaction quality based on image recognition. By combining image recognition technology with an improved CNN neural network model, it achieves rapid, non-contact, and high-precision prediction of sand compaction quality, thereby improving the efficiency and reliability of engineering construction quality testing.
[0007] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:
[0008] A method for predicting soil compaction quantity based on image recognition, characterized by comprising the following steps:
[0009] S10. Collect data on soil compaction degree and images of soil surface compaction under different conditions;
[0010] S20. Preprocess the collected images, including image normalization, grayscale conversion and binarization, and construct a dataset;
[0011] S30. Construct an improved CNN neural network model based on the preprocessed dataset;
[0012] S40. Import the dataset into the improved CNN neural network model for pre-training to obtain the pre-trained model;
[0013] S50. Import the collected images into the pre-trained model, freeze and fine-tune the pre-trained model to obtain a prediction model for the compaction mass of sand.
[0014] S60. After preprocessing, import the image of the compacted surface of the sand to be tested into the prediction model, output the predicted compaction value, and judge whether the compaction quality meets the standard according to the engineering design standard.
[0015] Furthermore, the specific steps of step S10 are as follows:
[0016] S101. Different conditions, including compaction machinery type, number of compaction passes, compaction speed, sand moisture content and gradation, are used to collect standard compaction data under different conditions using the ring cutter method.
[0017] When shooting with an S102 high-definition camera, keep the lens perpendicular to the sand surface, the shooting distance is 50-80cm, the image resolution is set to 1920×1080 pixels, the shooting environment is artificial light source, and the compaction data is marked one by one with the image.
[0018] Furthermore, the specific steps of step S20 are as follows:
[0019] S201. Perform size normalization processing on all acquired raw images, uniformly scaling the images to 224×224 pixels. At the same time, use the min-max normalization method to normalize the image pixel values to the [0,1] range, eliminating the interference caused by differences in image size and pixel value range. The formula is as follows:
[0020]
[0021] in, Here, x represents the normalized pixel value, and x represents the original pixel value. The maximum pixel value in the original image. The minimum pixel value in the original image;
[0022] S202. Convert the normalized color image to a grayscale image, and calculate the grayscale value using a weighted average method. This preserves the texture features and structural information of the sand surface in the image, while reducing the number of image channels and decreasing the computational cost of subsequent model training. The formula is as follows:
[0023] G = 0.299R + 0.587G + 0.114B
[0024] Where G is the pixel value of the grayscale image, and R, G, and B are the pixel values of the red, green, and blue channels of the original color image, respectively.
[0025] S203. Binarize the grayscale image by using an adaptive thresholding method to determine the binarization threshold, converting the grayscale image into a black and white binary image to highlight key features such as pores and particle boundaries on the sand surface and suppress background noise interference.
[0026] Furthermore, in step S30, an improved convolutional neural network (CNN) is used, which is optimized based on the RepVGG model. This neural network model includes an input layer, a RepVGG convolutional module layer, a pooling layer, a fully connected layer, and an output layer.
[0027] Input layer: Receives a pre-processed 224×224 pixel binary image with 1 input channel;
[0028] RepVGG Convolutional Module Layers: Five RepVGG convolutional modules are set up. Each module contains three parallel branches during training (3×3 convolutional branch, 1×1 convolutional branch, and identity mapping branch). During inference, they are merged into a single 3×3 convolutional layer through structural reparameterization. The first and second RepVGG convolutional modules each contain two merged 3×3 convolutional layers, and the third to fifth modules each contain three merged 3×3 convolutional layers. All convolutional kernels are 3×3, with a stride of 1. Zero padding is used to ensure that the size of the convolutional feature map is consistent with the input feature map size. Each convolutional layer is followed by a batch normalization (BN) layer to accelerate model training convergence and reduce gradient vanishing. The ReLU activation function is also used to enhance the model's non-linear fitting ability. The ReLU activation function formula is as follows:
[0029] f(x) = max(0,x)
[0030] Pooling layer: Each RepVGG convolutional module is followed by a max pooling layer with a 2×2 kernel size and a pooling stride of 2. This layer is used to reduce the dimensionality of the features extracted by the convolutional layer, retain key feature information, reduce the number of model parameters and computational cost, and prevent model overfitting.
[0031] Fully connected layers: Two fully connected layers are set. The first fully connected layer has 1024 neurons, and the second fully connected layer has 256 neurons. Each fully connected layer is followed by a Dropout layer with a Dropout probability of 0.5, which randomly drops some neurons to further prevent the model from overfitting. The ReLU activation function is used after the second fully connected layer.
[0032] Output layer: A linear activation function is used, with an output dimension of 1, corresponding to the predicted compaction degree of sand, ensuring that the predicted value can be continuously distributed and conforms to the actual physical meaning of compaction degree.
[0033] Furthermore, the specific steps of step S40 are as follows:
[0034] S401. In the pre-trained model, the dataset is divided into training set, validation set and test set according to 7:2:1. The pre-processed binary image is input and the compaction is output.
[0035] S402. The improved CNN neural network model is trained using the training set. During the training process, the batch size is set to 32, that is, the number of training samples is 32 each time. The loss function is minimized, the initial learning rate is set to 0.01, and the total number of iterations in the training process is 2400.
[0036] S403. When the loss value of the validation set no longer decreases for 5 consecutive epochs and the loss value of the training set tends to stabilize, stop pre-training, save the model parameters and obtain the pre-trained model.
[0037] Furthermore, the specific steps of step S50 are as follows:
[0038] S501. Select the compacted sand surface images collected in S10 that were not included in the pre-training (after preprocessing in S20) to fine-tune the pre-training model;
[0039] S502: Freeze the convolutional and pooling layers of the improved CNN neural network model, and train only the fully connected and regression layers;
[0040] S503. Retain some parameters of the pre-trained model and obtain a prediction model for the compaction degree of sand by fine-tuning.
[0041] Furthermore, in step S60, the compaction image of the sand surface to be tested is first preprocessed, then imported into the prediction model, and the predicted compaction value is output. Finally, the compaction quality is judged in combination with the engineering design standards to determine whether the compaction quality meets the standards.
[0042] In a second aspect, the present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described above.
[0043] Thirdly, the present invention also provides an electronic terminal, comprising: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to cause the terminal to perform the method described above.
[0044] Compared with existing technologies, the image recognition-based method, medium, and terminal for predicting soil compaction quality provided by this invention have at least the following advantages:
[0045] Many traditional methods for detecting the compaction quality of sand (such as the ring sampler method and sand cone method) require destructive sampling of the soil, resulting in cumbersome and inefficient processes that cannot meet the rapid detection needs of large-area, continuous construction. Furthermore, traditional methods rely on manual operation, leading to high costs, large errors, and the inability to achieve non-contact detection. This invention provides an image recognition-based method for detecting the compaction quality of sand. By acquiring images of the compacted sand surface and combining image recognition with a neural network model, the method first performs three-level preprocessing on the images: normalization, grayscale conversion, and adaptive binarization. This effectively highlights key features of the sand surface and reduces noise interference. Then, an improved CNN convolutional neural network is used, trained through pre-training and fine-tuning, to accurately learn the correlation between image features and compaction degree, constructing a sand compaction quality prediction model. During pre-training, the first few layers of the improved CNN model learn general image features, thus eliminating the need to relearn basic information in the sand compaction degree prediction task. The number of layers frozen or fine-tuned depends on the similarity between the source data and the target scene. Unlike unlearned models with randomly initialized variables, pre-trained neural networks are tuned based on general image data. These pre-trained weights and biases provide a better starting point for sand compaction prediction models, resulting in faster training convergence and a lower risk of getting trapped in local optima, leading to higher prediction efficiency and accuracy. By pre-training, the dependence of the neural network model on sand compaction sample data is reduced, improving learning efficiency and enhancing the model's generalization ability. Attached Figure Description
[0046] To more clearly illustrate the solution of the present invention, a brief introduction will be given to the drawings used in the description of the embodiments below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0047] Figure 1 A flowchart illustrating a method for predicting soil compaction quantity based on image recognition, provided as an embodiment of the present invention;
[0048] Figure 2The diagram shows the improved CNN neural network structure used in the image recognition-based method for predicting soil compaction quality provided in this embodiment of the invention. Detailed Implementation
[0049] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Preferred embodiments of the invention are shown in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to provide a thorough and complete understanding of the disclosure of the invention.
[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.
[0051] This invention provides a method for predicting soil compaction quality based on image recognition, applied to the prediction of sand compaction quality. The method for predicting soil compaction quality based on image recognition includes the following steps:
[0052] S10. Collect data on soil compaction degree and images of soil surface compaction under different conditions; S20. Preprocess the collected images, including image normalization, grayscale conversion, and binarization, to construct a dataset; S30. Construct an improved CNN neural network model based on the preprocessed dataset; S40. Import the dataset into the improved CNN neural network model for pre-training to obtain a pre-trained model; S5. Import the collected images into the pre-trained model, freeze and fine-tune the pre-trained model to obtain a prediction model for soil compaction quality; S6. Import the preprocessed images of the soil surface compaction to be tested into the prediction model, output the predicted compaction degree value, and determine whether the compaction quality meets the standards according to the engineering design standards.
[0053] The present invention has a simple process and is easy to operate. The obtained prediction model has strong robustness and generalization ability, and has high efficiency and accuracy in predicting the compaction quality of sandy soil.
[0054] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.
[0055] This invention provides a method for predicting the compaction mass of soil based on image recognition, applied to the prediction of the compaction mass of sandy soil, combined with... Figures 1 to 2 In this embodiment, the method for predicting soil compaction quantity based on image recognition includes the following steps:
[0056] S10, Obtain data;
[0057] Specifically, the ring cutter method was used to collect standard compaction data of sand under different compaction machinery models, number of compaction passes, compaction speed, sand moisture content, and gradation conditions. At the same time, when taking pictures with a high-definition camera, the lens was kept perpendicular to the sand surface, the shooting distance was 50-80cm, the image resolution was set to 1920×1080 pixels, the shooting environment was artificial light source, and the compaction data were marked one by one with the pictures.
[0058] S20, Data Preprocessing;
[0059] Specifically, the acquired images are preprocessed, including normalization: all images are scaled to 224×224 pixels, and min-max normalization is used to convert pixel values to the [0,1] range; grayscale processing: grayscale values are calculated using a weighted average method to convert color images into grayscale images, preserving surface texture and pore features; binarization processing: an adaptive thresholding method is used to automatically determine the threshold based on the grayscale distribution of different regions of the image, converting grayscale images into binary images to highlight particle boundaries and pores.
[0060] S30. Construct an improved CNN neural network model;
[0061] Specifically, a convolutional neural network (CNN) is used, which is optimized based on the RepVGG model. The model structure from the input layer to the output layer includes: input layer, RepVGG convolutional module layer, pooling layer, fully connected layer and output layer.
[0062] Input layer: Receives a pre-processed 224×224 pixel binary image with 1 input channel;
[0063] RepVGG Convolutional Module Layers: Five RepVGG convolutional modules are set up. Each convolutional module contains three parallel branches during the training phase (3×3 convolutional branch, 1×1 convolutional branch, and identity mapping branch). During the inference phase, they are merged into a single 3×3 convolutional layer through structural reparameterization. The first and second RepVGG convolutional modules each contain two merged 3×3 convolutional layers, and the third to fifth groups each contain three merged 3×3 convolutional layers. All convolutional kernels are 3×3 in size, with a stride of 1. Zero padding is used to ensure that the size of the feature map after convolution is consistent with the size of the input feature map. Each convolutional layer is followed by a batch normalization (BN) layer to accelerate the model training convergence speed and reduce the gradient vanishing problem. At the same time, the ReLU activation function is used to enhance the nonlinear fitting ability of the model. The formula for the ReLU activation function is: f(x)=max(0,x).
[0064] Pooling layer: Each RepVGG convolutional module is followed by a max pooling layer with a 2×2 kernel size and a pooling stride of 2. This layer is used to reduce the dimensionality of the features extracted by the convolutional layer, retain key feature information, reduce the number of model parameters and computational cost, and prevent overfitting.
[0065] Fully connected layers: Two fully connected layers are set. The first fully connected layer has 1024 neurons, and the second fully connected layer has 256 neurons. Each fully connected layer is followed by a Dropout layer with a Dropout probability of 0.5, which randomly drops some neurons to further prevent the model from overfitting. The ReLU activation function is used after the second fully connected layer.
[0066] Output layer: A linear activation function is used, with an output dimension of 1, corresponding to the predicted compaction degree of sand, ensuring that the predicted value can be continuously distributed and conforms to the actual physical meaning of compaction degree.
[0067] S40. Import the data into the improved CNN neural network model for pre-training to obtain the pre-trained model.
[0068] Specifically, in the pre-trained model, the dataset is divided into training, validation, and test sets in a 7:2:1 ratio. Preprocessed binary images are input, and compaction is used as the output. During training, the batch size is set to 32, meaning 32 samples are used in each training iteration. The Adam optimization algorithm is employed to minimize the loss function, with an initial learning rate of 0.01 and a learning rate reduction factor. After 800 training iterations, the learning rate is 0.01 × 0.1. The entire training process involves 2400 iterations. The model is trained using the training set and its prediction performance is evaluated using the test set.
[0069] Furthermore, regarding model evaluation:
[0070] The model is evaluated using metrics such as RMSE (Root Mean Square Error), MAE (Mean Absolute Error), and R² (Coefficient of Determination). The model evaluation formula is as follows:
[0071]
[0072]
[0073]
[0074] in Indicates the number of samples. This represents the true value of the i-th sample. This represents the predicted value of the i-th sample. This represents the average value of the sample.
[0075] The trained model is used as a pre-trained model for predicting the compaction quantity of soil.
[0076] S50. Load the pre-trained model, import the test set into the pre-trained model, freeze the convolutional and pooling layers of the improved CNN model, and train only the fully connected and regression layers, retaining most of the parameters of the pre-trained model. This helps to retain the useful features learned by the model during the pre-training stage. Adjust hyperparameters such as the number of training epochs and batch size according to the size of the dataset. Through fine-tuning, obtain the prediction model for soil compaction quantity.
[0077] This invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the methods in this embodiment.
[0078] This invention also provides an electronic terminal, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the terminal performs any of the methods in this embodiment.
[0079] As will be understood by those skilled in the art, the computer-readable storage medium described in this embodiment allows for the implementation of all or part of the steps in the above method embodiments by computer program-related hardware. The aforementioned computer program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0080] Obviously, the embodiments described above are merely preferred embodiments of the present invention, and not all embodiments. The accompanying drawings illustrate preferred embodiments of the present invention, but do not limit the scope of the patent. The present invention can be implemented in many different forms; rather, these embodiments are provided to provide a more thorough and complete understanding of the disclosure of the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this invention.
Claims
1. A method for predicting the compaction quality of a soil mass based on image recognition, characterized in that, Includes the following steps: S10. Collect data on soil compaction degree and images of soil surface compaction under different conditions; S20. Preprocess the collected images, including image normalization, grayscale conversion and binarization, and construct a dataset; S30. Construct an improved CNN neural network model based on the preprocessed dataset; S40. Import the dataset into the improved CNN neural network model for pre-training to obtain the pre-trained model; S50. Import the collected images into the pre-trained model, freeze and fine-tune the pre-trained model to obtain a prediction model for the compaction mass of sand. S60. After preprocessing, import the image of the compacted surface of the sand to be tested into the prediction model, output the predicted compaction value, and judge whether the compaction quality meets the standard according to the engineering design standard.
2. The method for predicting soil compaction quantity based on image recognition according to claim 1, characterized in that, The conditions in step S10 include the compaction machinery model, number of compaction passes, compaction speed, sand moisture content and gradation (characterized by the non-uniformity coefficient Cu, curvature coefficient Cc and the proportion of particles in each particle size range). Standard compaction data under different conditions are collected using the ring cutter method, and compaction images of the corresponding sand surface are collected using a high-definition camera. The compaction data and images are then marked to correspond one-to-one.
3. The method for predicting soil compaction quantity based on image recognition according to claim 1, characterized in that, In step S10, when taking pictures with the high-definition camera, keep the lens perpendicular to the sand surface, the shooting distance is 50-80cm, the image resolution is set to 1920×1080 pixels, and the shooting environment is natural light or uniform artificial light source.
4. The method for predicting soil compaction quantity based on image recognition according to claim 1, characterized in that, The specific steps of step S20 are as follows: S201. Perform size normalization processing on all acquired raw images, uniformly scaling the images to 224×224 pixels, and at the same time using the min-max normalization method to normalize the image pixel values to the [0,1] range, eliminating the interference caused by differences in image size and pixel value range; S202. Convert the normalized color image to a grayscale image, and use a weighted average method to calculate the grayscale value. This preserves the texture features and structural information of the sand surface in the image, while reducing the number of channels in the image and reducing the computational load for subsequent model training. S203. An adaptive thresholding method is adopted to automatically determine the threshold based on the grayscale distribution of different regions of the image, converting the grayscale image into a binary image to highlight the particle boundaries and pores.
5. The method for predicting soil compaction quantity based on image recognition according to claim 1, characterized in that, In step S30, an improved convolutional neural network (CNN) is used, which is optimized based on the RepVGG model. The RepVGG neural network model includes an input layer, a RepVGG convolutional module layer, a pooling layer, a fully connected layer, and an output layer.
6. The method for predicting soil compaction quantity based on image recognition according to claim 1, characterized in that, The specific steps of step S40 are as follows: S401. In the pre-trained model, the dataset is divided into training set, validation set and test set according to 7:2:
1. The pre-processed binary image is input and the compaction is output. S402. The improved CNN neural network model is trained using the training set. During the training process, the batch size is set to 32, that is, the number of training samples is 32 each time. The loss function is minimized, the initial learning rate is set to 0.01, and the total number of iterations in the training process is 2400. S403. When the validation set loss value no longer decreases for 5 consecutive epochs and the training set loss value tends to stabilize, stop pre-training, save the model parameters, and obtain the pre-trained model.
7. The method for predicting soil compaction quantity based on image recognition according to claim 1, characterized in that, The specific steps of step S50 are as follows: S501. Select the compacted sand surface images collected in S10 that were not included in the pre-training (after preprocessing in S20) to fine-tune the pre-training model; S502: Freeze the convolutional and pooling layers of the improved CNN neural network model, and train only the fully connected and regression layers; S503. Retain some parameters of the pre-trained model and obtain a prediction model for the compaction degree of sand by fine-tuning.
8. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 9.
9. An electronic terminal, characterized in that, include: Processor and memory; The memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to cause the terminal to perform the method as described in any one of claims 1 to 9.