A graphite ore grade classification model training method, application method and related device
By constructing a TRA-FFNet model based on ResNet-50 and Transformer, the problem of high time-consuming and cost-effective traditional graphite ore grade detection methods is solved, and the rapid and accurate identification and classification of graphite ore grade is achieved, which improves production efficiency and reduces Testing cost.
Patent Information
- Application Number
- CN202410561008.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-05-08
AI Technical Summary
Traditional graphite ore grade detection methods are time-consuming, costly and time-consuming, making it difficult to meet the needs of modern industrial production for rapid, accurate, economical and environmental protection.
Using the TRA-FFNet model built on ResNet-50 deep residual network and Transformer deep neural network, a fast and accurate graphite is designed by using graphite ore image samples. Ore grade classification model.
It realizes rapid and accurate identification and classification of graphite ore grades, reduces detection time and cost, improves production efficiency, and effectively prevents overfitting under limited data sets.
Smart Images

Figure CN118485859B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of graphite ore grade classification, and in particular to a graphite ore grade classification model training method, an application method and related devices. Background Art
[0002] As an important natural resource, graphite ore has a wide range of applications covering multiple key industrial fields. In China, graphite ore is not only an important pillar of national industrial development, but also one of the key materials for the development of emerging technology fields. As the world's largest graphite producer and consumer, China's dependence on graphite ore resources is growing, and the accurate and rapid detection of graphite ore grade has become more important. However, traditional graphite ore grade detection methods mainly rely on chemical analysis technology, such as high-frequency infrared carbon-sulfur analyzers. This method is time-consuming and costly, and has the problem of insufficient timeliness in large-scale sample analysis. Solving the time lag problem is the key to improving production efficiency. In view of this, it is of great significance to develop a faster, more accurate, economical and environmentally friendly graphite ore carbon grade identification and classification model, which is also in response to the needs of modern industrial production intelligent development. Summary of the invention
[0003] The purpose of the present invention is to provide a graphite ore grade classification model training method, application method and related device, which can quickly and accurately identify and classify the graphite ore grade.
[0004] To achieve the above object, the present invention provides the following solutions:
[0005] In a first aspect, the present invention provides a graphite ore grade classification model training method, the method comprising:
[0006] A training set is obtained; the training set is graphite ore image samples of several categories.
[0007] The graphite ore image samples in the training set are input into the TRA-FFNet model to obtain the grade classification output of the TRA-FFNet model; the TRA-FFNet model is a model built based on the ResNet-50 deep residual network and the Transformer deep neural network.
[0008] The loss value is determined according to the grade classification output of the TRA-FFNet model, the category corresponding to the graphite ore image sample in the training set, and the determined loss function.
[0009] The network parameters of the TRA-FFNet model are optimized according to the loss value to obtain a graphite ore grade classification model.
[0010] Optionally, the obtaining of a training set specifically includes:
[0011] Image enhancement processing is performed on several categories of graphite ore original images to obtain graphite ore image samples corresponding to the several categories; the image enhancement processing includes: random inversion and center cropping.
[0012] Optionally, the TRA-FFNet model includes:
[0013] Input module, used to input graphite ore image samples.
[0014] The first feature extraction module is used to extract features from the graphite ore image sample to obtain a first feature map.
[0015] The second feature extraction module is used to extract features from the first feature map to obtain a second feature map.
[0016] The third feature extraction module is used to extract features from the second feature map to obtain a third feature map.
[0017] The fourth feature extraction module is used to perform channel weighting of the third feature map to obtain a weighted feature map, and perform feature extraction on the weighted feature map to obtain a fourth feature map; the channel weighting of the feature map is implemented through TransformerBlock.
[0018] The first adaptive maximum pooling layer is connected to the second feature extraction module and is used to adjust the size of the second feature map to obtain a first adjusted feature map.
[0019] The second adaptive maximum pooling layer is connected to the third feature extraction module and is used to adjust the size of the third feature map to obtain a second adjusted feature map.
[0020] The third adaptive maximum pooling layer is connected to the fourth feature extraction module and is used to adjust the size of the fourth feature map to obtain a third adjusted feature map; the sizes of the first adjusted feature map, the second adjusted feature map and the third adjusted feature map are equal.
[0021] A fusion module is used to fuse the first adjustment feature map, the second adjustment feature map and the third adjustment feature map to obtain a fused feature map; the fused feature map is a feature map of a one-dimensional vector.
[0022] The fully connected layer is connected to the fusion module and is used to classify the fused feature map to obtain the grade classification output of the graphite ore image sample.
[0023] Optionally, the TransformerBlock includes:
[0024] The compression unit is used to compress the width direction and the height direction of the third feature map respectively to obtain features in the width direction and the height direction.
[0025] The fusion unit is used to fuse the features in the width direction and the height direction to obtain a fusion feature.
[0026] The dimension reduction unit is used to reduce the dimension of the fused feature to obtain a reduced dimension feature.
[0027] The Transformer Encoder unit is used to extract features from the dimensionality reduction features through a self-attention mechanism to obtain a feature sequence.
[0028] A weight coefficient determination unit is used to determine the weight coefficient according to the feature sequence.
[0029] A weighted feature map determining unit is used to multiply the third feature map by the weight coefficient to obtain a weighted feature map.
[0030] Optionally, the fusion module includes:
[0031] The splicing unit is used to splice the first adjustment feature map, the second adjustment feature map and the third adjustment feature map to obtain a spliced feature map.
[0032] The channel number adjustment unit is used to adjust the channel number of the spliced feature map to obtain a feature map after the channel number is adjusted.
[0033] The adaptive average pooling layer is used to adjust the size of the feature map after the number of channels is adjusted, and obtain a feature map of a one-dimensional vector through a Flatten operation.
[0034] Optionally, the loss function is a CrossEntropyLoss loss function.
[0035] In a second aspect, the present invention provides a graphite ore grade classification model application method, the method comprising:
[0036] Obtain a sample of the graphite ore image to be detected.
[0037] The graphite ore image sample to be detected is input into a graphite ore grade classification model to obtain a graphite ore grade classification; the graphite ore grade classification model is a model trained according to a graphite ore grade classification model training method described in the first aspect.
[0038] In a third aspect, the present invention provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of a graphite ore grade classification model training method as described in the first aspect, or executes the steps of a graphite ore grade classification model application method as described in the second aspect.
[0039] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a graphite ore grade classification model training method described in the first aspect, or executes the steps of a graphite ore grade classification model application method described in the second aspect.
[0040] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of a graphite ore grade classification model training method described in the first aspect, or executes the steps of a graphite ore grade classification model application method described in the second aspect.
[0041] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0042] The present invention provides a graphite ore grade classification model training method, application method and related devices. The graphite ore grade classification model of the present invention is a model constructed based on the deep residual network of ResNet-50 and the deep neural network of Transformer. The model takes graphite ore image samples as input and graphite ore grade classification as output, and can quickly and accurately identify and classify graphite ore grades. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] 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 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.
[0044] Figure 1 A schematic flow chart of a graphite ore grade classification model training method provided in Example 1 of the present invention.
[0045] Figure 2 It is a schematic structural diagram of a basic Bottle Neck module provided for Example 1 of the present invention.
[0046] Figure 3 The images of some grades of graphite ore provided in Example 1 of the present invention are as follows: Figure 3 (a) graphite ore with a carbon content of 1% to 2%; Figure 3 (b) graphite ore with a carbon content of 10% to 11%; Figure 3 (c) Graphite ore with a carbon content of 19% to 20%.
[0047] Figure 4 A schematic diagram of the network structure of the TRA-FFNet model provided in Example 1 of the present invention.
[0048] Figure 5 A schematic diagram of the structure of the TransformerBlock module provided in Example 1 of the present invention.
[0049] Figure 6 A schematic flow chart of a method for applying a graphite ore grade classification model provided in Example 2 of the present invention.
[0050] Figure 7 This is a diagram of the internal structure of a computer device provided in Example 6 of the present invention. DETAILED DESCRIPTION
[0051] The following will be combined with the drawings in 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.
[0052] Image classification technology based on deep learning has shown significant impact in many fields, including remote sensing image processing, medical image analysis, intelligent traffic monitoring, smart agriculture construction, natural resource management, industrial product defect detection, etc. In recent years, more and more scholars have applied deep learning to the field of ore image processing, directly predicting the grade of graphite ore based on its image. This technology does not require destructive chemical treatment of ore samples, can automatically process a large amount of image data, and can also provide intuitive visualization results to help users understand the grade of ore more intuitively. Compared with chemical detection methods, the image recognition-based method is suitable for deploying the developed graphite ore grade identification and classification system on embedded devices. It has certain accuracy and portability, and can realize online real-time high-precision sorting of ore.
[0053] For the detection of carbon content in graphite ore, although the traditional chemical detection method can provide high detection precision and accuracy and strong reliability, it has extremely high requirements on the quality of the relevant operators, and requires rich chemical knowledge and practical experience. In addition, when faced with heavy measurement tasks, this method requires a long detection time, and the time cost is too high, which affects production efficiency. In contrast, image recognition technology based on deep learning has the advantages of rapid identification and real-time sorting. However, most of the current research based on deep learning focuses on distinguishing the classification of different types of ores, while there are relatively few studies on multi-category classification and identification based on the content of a certain substance in the same ore. This also means that when dealing with the classification of carbon grade in graphite ore, methods based on deep learning face some challenges.
[0054] The present invention constructs a graphite ore dataset containing 19 categories of different grades. By analyzing the dataset, it is found that in the classification and recognition of graphite ore images, there is not much difference in space between ores of different grades, that is, the shapes and positions of ores of different categories are similar. The main basis for classification is the luster, color, texture, scales, edges and other characteristics of the ore. However, the graphite ore image shows a random distribution of texture features on the image plane, which is composed of multi-level and multi-angle textures, has relatively high complexity, and feature extraction is relatively difficult.
[0055] In order to improve the accuracy and reliability of artificial intelligence algorithms in the task of graphite ore grade identification, two problems need to be solved. The first is to design an efficient feature extraction network. In view of the complex characteristics of graphite ore, it is necessary to develop a special feature extraction strategy to effectively extract image features. The second is to solve the problem that the algorithm is prone to overfitting under limited data sets.
[0056] The purpose of the present invention is to provide a graphite ore grade classification model training method, application method and related device, which can quickly and accurately identify and classify the graphite ore grade.
[0057] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0058] Example 1
[0059] like Figure 1 As shown, this embodiment provides a graphite ore grade classification model training method, the method comprising:
[0060] A1: Obtain a training set; the training set is graphite ore image samples of several categories.
[0061] A2: Input the graphite ore image samples in the training set into the TRA-FFNet model to obtain the grade classification output of the TRA-FFNet model; the TRA-FFNet model is a model built based on the ResNet-50 deep residual network and the Transformer deep neural network.
[0062] Among them, the ResNet-50 deep residual network consists of six main parts, including an input module, four module groups and an output module. The input module consists of 64 convolution kernels of size (7, 7) and stride 2 and (3, 3) maximum pooling downsampling operations with a stride of 2. This module is responsible for accepting input image data and performing a series of convolution and pooling operations on the image to extract features and reduce spatial dimensions. After this module, the number of output channels of the feature map is 64; The ResNet-50 deep residual network contains 4 module groups, each of which contains multiple residual modules. The function of these module groups is to gradually reduce the size of the feature map and increase the depth of the feature map. a. The first module group uses 3 residual layers, and the number of feature map channels outputted by this stage is 256; b. The second module group uses 4 residual layers, and the number of feature map channels outputted by this stage is 512; c. The third module group uses 6 residual layers, and the number of feature map channels outputted by this stage is 1024; d. The fourth module group uses 3 residual layers, and the number of feature map channels outputted by this stage is 2048; The output module consists of a global average downsampling layer, a fully connected layer, and a softmax operation, which is used to map the feature vector obtained by the pooling operation to the category probability distribution and output the probability of belonging to each category.
[0063] The four module groups are respectively composed of 3, 4, 6, and 3 Bottle Neck residual blocks stacked together. The building blocks of the network model are essentially residual block structures. The basic Bottle Neck modules are as follows: Figure 2As shown. The number of channels of the input feature map is 256. After passing through the first layer of 64 (1, 1) convolution layers, the height and width of the feature map remain unchanged, the number of channels becomes 64, and the feature map undergoes a dimensionality reduction operation; after passing through the relu activation function, it passes through the second layer of 64 (3, 3) convolution layers, which is the core part of the Bottle Neck structure and is responsible for capturing the spatial information in the feature map; finally, after passing through the relu activation function, it enters the third layer, and the third layer passes through 256 (1, 1) convolution kernels, and the output channel of the feature map becomes 256 again, and the feature map undergoes a dimensionality increase operation. ResNet uses a skip connection method to add the input x and the final output F (x) to obtain the final residual block output. This structure is conducive to the flow of information and improves the network depth. In view of the characteristics of the graphite mine data set, the parameter amount of the deep convolutional neural network used in the present invention should not be too large, but it is also necessary to have a deeper number of network layers and a stronger feature extraction capability. Therefore, it is better to select ResNet-50 as the backbone feature extraction network. The structure diagram of ResNet-50 is shown in Table 1.
[0064] Table 1 Structure of ResNet-50
[0065]
[0066]
[0067] In the task of graphite ore image recognition and classification, the present invention adopts a transfer learning strategy that applies the ResNet-50 network architecture to the ImageNet database, that is, migrating the model parameters pre-trained on ImageNet (source domain) to the task of ore image classification (target domain). The ImageNet database itself contains 12 million images covering 1,000 different categories. These images are feature-rich and contain a variety of color and texture information, providing a rich visual feature learning foundation for deep learning models. The improved TRA-FFNet model proposed in the present invention uses the pre-trained weights on ImageNet to initialize the model parameters. This initialization method significantly improves the accuracy in the early stage of model training.
[0068] A3: Determine the loss value according to the grade classification output of the TRA-FFNet model, the categories corresponding to the graphite ore image samples in the training set, and the determined loss function.
[0069] A4: The network parameters of the TRA-FFNet model are optimized according to the loss value to obtain a graphite ore grade classification model.
[0070] It should be noted that the graphite ore image samples input into the graphite ore grade classification model are preprocessed samples.
[0071] Thanks to the outstanding performance of convolutional neural networks in image processing, this embodiment proposes a TRA-FFNet model for the classification of 19 types of graphite ore. The images of graphite ore of some grade categories are as follows: Figure 3 shown.
[0072] This embodiment proposes a graphite ore image recognition and classification model based on the deep residual network ResNet-50, and designs a transformer module based on spatial feature compression fusion. At the same time, in order to better extract and utilize the surface graphic features of the ore, global context information fusion is introduced to allow the shallow features of the image to also participate in the final classification decision, and pre-trained weights are used for transfer learning.
[0073] As an optional implementation method provided in this embodiment, step A1 specifically includes:
[0074] Image enhancement processing is performed on several categories of graphite ore original images to obtain graphite ore image samples corresponding to the several categories; the image enhancement processing includes: random inversion and center cropping.
[0075] Although the design of the backbone network has optimized the feature extraction capability of the TRA-FFNet network to a certain extent, the interaction between images and semantic information between different layers is still the main bottleneck limiting recognition accuracy. Usually, the shallow layers of the backbone network mainly respond to image features, such as texture, color, and edges, but also contain more interference information; while the deep layers tend to respond to abstract semantic features, such as object categories and overall structures. Deep learning uses the hierarchical principle to extract features layer by layer and feed back the extracted low-level information to the high-level layers. How to retain the semantic information of high-level features without losing the low-level structure is the focus of research. The problem of ore recognition and classification mainly depends on the surface features of the image, while the features used by the deep neural network for classification decisions are the deep semantic features of the image. To solve this problem, a global context information fusion module is introduced to splice features from different levels, and the representation ability of the model is improved by fusing the multi-level feature maps extracted from different backbone layers.
[0076] This embodiment proposes a graphite ore identification method that integrates low-level features and high-level features, such as Figure 4 As shown in the figure, this embodiment uses the pre-trained ResNet-50 for feature extraction. The network in this paper embeds a Figure 5The TransformerBlock module shown in the figure first passes the feature map output by Layer3 through TransformerBlock to perform channel weighting of the feature map, and then passes it through three Bottle Neck blocks. Since the sizes of feature maps extracted by Layer2, Layer3 and Layer4 are different, an adaptive maximum pooling (adaptive_max_pool2d) is added after the feature maps extracted by Layer2, Layer3 and Layer4. Maximum pooling can obtain strong texture features of ore images and convert the feature maps output by these three layers into the same size of 16×16 to obtain a more compact representation, which is conducive to subsequent feature fusion. First, use Concat to splice the feature maps of the three layers, and then use a Conv2d convolution layer with a convolution kernel size of 3 and a step size of 2 to adjust the number of channels of the fused feature image, and integrate the information of different channels into a more compact representation, which helps the network learn higher-level features. At the same time, use adaptive average pooling to adjust the size of the feature map to 1×1, and then use the Flatten operation to flatten this two-dimensional feature map into a one-dimensional vector, and finally input it into the fully connected layer (classifier) for classification.
[0077] Specifically, Figure 4 As shown, the TRA-FFNet model includes:
[0078] Input module, used to input graphite ore image samples.
[0079] The first feature extraction module is used to extract features from the graphite ore image sample to obtain a first feature map.
[0080] The second feature extraction module is used to extract features from the first feature map to obtain a second feature map.
[0081] The third feature extraction module is used to extract features from the second feature map to obtain a third feature map.
[0082] The fourth feature extraction module is used to perform channel weighting of the third feature map to obtain a weighted feature map, and perform feature extraction on the weighted feature map to obtain a fourth feature map; the channel weighting of the feature map is implemented through TransformerBlock.
[0083] The first adaptive maximum pooling layer is connected to the second feature extraction module and is used to adjust the size of the second feature map to obtain a first adjusted feature map.
[0084] The second adaptive maximum pooling layer is connected to the third feature extraction module and is used to adjust the size of the third feature map to obtain a second adjusted feature map.
[0085] The third adaptive maximum pooling layer is connected to the fourth feature extraction module and is used to adjust the size of the fourth feature map to obtain a third adjusted feature map; the sizes of the first adjusted feature map, the second adjusted feature map and the third adjusted feature map are equal.
[0086] A fusion module is used to fuse the first adjustment feature map, the second adjustment feature map and the third adjustment feature map to obtain a fused feature map; the fused feature map is a feature map of a one-dimensional vector.
[0087] The fully connected layer is connected to the fusion module and is used to classify the fused feature map to obtain the grade classification output of the graphite ore image sample.
[0088] Transformer is a deep neural network based on the self-attention mechanism, consisting of an encoder and a decoder. It is a model architecture for sequence-to-sequence learning.
[0089] Transformer is applied to mineral image recognition. The conventional method is to flatten the image and input it into the transformer as a sequence. However, since the image is a matrix, the length of the sequence generated by flattening the image is too long, which is prone to two problems: 1. It is difficult for the transformer to capture the dependency between pixels and the features of the mineral image are not optimized; 2. The amount of computation and memory are increased, and the computational complexity is too high. To solve these two problems, it is hoped that the feature sequence can be shortened as much as possible while retaining the features. To overcome the above challenges, this embodiment designs a Transformerblock structure based on spatial feature compression and fusion. This structure aims to optimize the length of the feature sequence while retaining key image feature information. It is expected that the Transformer can more efficiently capture the correlation between feature map channels and weight different channels. The detailed structure of the designed Transformer is shown below. Figure 5 shown.
[0090] Assume there is a feature map F(X,Y,C), the image height is H, width is W, and the number of channels is CH, that is, X∈[0,W], Y∈[0,H], C∈[0,CH], first, compress the feature map F along the width and height directions respectively to extract the abstract representation F in the width and height directions W and F H .
[0091]
[0092]
[0093] Among them, i is the loop variable, representing each row or column.
[0094] Next, the features F in these two directions are W and F H Fusion is performed to obtain a comprehensive feature F1.
[0095] F1=Concat(F W , F H ) (3);
[0096] The fused feature F1 is then subjected to dimensionality reduction processing to obtain a more compact feature representation F2.
[0097] F2 = Conv1D(F1) (4);
[0098] The reduced feature sequence F2 is then input into the Transformer Encoder module, and the feature F3 is further extracted through the self-attention mechanism, which effectively shortens the feature sequence length while minimizing feature loss.
[0099] F3 = Transformer (F2) (5);
[0100] After that, the output feature sequence of the Transformer is converted into a vector whose length is consistent with the number of channels of the feature map. By taking the mean of the vector, it is compressed to the channel dimension and the weight coefficient α of each channel is obtained. The weight is used to indicate the importance of each channel to the final feature representation. Here, n represents the sequence length.
[0101]
[0102] Finally, these weights α are multiplied with the original feature map F to obtain the weighted feature map F 加权 , which can emphasize more important channels and reduce the influence of unimportant channels.
[0103] F 加权 =F(X, Y, C)·α (7);
[0104] This process compresses and fuses the information of the height and width of the feature map, further refines the features through the Transformer encoder, and strengthens the key information through the channel attention mechanism, thereby reducing the feature dimension while maintaining important information, reducing the size and computing requirements of the model, and facilitating subsequent processing or learning tasks.
[0105] Specifically, the TransformerBlock includes:
[0106] The compression unit is used to compress the width direction and the height direction of the third feature map respectively to obtain features in the width direction and the height direction.
[0107] The fusion unit is used to fuse the features in the width direction and the height direction to obtain a fusion feature.
[0108] The dimension reduction unit is used to reduce the dimension of the fused feature to obtain a reduced dimension feature.
[0109] The TransformerEncoder unit is used to extract features from the dimensionality reduction features through a self-attention mechanism to obtain a feature sequence.
[0110] A weight coefficient determination unit is used to determine the weight coefficient according to the feature sequence.
[0111] A weighted feature map determining unit is used to multiply the third feature map by the weight coefficient to obtain a weighted feature map.
[0112] Optionally, the fusion module includes:
[0113] The splicing unit is used to splice the first adjustment feature map, the second adjustment feature map and the third adjustment feature map to obtain a spliced feature map.
[0114] The channel number adjustment unit is used to adjust the channel number of the spliced feature map to obtain a feature map after the channel number is adjusted.
[0115] The adaptive average pooling layer is used to adjust the size of the feature map after the number of channels is adjusted, and obtain a feature map of a one-dimensional vector through a Flatten operation.
[0116] As an optional implementation provided by this embodiment, the loss function is a CrossEntropyLoss loss function.
[0117] In specific applications, taking the identification of graphite ore with a grade range of 1% to 20% as an example, the grade category is subdivided into 19 categories, namely 1% to 2%, 2% to 3%, 3% to 4%, ... 19% to 20%. The main steps to implement the invention are as follows:
[0118] 1. Build the image feature extraction model TRA-FFNet based on Python3.8 programming language and Pytorch1.8.1 deep learning framework.
[0119] 2. The ResNet-50 model was pre-trained on the ImageNet dataset, and the Top-1 accuracy of the model reached 90.633%.
[0120] 3. Save the pre-trained ResNet-50 model parameters to a binary file for later use.
[0121] 4. Perform image enhancement processing on the collected 19 categories of graphite mine image samples, including random inversion, center cropping and other operations, to increase the richness and diversity of training data.
[0122] 5. The graphite mine dataset is automatically divided into a training set and a test set in a ratio of 8:2, where the training set contains 6542 images and the test set contains 1627 images.
[0123] 6. A graphite ore recognition model was built based on Python 3.8 programming language and Pytorch 1.8.1 deep learning framework. The model parameters saved in step 3 were reloaded into the image feature extraction network, and the network parameters were randomly initialized.
[0124] 7.Train the TRA-FFNet model on the graphite ore image dataset. After preprocessing the image dataset, adjust the image resolution to 300×300 and input it into the neural network. Use stochastic gradient descent (SGD) as the optimizer, set the batch size to 64, that is, train and test 64 images per iteration, set the total number of iterations (Epoch) to 300, and select the CrossEntropyLoss loss function as the loss function. In order to more effectively adjust the learning rate, the cosine annealing (Cosine Decay) learning rate decay strategy is adopted, with the initial learning rate (lr) being 0.01 and the decay parameter being set to 0.05. This strategy aims to gradually reduce the learning rate when the model approaches the global minimum of the loss function, so as to promote more accurate convergence of the model.
[0125] 8. After each training cycle is completed, use the test set to detect the accuracy and loss function of the model. If the accuracy keeps increasing or the loss function keeps decreasing, continue to train the model, otherwise terminate the training.
[0126] 9. After training, a graphite ore grade recognition model with a grade range of 1% to 20% was obtained on the test set, with a recognition accuracy of 93.142%, a precision of 94.044%, a recall rate of 94.061%, and an F1 value of 94.023%, showing a very good balance between precision and recall. This research result provides reliable technical support for graphite ore grade recognition.
[0127] Compared with the existing inventions, the innovations of this invention are as follows: (1) A graphite ore grade recognition model based on deep learning is proposed, which realizes accurate classification and recognition of graphite ore in an end-to-end manner. (2) In the recognition and classification process of graphite ore images, transfer learning technology is introduced. Transfer learning can improve the generalization ability of the model and improve the classification accuracy when the data set is insufficient, while effectively preventing the model from overfitting. (3) Considering the rich and diverse graphite ore images and the complex feature extraction, the present invention designs a Transformer structure based on spatial feature compression and fusion, which weights the feature map channels, and reduces the parameters and calculation amount of the model while capturing feature dependencies. (4) The present invention proposes a global context feature fusion structure, which can effectively integrate low-level features such as color and texture of graphite ore into the high-level layer of the backbone network, ensuring that these features will not disappear as the network depth increases, realizing the effective use of features at different levels, and finally obtaining a more comprehensive feature representation.
[0128] Example 2
[0129] like Figure 6 As shown, this embodiment provides a graphite ore grade classification model application method, the method comprising:
[0130] B1: Obtain a sample of graphite ore image to be detected.
[0131] B2: Inputting the graphite ore image sample to be detected into a graphite ore grade classification model to obtain a graphite ore grade classification; the graphite ore grade classification model is a model trained according to a graphite ore grade classification model training method described in Example 1.
[0132] It should be noted that the graphite ore image samples to be detected that are input into the graphite ore grade classification model are pre-processed samples.
[0133] Example 3
[0134] This embodiment provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of a graphite ore grade classification model training method described in Example 1, or to implement the steps of a graphite ore grade classification model application method described in Example 2.
[0135] Example 4
[0136] This embodiment provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of a graphite ore grade classification model training method described in Example 1 are implemented, or the steps of a graphite ore grade classification model application method described in Example 2 are implemented.
[0137] Example 5
[0138] This embodiment provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of a graphite ore grade classification model training method described in Example 1, or executes the steps of a graphite ore grade classification model application method described in Example 2.
[0139] Example 6
[0140] A computer device, which may be a database, may have an internal structure as shown in Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store pending transactions. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps of a graphite ore grade classification model training method described in Example 1 are implemented, or the steps of a graphite ore grade classification model application method described in Example 2 are executed.
[0141] It should be noted that the object information (including but not limited to object device information, object personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the object or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0142] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided by the present invention may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited thereto. The processor involved in each embodiment provided by the present invention may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited thereto.
[0143] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0144] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A graphite ore grade classification model training method, characterized in that: The method comprises: Obtaining a training set; the training set is graphite ore image samples of several categories; Inputting the graphite ore image samples in the training set into the TRA-FFNet model to obtain the grade classification output of the TRA-FFNet model; the TRA-FFNet model is a model constructed based on the ResNet-50 deep residual network and the Transformer deep neural network; Determine a loss value according to the grade classification output of the TRA-FFNet model, the category corresponding to the graphite ore image sample in the training set, and the determined loss function; The network parameters of the TRA-FFNet model are optimized according to the loss value to obtain a graphite ore grade classification model; The TRA-FFNet model includes: An input module, used for inputting graphite ore image samples; A first feature extraction module, used to extract features from the graphite ore image sample to obtain a first feature map; A second feature extraction module, used to extract features from the first feature map to obtain a second feature map; A third feature extraction module, used to extract features from the second feature map to obtain a third feature map; A fourth feature extraction module, used for performing channel weighting of the feature map on the third feature map to obtain a weighted feature map, and performing feature extraction on the weighted feature map to obtain a fourth feature map; the channel weighting of the feature map is implemented by a Transformer Block; A first adaptive maximum pooling layer, connected to the second feature extraction module, is used to adjust the size of the second feature map to obtain a first adjusted feature map; A second adaptive maximum pooling layer, connected to the third feature extraction module, is used to adjust the size of the third feature map to obtain a second adjusted feature map; a third adaptive maximum pooling layer, connected to the fourth feature extraction module, and used to adjust the size of the fourth feature map to obtain a third adjusted feature map; the sizes of the first adjusted feature map, the second adjusted feature map and the third adjusted feature map are equal; A fusion module, used for fusing the first adjustment feature map, the second adjustment feature map and the third adjustment feature map to obtain a fused feature map; the fused feature map is a feature map of a one-dimensional vector; A fully connected layer, connected to the fusion module, for classifying the fused feature map to obtain a grade classification output of the graphite ore image sample; The Transformer Block includes: A compression unit, used to compress the third feature map in the width direction and the height direction respectively to obtain features in the width direction and the height direction; A fusion unit, used for fusing the features in the width direction and the height direction to obtain a fusion feature; A dimension reduction unit, used for reducing the dimension of the fused feature to obtain a reduced dimension feature; A Transformer Encoder unit is used to extract features from the dimensionality reduction features through a self-attention mechanism to obtain a feature sequence; A weight coefficient determination unit, used to determine the weight coefficient according to the feature sequence; A weighted feature map determining unit, configured to multiply the third feature map by the weight coefficient to obtain a weighted feature map; The fusion module includes: a splicing unit, configured to splice the first adjustment feature map, the second adjustment feature map and the third adjustment feature map to obtain a spliced feature map; A channel number adjustment unit, used for adjusting the number of channels of the spliced feature map to obtain a feature map after the number of channels is adjusted; The adaptive average pooling layer is used to adjust the size of the feature map after the number of channels is adjusted, and obtain a feature map of a one-dimensional vector through a Flatten operation.
2. A graphite ore grade classification model training method according to claim 1, characterized in that: The obtaining of the training set specifically includes: Image enhancement processing is performed on several categories of graphite ore original images to obtain graphite ore image samples corresponding to the several categories; the image enhancement processing includes: random inversion and center cropping.
3. A graphite ore grade classification model training method according to claim 1, characterized in that: The loss function is the CrossEntropyLoss loss function.
4. A graphite ore grade classification model application method, characterized in that: The method comprises: Obtaining a graphite ore image sample to be detected; The graphite ore image sample to be detected is input into a graphite ore grade classification model to obtain a graphite ore grade classification; the graphite ore grade classification model is a model trained according to a graphite ore grade classification model training method according to any one of claims 1 to 3.
5. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of a graphite ore grade classification model training method as described in any one of claims 1 to 3, or to implement the steps of a graphite ore grade classification model application method as described in claim 4.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the steps of a graphite ore grade classification model training method as described in any one of claims 1 to 3, or executes the steps of a graphite ore grade classification model application method as described in claim 4.
7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the steps of a graphite ore grade classification model training method as described in any one of claims 1 to 3, or executes the steps of a graphite ore grade classification model application method as described in claim 4.
