Aluminum alloy grade identification method based on lightweight spectral attention network
The aluminum alloy grade recognition method is converted into a two-dimensional spectrum through Gram field transform and lightweight spectral attention network, which solves the problems of long time consumption of traditional methods and insufficient generalization ability of existing algorithms, and realizes accurate recognition and robustness of aluminum alloy grades, which is suitable for aerospace, automobile manufacturing, building structures and other fields.
Patent Information
- Application Number
- CN202411652117.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-11-19
AI Technical Summary
Traditional aluminum alloy grade identification methods are time-consuming, costly, and not suitable for large-scale rapid screening. Existing machine learning algorithms have problems of overfitting and insufficient generalization when processing high-dimensional spectral data, making it difficult to accurately distinguish aluminum alloy grades.
The Gram field transform is used to convert the one-dimensional XRF spectrum into a two-dimensional spectrum. Combined with the lightweight spectral attention network, a lightweight spatial self-attention network LSAFormer is designed. Through adaptive calculation, it focuses on important information and suppresses redundant information, thereby achieving accurate identification of aluminum alloy grades.
It improves the accuracy and robustness of aluminum alloy grade recognition, realizes non-destructive and rapid aluminum alloy grade recognition, and is suitable for aerospace, automobile manufacturing, building structure and other fields, and is suitable for mobile terminal deployment.
Smart Images

