A method, device and method for constructing a surface roughness prediction model
By constructing a dual-path input model and combining deep convolutional neural networks and multi-dimensional feature texture extraction, the problems of low accuracy and environmental sensitivity of traditional surface roughness detection methods are solved, and efficient and reliable surface roughness prediction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TAIYUAN UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2026-01-30
- Publication Date
- 2026-06-12
AI Technical Summary
Traditional surface roughness detection methods suffer from problems such as scratching materials, slow detection speed, results being easily affected by the environment, and low prediction accuracy due to a single feature extraction method.
A dual-path input model is constructed, which combines deep convolutional neural networks and multi-dimensional feature texture extraction. A multi-head attention mechanism and a Mamba module are used to process texture statistical features, thereby achieving multi-scale feature extraction and texture feature encoding.
It improves the accuracy and reliability of surface roughness prediction, can better handle complex textures, filter noise and understand the intrinsic relationships between features, and improves the efficiency and accuracy of pattern recognition.
Smart Images

Figure CN122201531A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and intelligent manufacturing technology, and in particular to a method, apparatus and method for constructing a surface roughness prediction model. Background Technology
[0002] Surface roughness is a core parameter for measuring the microscopic geometric characteristics of a material surface, directly affecting the friction performance, sealing performance, fatigue strength, and service life of a workpiece. In aerospace, precision manufacturing, and medical device industries, roughness inspection is a crucial aspect of quality control. Arithmetic mean roughness is the most widely used surface roughness evaluation parameter, offering advantages such as fast inspection speed, strong industry applicability, and high suitability for artificial intelligence.
[0003] Traditional inspection methods, such as contact probe measurements, have limitations: the probe may scratch soft materials when mechanically sliding on the workpiece surface; the inspection speed is slow and cannot meet the needs of online inspection; and the results are easily affected by vibration and temperature. Methods that predict roughness from images using traditional machine learning features have limited information due to their single-dimensional feature extraction approach, and are insufficient for analyzing complex textured surfaces, resulting in low accuracy in roughness prediction. Summary of the Invention
[0004] The purpose of this invention is to provide a method, apparatus and prediction method for constructing a surface roughness prediction model, which solves the problem of low roughness prediction accuracy caused by the information limitation of existing roughness prediction methods that use a single feature extraction method.
[0005] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for constructing a surface roughness prediction model, comprising: Acquire sample data; the sample data includes workpiece surface images and roughness category labels; Construct a dual-path input model, which includes at least a deep convolutional neural network sub-model and a multi-dimensional feature texture extraction sub-model; The deep convolutional neural network sub-model is used to extract multi-scale features from the workpiece surface image to obtain a high-dimensional feature map. The multi-dimensional feature texture extraction sub-model extracts multi-dimensional texture statistical features of the workpiece surface image, and processes the texture statistical features based on the multi-head attention mechanism and the Mamba module to obtain texture feature encoding. The dual-path input model is optimized based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.
[0006] Optionally, the step of extracting multi-dimensional texture statistical features of the workpiece surface image through the multi-dimensional feature texture extraction sub-model, and processing the texture statistical features based on the multi-head attention mechanism and the Mamba module to obtain texture feature encoding includes: Multiple texture feature extraction algorithms are used to extract texture features from the workpiece surface image to obtain multi-dimensional texture statistical features; the texture statistical features include gray-level co-occurrence matrix features, gray-level difference statistical features, first-order statistical features, Tamura texture features, wavelet transform features, and local binary pattern features; The gray-level co-occurrence matrix features, the gray-level difference statistical features, the first-order statistical features, the Tamura texture features, the wavelet transform features, and the local binary pattern features are concatenated to obtain the texture feature tensor; The texture feature tensor is processed using a multi-head attention mechanism to obtain an attention-enhanced feature vector; The attention-enhanced feature vector is input into the selective state-space model, and feature modeling and transformation are performed on the attention-enhanced feature vector to obtain a feature sequence; The feature sequence is input into a fully connected layer to obtain texture feature encoding.
[0007] Optionally, the step of using multiple texture feature extraction algorithms to extract texture features from the workpiece surface image to obtain multi-dimensional texture statistical features includes: A gray-level co-occurrence matrix in four directions is constructed based on the workpiece surface image, and gray-level co-occurrence matrix features are calculated based on the gray-level co-occurrence matrix; the gray-level co-occurrence matrix features are obtained by splicing together the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels; Calculate the grayscale difference in the target direction of the workpiece surface image, calculate the first mean and the second moment of the angle based on the grayscale difference, and then stitch the first mean and the second moment of the angle together to obtain the grayscale difference statistical features; Calculate the gray-level probability distribution of the workpiece surface image, calculate the second mean, variance and first standard deviation based on the gray-level probability distribution, and concatenate the second mean, variance and first standard deviation to obtain a first-order statistical feature. Calculate the Tamura texture features of the workpiece surface image; the Tamura texture features are obtained by stitching together roughness, contrast, and orientation, where roughness is the mean gray level of the entire workpiece surface image; contrast is the standard deviation of the gray level of the entire workpiece surface image; and orientation is the gray level distribution histogram of the gradient direction of the workpiece surface image. Wavelet decomposition is performed on the workpiece surface image based on wavelet basis functions to obtain wavelet transform features; The workpiece surface image is subjected to neighborhood binarization based on a preset window to obtain binary code, and the binary code is converted into decimal LBP value. Local binary pattern features are determined based on the decimal LBP.
[0008] Optionally, the step of constructing a gray-level co-occurrence matrix in four directions based on the workpiece surface image, and calculating gray-level co-occurrence matrix features based on the gray-level co-occurrence matrix includes: Formula used: ; Construct gray-level co-occurrence matrices with included angles of 0°, 90°, 45°, and 135°; in, For size The matrix, The grayscale level represents the image of the workpiece surface, and # represents the number of elements in the set. and Let i be the number of pixels in the image of the workpiece surface. The grayscale value, j is The grayscale value, d is and The distance between them, θ is and The angle with the horizontal axis; Formula used: ; ; ; ; Calculate the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels for the four directions respectively. in, For the clarity of the texture, For local homogeneity, For texture uniformity, The linear correlation of gray levels. Let i be the mean of variable i. (where i is the standard deviation of variable i) Let j be the standard deviation of variable j; The gray-level co-occurrence matrix features are obtained by concatenating the texture clarity, local homogeneity, texture uniformity, and linear correlation of gray levels in the four directions.
[0009] Optionally, the step of performing wavelet decomposition on the workpiece surface image based on wavelet basis functions to obtain wavelet transform features includes: Formula used: ; ; The low-frequency approximate components and high-frequency detail components are calculated. Where h[n] is the low-pass filter, g[n] is the high-pass filter, and n is the index of the input signal. This is a low-frequency approximation component. For high-frequency detail components, To decompose the hierarchy, This is the output time; The third mean and the second standard deviation are calculated based on the low-frequency approximation components, and the fourth mean and the third standard deviation are calculated based on the high-frequency detail components. The wavelet transform feature is obtained by concatenating the third mean, the second standard deviation, the fourth mean, and the third standard deviation.
[0010] Optionally, determining the local binary pattern features based on the decimal LBP includes: Formula used: ; Calculate a statistical histogram; the statistical histogram is a local binary pattern feature; in, To compile a statistical histogram, The mode value for LBP is in decimal. The x-coordinate of the pixel in the workpiece surface image. The vertical coordinate of the pixel in the workpiece surface image. This is the Dirac function.
[0011] Optionally, the deep convolutional neural network sub-model is MobileNet Version 3; the dual-path input model further includes a global average pooling layer and a global max pooling layer; the optimization of the surface roughness prediction model based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain the surface roughness prediction model includes: The high-dimensional feature map is processed using a global average pooling layer to obtain the first high-dimensional feature; The high-dimensional feature map is processed using a global max pooling layer to obtain a second high-dimensional feature; The first high-dimensional feature and the second high-dimensional feature are flattened and spliced together to obtain the first fused feature; The first fusion feature and the texture feature encoding are fused together to obtain the second fusion feature; The surface roughness prediction model is optimized based on the first high-dimensional feature, the second fusion feature, the texture feature encoding, and the roughness category label to obtain the surface roughness prediction model.
[0012] Optionally, the surface roughness prediction model is optimized based on the first high-dimensional feature, the second fusion feature, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model; The cross-entropy loss function is used to calculate the loss values between the first high-dimensional feature, the second fused feature, and the texture feature encoding and the roughness category label, respectively. Based on the loss value, the dual-path input model is trained using a stochastic gradient descent optimizer to obtain a surface roughness prediction model.
[0013] Compared with existing technologies, this invention provides a method for constructing a surface roughness prediction model, comprising: acquiring sample data; constructing a dual-path input model, wherein the dual-path input model includes at least a deep convolutional neural network sub-model and a multi-dimensional feature texture extraction sub-model; using the deep convolutional neural network sub-model to perform multi-scale feature extraction on the workpiece surface image to obtain a high-dimensional feature map; using the multi-dimensional feature texture extraction sub-model to extract multi-dimensional texture statistical features of the workpiece surface image, and processing the texture statistical features based on a multi-head attention mechanism and a Mamba module to obtain texture feature encoding; optimizing the dual-path input model based on the high-dimensional feature map, texture feature encoding, and roughness category label to obtain a surface roughness prediction model. This application combines the high-dimensional feature map automatically extracted by deep learning with the extracted multi-dimensional texture features to achieve comprehensive and multi-dimensional capture of workpiece surface roughness information. This complementary mechanism of heterogeneous features can overcome the limitations of single feature extraction methods, greatly improving the accuracy and reliability of roughness prediction. Furthermore, the introduction of a multi-head self-attention mechanism and a Mamba module into the multi-dimensional feature texture extraction sub-model effectively enhances the model's ability to focus on key texture features and capture long-distance dependencies between different texture features. This enables the model to better filter noise, highlight key features, and deeply understand the intrinsic relationships between features when dealing with complex surface textures, thereby improving the efficiency and accuracy of pattern recognition.
[0014] Secondly, the present invention provides a surface roughness prediction method, which uses a surface roughness prediction model constructed by the aforementioned surface roughness prediction model construction method to perform prediction. The method includes: Acquire an image of the workpiece surface to be predicted; The surface image of the workpiece to be predicted is input into the surface roughness prediction model to predict the roughness of the workpiece.
[0015] Compared with the prior art, the beneficial effects of the prediction method for a surface roughness prediction model provided by the present invention are the same as the beneficial effects of the construction method for a surface roughness prediction model described in the above technical solution, and will not be repeated here.
[0016] Thirdly, the present invention provides an apparatus for constructing a surface roughness prediction model, comprising: The sample data acquisition module is used to acquire sample data, which includes workpiece surface images and roughness category labels. A dual-path input model construction module is used to construct a dual-path input model, which includes at least a deep convolutional neural network sub-model and a multi-dimensional feature texture extraction sub-model. The multi-scale feature extraction module is used to extract multi-scale features from the workpiece surface image using the deep convolutional neural network sub-model to obtain a high-dimensional feature map. The texture statistical feature extraction module is used to extract multi-dimensional texture statistical features of the workpiece surface image through the multi-dimensional feature texture extraction sub-model, and process the texture statistical features based on the multi-head attention mechanism and the Mamba module to obtain texture feature encoding. An optimization module is used to optimize the dual-path input model based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.
[0017] Compared with the prior art, the beneficial effects of the surface roughness prediction model construction device provided by the present invention are the same as the beneficial effects of the surface roughness prediction model construction method described in the above technical solution, and will not be repeated here. Attached Figure Description
[0018] The accompanying drawings, which are provided to further illustrate the invention and constitute a part of this invention, are illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an undue limitation of the invention.
[0019] In the attached diagram: Figure 1 A flowchart illustrating a method for constructing a surface roughness prediction model provided by the present invention; Figure 2 This is a schematic diagram of the structure of the dual-path input model and the classification model provided by the present invention; Figure 3 A schematic diagram illustrating the principle and structure of the MTEF provided by this invention; Figure 4 This is a schematic diagram of the structure of a surface roughness prediction model construction device provided by the present invention. Detailed Implementation
[0020] To facilitate a clear description of the technical solutions in the embodiments of the present invention, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. For example, the first threshold and the second threshold are merely used to distinguish different thresholds and do not limit their order. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that the terms "first" and "second" are not necessarily different.
[0021] It should be noted that in this invention, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in this invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0022] In this invention, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, a combination of a and b, a combination of a and c, a combination of b and c, or a, b, and c, where a, b, and c can be single or multiple.
[0023] Traditional methods for predicting workpiece surface roughness have the following problems: 1. The mechanical sliding of the probe can scratch the surface of soft materials, affecting the quality of the workpiece; the detection equipment needs to scan slowly point by point, and a single measurement takes several minutes, which cannot meet the real-time requirements of online detection; the equipment is sensitive to environmental vibration and temperature changes, and the detection results are easily interfered with, which limits its widespread application in industrial fields.
[0024] 2. The generalization ability of manual feature extraction methods is insufficient: the sharpness model requires a fixed light source angle and is only applicable to diffuse reflective surfaces; the quaternion singular value entropy (QSVE) method has poor transferability, has the risk of overfitting, and is difficult to adapt to the surface roughness detection needs under different working conditions.
[0025] 3. Deep learning methods face challenges in interpretability and adaptability: Although deep learning-based vision methods can automatically learn multi-level abstract features and have good generalization ability, they suffer from the "black box" problem of poor model interpretability and opaque decision-making process; they are prone to overfitting in small sample scenarios and have high requirements for the amount and quality of training data; they are sensitive to changes in imaging conditions and their stability under different imaging conditions such as illumination and angle needs to be improved.
[0026] 4. High Deployment Complexity of Multimodal Fusion Methods: While multimodal methods improve prediction accuracy by integrating multiple data sources such as images, vibration signals, and processing parameters, they inevitably lead to complex testing processes and deployment challenges. Multi-sensor data fusion requires sophisticated equipment, such as dual-light source synchronous acquisition, resulting in complex detection systems. It also incurs high computational overhead and a large number of model parameters, making it difficult to meet the real-time requirements of online industrial deployments. Furthermore, multimodal data still relies on manually designed features, increasing system complexity and maintenance costs.
[0027] In summary, traditional methods suffer from insufficient generalization ability of handcrafted features, poor interpretability of deep learning models, high complexity of multimodal methods, and single feature dimension.
[0028] To address the aforementioned problems, this invention provides a method, apparatus, and prediction method for constructing a surface roughness prediction model, integrating deep learning feature extraction methods and texture feature extraction methods to improve the interpretability and robustness of the model. The following description is in conjunction with the accompanying drawings.
[0029] See Figure 1 The present invention provides a method for constructing a surface roughness prediction model, comprising the following steps: Step 101: Obtain sample data; The sample data includes images of the workpiece surface and roughness category labels.
[0030] In practical applications, sample data can be obtained by building an experimental platform. The hardware consists of an industrial camera and an optical platform for fixing the sample. After all the devices are correctly connected, the device status and communication link are checked in sequence, and key camera parameters, such as focal length and aperture, are calibrated to ensure the consistency of subsequent data acquisition.
[0031] For example, Q235 steel was used as the workpiece material, and samples with different roughnesses were obtained by processing under different parameters. Surface roughness was measured at 16 different locations on each sample using a contact surface profilometer, and the average value was used as the overall roughness value for that sample. The roughness values of all samples ranged from 0 to 1.6 μm and were accordingly divided into three categories: Category 0 (0–0.4 μm), Category 1 (0.4–0.8 μm), and Category 2 (0.8–1.6 μm). After workpiece preparation and calibration, the samples were fixed on an optical platform. Camera acquisition parameters, such as resolution, exposure time, and gain, were set to acquire surface images of the samples under natural light, ultimately generating 2560 images. The acquired images are then preprocessed to ensure quality and prepare for model training. The preprocessing process mainly includes: applying camera calibration parameters to correct lens distortion and ensure image geometric accuracy; eliminating the effects of uneven lighting to make brightness and contrast comparable between different images; using techniques such as contrast stretching and histogram equalization to highlight surface texture features; and checking image sharpness and integrity, automatically removing blurry or failed-to-acquire images. The preprocessed high-quality images are then correlated with the obtained accurate roughness measurements, assigning each image a corresponding roughness category label (class 0, class 1, or class 2). The entire multimodal dataset is then divided into a training set and a validation set in approximately an 8:2 ratio, with the training set containing 2049 samples and the validation set containing 511 samples. Finally, the data index files required for training and validation are generated, completing the final dataset construction. The model is trained using the training set and validated using the validation set. The sample data in this step refers to the training set.
[0032] Step 102: Construct a dual-path input model; like Figure 2 As shown, the dual-path input model processes the input workpiece surface image through two input paths. The dual-path input model includes a deep convolutional neural network sub-model, a multi-dimensional feature texture extraction sub-model, a global average pooling layer, a global max pooling layer, a stitching module, and four fully connected layers. The deep convolutional neural network sub-model is a neural network capable of multi-scale feature extraction from images, such as MobileNet Version 3 (MobileNetV3), which includes depthwise separable convolutions, an inverted residual structure with a linear bottleneck layer, a lightweight attention module, and uses the h-swish activation function.
[0033] The multi-dimensional feature texture extraction sub-model includes the MTFE module, multi-head attention mechanism, Mamba module, and fully connected layer 0.
[0034] Step 103: Use the deep convolutional neural network sub-model to perform multi-scale feature extraction on the workpiece surface image to obtain a high-dimensional feature map; Specifically, MobileNetV3 uses depthwise separable convolutions to reduce the number of computational parameters, uses multi-scale receptive fields to capture features of different granularities, and utilizes inverse residual structures and linear bottleneck layers to extract deep features while maintaining lightweight design.
[0035] Step 104: Extract multi-dimensional texture statistical features of the workpiece surface image through the multi-dimensional feature texture extraction sub-model, and process the texture statistical features based on the multi-head attention mechanism and Mamba module to obtain texture feature encoding; Specifically, the MTFE module combines six texture feature extraction algorithms: gray-level co-occurrence matrix, gray-level difference statistics, first-order statistics, Tamura texture features, wavelet transform texture features, and local binary patterns. These algorithms extract the statistical texture features of the workpiece surface image, improving the model's ability to perceive roughness images in both the time and frequency domains, refining the relationships between texture features, and highlighting key texture features. The introduction of a multi-head self-attention mechanism and a fully receptive field Mamba module enables automatic learning of dependencies between features, extracting the most discriminative feature combinations while maintaining computational efficiency.
[0036] Step 105: Optimize the dual-path input model based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.
[0037] Figure 1 The aforementioned method, by combining high-dimensional feature maps automatically extracted through deep learning with extracted multi-dimensional texture features, comprehensively captures the global, frequency-domain, and local statistical features of surface images. This complementary mechanism of heterogeneous features overcomes the limitations of single feature extraction methods, significantly improving the accuracy and reliability of roughness prediction. Furthermore, the introduction of a multi-head self-attention mechanism and a Mamba module into the multi-dimensional feature texture extraction sub-model effectively enhances the model's ability to focus on key texture features and capture long-distance dependencies between different texture features. This enables the model to better filter noise, highlight key features, and deeply understand the intrinsic connections between features when processing complex surface textures, thus improving the efficiency and accuracy of pattern recognition.
[0038] based on Figure 1 In addition to the method described herein, this specification also provides some specific implementation methods of this method, which will be described below.
[0039] As an alternative approach, step 104 can be implemented based on S41-S45.
[0040] S41: The MTFE module employs various texture feature extraction algorithms to extract texture features from the workpiece surface image, thereby obtaining multi-dimensional texture statistical features; Among them, such as Figure 3 As shown, the MTFE module includes six parallel texture statistical feature calculation modules: GLCM, gray-level difference statistics, first-order statistics, Tamura, wavelet transform, and LBP. The calculated texture statistical features include gray-level co-occurrence matrix features, gray-level difference statistics features, first-order statistics features, Tamura texture features, wavelet transform features, and local binary pattern features.
[0041] As an optional approach, S41 is implemented based on S411-S416: S411: Construct a gray-level co-occurrence matrix in four directions based on the workpiece surface image, and calculate gray-level co-occurrence matrix features based on the gray-level co-occurrence matrix; the gray-level co-occurrence matrix features are obtained by splicing together the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels; The gray-level co-occurrence matrix (GLCM) represents the probability of two pixel gray values occurring simultaneously; it is defined by the joint probability density of the pixel at the two locations. The results reflect the distribution characteristics of pixels with the same brightness and pixels with similar brightness, and represent the brightness variation characteristics of the image in a specific direction. Let... The image shows the surface of a workpiece with a size of M×N and a grayscale level of [missing information]. Then the gray-level co-occurrence matrix that satisfies a specific spatial relationship is shown in formula (1): (1); The gray-level co-occurrence matrices with included angles of 0°, 90°, 45° and 135° are constructed using formula (1); in, For size The matrix, The grayscale level represents the image of the workpiece surface, and # represents the number of elements in the set. and Let i be the number of pixels in the image of the workpiece surface. The grayscale value, j is The grayscale value, d is and The distance between them, θ is and The angle between the formed straight line and the horizontal axis; Then, use formulas (2)-(5): (2); (3); (4); (5); Calculate the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels in four directions; each direction corresponds to an included angle. in, This represents the clarity of the texture; the larger the value, the more drastic the local grayscale changes. For local homogeneity, the larger the value, the smoother the texture. For texture uniformity, the larger the value, the more regular the gray level distribution. This represents the linear correlation of gray levels; a larger value indicates a directional texture. Let i be the mean of variable i. Let i be the standard deviation of variable i. Let j be the standard deviation of variable j; Sixteen features, including texture clarity, local homogeneity, texture uniformity, and linear correlation of gray levels in the four directions, are concatenated to obtain a 16-dimensional gray-level co-occurrence matrix feature.
[0042] S412: Calculate the grayscale difference in the target direction of the workpiece surface image, calculate the first mean and the second moment of the angle based on the grayscale difference, and stitch the first mean and the second moment of the angle together to obtain the grayscale difference statistical features; The target directions mentioned above refer to the horizontal, vertical, and diagonal directions of the workpiece surface image. The grayscale difference between each pixel (x, y) and the offset point (x + Δx, y + Δy) in the image is calculated as shown in formula (6): (6); Where Δx and Δy represent tiny pixel displacements, taken as 1 pixel. Let k represent the grayscale difference. For ease of explanation later, we use k to represent the value of the grayscale difference. We iterate through the entire workpiece surface image and count the frequency of each grayscale difference value k, thus obtaining the probability density distribution histogram of the grayscale difference values. The range of k is the same as the range of the grayscale difference. The probability density distribution histogram of the grayscale difference values reflects the intensity of local variations in texture. If the probability density distribution histogram of the grayscale difference values shows a high probability when the k value is small, the surface texture is rough; if the distribution is flat, the texture is fine.
[0043] The first mean is the mean of the probability density distribution histogram of the gray-level difference. The formula for calculating the first mean is shown in formula (7): (7); The formula for calculating the second moment of an angle is shown in formula (8): (8); in, This represents the mean of the grayscale difference probability density, indicating the overall roughness. A larger value indicates a coarser texture, while a smaller value indicates a finer texture. This represents the maximum value of the grayscale difference. This represents the probability density distribution of grayscale difference. The second moment of the gray-level difference probability density describes the uniformity of the texture. A higher value indicates that the gray-level difference distribution is concentrated, while a lower value indicates that the distribution is more dispersed.
[0044] The second mean and second moment of the angle in the horizontal, vertical and diagonal directions are calculated according to formulas (7) and (8), resulting in a total of 6 statistical measures. These measures are then combined to form a 6-dimensional gray-scale difference statistical feature.
[0045] S413: Calculate the gray-level probability distribution of the workpiece surface image, calculate the second mean, variance and first standard deviation based on the gray-level probability distribution, and concatenate the second mean, variance and first standard deviation to obtain a 3D first-order statistical feature; the second mean is the mean of the gray-level probability distribution, and the first standard deviation is the standard deviation of the gray-level probability distribution.
[0046] Specifically, the macroscopic characteristics of the texture are described by quantifying the distribution pattern of pixel gray values in the image, while ignoring the spatial relationship between pixels. Based on the gray-level histogram, the probability distribution of gray levels is calculated. Let the range of image gray levels be [0, L-1], where L represents the maximum gray level. The gray-level histogram represents the frequency of gray values appearing in the workpiece surface image. The probability distribution of gray levels is shown in formula (9): (9); in, It is a gray-level probability distribution. H(e) is the gray-level histogram, e is the gray-level value, and N represents the total number of pixels in the image. The histogram reflects the overall gray-level distribution of the image.
[0047] choose The mean, variance, and standard deviation of an image are used to characterize its overall gray-level distribution. The mean describes the overall brightness level of the image. A high mean corresponds to bright textures, while a low mean corresponds to dark textures. The mean and standard deviation measure the dispersion of the gray-level distribution. A larger mean indicates higher contrast and sharper edges, while a smaller mean indicates more uniform gray levels. Therefore, first-order statistical features introduce the mean, variance, and standard deviation to quantify the image.
[0048] S414: Calculate the Tamura texture features of the workpiece surface image; the Tamura texture features are obtained by stitching together roughness, contrast, and orientation, wherein the roughness is the mean gray level of the entire workpiece surface image; the contrast is the standard deviation of the gray level of the entire workpiece surface image; and the orientation is the gray level distribution histogram of the gradient direction of the workpiece surface image; for example, such as... Figure 3 The above results in a 32-dimensional Tamura texture feature.
[0049] S415: Perform wavelet decomposition on the workpiece surface image based on wavelet basis functions to obtain wavelet transform features; Wavelet decomposition is performed using Discrete Wavelet Transform (DWT) to decompose a two-dimensional DWT image. Multi-resolution analysis (MRA) is used to decompose the image signal into low-frequency approximation components and high-frequency detail components, as shown in Equations (10) and (11): (10); (11); Specifically, the steps to obtain the wavelet transform features are as follows: the low-frequency approximate components and high-frequency detail components are calculated using formulas (10) and (11); Where h[n] is the low-pass filter, g[n] is the high-pass filter, and n is the index of the input signal. This includes time-domain information of the workpiece surface image, specifically the low-frequency approximation component. This includes frequency domain information of the workpiece surface image, specifically the high-frequency detail components. To decompose the hierarchy, This is the output time; The third mean and the second standard deviation are calculated based on the low-frequency approximation components, and the fourth mean and the third standard deviation are calculated based on the high-frequency detail components; the third mean is the mean of the low-frequency approximation components, and the second standard deviation is the standard deviation of the low-frequency approximation components; the fourth mean is the mean of the high-frequency detail components, and the third standard deviation is the standard deviation of the high-frequency detail components. By concatenating the third mean, the second standard deviation, the fourth mean, and the third standard deviation, a 4-dimensional wavelet transform feature is obtained.
[0050] S416: Perform neighborhood binarization processing on the workpiece surface image based on a preset window to obtain binary code, and convert the binary code into decimal LBP value, and determine local binary pattern features based on the decimal LBP.
[0051] This step involves generating a code by binarizing the grayscale differences between neighboring pixels and the center pixel to describe the local texture structure. Neighborhood binarization is the fundamental mathematical principle of LBP (Local Backpropagation). A preset window can be 3×3. Within this window, the grayscale value of the center pixel is used as a threshold and compared with the grayscale values of its eight neighboring pixels to generate an 8-bit binary code. This binary code is then converted into a decimal LBP value.
[0052] Formula (12) is used: (12); Calculate a statistical histogram; the statistical histogram is a local binary pattern feature; in, To compile a statistical histogram, The mode value for LBP is in decimal. The x-coordinate of the pixel in the workpiece surface image. The vertical coordinate of the pixel in the workpiece surface image. For the Dirac function, T refers to , ∈[0, B-1], To count the number of bins in the histogram.
[0053] For example, if the number of bins in the statistical histogram is set to 10, the local binary pattern features will be 10-dimensional vectors.
[0054] The LBP algorithm used in the above steps abstracts local textures into binary codes based on gray-level differences. It quantizes the global distribution using statistical histograms, offering advantages such as low computational complexity, strong robustness, and high adaptability to pose.
[0055] S42: The gray-level co-occurrence matrix features, the gray-level difference statistical features, the first-order statistical features, the Tamura texture features, the wavelet transform features, and the local binary pattern features are concatenated to obtain the texture feature tensor; Specifically, six texture statistical features are concatenated using the concat method, and the concatenation process is shown in formula (13): (13); in, For the splicing result, , is a feature of the gray-level co-occurrence matrix. , representing the statistical characteristics of grayscale difference. This is a first-order statistical feature. , is the Tamura texture feature, This is a wavelet transform feature. This is a feature of a local binary pattern. , , , , as well as Let be the dimension of each texture statistical feature.
[0056] The stitched result is converted into a texture feature tensor through a fully connected layer.
[0057] S43: The texture feature tensor is processed using a multi-head attention mechanism to obtain an attention-enhanced feature vector; Multi-head self-attention mechanisms enhance the model's ability to capture complex relationships by computing multiple attention heads in parallel. A single learnable parameter matrix is used to generate the query vector, key vector, and value vector, as shown in equations (14)-(16): (14); (15); (16); in, Given an input sequence matrix, p is the sequence length, and d is the feature dimension. Let r be the query vector of the attention head. Let r be the key vector of the attention head. Let r be the value vector of the attention head. , , , , , For a trainable weight matrix, For the key dimension of each head, For each head, the value dimension is defined, where R is a real number and h is the number of attention heads.
[0058] In the head segmentation, Q, K, and V are divided into h independent subspaces along the feature dimensions, as shown in Equation (17): (17); in, For the output of the r-th attention head, This is the self-attention computation function.
[0059] Reduce the dimensions of each head to This reduces computational load and enables parallelization. In scaled dot product attention, for each head, the dot product of query and key is computed and scaled to prevent gradient instability, as shown in Equation (18): (18); Softmax normalization transforms the dot product results into a probability distribution, representing the attention weights at different locations. Finally, the outputs of h heads are concatenated along the feature dimension, restoring the dimension to p×d. By mapping the learnable matrix to the target space, the final output dimension becomes consistent with the input dimension.
[0060] S44: Input the attention-enhanced feature vector into the selective state-space model, perform feature modeling and transformation on the attention-enhanced feature vector, and obtain a feature sequence; The Mamba module employs the Mamba algorithm, a sequence processing architecture based on a selective state-space model. Through dynamic parameter adjustment and hardware optimization, it achieves linear computational complexity and efficient modeling of long sequences. Its core mathematical principle lies in the combination of state-space model discretization, selective mechanisms, and hardware-aware algorithms. Its core is a continuous-time state-space model, which describes system dynamics through differential equations, as shown in equations (19) and (20): (19); (20); in, , , , These are weighted parameters. The input is the texture feature sequence, i.e., the attention-enhanced feature vector obtained from S43. The feature sequence is the output after processing by the 32-layer Mamba algorithm. This is the hidden state. The model uses a zero-order hold (ZOH) discretized continuous system and employs a selective scan algorithm to decompose the sequence into sub-blocks for parallel computation, ultimately outputting a feature sequence with global context information.
[0061] S45: Input the feature sequence into the fully connected layer 0 to obtain the texture feature encoding.
[0062] This step aims to map the dimension of the feature sequence to 128 dimensions to accommodate the dimensionality requirements of feature fusion, thereby obtaining the final texture feature encoding.
[0063] As an optional approach, step 105 can be implemented based on S51-S55; S51: The high-dimensional feature map is processed by a global average pooling layer to obtain the first high-dimensional feature; S52: The high-dimensional feature map is processed using a global max pooling layer to obtain a second high-dimensional feature; S53: Flatten and stitch the first high-dimensional feature and the second high-dimensional feature to obtain the first fused feature; S54: Fuse the first fusion feature and the texture feature encoding to obtain the second fusion feature; A dual-encoding fusion strategy is employed, combining the first fusion feature with texture feature encoding to perform pattern recognition tasks. By strategically stitching these complementary representations, the algorithm maximizes the preservation of intrinsic data information, achieves effective downsampling for pattern extraction, enriches complex texture feature relationships, and significantly improves the model's robustness in roughness-sensitive applications. The algorithm implements two fusion strategies, each with different structural and computational characteristics.
[0064] The calculation of the second fusion feature is shown in formula (21): (twenty one) in, This is the second fusion feature. This is the first fusion feature. This is for encoding texture features. The dimension of the first fusion feature Z represents the dimension for encoding texture features, and Z is the batch size set during model training.
[0065] S55: Optimize the surface roughness prediction model based on the first high-dimensional feature, the second fusion feature, the texture feature encoding, and the roughness category label to obtain the surface roughness prediction model.
[0066] Specifically, S55 can be implemented based on S551-S552.
[0067] S551: The cross-entropy loss function is used to calculate the loss values between the first high-dimensional feature, the second fused feature, and the texture feature encoding and the roughness category label, respectively; Cross-entropy loss has a large gradient when there are mispredictions and converges quickly, making it a commonly used function in classification tasks.
[0068] Its synergy with softmax and sigmoid makes gradient calculation more efficient, and compared to MSE, it is more suitable for the probabilistic nature of classification tasks.
[0069] S552: Based on the loss value, the dual-path input model is trained using a stochastic gradient descent optimizer to obtain the surface roughness prediction model.
[0070] As an optional approach, to fully demonstrate the efficiency and accuracy of the method of the present invention, the following evaluation indicators are specifically set: Accuracy: The proportion of samples correctly predicted by the model out of the total number of samples. Calculated as shown in formula (22): (twenty two); Where Accuracy is the accuracy rate, TP is the case where the actual class is positive and the prediction is also positive; TN is the case where the actual class is negative and the prediction is also negative; FP is the case where the actual class is negative and the prediction is also negative, i.e., false positive; FN is the case where the actual class is positive but is predicted as negative, i.e., false negative.
[0071] Precision: The proportion of samples that the model predicts as positive also being positive in the actual class. Calculated as shown in formula (23): (twenty three); Precision refers to the accuracy rate.
[0072] Recall: The proportion of actual positive samples correctly identified by the model. The calculation formula is shown in formula (24): (twenty four); Here, Recall is the recall rate.
[0073] Score: The harmonic mean of precision and recall, which comprehensively balances the performance of both. Calculated as in formula (25): (25); in, It is a fraction.
[0074] As shown in Table 1, the surface roughness prediction model constructed in this application has higher accuracy, precision, recall, and F1 score than traditional models, and has the lowest complexity. This shows that this application greatly improves the accuracy and reliability of roughness prediction, while significantly reducing the computational complexity.
[0075] Table 1: Quantitative Comparison Results of the Model in this Application with Traditional Models In specific implementation, such as Figure 2As shown, the sample data is input into a dual-path input model, where image feature extraction is performed in two paths. The first path inputs to MobileNet Version 3, outputting a high-dimensional feature map. This high-dimensional feature map is then processed by a global average pooling layer and a global max pooling layer to obtain the first and second high-dimensional features. After dimensionality reduction, these two features are concatenated to obtain the first fused feature. The second path inputs to a multi-dimensional feature texture extraction sub-model, which uses an MTFE module integrating six texture feature algorithms to extract six texture statistical features. These six texture statistical features are then concatenated to obtain a texture feature tensor. A multi-head attention mechanism and a Mamba module are used to process the texture feature tensor. After passing through a fully connected layer 0, the texture feature encoding is output. This texture feature encoding is then concatenated with the first fused feature to obtain the second fused feature. A multi-output supervision strategy is then used to transform the first high-dimensional feature, the first fused feature, and the second fused feature through a fully connected layer and output to the classification module for classification. Based on the classification results, the parameters of MobileNet Version 3, the multi-head attention mechanism, and the Mamba module are optimized to obtain the final surface roughness prediction model.
[0076] Based on the above method, the present invention also provides a prediction method for a surface roughness prediction model, wherein the surface roughness prediction model constructed using the aforementioned surface roughness prediction model construction method is used for prediction, and the steps include: Acquire an image of the workpiece surface to be predicted; The surface image of the workpiece to be predicted is input into the surface roughness prediction model to predict the roughness of the workpiece.
[0077] It should be noted that the predicted roughness is obtained by concatenating the outputs of the global average pooling layer, the global max pooling layer, and the multi-dimensional feature texture extraction sub-model.
[0078] The embodiments of the present invention can divide functional modules according to the above method examples. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in the embodiments of the present invention is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0079] When dividing each function into modules according to its corresponding function. Figure 4 A schematic diagram of a device for constructing a surface roughness prediction model provided by the present invention is shown. Figure 4 As shown, the device includes: The sample data acquisition module 401 is used to acquire sample data; the sample data includes workpiece surface images and roughness category labels. Dual-path input model construction module 402 is used to construct a dual-path input model, wherein the dual-path input model includes at least a deep convolutional neural network sub-model and a multi-dimensional feature texture extraction sub-model. The multi-scale feature extraction module 403 is used to perform multi-scale feature extraction on the workpiece surface image using the deep convolutional neural network sub-model to obtain a high-dimensional feature map. The texture statistical feature extraction module 404 is used to extract multi-dimensional texture statistical features of the workpiece surface image through the multi-dimensional feature texture extraction sub-model, and process the texture statistical features based on the multi-head attention mechanism and the Mamba module to obtain texture feature encoding. The optimization module 405 is used to optimize the dual-path input model based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.
[0080] Optionally, the texture statistical feature extraction module 404 may specifically include: The multi-dimensional texture statistical feature extraction unit is used to extract texture features from the workpiece surface image using various texture feature extraction algorithms to obtain multi-dimensional texture statistical features. The texture statistical features include gray-level co-occurrence matrix features, gray-level difference statistical features, first-order statistical features, Tamura texture features, wavelet transform features, and local binary pattern features. The first fusion unit is used to concatenate the gray-level co-occurrence matrix features, the gray-level difference statistical features, the first-order statistical features, the Tamura texture features, the wavelet transform features, and the local binary pattern features to obtain a texture feature tensor. A multi-head attention mechanism processing unit is used to process the texture feature tensor using a multi-head attention mechanism to obtain an attention-enhanced feature vector; The Mamba algorithm computation unit is used to input the attention-enhanced feature vector into the selective state space model, perform feature modeling and transformation on the attention-enhanced feature vector, and obtain a feature sequence. A fully connected unit is used to input the feature sequence into a fully connected layer to obtain texture feature encoding.
[0081] Optionally, the multi-dimensional texture statistical feature extraction unit may specifically include: The gray-level co-occurrence matrix calculation subunit is used to construct gray-level co-occurrence matrices in four directions based on the workpiece surface image, and to calculate gray-level co-occurrence matrix features based on the gray-level co-occurrence matrix; the gray-level co-occurrence matrix features are obtained by splicing together the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels; The grayscale difference statistical feature calculation subunit is used to calculate the grayscale difference in the target direction of the workpiece surface image, calculate the first mean and the second moment of the angle based on the grayscale difference, and concatenate the first mean and the second moment of the angle to obtain the grayscale difference statistical feature. The first-order statistical feature calculation subunit is used to calculate the gray level probability distribution of the workpiece surface image, calculate the second mean, variance and first standard deviation based on the gray level probability distribution, and concatenate the second mean, the variance and the first standard deviation to obtain the first-order statistical feature. The Tamura texture feature calculation subunit is used to calculate the Tamura texture features of the workpiece surface image. The Tamura texture features are obtained by stitching together roughness, contrast, and orientation. The roughness is the mean gray level of the entire workpiece surface image. The contrast is the standard deviation of the gray level of the entire workpiece surface image. The orientation is the gray level distribution histogram of the gradient direction of the workpiece surface image. The wavelet transform subunit is used to perform wavelet decomposition on the workpiece surface image based on wavelet basis functions to obtain wavelet transform features. The local binary pattern feature calculation subunit is used to perform neighborhood binarization processing on the workpiece surface image based on a preset window to obtain binary code, convert the binary code into decimal LBP value, and determine the local binary pattern feature based on the decimal LBP.
[0082] Optionally, the gray-level co-occurrence matrix calculation subunit can be specifically used for: Formula used: ; Construct gray-level co-occurrence matrices with included angles of 0°, 90°, 45°, and 135°; in, For size The matrix, The grayscale level represents the image of the workpiece surface, and # represents the number of elements in the set. and Let i be the number of pixels in the image of the workpiece surface. The grayscale value, j is The grayscale value, d is and The distance between them, θ is and The angle with the horizontal axis; Formula used: ; ; ; ; Calculate the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels for the four directions respectively. in, For the clarity of the texture, For local homogeneity, For the uniformity of texture, The linear correlation of gray levels. Let i be the mean of variable i. Let i be the standard deviation of variable i. Let j be the standard deviation of variable j; The gray-level co-occurrence matrix features are obtained by concatenating the texture clarity, local homogeneity, texture uniformity, and linear correlation of gray levels in the four directions.
[0083] Optionally, the wavelet transform subunit may specifically include: Formula used: ; ; The low-frequency approximate components and high-frequency detail components are calculated. Where h[n] is the low-pass filter, g[n] is the high-pass filter, and n is the index of the input signal. This is a low-frequency approximation component. For high-frequency detail components, To decompose the hierarchy, This is the output time; The third mean and the second standard deviation are calculated based on the low-frequency approximation components, and the fourth mean and the third standard deviation are calculated based on the high-frequency detail components. The wavelet transform feature is obtained by concatenating the third mean, the second standard deviation, the fourth mean, and the third standard deviation.
[0084] Optionally, the local binary pattern feature calculation subunit can be used specifically for: Formula used: ; Calculate a statistical histogram; the statistical histogram is a local binary pattern feature; in, To compile a statistical histogram, The mode value for LBP is in decimal. The x-coordinate of the pixel in the workpiece surface image. The vertical coordinate of the pixel in the workpiece surface image. This is the Dirac function.
[0085] Optionally, the deep convolutional neural network sub-model is MobileNet Version 3; the dual-path input model further includes a global average pooling layer and a global max pooling layer; the optimization module 405 may specifically include: The average pooling processing unit is used to process the high-dimensional feature map using a global average pooling layer to obtain the first high-dimensional feature. A global pooling unit is used to process the high-dimensional feature map using a global max pooling layer to obtain a second high-dimensional feature. The first splicing unit is used to flatten and splice the first high-dimensional feature and the second high-dimensional feature to obtain the first fused feature. The second splicing unit is used to fuse the first fusion feature and the texture feature encoding to obtain the second fusion feature; An optimization unit is used to optimize the surface roughness prediction model based on the first high-dimensional feature, the second fusion feature, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.
[0086] Optionally, the optimization unit may specifically be used for: The cross-entropy loss function is used to calculate the loss values between the first high-dimensional feature, the second fused feature, and the texture feature encoding and the roughness category label, respectively. Based on the loss value, the dual-path input model is trained using a stochastic gradient descent optimizer to obtain a surface roughness prediction model.
[0087] The above mainly describes the solutions provided by the embodiments of the present invention from the perspective of the interaction between various modules. It is understood that, in order to achieve the above functions, it includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, the present invention can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0088] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are performed entirely or partially. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a terminal, a user equipment, or other programmable device. The computer program or instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc (DVD); or it can be a semiconductor medium, such as a solid-state drive (SSD).
[0089] Although the invention has been described herein in conjunction with various embodiments, those skilled in the art will understand and implement other variations of the disclosed embodiments by reviewing the accompanying drawings, the disclosure, and the appended claims in carrying out the claimed invention. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude a plurality. A single processor or other unit can implement several functions listed in the claims. While different dependent claims may recite certain measures, this does not mean that these measures cannot be combined to produce good results.
[0090] Although the invention has been described in conjunction with specific features and embodiments, it is obvious that various modifications and combinations can be made therein without departing from the spirit and scope of the invention. Accordingly, this specification and drawings are merely exemplary descriptions of the invention as defined by the appended claims, and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of the invention. Clearly, those skilled in the art can make various alterations and modifications to the invention without departing from its spirit and scope. Thus, if such modifications and modifications of the invention fall within the scope of the claims and their equivalents, the invention is also intended to include such modifications and modifications.
Claims
1. A method for constructing a surface roughness prediction model, characterized in that, include: Acquire sample data; the sample data includes workpiece surface images and roughness category labels; Construct a dual-path input model, which includes at least a deep convolutional neural network sub-model and a multi-dimensional feature texture extraction sub-model; The deep convolutional neural network sub-model is used to extract multi-scale features from the workpiece surface image to obtain a high-dimensional feature map. The multi-dimensional feature texture extraction sub-model extracts multi-dimensional texture statistical features of the workpiece surface image, and processes the texture statistical features based on the multi-head attention mechanism and the Mamba module to obtain texture feature encoding. The dual-path input model is optimized based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.
2. The method for constructing a surface roughness prediction model according to claim 1, characterized in that, The multi-dimensional texture extraction sub-model extracts multi-dimensional texture statistical features from the workpiece surface image, and processes these features based on a multi-head attention mechanism and a Mamba module to obtain texture feature encoding, including: Multiple texture feature extraction algorithms are used to extract texture features from the workpiece surface image to obtain multi-dimensional texture statistical features; the texture statistical features include gray-level co-occurrence matrix features, gray-level difference statistical features, first-order statistical features, Tamura texture features, wavelet transform features, and local binary pattern features; The gray-level co-occurrence matrix features, the gray-level difference statistical features, the first-order statistical features, the Tamura texture features, the wavelet transform features, and the local binary pattern features are concatenated to obtain the texture feature tensor; The texture feature tensor is processed using a multi-head attention mechanism to obtain an attention-enhanced feature vector; The attention-enhanced feature vector is input into the selective state-space model, and feature modeling and transformation are performed on the attention-enhanced feature vector to obtain a feature sequence; The feature sequence is input into a fully connected layer to obtain texture feature encoding.
3. The method for constructing a surface roughness prediction model according to claim 2, characterized in that, The process employs multiple texture feature extraction algorithms to extract texture features from the workpiece surface image, resulting in multi-dimensional texture statistical features, including: A gray-level co-occurrence matrix in four directions is constructed based on the workpiece surface image, and gray-level co-occurrence matrix features are calculated based on the gray-level co-occurrence matrix; the gray-level co-occurrence matrix features are obtained by splicing together the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels; Calculate the grayscale difference in the target direction of the workpiece surface image, calculate the first mean and the second moment of the angle based on the grayscale difference, and then stitch the first mean and the second moment of the angle together to obtain the grayscale difference statistical features; Calculate the gray-level probability distribution of the workpiece surface image, calculate the second mean, variance and first standard deviation based on the gray-level probability distribution, and concatenate the second mean, variance and first standard deviation to obtain a first-order statistical feature. Calculate the Tamura texture features of the workpiece surface image; the Tamura texture features are obtained by stitching together roughness, contrast, and orientation, where roughness is the mean gray level of the entire workpiece surface image; contrast is the standard deviation of the gray level of the entire workpiece surface image; and orientation is the gray level distribution histogram of the gradient direction of the workpiece surface image. Wavelet decomposition is performed on the workpiece surface image based on wavelet basis functions to obtain wavelet transform features; The workpiece surface image is subjected to neighborhood binarization based on a preset window to obtain binary code, and the binary code is converted into decimal LBP value. Local binary pattern features are determined based on the decimal LBP.
4. The method for constructing a surface roughness prediction model according to claim 3, characterized in that, The step of constructing a gray-level co-occurrence matrix in four directions based on the workpiece surface image, and calculating the gray-level co-occurrence matrix features based on the gray-level co-occurrence matrix includes: Formula used: ; Construct gray-level co-occurrence matrices with included angles of 0°, 90°, 45°, and 135°; in, For size The matrix, The grayscale level represents the image of the workpiece surface, and # represents the number of elements in the set. and Let i be the number of pixels in the image of the workpiece surface. The grayscale value, j is The grayscale value, d is and The distance between them, θ is and The angle with the horizontal axis; Formula used: ; ; ; ; Calculate the texture sharpness, local homogeneity, texture uniformity, and linear correlation of gray levels for the four directions respectively. in, For the clarity of the texture, For local homogeneity, For the uniformity of texture, The linear correlation of gray levels. Let i be the mean of variable i. Let i be the standard deviation of variable i. Let j be the standard deviation of variable j; The gray-level co-occurrence matrix features are obtained by concatenating the texture clarity, local homogeneity, texture uniformity, and linear correlation of gray levels in the four directions.
5. The method for constructing a surface roughness prediction model according to claim 3, characterized in that, The wavelet decomposition of the workpiece surface image based on wavelet basis functions to obtain wavelet transform features includes: Formula used: ; ; The low-frequency approximate components and high-frequency detail components are calculated. Where h[n] is the low-pass filter, g[n] is the high-pass filter, and n is the index of the input signal. This is a low-frequency approximation component. For high-frequency detail components, To decompose the hierarchy, This is the output time; The third mean and the second standard deviation are calculated based on the low-frequency approximation components, and the fourth mean and the third standard deviation are calculated based on the high-frequency detail components. The wavelet transform feature is obtained by concatenating the third mean, the second standard deviation, the fourth mean, and the third standard deviation.
6. The method for constructing a surface roughness prediction model according to claim 3, characterized in that, The determination of local binary pattern features based on the decimal LBP includes: Formula used: ; Calculate a statistical histogram; the statistical histogram is a local binary pattern feature; in, To compile a statistical histogram, The mode value for LBP is in decimal. The x-coordinate of the pixel in the workpiece surface image. The vertical coordinate of the pixel in the workpiece surface image. This is the Dirac function.
7. The method for constructing a surface roughness prediction model according to claim 1, characterized in that, The deep convolutional neural network sub-model is MobileNet Version 3; the dual-path input model further includes a global average pooling layer and a global max pooling layer; the optimization of the surface roughness prediction model based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain the surface roughness prediction model includes: The high-dimensional feature map is processed using a global average pooling layer to obtain the first high-dimensional feature; The high-dimensional feature map is processed using a global max pooling layer to obtain a second high-dimensional feature; The first high-dimensional feature and the second high-dimensional feature are flattened and spliced together to obtain the first fused feature; The first fusion feature and the texture feature encoding are fused together to obtain the second fusion feature; The surface roughness prediction model is optimized based on the first high-dimensional feature, the second fusion feature, the texture feature encoding, and the roughness category label to obtain the surface roughness prediction model.
8. The method for constructing a surface roughness prediction model according to claim 7, characterized in that, The surface roughness prediction model is optimized based on the first high-dimensional feature, the second fusion feature, the texture feature encoding, and the roughness category label to obtain the surface roughness prediction model. The cross-entropy loss function is used to calculate the loss values between the first high-dimensional feature, the second fused feature, and the texture feature encoding and the roughness category label, respectively. Based on the loss value, the dual-path input model is trained using a stochastic gradient descent optimizer to obtain a surface roughness prediction model.
9. A prediction method for a surface roughness prediction model, comprising using a surface roughness prediction model constructed according to any one of claims 1-8, characterized in that, include: Acquire an image of the workpiece surface to be predicted; The surface image of the workpiece to be predicted is input into the surface roughness prediction model to predict the roughness of the workpiece.
10. A device for constructing a surface roughness prediction model, characterized in that, include: The sample data acquisition module is used to acquire sample data, which includes workpiece surface images and roughness category labels. A dual-path input model construction module is used to construct a dual-path input model, which includes at least a deep convolutional neural network sub-model and a multi-dimensional feature texture extraction sub-model. The multi-scale feature extraction module is used to extract multi-scale features from the workpiece surface image using the deep convolutional neural network sub-model to obtain a high-dimensional feature map. The texture statistical feature extraction module is used to extract multi-dimensional texture statistical features of the workpiece surface image through the multi-dimensional feature texture extraction sub-model, and process the texture statistical features based on the multi-head attention mechanism and the Mamba module to obtain texture feature encoding. An optimization module is used to optimize the dual-path input model based on the high-dimensional feature map, the texture feature encoding, and the roughness category label to obtain a surface roughness prediction model.