Multi-category rock and mineral rapid classification method, equipment and storage medium based on ViT framework
Through the rapid classification method of multi-category rocks and minerals based on the ViT framework, and using technologies such as transfer convolution and multi-head attention modules, the problem of rapid and accurate identification of natural rock ore images in large-capacity and multi-category environments has been solved, and the identification of natural rocks and minerals has been realized. Accurate identification of mine images reduces the impact of interference factors.
Patent Information
- Application Number
- CN202111409265.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-25
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2041-11-25
AI Technical Summary
Existing technology is difficult to achieve rapid and accurate identification of natural rock ore images in large-capacity and multi-category situations. Traditional manual identification methods are time-consuming and rely on professional knowledge, and complex interference factors in natural rock ore images lead to inaccurate classification results.
A multi-category rock ore rapid classification method based on the ViT framework is used to extract image features through the preprocessing, data processing and result processing modules of the natural rock ore image recognition model, combined with migration convolution, ECTG, Mlti-Head Attention and STFE modules. And slow down over-fitting to achieve rapid and accurate identification of rock ore images.
It effectively reduces the influence of interference factors in the recognition process, improves the accuracy and reliability of classification results, and achieves fast and accurate recognition in large-capacity and multi-category situations.
Smart Images

Figure CN114219988B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural rock and mineral image recognition, and in particular to a multi-category rock and mineral rapid classification method, device and storage medium based on a ViT framework. Background Art
[0002] The identification and classification of natural rocks and minerals can provide more efficient assistance for field rock and mineral exploration, and is of great significance for the classification of rock and mineral samples in different environments and for non-professionals to understand rock and mineral knowledge.
[0003] Generally speaking, traditional natural rock and mineral identification requires professionals to identify and classify through physical objects or multi-faceted image information. This manual identification method, on the one hand, takes a lot of time, and on the other hand, it also has high requirements for the relevant knowledge of the identification personnel.
[0004] In recent years, the recognition technology in the field of natural rock and mineral images has made remarkable progress. The introduction of deep learning methods has further improved the efficiency of automatic identification of rock and mineral categories, and can classify natural rock and mineral images based on image features. However, natural rock and mineral images are different from other images. Natural rock and minerals come from the natural environment and have more complex and variable interference factors, such as light brightness, shooting angle, the proportion of the target in the image, the clarity of the image, the coverage ratio of impurities on the sample surface, etc. Compared with professional rock and mineral slice images, there are more redundant and dry information, which leads to inaccurate results when classifying multiple categories of natural rock and mineral images.
[0005] In addition, the identification of natural rocks and minerals relies more on the support of data sets and requires feature learning based on a large amount of data. At the same time, the authenticity and reliability of the data are required to ensure the reliability of the learning results.
[0006] Therefore, there is currently no universally applicable method that can solve the problem of being unable to quickly and accurately identify rock and mineral images in large-capacity and multi-category situations. Summary of the invention
[0007] In view of this, the present invention proposes a multi-category rock and mineral rapid classification method based on the ViT framework, which is used to solve the problem that it is impossible to achieve rapid and accurate recognition of rock and mineral images in the case of large-capacity and multi-category.
[0008] The technical solution of the present invention is achieved in this way:
[0009] In a first aspect, the present invention discloses a multi-category rock and mineral rapid classification method based on a ViT framework, and establishes a natural rock and mineral image recognition model to perform multi-category rock and mineral rapid classification. The method comprises:
[0010] S1, collecting rock and mineral image data set samples and inputting them into the preprocessing module of the natural rock and mineral image recognition model to perform feature pre-extraction and suppress overfitting processing, wherein the data set samples include image data and the corresponding category labels, and then proceeding to step S2;
[0011] S2, input the data set samples after the preprocessing module into the data processing module of the natural rock and mineral image recognition model for parameter training and token extraction, and continue to step S3;
[0012] S3, the result processing module of the natural rock and mineral image recognition model performs token separation and category mapping according to the parameter training and token extraction results and outputs the classification results, completing the training of the natural rock and mineral image recognition model; and proceeding to step S4;
[0013] S4, obtaining the image data to be identified and inputting it into the natural rock and mineral image recognition model, completing the classification of the image data to be identified and outputting the result.
[0014] The present invention establishes a natural rock and mineral image recognition model through the above method, obtains important features in the image data, reduces the influence of interference factors on the recognition results during the recognition process, and obtains accurate and reliable classification results.
[0015] On the basis of the above technical solution, preferably, in the natural rock and mineral image recognition model,
[0016] The preprocessing module includes: sequentially connected input layer, image unified format preprocessing module, migration model, ECTG module, and Dropout layer;
[0017] The data processing module includes: sequentially connected parameter regularization layer, Mlti-Head Attention module, Linear layer, ECTG module, Linear+Dropout layer, parameter regularization layer, Linear+GeLU layer, Dropout+Linear layer, Dropout+Linear layer, STFE module, Linear layer;
[0018] The result processing module includes: a parameter regularization layer, an ECTG module, and an RCLinear+Softmax layer connected in sequence.
[0019] The present invention constructs the internal structure of the natural rock and mineral image recognition model through the above method. While adopting the transfer convolution combined with the ViT framework, it adds the STFE module, the ECTG module and the Mlti-Head Attention module, thereby reducing overfitting and extracting the features of the image data more accurately and completely.
[0020] On the basis of the above technical solution, preferably, step S1 specifically includes:
[0021] S1-1, after the data set sample enters the input layer of the natural rock and mineral image recognition model, the image unified format preprocessing module processes the image data in a unified size and color space, and inputs it into the migration model for feature pre-extraction, and then continues to execute step S1-2;
[0022] S1-2, the output mapping layer of the migration model outputs the features of the image data, which are input to the ECTG module for class mark Token extraction, and the Dropout layer suppresses overfitting, and outputs the mark Token corresponding to the image data, which is recorded as Token T;
[0023] The ECTG module includes a linear layer, a dropout layer and a linear layer connected in sequence. The first linear layer is used to map the features, activated by a GeLU function, and then the dropout layer is used to suppress overfitting. The second linear layer maps the features to a Patch Number times the encoding length and then outputs it, where the Patches Number represents the actual number of Patches calculated by presetting the size of the segmented Patches.
[0024] Through the above method, the present invention enables the image data to be processed by the ECTG module, retains the features therein in time, realizes feature pre-extraction of the image data and preliminary suppression of overfitting processing, generates Token T corresponding to the image data, and has better generalization ability and recognition accuracy when Class Token is finally used for category mapping.
[0025] Based on the above technical solution, preferably, Token T specifically includes:
[0026] The Token is generated by fusing the features of n Patches into the 0th Patch through the ECTG module to generate a Token T of the same size as the Patch:
[0027]
[0028] Among them, F is the eigenvalue sequence matrix, f i is the i-th vector of matrix F, W is the weight parameter matrix after training, W j is the jth vector of matrix W, B is the bias parameter matrix, B i is the i-th vector of matrix B, and dim is the size of Patch.
[0029] The present invention generates Token T corresponding to the features of the image data through the above method, which is convenient for final classification and recognition.
[0030] On the basis of the above technical solution, preferably, step S2 specifically includes:
[0031] S2-1, the features output by the preprocessing module mapped to the Patch Number times the coding length are normalized by the parameter regularization layer in the data processing module, and input into the Mlti-HeadAttention module composed of multiple P-Attentions to obtain output data. Different P-Attentions provide an image attention focus area for recognition, and continue to execute step S2-2;
[0032] S2-2, rearrange the parameter shape through the Linear layer to obtain the feature value of each patch in each image data, perform the same processing as step S1-2 through the ECTG module to update Token T, and continue to execute step S2-3;
[0033] S2-3, the eigenvalue is restored through the Linear+Dropout layer to suppress overfitting, and the layer parameters are regularized through the next parameter regularization layer, and then enters the Linear+GeLU layer activation function, passes through two Dropout+Linear layers, and continues to execute step S2-4;
[0034] S2-4, the eigenvalue enters the STFE module to more significantly suppress overfitting, and then passes through a Linear layer to restore the eigenvalue to the feature of the same dimension as S1-2.
[0035] Through the above method, the present invention performs residual connection on the output data of the preprocessing module in step S1 and the output data of the Mlti-Head Attention module in the data processing module in step S2, and outputs the result to the ECTG module in the data processing module, and extracts the features of each image to obtain Token through a convolution layer with a convolution kernel size of 1; the data processing module performs parameter training and Token extraction, wherein the parameter regularization layer maintains the consistency and stability of the data distribution, and the STFE module slows down the training speed to a certain extent, so that the natural rock and mineral image recognition model can fully learn more detailed features.
[0036] Based on the above technical solution, preferably, step S2-1 specifically includes:
[0037] In P-Attention, four matrices are generated through parameters: Query, Key, Filter, and Value. The Value matrix represents the features inherited from the input data, Query represents the query vector group perceived from the input data, Key represents the feature position information vector group perceived from the input data, and Filter represents the probability mask matrix perceived from the input data.
[0038] Get the attention matrix through Query and Key:
[0039]
[0040] The remaining matrix is obtained by Value and Filter:
[0041]
[0042] By multiplying attention and remnant, we finally get the output data:
[0043] out=attention.×remnant
[0044] The Multi-Head Attention here means that there are multiple sets of Query, Key, Filter, and Value being calculated.
[0045] The present invention relies on four sets of auxiliary data generated from the input image data X through a fully connected network through the above method, namely, a query matrix Query, a key matrix Key, a filter matrix Filter, and an eigenvalue matrix Value; the network that generates these four matrices places the four types of information of the original input image data X in these four matrices by adjusting the parameters during the training process, and through the matrix multiplication operation of Query and Key, each vector in Query is multiplied by each vector in Key to obtain the attention position information that is the same as the feature domain of the Value matrix, that is, to inform the model of the location of the area that needs attention; through the product of Filter and Value, the originally isolated values in Value can be filtered and fused, so that each value contains the global information of Value; thereby, the attention matrix is obtained from Query and Key, and the remnant matrix is obtained from Filter and Value, which means that one attention matrix contains the position information that needs attention, and the other remnant matrix contains the feature information at all positions, and then the two are multiplied point by point, so that the information of the prominent position in the attention can be reflected in the remnant.
[0046] Based on the above technical solution, preferably, step S2-4 specifically includes:
[0047] The STFE module uses similarity feature extraction, the principle is:
[0048]
[0049] Wherein M is a real symmetric matrix serving as a mask image, X is the input data, namely the eigenvalue, and dim is the size of the Patch. Dividing by dim is to ensure the distribution consistency of the data.
[0050] The present invention uses the STFE module based on the similarity matrix transformation theory through the above method to generate a mask image through the network for the original input image data X. The data obtained by the similarity transformation based on the mask image is limited by the influence of the probability value distribution in the mask, so that under the premise of retaining the original features, some feature areas in the image are highlighted and the areas in the image that do not want to be perceived are weakened, thereby achieving the purpose of slowing down the occurrence of overfitting.
[0051] On the basis of the above technical solution, preferably, step S3 specifically includes:
[0052] S3-1, the feature is input to the result processing module, through the parameter regularization layer, the Token T corresponding to the feature is stripped through the ECTG module, and the classification result is mapped to a probability value through the RCLinear+Softmax layer;
[0053] The RCLinear layer uses interval compression mapping, the principle is:
[0054]
[0055] E(x i )=-x i 2 +(a i +b i )x i -a i b i
[0056] where y j is the output of the RCLinear layer, x i is the input of the RCLinear layer, e is a constant, a i and b i Indicates the left and right endpoints of the compressed interval, by processing the enhanced interval (a i ,b i ) and suppress the output outside the interval, adjusting the position and length of the interval as the model is trained;
[0057] The probability value is input to the output end of the natural rock and mineral image recognition model. At this time, according to the set depth value, it is decided to return to step S2-1 or continue to execute step S3-2. The depth value is the number of times steps S2-1 to S3-1 are repeated;
[0058] S3-2, the output end of the natural rock and mineral image recognition model processes the probability value into a preset style and displays it on the corresponding input picture.
[0059] The present invention obtains and outputs predicted probability values of image data for multiple categories through the above method, thereby achieving classification of natural rocks and minerals through recognition of natural rock and mineral image data.
[0060] According to a second aspect of the present invention, an electronic device is disclosed, comprising: at least one processor, at least one memory, a communication interface and a bus; wherein the processor, memory and communication interface communicate with each other via the bus; the memory stores a program for a multi-category rapid classification method of rocks and minerals based on a ViT framework that can be executed by the processor, and the program for a multi-category rapid classification method of rocks and minerals based on a ViT framework is configured to implement a multi-category rapid classification method of rocks and minerals based on a ViT framework as described in the first aspect of the present invention.
[0061] In a third aspect of the present invention, a computer-readable storage medium is disclosed, on which is stored a program for a method for rapid classification of multiple categories of rocks and minerals based on a ViT framework. When the program for rapid classification of multiple categories of rocks and minerals based on a ViT framework is executed, the method for rapid classification of multiple categories of rocks and minerals based on a ViT framework as described in the first aspect of the present invention is implemented.
[0062] The multi-category rock and mineral rapid classification method based on the ViT framework of the present invention has the following beneficial effects compared with the prior art:
[0063] (1) Through the natural rock and mineral image recognition model, important features in the image data are obtained, and the influence of interference factors on the recognition results during the recognition process is reduced to obtain accurate and reliable classification results;
[0064] (2) While adopting the transfer convolution combined with the ViT framework, the STFE module, the ECTG module and the Mlti-Head Attention module are added to retain the original characteristics of the image data to the greatest extent, reduce overfitting, improve the fault tolerance of the mapping, pay attention to the different information characteristics of the image data, thereby reducing interference factors, and realize fast and accurate recognition of rock and mineral images in large-capacity and multi-category situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0066] Figure 1 This is a workflow diagram of a multi-category rock and mineral rapid classification method based on the ViT framework of the present invention;
[0067] Figure 2 This is a schematic diagram of the structure of a natural rock and mineral image recognition model for a multi-category rock and mineral rapid classification method based on the ViT framework of the present invention. DETAILED DESCRIPTION
[0068] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] Example
[0070] The workflow of the multi-category rock and mineral rapid classification method based on the ViT framework of the present invention is shown in Figure 1 , the processing steps are as follows:
[0071] The first step is to establish a natural rock and mineral image recognition model to process rock and mineral image data, collect rock and mineral image data set samples and input them into the preprocessing module of the natural rock and mineral image recognition model to perform feature pre-extraction and suppress overfitting processing. The data set samples include image data and corresponding category labels. Go to the second step.
[0072] It should be understood that the natural rock and mineral image recognition model includes a preprocessing module, a data processing module and a result processing module; Figure 2The schematic diagram of the structure of a natural rock and mineral image recognition model of a multi-category rock and mineral rapid classification method based on the ViT framework of the present invention is shown, wherein the preprocessing module includes: a sequentially connected input layer, an image unified format preprocessing module, a migration model, an ECTG (Epitome Class Token Generator) module, and a Dropout layer; the data processing module includes: a sequentially connected parameter regularization layer, an Mlti-Head Attention module, a Linear layer, an ECTG (Epitome Class Token Generator) module, a Linear+Dropout layer, a parameter regularization layer, a Linear+GeLU layer, a Dropout+Linear layer, a Dropout+Linear layer, an STFE (Similar Transform Feature Extraction) module, and a Linear layer; the result processing module includes: a sequentially connected parameter regularization layer, an ECTG (Epitome Class Token Generator) module, and an RCLinear (Regional Compress Linear)+Softmax layer.
[0073] It should be understood that, based on the above technical solution, after the data set samples enter the input layer of the natural rock and mineral image recognition model, the image unified format preprocessing module processes the image data in a unified size and color space, and inputs it into the migration model for feature pre-extraction; when unifying the color space, it is believed through experiments that among the three color spaces of RGB, LAB, and HSV, the LAB space has clearer segmentation boundaries and is more suitable for classification, so the color space can be uniformly converted to LAB, but this is not limited to the use of only LAB.
[0074] It should be understood that, based on the above technical solution, the migration model pre-extracts features of the image data, and outputs the features of the image data in the output mapping layer of the migration model, which are input to the ECTG module for category mapping processing, extracting the class marker Token, suppressing overfitting through the Dropout layer, and outputting the marker Token corresponding to the image data, which is recorded as Token T; the migration model includes but is not limited to MobileNet, ShuffleNet, GhostNet, SqueezeNet;
[0075] The ECTG module includes a linear layer, a dropout layer and a linear layer connected in sequence. The first linear layer is used to map the features, activated by a GeLU function, and then the dropout layer is used to suppress overfitting. The second linear layer maps the features to a Patch Number times the encoding length and then outputs it, where the Patches Number represents the actual number of Patches calculated by presetting the size of the segmented Patches.
[0076] It should be understood that, based on the above technical solution, Token T specifically includes:
[0077] The Token is generated by fusing the features of n Patches into the 0th Patch through the ECTG module to generate a Token T of the same size as the Patch:
[0078]
[0079] Among them, F is the eigenvalue sequence matrix, f i is the i-th vector of matrix F, W is the weight parameter matrix after training, W j is the jth vector of matrix W, B is the bias parameter matrix, B i is the i-th vector of matrix B, and dim is the size of Patch.
[0080] In the second step, the data set samples that have passed the preprocessing module are input into the data processing module of the natural rock and mineral image recognition model for parameter training and token extraction. Go to the third step.
[0081] It should be understood that, based on the above technical solution, the data set samples are mapped to features of Patch Number times the coding length through the preprocessing module, and then normalized through the parameter regularization layer in the data processing module to maintain the consistency and stability of the data distribution and avoid excessive gradients caused by numerical differences. Then, the samples enter the Mlti-Head Attention module composed of multiple P-Attentions to obtain output data. Different P-Attentions provide a focus area of image attention for recognition.
[0082] It should be understood that four matrices are generated by parameters in the P-Attention: Query, Key, Filter, and Value, where the Value matrix represents the features inherited from the input data, the Query represents the query vector group perceived from the input data, the Key represents the feature position information vector group perceived from the input data, and the Filter represents the probability mask matrix perceived from the input data;
[0083] Get the attention matrix through Query and Key:
[0084]
[0085] The remaining matrix is obtained by Value and Filter:
[0086]
[0087] By multiplying attention and remnant, we finally get the output data:
[0088] out=attention.×remnant
[0089] The Multi-Head Attention here means that there are multiple sets of Query, Key, Filter, and Value being calculated.
[0090] It should be understood that after the Mlti-Head Attention module, the Linear layer rearranges the parameter shape to obtain the feature value of each Patch in each image data. In the ECTG module, a convolution layer with a convolution kernel size of 1 is used to extract the features of each image to obtain a Token, and the new Token is used to update the Token in the original data to achieve the update of Token T.
[0091] It should be understood that after updating Token T, the features are restored and overfitting is suppressed through the Linear+Dropout layer, the layer parameters are regularized through the next parameter regularization layer, and then the Linear+GeLU layer activation function is entered. After two layers of Dropout+Linear layers, it comes to the STFE module for more significant overfitting suppression, and then a Linear layer is passed to restore the eigenvalues to features of the same dimension as the first step, and the data is re-encoded into feature data, so that each Patch is restored to a feature map of unified dimension.
[0092] It should be understood that the STFE module is based on the similarity matrix transformation theory. The original input image data X is generated through the network to obtain a mask image. The data obtained through the similarity transformation based on the mask image is limited by the influence of the probability value distribution in the mask, so that under the premise of retaining the original features, some feature areas in the image are highlighted and the areas that are not desired to be perceived in the image are weakened, thereby achieving the purpose of slowing down the occurrence of overfitting; while performing the similarity transformation, in order to ensure the consistency of the variance of the original data distribution, the transformation result is divided by the encoding dimension so that the variance of the numerical distribution of the transformation result remains unchanged. Therefore, adding the STFE module can effectively suppress the occurrence of overfitting, but it has specific applicability, that is, it is suitable for input data containing interference information;
[0093] The principle of STFE module is:
[0094]
[0095] Wherein M is a real symmetric matrix serving as a mask image, X is the input data, namely the eigenvalue, and dim is the size of the Patch. Dividing by dim is to ensure the distribution consistency of the data.
[0096] In the third step, the result processing module of the natural rock and mineral image recognition model performs token separation and category mapping according to the parameter training and token extraction results to complete the training of the natural rock and mineral image recognition model. Go to the fourth step.
[0097] It should be understood that the features of the image data output in the third step and the corresponding Token T are input to the result processing module, and the Token T corresponding to the features is stripped through the parameter regularization layer, and the classification results are mapped to probability values through the RCLinear+Softmax layer;
[0098] The RCLinear layer uses interval compression mapping to improve the generalization ability and fault tolerance of mapping. The principle is:
[0099]
[0100] E(x i )=-x i 2 +(a i +b i )x i -a i b i
[0101] where y j is the output of the RCLinear layer, x i is the input of the RCLinear layer, e is a constant, a iand b i Indicates the left and right endpoints of the compressed interval, by processing the enhanced interval (a i ,b i ) and suppress the output outside the interval. As the model is trained, the position and length of the interval are adjusted to allow the model to have better generalization ability.
[0102] The probability value is input to the output end of the natural rock and mineral image recognition model. At this time, it is determined whether the depth value reaches the preset depth value. The depth value is the number of times the second step to the third step is repeated. If it is satisfied, the training of the natural rock and mineral image recognition model is completed and the fourth step is continued; if it is not satisfied, it returns to the second step and continues the training of the natural rock and mineral image recognition model.
[0103] It should be understood that, in order to retain the features of the image data that has been processed for interference suppression by the STFE module in a timely manner, the ECTG module first restores the features to two-dimensional features, thereby augmenting the two-dimensional position information, and then uses a one-dimensional convolutional layer to fuse the features of n Patches into the 0th Patch, that is, the Class Token, and then performs a GeLU activation, and finally flattens the two-dimensional feature information into a one-dimensional feature code; the ECTG module can have better generalization ability and recognition accuracy when the Class Token is finally used for category mapping.
[0104] Step 4: Output the predicted probability values of the image data in the rock and mineral image dataset samples for multiple categories as the output results, and process the results into pre-designed styles, text annotations or icons, etc., and display them on the input image. Go to step 5.
[0105] For example, the features of image data are input into the ECTG module. The ECTG module passes the input [100, 50, 128] data through a convolution layer with a convolution kernel size of 1, extracts the features of each image to obtain Token T with a shape of [100, 1, 128], and inputs this Token T into the RCLinear+Softmax layer; the original data [100, 1, 128] is mapped to the hidden layer code through the RCLinear+Softmax layer. Assuming that the hidden layer code dimension is equal to the final number of categories of 10, the first step is to remap the input data to [100, 1, 10], and then pass through the SoftMax layer, so that the predicted probability values of each image for ten categories are obtained; these ten probability values are used as output results and displayed on the image in the form of preset text annotations.
[0106] The fifth step is to complete the construction and training of the natural rock and mineral image recognition model, collect the image data to be recognized, and input it into the trained natural rock and mineral image recognition model. The preprocessing module, data processing module and result processing module in the natural rock and mineral image recognition model perform classification and recognition and output the classification results of the image to be recognized.
[0107] The present invention also discloses an electronic device, comprising: at least one processor, at least one memory, a communication interface and a bus; wherein the processor, memory and communication interface communicate with each other through the bus; the memory stores a multi-category rock and mineral rapid classification method program based on the ViT framework that can be executed by the processor, and the multi-category rock and mineral rapid classification method program based on the ViT framework is configured to implement a multi-category rock and mineral rapid classification method based on the ViT framework as described in an embodiment of the present invention.
[0108] The present invention also discloses a computer-readable storage medium, on which is stored a multi-category rock and mineral rapid classification method program based on the ViT framework. When the multi-category rock and mineral rapid classification method program based on the ViT framework is executed, a multi-category rock and mineral rapid classification method based on the ViT framework as described in an embodiment of the present invention is implemented.
[0109] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A multi-category rapid classification method for rocks and minerals based on the ViT framework. It is characterized in that A natural rock and mineral image recognition model is established to quickly classify multiple categories of rocks and minerals. The method comprises the following steps: S1, collecting rock and mineral image data set samples and inputting them into the preprocessing module of the natural rock and mineral image recognition model to perform feature pre-extraction and suppress overfitting processing, wherein the data set samples include image data and the corresponding category labels, and then proceeding to step S2; S2, input the data set samples after the preprocessing module into the data processing module of the natural rock and mineral image recognition model for parameter training and token extraction, and continue to step S3; S3, the result processing module of the natural rock and mineral image recognition model performs token separation and category mapping according to the parameter training and token extraction results and outputs the classification results, completing the training of the natural rock and mineral image recognition model; and proceeding to step S4; S4, obtaining the image data to be identified and inputting it into the natural rock and mineral image recognition model, completing the classification of the image data to be identified and outputting the result; In the natural rock and mineral image recognition model, The preprocessing module includes: an input layer, an image unified format preprocessing module, a migration model, an ECTG module, and a Dropout layer connected in sequence; The data processing module includes: a parameter regularization layer, a Mlti-Head Attention module, a Linear layer, an ECTG module, a Linear+Dropout layer, a parameter regularization layer, a Linear+GeLU layer, a Dropout+Linear layer, a Dropout+Linear layer, a STFE module, and a Linear layer connected in sequence; The result processing module includes: a parameter regularization layer, an ECTG module, and an RCLinear+Softmax layer connected in sequence.
2. A multi-category rock and mineral rapid classification method based on ViT framework as claimed in claim 1, It is characterized in that The step S1 specifically includes: S1-1, after the data set sample enters the input layer of the natural rock and mineral image recognition model, the image unified format preprocessing module processes the image data in a unified size and color space, and inputs it into the migration model for feature pre-extraction, and then continues to execute step S1-2; S1-2, the output mapping layer of the migration model outputs the features of the image data, which are input to the ECTG module for class mark Token extraction, and the Dropout layer suppresses overfitting, and outputs the mark Token corresponding to the image data, which is recorded as TokenT; The ECTG module includes a linear layer, a dropout layer and a linear layer connected in sequence. The first linear layer is used to map the features, activated by a GeLU function, and then the dropout layer is used to suppress overfitting. The second linear layer maps the features to a Patch Number times the encoding length and then outputs it, where the Patches Number represents the actual number of Patches calculated by presetting the size of the segmented Patches.
3. A multi-category rock and mineral rapid classification method based on ViT framework as claimed in claim 2, It is characterized in that The Token T specifically includes: The Token is generated by fusing the features of n Patches into the 0th Patch through the ECTG module to generate a Token T of the same size as the Patch: Among them, F is the eigenvalue sequence matrix, f i is the i-th vector of matrix F, W is the weight parameter matrix after training, W j is the jth vector of matrix W, B is the bias parameter matrix, B i is the i-th vector of matrix B, and dim is the size of Patch.
4. A multi-category rock and mineral rapid classification method based on ViT framework as claimed in claim 2, It is characterized in that The step S2 specifically includes: S2-1, the features output by the preprocessing module mapped to the Patch Number times the coding length are normalized by the parameter regularization layer in the data processing module, and input into the Mlti-HeadAttention module composed of multiple P-Attentions to obtain output data. Different P-Attentions provide an image attention focus area for recognition, and continue to execute step S2-2; S2-2, rearrange the parameter shape through the Linear layer to obtain the feature value of each patch in each image data, perform the same processing as step S1-2 through the ECTG module to update Token T, and continue to execute step S2-3; S2-3, the eigenvalue is restored through the Linear+Dropout layer to suppress overfitting, and the layer parameters are regularized through the next parameter regularization layer, and then enters the Linear+GeLU layer activation function, passes through two Dropout+Linear layers, and continues to execute step S2-4; S2-4, the eigenvalue enters the STFE module to more significantly suppress overfitting, and then passes through a Linear layer to restore the eigenvalue to the feature of the same dimension as S1-2.
5. A multi-category rock and mineral rapid classification method based on ViT framework as claimed in claim 4, It is characterized in that The step S2-1 specifically includes: In P-Attention, four matrices are generated through parameters: Query, Key, Filter, and Value. The Value matrix represents the features inherited from the input data, Query represents the query vector group perceived from the input data, Key represents the feature position information vector group perceived from the input data, and Filter represents the probability mask matrix perceived from the input data. Get the attention matrix through Query and Key: The remaining matrix is obtained by Value and Filter: By multiplying attention and remnant, we finally get the output data: out=attention.×remnant The Multi-Head Attention here means that there are multiple sets of Query, Key, Filter, and Value being calculated.
6. A multi-category rock and mineral rapid classification method based on ViT framework as claimed in claim 5, It is characterized in that The step S2-4 specifically includes: The STFE module uses similarity feature extraction, the principle is: Wherein M is a real symmetric matrix serving as a mask image, X is the input data, namely the eigenvalue, and dim is the size of the Patch. Dividing by dim is to ensure the distribution consistency of the data.
7. A multi-category rock and mineral rapid classification method based on ViT framework as claimed in claim 4, It is characterized in that The step S3 specifically includes: S3-1, the feature is input to the result processing module, through the parameter regularization layer, the Token T corresponding to the feature is stripped through the ECTG module, and the classification result is mapped to a probability value through the RCLinear+Softmax layer; The RCLinear layer uses interval compression mapping, the principle is: E(x i )=-x i 2 +(a i +b i )x i -a i b i where y j is the output of the RCLinear layer, x i is the input of the RCLinear layer, e is a constant, a i and b i Indicates the left and right endpoints of the compressed interval. The interval (a i ,b i ), suppressing the output outside the interval, and adjusting the position and length of the interval during model training; The probability value is input to the output end of the natural rock and mineral image recognition model. At this time, according to the set depth value, it is decided to return to step S2-1 or continue to execute step S3-2. The depth value is the number of times steps S2-1 to S3-1 are repeated; S3-2, the output end of the natural rock and mineral image recognition model processes the probability value into a preset style and displays it on the corresponding input picture.
8. An electronic device, It is characterized in that It includes at least one processor, at least one memory, a communication interface and a bus; wherein the processor, memory and communication interface communicate with each other through the bus; the memory stores a multi-category rock and mineral rapid classification method program based on the ViT framework that can be executed by the processor, and the multi-category rock and mineral rapid classification method program based on the ViT framework is configured to implement a multi-category rock and mineral rapid classification method based on the ViT framework as claimed in any one of claims 1 to 7.
9. A computer-readable storage medium, It is characterized in that The storage medium stores a multi-category rock and mineral rapid classification method program based on the ViT framework, and when the multi-category rock and mineral rapid classification method program based on the ViT framework is executed, it implements a multi-category rock and mineral rapid classification method based on the ViT framework as claimed in any one of claims 1 to 7.