Figure CN119513576B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of spectral technology and deep learning technology, and specifically provides an aluminum alloy brand recognition method based on Gram field transform combined with a lightweight spectral attention network. Background Art
[0002] As a lightweight, high-strength metal material, aluminum alloy has been widely used in aerospace, automobile manufacturing, building structures and other fields. There are many grades of aluminum alloy, and each grade has different alloy composition and properties, suitable for different application scenarios. Correctly identifying the grade of aluminum alloy is crucial to ensure that the material properties meet the specified engineering requirements. However, traditional aluminum alloy grade identification methods have some limitations, and a more intelligent and efficient identification method is urgently needed.
[0003] Traditional aluminum alloy grade identification typically relies on chemical analysis and mechanical property testing, which are often time-consuming, costly, and somewhat destructive. For example, chemical analysis requires dissolving the sample and using techniques such as spectral analysis to determine the alloy composition, while mechanical property testing requires operations such as stretching or compressing the material. These methods are not only inefficient but also unsuitable for large-scale rapid screening and online testing. Furthermore, with the increasing variety of aluminum alloy materials, it has become difficult to accurately distinguish different aluminum alloy grades based solely on appearance or simple physical testing. Therefore, the development of a fast, non-destructive, and intelligent aluminum alloy grade identification method is of great practical significance.
[0004] In recent years, with the development of spectral technology and machine learning algorithms, intelligent recognition methods based on spectral analysis have gradually become a research hotspot. For example, laser-induced breakdown spectroscopy (LIBS) and X-ray fluorescence spectroscopy (XRF) technology can quickly obtain the chemical composition information of materials by analyzing the spectrum generated on the surface of the material. Combined with machine learning algorithms, spectral data can be analyzed in depth to achieve intelligent recognition of aluminum alloy grades. However, there are still some challenges in aluminum alloy grade recognition. First, the chemical composition difference between different aluminum alloy grades may be small, leading to overlapping spectral features and increasing the difficulty of recognition. Second, factors such as the surface state and oxide layer thickness of aluminum alloy materials can also affect the stability and accuracy of spectral signals. In addition, the XRF spectra of different grades of aluminum alloys are very similar, making it challenging to distinguish alloy types directly from one-dimensional spectra. Background interference and matrix effects in one-dimensional XRF spectra can also affect decision accuracy. Finally, existing machine learning algorithms may have problems such as overfitting and insufficient generalization ability when dealing with high-dimensional spectral data. To overcome these problems, more advanced data processing and feature extraction methods need to be developed to improve the accuracy and robustness of the recognition method. In addition, advanced machine learning techniques such as deep learning can better exploit complex patterns in spectral data and improve the intelligent recognition ability of aluminum alloy grades. SUMMARY
[0005] The purpose of the present application is to provide an aluminum alloy grade recognition method based on a lightweight spectral attention network to improve the accuracy and robustness of aluminum alloy grade recognition. First, the present application converts one-dimensional XRF spectra into two-dimensional spectral images through Gram field transformation (GAF) to enrich spatial information and amplify spectral detail differences. Then, the present application proposes a lightweight spectral attention module that focuses on important information in the spectral image and suppresses redundant information through lightweight adaptive computation. Finally, a lightweight spatial self-attention network (LSAFormer) is designed based on the lightweight spatial attention module and the ShuffleNet structure to achieve accurate recognition of aluminum alloy grades.
[0006] To achieve the above purpose, the technical scheme adopted by the present application is as follows:
[0007] An aluminum alloy grade recognition method based on a lightweight spectral attention network, characterized in that it comprises the following steps:
[0008] Obtain XRF one-dimensional spectral information of aluminum alloy samples of prior grades, encode the XRF one-dimensional spectral information using Gram angle difference field transformation to obtain Gram angle difference field (GADF);
[0009] Take the Gram angle difference field of the aluminum alloy sample as input and the prior grade of the aluminum alloy sample as label to form a training set;
[0010] Construct a lightweight spectral attention network and complete the training. The lightweight spectral attention network includes: a convolutional module (Conv stem), a patch embedding layer (Patch embedding), a first lightweight spectral attention module (LSA), a first patch conversion layer (Patch merge), a second lightweight spectral attention module (LSA), a second patch conversion layer (Patch merge), a third lightweight spectral attention module (LSA), a maximum pooling layer (AvgPool) and a classification head (Classification head).
[0011] The XRF one-dimensional spectrum information of the aluminum alloy to be tested is obtained and converted into the Gram angle difference field, which is input into the trained lightweight spectral attention network, and then the lightweight spectral attention network outputs the brand recognition result.
[0012] Furthermore, the specific process of Gram angle difference field transformation is:
[0013] First, the XRF one-dimensional spectrum information is normalized to obtain the normalized spectrum sequence Expressed as represents the spectral intensity of the i-th channel in the normalized spectral sequence, and n represents the number of channels of the XRF one-dimensional spectral information;
[0014] Then, the normalized spectral sequence is processed using the piecewise aggregate approximation algorithm (PAA). Perform dimensionality reduction processing to obtain a reduced-dimensional spectrum sequence Expressed as represents the spectral intensity of the i-th channel in the dimensionality-reduced spectral sequence, and L represents the number of channels after dimensionality reduction using the segmented aggregation approximation algorithm;
[0015] Then, the dimension-reduced spectral sequence Transform to polar coordinates: φ i Indicates the angle value;
[0016] Finally, the Gram Angle Difference Field (GADF) is calculated:
[0017]
[0018] Here, GADF stands for Gram Angle Difference Field.
[0019] Furthermore, in the lightweight spectral attention network, the input of the convolution module is marked as C in , the output is marked as C out , the convolution module is specifically expressed as:
[0020] C out =GELU(BN 2d (PConv(Conv 2d (C in ))))
[0021] Among them, Conv 2d represents two-dimensional convolution, PConv represents point convolution, BN 2d represents two-dimensional batch normalization, and GELU represents the GELU activation function.
[0022] Furthermore, in the lightweight spectral attention network, the input of the Patch embedding layer is marked as Pe in , the output is marked as Pe out , the Patch embedding layer is specifically expressed as:
[0023] Pe out =Norm(proj(Pe in ))
[0024] Among them, proj represents Patch embedding and Norm represents normalization.
[0025] Furthermore, in the lightweight spectral attention network, the input of the lightweight spectral attention module is marked as L in , the output is marked as L out , then the lightweight spectral attention module is specifically expressed as:
[0026]
[0027] Among them, Norm means normalization, LFFN means lightweight feedforward enhancement module, LMHA means lightweight multi-head self-attention module, represents matrix addition;
[0028] Furthermore, the input of the lightweight multi-head self-attention module (LMHA) is labeled as LM in , the output is marked as LM out , the lightweight multi-head self-attention module is specifically expressed as:
[0029] Q,K,V=BN 1d (Conv 1d (LM in ))
[0030]
[0031] LM out =PConv(W)
[0032] Among them, BN1d Represents one-dimensional batch normalization, Conv 1d Represents a convolution, Sigmoid represents the sigmoid activation function, PConv represents the point convolution, represents matrix multiplication; K T represents the transpose of the K matrix; W represents the weight matrix, which is used to represent the importance distribution in space.
[0033] Furthermore, the input of the lightweight feedforward enhancement module (LFFN) is marked as LF in , output mark is LF out , the lightweight feedforward enhancement module is specifically expressed as:
[0034] LF out =GELU(PConv(GELU(PConv(LF in ))))
[0035] Among them, PConv represents point convolution and GELU represents GELU activation function.
[0036] Furthermore, in the lightweight spectral attention network, the input of the Patch conversion layer is marked as Pm in , output marked as Pm out , the Patch conversion layer is specifically expressed as:
[0037] Pm out =PConv(Pm in )
[0038] Among them, PConv represents point convolution.
[0039] Furthermore, in the lightweight spectral attention network, the classification head includes: two fully connected layers (FCLayer) and a softmax classifier connected in sequence.
[0040] Furthermore, during the training process of the lightweight spectral attention network, the loss function is set to the cross entropy loss function, and the Adam optimizer is used to complete the training of the lightweight spectral attention network.
[0041] Based on the above technical solution, the beneficial effects of the present invention are:
[0042] The present invention proposes an aluminum alloy brand recognition method based on Gram field transform combined with a lightweight spectral attention network. First, the one-dimensional XRF spectrum is converted into a two-dimensional spectrum through Gram field transform (GAF) to enrich the spatial information and amplify the differences in spectral details; then, a lightweight spectral attention module is proposed, which reduces the amount of computation, focuses on important information of the spectrum and suppresses redundant information through simple adaptive calculation; finally, based on the lightweight spatial attention module and combined with the ShuffleNet structure, a lightweight spatial self-attention network (LSAFormer) is designed to achieve accurate recognition of aluminum alloy brands, effectively improving the accuracy and robustness of aluminum alloy brand recognition; and, as an end-to-end deep learning model, the aluminum alloy brand recognition method in the present invention can accurately identify the alloy brand without complex preprocessing of the sample. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is a flow chart of the aluminum alloy grade recognition method based on Gram field transform combined with lightweight spectral attention network in the present invention.
[0044] Figure 2 Schematic diagram of the structure of the lightweight spatial spectral attention module and the lightweight spectral attention network in the present invention. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and beneficial effects of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0046] This embodiment provides an aluminum alloy brand recognition method based on Gram field transform combined with lightweight spectral attention network, the process is as follows: Figure 1 As shown, the specific steps include:
[0047] Step 1. Obtain XRF one-dimensional spectrum information of the aluminum alloy sample of the prior grade;
[0048] Several aluminum alloy materials of a priori grades are obtained and made into standard samples after grinding, drying and other treatments. The XRF one-dimensional spectrum sequence of the standard samples is obtained using a handheld energy dispersive X-ray fluorescence spectrometer; the original spectrum sequence of each standard sample is expressed as X = {x1, x2, ..., x i ,...,x n}, where n represents the number of channels (i.e., the sequence length, n = 1000), xi represents the spectral intensity of the i-th channel in the original spectral sequence, i = 1, 2, ..., n;
[0049] Step 2. Use Gram angle difference field transform to encode the XRF one-dimensional spectrum information to obtain the encoding feature;
[0050] First, the XRF one-dimensional spectrum sequence is normalized and scaled to the range of [0, 1]. The normalization process is specifically expressed as:
[0051]
[0052] in, Represents the spectral intensity of the i-th channel in the normalized spectral sequence, which is the spectral intensity x i Normalized result; min(X) and max(X) represent the minimum and maximum values of the original spectrum sequence X respectively;
[0053] After the original spectral sequence X undergoes the above normalization process, the normalized spectral sequence is obtained. Expressed as
[0054] Then, the normalized spectral sequence is processed using the piecewise aggregate approximation algorithm (PAA). Perform dimensionality reduction processing; PAA is a feature extraction algorithm based on segmented sequence averaging. It first divides the sequence into segments of equal length, and then uses the segment average to represent the value of all data in the segment. Specifically expressed as:
[0055]
[0056] in, Represents the spectral mean of the i-th segment in the dimensionality reduction spectrum sequence, and the length of each segment is n represents the length of the sequence after normalization, and L represents the length of the sequence after dimensionality reduction using the segmented aggregation approximation algorithm.
[0057] Normalized spectral sequence After the above dimensionality reduction process, the reduced dimensionality spectrum sequence is obtained Expressed as The dimension-reduced spectral sequence can still reflect the overall trend of the original spectral sequence and smooth the noise to varying degrees, thereby improving the performance of the classifier;
[0058] Then, the one-dimensional spectrum sequence in the rectangular coordinate system after dimensionality reduction is transformed into the polar coordinate system, which can be expressed as follows:
[0059]
[0060] Among them, φ i Indicates the angle value;
[0061] Finally, the Gram Angular Difference Field (GADF) is obtained by calculating the sine of the angle difference between different points, which is specifically expressed as:
[0062]
[0063] wherein GADF represents the Gram angle difference field, the main diagonal of the matrix is composed of the original spectral sequence, and the sequence of the spectral signal can be maintained;
[0064] Step 3. The Gram angle difference field of the aluminum alloy sample is taken as input, and the prior brand of the aluminum alloy sample is taken as label to form a data set, and the data set is divided into a training set and a test set according to a ratio of 8:2;
[0065] Step 4. A lightweight spectral attention network is constructed;
[0066] The lightweight spectral attention network is as shown in Figure 2 , and includes a convolution module (Conv stem), a Patch embedding layer, a first lightweight spectral attention module (LSA), a first Patch merge layer, a second lightweight spectral attention module (LSA), a second Patch merge layer, a third lightweight spectral attention module (LSA), an average pooling layer (AvgPool) and a classification head (Classification head) connected in sequence.
[0067] The input data of the lightweight spectral attention network is the Gram angle difference field (GADF) after Gram field transformation coding, that is, a two-dimensional spectral matrix. First, the convolution module (Conv stem) is used to realize preliminary extraction of features and control of spatial dimensions, and the size (dimension C is 64) of the spatial feature map is compressed to obtain a spectral feature map I0. After preliminary feature extraction, the spectral feature map I0 is subjected to position coding by the Patch embedding layer (Patch embedding) and is sent to the lightweight spectral attention module. By self-correlation calculation between feature maps, important areas in the aluminum alloy two-dimensional image space are roughly focused on to obtain a spectral feature output I1. The spectral feature output I1 is sequentially subjected to the first Patch merge layer (Patch merge), the second lightweight spectral attention module (LSA), the second Patch merge layer (Patch merge) and the third lightweight spectral attention module (LSA) to map the feature map to a higher spatial dimension and a smaller spatial size, complete feature refinement and focus on finer features, and the dimensions are 128 and 256, respectively, to obtain a spectral feature output I2. The spectral feature output I2 integrates the features by the average pooling layer, and then the classification head (classification head) is used to complete classification to obtain a recognition result.
[0068] Further, the convolution module (Conv stem) is as shown in Figure 2 (a), and the input of the convolution module is marked as Cin , the output is marked as C out , then the convolution module is specifically expressed as:
[0069] C out =GELU(BN 2d (PConv(Conv 2d (C in ))))
[0070] Among them, Conv 2d represents two-dimensional convolution, PConv represents point convolution, BN 2d represents two-dimensional batch normalization, GELU represents the GELU activation function;
[0071] Furthermore, the Patch embedding layer is as follows Figure 2 As shown in (b), the input of the Patch embedding layer is marked as Pe in , the output is marked as Pe out , then the Patch embedding layer is specifically expressed as:
[0072] Pe out =Norm(proj(Pe in ))
[0073] Among them, proj represents Patch embedding, and Norm represents normalization;
[0074] Furthermore, the lightweight spectral attention module (LSA) is Figure 2 As shown in (c), the standard Transformer encoder architecture is used to obtain an attention feature map through inexpensive convolution and autocorrelation calculations. Attention calculations are then performed on the input feature map, adaptively focusing on the important information of the encoded two-dimensional spectral matrix and suppressing redundant information. Finally, a lightweight feedforward neural network is used to increase the nonlinearity of the model, thereby mining deep spectral features and improving classification performance.
[0075] Specifically, the input of the lightweight spectral attention module is marked as L in , the output is marked as L out , then the lightweight spectral attention module is specifically expressed as:
[0076]
[0077] Among them, Norm means normalization, LFFN means lightweight feedforward enhancement module, LMHA means lightweight multi-head self-attention module, represents matrix addition;
[0078] Furthermore, the lightweight multi-head self-attention module (LMHA) is Figure 2 As shown in (d), the input of the lightweight multi-head self-attention module (LMHA) is marked as LM in , the output is marked as LM out , then the lightweight multi-head self-attention module is specifically expressed as:
[0079] Q,K,V=BN 1d (Conv 1d (LM in ))
[0080]
[0081] LM out =PConv(W)
[0082] Among them, BN 1d Represents one-dimensional batch normalization, Conv 1d Represents a convolution, Sigmoid represents the sigmoid activation function, PConv represents the point convolution, represents matrix multiplication; K T represents the transpose of the K matrix; W represents the weight matrix, which is used to represent the importance distribution in space;
[0083] In the lightweight multi-head self-attention module (LMHA), in order to perform multi-head autocorrelation calculation, the query matrix Q, key matrix K and value matrix V in the spectral space must be generated first; the multi-head autocorrelation calculation calculates the similarity score between each spectral element and other spectral elements through the Q, K, and V matrices in the two-dimensional spectral space, and then generates a new representation of the spectral features through a normalization method, that is, the similarity matrix of the spectral features is obtained by the dot product of the Q matrix and the K matrix, and then the features are normalized into probability distributions through an activation function, and finally weighted into the V matrix to obtain a spatial attention map; in the lightweight spectral attention module (LSA), the spatial attention map output by the lightweight multi-head self-attention module is connected to the input feature map through residual learning, which can effectively prevent feature degradation; in addition, the lightweight feedforward enhancement network LFFN is used to enhance the network's expressiveness.
[0084] Furthermore, the lightweight feedforward enhancement module (LFFN) such as Figure 2 As shown in (f), the input of the lightweight feedforward enhancement module (LFFN) is marked as LF in , output mark is LF out , then the lightweight feedforward enhancement module is specifically expressed as:
[0085] LF out =GELU(PConv(GELU(PConv(LF in ))))
[0086] Among them, PConv represents point convolution, GELU represents GELU activation function;
[0087] Furthermore, the Patch merge layer is as follows Figure 2 As shown in (e), the input of the Patch conversion layer is marked as Pm in , output marked as Pm out , then the Patch conversion layer is specifically expressed as:
[0088] Pm out =PConv(Pm in )
[0089] Among them, PConv represents point convolution;
[0090] Furthermore, the classification head includes: two fully connected layers (FCLayer) and a softmax classifier connected in sequence; the two fully connected layers are FCLayer1 and FCLayer2, the number of neurons in FCLayer1 is 32, and the number of neurons in FCLayer2 is 8, which is the number of output categories;
[0091] Step 5. Set the loss function and use the Adam optimizer to train the lightweight spectral attention network;
[0092] The training data is fed into the lightweight spectral attention network for training. The batch size of the training process is 60, the number of iterations is 100, and the network parameters are optimized using the Adam optimizer. The loss function is the cross entropy loss function, specifically:
[0093]
[0094] Among them, p(x m ) represents the true distribution, q(x m ) represents the predicted distribution, M represents the number of categories;
[0095] Step 6. Use steps 1 to 2 to obtain the Gram angle difference field (GADF) of the aluminum alloy to be identified, input it into the trained lightweight spectral attention network, and the lightweight spectral attention network outputs the brand recognition result.
[0096] The beneficial effects of the present invention are described in detail below in conjunction with simulation tests.
[0097] In this embodiment, accuracy, precision, recall, and F1-score are introduced as evaluation indicators of classification performance. The closer the value of each indicator is to 1, the better the classification performance of the surface model. The calculation formulas for the above indicators are:
[0098]
[0099] Among them, TP is true positive, TN is true negative, FP is false positive, and FN is false negative;
[0100] At the same time, the number of parameters and computational complexity are selected to measure the complexity of the model. Parameters (Params) reflect the spatial complexity of the model, and the number of operations (MACs) represents the time complexity of the model. The lower their values, the lower the model complexity.
[0101] In this embodiment, a total of 2190 sets of 8 different grades of alloy spectrum data were collected, X = {x1, x2, ..., x i ,...,x 1000}, after Gram angle difference field transformation, the Gram angle difference field (GADF) of each set of spectral data is obtained as a two-dimensional spectral matrix; the training set and test set are divided into training set and test set in a ratio of 8:2, with a total of 1752 samples in the training set and 438 samples in the test set; after the lightweight spectral attention network is trained on the training set, it is tested on the test set; the test is repeated five times to obtain the standard deviation of the mean, and the test results are Accuracy: 97.44% ± 0.33, Precision: 97.50% ± 0.33, Recall: 97.61% ± 0.26, F1-score: 97.52% ± 0.11, Params: 3.21M, MACs: 0.59G.
[0102] Furthermore, the lightweight spectral attention network (LSAFormer) in this embodiment is compared with other advanced classification models. The comparison examples include: one-dimensional comparison methods (PCA-SVM, 1D-CNN, DeepSpectra, SpectraNet-32, MLP and LucasVGGNet-16); two-dimensional comparison methods (ResT, LightViT, EfficientV1, EfficientV2 and ResNet18); the comparison results of the one-dimensional method with one-dimensional spectral data as input are shown in the figure. As shown in Table 1, the Train_Acc of PCA-SVM, 1D-CNN, DeepSpectra, SpectraNet-32, MLP and LucasVGGNet-16 are 84.84%, 79.85%, 88.15%, 79.99%, 95.41% and 98.02%, respectively, and the Test_Acc are 84.93%±1.44, 91.10%±3.13, 91.87%±1.31, 92.23%±1.44, 92.83%±1.02 and 93.74%±1.10, respectively. The comparison results of using two-dimensional GADF spectral data as input are shown in Table 2. The Train_Acc of ResT, LightViT, EfficientV1, EfficientV2 and ResNet18 are 94.82%, 97.74%, 98.47%, 99.01%, 99.15%, respectively, and the Test_Acc are 94.33%±1.41, 95.66%±1.04, 96.98%±0.63, 96.43%±0.58, 96.80%±0.72, respectively.
[0103] Table 1
[0104] Model Train_Acc Test_Acc Precision Recall F1-score PCA-SVM 84.84% 84.93%±1.44 84.61%±1.64 84.71%±1.29 83.74%±1.43 1D-CNN 79.85% 91.10%±3.13 92.71%±1.86 93.80%±2.75 91.26%±2.57 DeepSpectra 88.15% 91.87%±1.31 93.87%±1.78 90.94%±2.77 90.37%±3.01 SpectraNet-32 79.99% 92.23%±1.44 90.82%±4.97 93.40%±5.00 90.71%±4.56 MLP 95.41% 92.83%±1.02 92.76%±1.37 93.05%±1.07 92.77%±1.14 LucasVGGNet-16 98.02% 93.74%±1.10 94.49%±2.56 94.57%±3.29 93.88%±2.81
[0105] Table 2
[0106] Model Train_Acc Test_Acc Precision Recall F1-score Params MACs ResT 94.82% 94.33%±1.41 94.15%±1.21 94.47%±2.07 94.14%±1.52 9.99M 1.47G LightViT 97.74% 95.66%±1.04 95.72%±1.14 95.53%±1.52 95.56%±1.33 8.11M 0.72G EfficientV1 98.47% 96.98%±0.63 96.78%±1.06 97.04%±0.61 96.84%±0.85 4.02M 0.39G EfficientV2 99.01% 96.43%±0.58 96.50%±0.89 96.15%±1.09 96.22%±0.84 20.19M 2.88G ResNet18 99.15% 96.80%±0.72 96.62%±1.08 96.96%±0.86 96.73%±0.93 11.54M 1.76G LSAFormer 99.76% 97.44%±0.33 97.50%±0.33 97.61%±0.26 97.52%±0.11 3.21M 0.59G
[0107] As can be seen from Tables 1 and 2, the lightweight spectral attention network proposed in this paper achieves the best overall classification performance; in addition, due to its lightweight computing method and network structure, LSAFormer also shows great advantages in model complexity and is expected to be deployed and applied on mobile terminals.
[0108] To sum up, the application firstly enriches the spatial information and amplifies the spectral detail differences by converting the one-dimensional XRF spectrum into a two-dimensional spectrum through Gram field transformation, and then designs a lightweight spectral attention network (LSAFormer) to realize accurate identification of aluminum alloys of different brands; The accuracy of classification is improved, which shows that LSAFormer effectively focuses on important information of the spectrum and suppresses redundant information, and in addition, the lightweight calculation method and network structure embody the superiority of the method of the application.
[0109] The above is only a specific embodiment of the application, and any feature disclosed in the specification can be replaced by other equivalent or similar purpose alternative features unless specifically described. All features disclosed or all steps in the method or process can be combined in any way except for mutually exclusive features and / or steps.
Claims
1. A method for aluminum alloy brand recognition based on lightweight spectral attention network, characterized in that: The following steps are involved: Obtain the XRF one-dimensional spectrum information of the aluminum alloy sample of the prior grade, and use Gram angle difference field transformation to encode the XRF one-dimensional spectrum information to obtain the Gram angle difference field; The Gram angle difference field of the aluminum alloy sample is used as input, and the prior grade of the aluminum alloy sample is used as the label to form a training set; Construct a lightweight spectral attention network and complete training. The lightweight spectral attention network includes: a convolution module, a patch embedding layer, a first lightweight spectral attention module, a first patch conversion layer, a second lightweight spectral attention module, a second patch conversion layer, a third lightweight spectral attention module, a maximum pooling layer, and a classification head connected in sequence; In the lightweight spectral attention network, the input of the lightweight spectral attention module is marked as L in , the output is marked as L out , then the lightweight spectral attention module is specifically expressed as: Among them, Norm means normalization, LFFN means lightweight feedforward enhancement module, LMHA means lightweight multi-head self-attention module, represents matrix addition; The input of the lightweight multi-head self-attention module is labeled LM in , the output is marked as LM out , the lightweight multi-head self-attention module is specifically expressed as: Q,K,V=BN 1d (Conv 1d (LM in )) LM out =PConv(W) Among them, BN 1d Represents one-dimensional batch normalization, Conv 1d Represents one-dimensional convolution, Sigmoid represents sigmoid activation function, PConv represents point convolution, represents matrix multiplication; K T represents the transpose of the K matrix; W represents the weight matrix, which is used to represent the importance distribution in the space; Q represents the query matrix, K represents the key matrix, and V represents the value matrix; The input of the lightweight feedforward augmentation module is marked as LF in , output mark is LF out , the lightweight feedforward enhancement module is specifically expressed as: LF out =GELU(PConv(GELU(PConv(LF in )))) Among them, PConv represents point convolution, GELU represents GELU activation function; In the lightweight spectral attention network, the input of the Patch conversion layer is marked as Pm in , output marked as Pm out , the Patch conversion layer is specifically expressed as: Pm out =PConv(Pm in ) Among them, PConv represents point convolution; The XRF one-dimensional spectrum information of the aluminum alloy to be tested is obtained and converted into the Gram angle difference field, which is input into the trained lightweight spectral attention network, and then the lightweight spectral attention network outputs the brand recognition result.
2. The aluminum alloy grade recognition method based on lightweight spectral attention network according to claim 1 is characterized in that: The specific process of Gram angle difference field transformation is: First, the XRF one-dimensional spectrum information is normalized to obtain the normalized spectrum sequence Expressed as represents the spectral intensity of the i-th channel in the normalized spectral sequence, and n represents the number of channels of the XRF one-dimensional spectral information; Then, the normalized spectral sequence is approximated using the segmented aggregation algorithm. Perform dimensionality reduction processing to obtain a reduced-dimensional spectrum sequence Expressed as represents the spectral intensity of the i-th channel in the dimensionality-reduced spectral sequence, and L represents the number of channels after dimensionality reduction using the segmented aggregation approximation algorithm; Then, the dimension-reduced spectral sequence Transform to polar coordinates: φ i Indicates the angle value; Finally, calculate the Gram angle difference field: Here, GADF stands for Gram Angle Difference Field.
3. The aluminum alloy grade recognition method based on lightweight spectral attention network according to claim 1 is characterized in that: In the lightweight spectral attention network, the input of the convolution module is marked as C in , the output is marked as C out , the convolution module is specifically expressed as: C out =YELLOW(BN 2d (PConv(Conv 2d (C in )))) in, Conv 2d represents two-dimensional convolution, PConv represents point convolution, BN 2d represents two-dimensional batch normalization, and GELU represents the GELU activation function.
4. The aluminum alloy grade recognition method based on lightweight spectral attention network according to claim 1 is characterized in that: In the lightweight spectral attention network, the input of the Patch embedding layer is marked as Pe in , the output is marked as Pe out , the Patch embedding layer is specifically expressed as: On out =Norm(proj(Pe in )) Among them, proj represents Patch embedding and Norm represents normalization.
5. The aluminum alloy grade recognition method based on lightweight spectral attention network according to claim 1 is characterized in that: In the lightweight spectral attention network, the classification head consists of two fully connected layers and a softmax classifier connected in sequence.
6. The aluminum alloy grade recognition method based on lightweight spectral attention network according to claim 1 is characterized in that: During the training process of the lightweight spectral attention network, the loss function is set to the cross entropy loss function, and the Adam optimizer is used to complete the training of the lightweight spectral attention network.
Citation Information
Patent Citations
Image-level hyperspectral image classification method
CN114781534A
Intelligent data and knowledge-driven method for modulation recognition
US11700156B1