Method, device and equipment for classifying mineral images and storage medium
By constructing a lightweight intelligent recognition model based on multiple mineral image labels, and employing dual-path feature extraction and cross-scale fusion, the problems of low accuracy and efficiency in mineral image classification are solved, and efficient automatic mineral image classification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNIV OF PETROLEUM (BEIJING)
- Filing Date
- 2026-02-02
- Publication Date
- 2026-07-31
AI Technical Summary
Existing mineral image classification methods suffer from poor classification accuracy and low classification efficiency, mainly due to incomplete feature modeling, which fails to effectively capture the high intra-class and low inter-class differences in mineral images.
A classification model is constructed based on multiple mineral images and the corresponding mineral type label for each mineral image. Through dual-path feature extraction, cross-scale fusion, and lightweight aggregation, combined with a feature enhancement mechanism, a lightweight intelligent recognition model is built to achieve automatic classification of mineral images.
It improves the accuracy and efficiency of mineral image classification, reduces the workload of manual identification, and enhances the efficiency of model training and inference.
Smart Images

Figure CN121861384B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, device and storage medium for classifying mineral images. Background Technology
[0002] Mineral image classification is a fundamental and crucial technical step in geological exploration, mineral processing, resource assessment, and geological research. Because mineral images exhibit significant high intra-class variability (such as differences in crystal morphology and texture distribution among different samples of the same mineral) and low inter-class variability (such as similarities in color, luster, and other characteristics among different minerals), different mineral types can be classified through the analysis and processing of mineral images.
[0003] Existing methods for classifying mineral images mainly rely on human experience or traditional deep learning models. Human identification methods determine mineral categories through visual analysis of features such as optical properties and crystal morphology in mineral images; while traditional deep learning models classify mineral images through simple feature extraction.
[0004] However, existing mineral image classification methods suffer from poor classification accuracy and low classification efficiency. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for classifying mineral images, in order to improve the accuracy and efficiency of mineral image classification.
[0006] In a first aspect, embodiments of this application provide a method for classifying mineral images, including:
[0007] Acquire images of the minerals to be processed;
[0008] The mineral image to be processed is preprocessed to obtain a standard mineral image to be processed. The preprocessing includes uniform size scaling and pixel normalization.
[0009] The standard mineral image to be processed is input into the classification model to obtain the mineral type corresponding to the mineral image to be processed. The classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image.
[0010] In one or more embodiments, before inputting the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image to be processed, the method further includes:
[0011] The multiple mineral images are preprocessed to obtain multiple standard mineral images;
[0012] The initial classification model is trained based on the multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model. The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit.
[0013] In one or more embodiments, training an initial classification model based on the plurality of standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model includes:
[0014] S1, For each standard mineral image, the standard mineral image is input into the feature extraction unit for dual-path feature extraction to obtain global feature data and local detail feature data. The dual-path feature extraction includes global feature extraction and local detail feature extraction.
[0015] S2, the global feature data and the local detail feature data are input into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data;
[0016] S3, the multi-scale fusion feature data is input into the lightweight aggregation unit for integration processing to obtain aggregated feature data;
[0017] S4, the aggregated feature data is input into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data;
[0018] S5, input the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image;
[0019] S6. Update the parameters of the initial classification model according to the mineral type corresponding to the standard mineral image and the mineral type label corresponding to each mineral image. Repeat steps S1-S6 until the preset training stopping condition is met to obtain the classification model.
[0020] In one or more embodiments, the step of inputting the global feature data and the local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data includes:
[0021] The global feature data and the local detail feature data are convolved to obtain standard global feature data and standard local detail feature data of the same dimension.
[0022] Based on a preset feature correlation matrix, key discrimination information is extracted from the standard local detail feature data. The key discrimination information is used to indicate the degree of contribution of the standard local detail feature data to classification and recognition.
[0023] The key discrimination information is nonlinearly mapped using an activation function to obtain global feature gating weights;
[0024] Based on the global feature gating weights and the complementary weight constraints, local feature gating weights are obtained. The complementary weight constraints include the global feature gating weights and local feature gating weights being complementary and having a sum of one.
[0025] Based on the global feature gating weights and the local feature gating weights, the standard global feature data and the standard local detail feature data are weighted and fused to obtain the multi-scale fused feature data.
[0026] In one or more embodiments, the step of inputting the multi-scale fusion feature data into the lightweight aggregation unit for integration processing to obtain aggregated feature data includes:
[0027] The multi-scale fused feature data is subjected to depthwise separable convolution processing to obtain basic fused feature data with a preset number of channels;
[0028] The basic fusion feature data is subjected to upsampling and downsampling processes respectively to obtain the aggregated feature data.
[0029] In one or more embodiments, the step of inputting the aggregated feature data into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data includes:
[0030] The aggregated feature data is subjected to global average pooling along the horizontal and vertical axes respectively to obtain horizontal feature data and vertical feature data.
[0031] The horizontal feature data and the vertical feature data are concatenated to obtain concatenated feature data.
[0032] The spliced feature data is non-linearly mapped to obtain horizontal attention weights and vertical attention weights.
[0033] Based on the horizontal attention weights and the vertical attention weights, spatial attention enhancement is performed on the aggregated feature data to obtain the enhanced feature data.
[0034] In one or more embodiments, inputting the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image includes:
[0035] Global average pooling is performed on the enhanced feature data to obtain a multi-scale integrated vector;
[0036] The multi-scale integrated vector and the local high-dimensional vector are residually connected to obtain residual feature data. The local high-dimensional vector is obtained by high-dimensional feature extraction of the local detail feature data.
[0037] The residual feature data is input into the multilayer perceptron classifier in the classification unit to obtain the mineral type corresponding to the standard mineral image.
[0038] Secondly, embodiments of this application provide a mineral image classification device, comprising:
[0039] The acquisition module is used to acquire images of the minerals to be processed.
[0040] The processing module is used to preprocess the mineral image to be processed to obtain a standard mineral image to be processed. The preprocessing includes uniform size scaling and pixel normalization processing.
[0041] The classification module is used to input the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image to be processed. The classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image.
[0042] In one or more embodiments, before inputting the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image to be processed, the classification module is further configured to:
[0043] The multiple mineral images are preprocessed to obtain multiple standard mineral images;
[0044] The initial classification model is trained based on the multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model. The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit.
[0045] In one or more embodiments, the classification module trains an initial classification model based on the plurality of standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model, specifically for:
[0046] S1, For each standard mineral image, the standard mineral image is input into the feature extraction unit for dual-path feature extraction to obtain global feature data and local detail feature data. The dual-path feature extraction includes global feature extraction and local detail feature extraction.
[0047] S2, the global feature data and the local detail feature data are input into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data;
[0048] S3, the multi-scale fusion feature data is input into the lightweight aggregation unit for integration processing to obtain aggregated feature data;
[0049] S4, the aggregated feature data is input into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data;
[0050] S5, input the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image;
[0051] S6. Update the parameters of the initial classification model according to the mineral type corresponding to the standard mineral image and the mineral type label corresponding to each mineral image. Repeat steps S1-S6 until the preset training stopping condition is met to obtain the classification model.
[0052] In one or more embodiments, the classification module inputs the global feature data and the local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data, specifically for:
[0053] The global feature data and the local detail feature data are convolved to obtain standard global feature data and standard local detail feature data of the same dimension.
[0054] Based on a preset feature correlation matrix, key discrimination information is extracted from the standard local detail feature data. The key discrimination information is used to indicate the degree of contribution of the standard local detail feature data to classification and recognition.
[0055] The key discrimination information is nonlinearly mapped using an activation function to obtain global feature gating weights;
[0056] Based on the global feature gating weights and the complementary weight constraints, local feature gating weights are obtained. The complementary weight constraints include the global feature gating weights and local feature gating weights being complementary and having a sum of one.
[0057] Based on the global feature gating weights and the local feature gating weights, the standard global feature data and the standard local detail feature data are weighted and fused to obtain the multi-scale fused feature data.
[0058] In one or more embodiments, the classification module inputs the multi-scale fusion feature data into the lightweight aggregation unit for integration processing to obtain aggregated feature data, specifically for:
[0059] The multi-scale fused feature data is subjected to depthwise separable convolution processing to obtain basic fused feature data with a preset number of channels;
[0060] The basic fusion feature data is subjected to upsampling and downsampling processes respectively to obtain the aggregated feature data.
[0061] In one or more embodiments, the classification module inputs the aggregated feature data into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data, specifically for:
[0062] The aggregated feature data is subjected to global average pooling along the horizontal and vertical axes respectively to obtain horizontal feature data and vertical feature data.
[0063] The horizontal feature data and the vertical feature data are concatenated to obtain concatenated feature data.
[0064] The spliced feature data is non-linearly mapped to obtain horizontal attention weights and vertical attention weights.
[0065] Based on the horizontal attention weights and the vertical attention weights, spatial attention enhancement is performed on the aggregated feature data to obtain the enhanced feature data.
[0066] In one or more embodiments, the classification module inputs the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image, specifically for:
[0067] Global average pooling is performed on the enhanced feature data to obtain a multi-scale integrated vector;
[0068] The multi-scale integrated vector and the local high-dimensional vector are residually connected to obtain residual feature data. The local high-dimensional vector is obtained by high-dimensional feature extraction of the local detail feature data.
[0069] The residual feature data is input into the multilayer perceptron classifier in the classification unit to obtain the mineral type corresponding to the standard mineral image.
[0070] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0071] The memory stores computer-executed instructions;
[0072] The processor executes computer execution instructions stored in the memory, such that the processor, when executed, is used to implement the method described in the first aspect and any of the embodiments above.
[0073] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the methods described in the first aspect and any of the embodiments above.
[0074] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, is used to implement a mineral image classification method as described in the first aspect and various possible implementations of the first aspect.
[0075] This application provides a method, apparatus, device, and storage medium for classifying mineral images. The method first acquires a mineral image to be processed, then preprocesses it to obtain a standard mineral image. The preprocessing includes uniform scaling and pixel normalization. The standard mineral image is then input into a classification model to obtain the mineral type corresponding to the image. The classification model is determined based on multiple mineral images and the corresponding mineral type label for each image. In this method, by uniformly scaling the mineral images to be processed to the same size, the consistency of the mineral image size input to the model is ensured. Furthermore, pixel normalization eliminates the influence of image brightness and contrast, allowing the model to focus more on the texture and structural features of the image, thereby improving the training and inference efficiency of the subsequent classification model. The classification model trained based on multiple mineral images and the corresponding mineral type label for each image can learn the characteristics of various minerals, capture subtle features in the mineral images, and effectively classify the mineral images to be processed, improving the accuracy of mineral identification. By constructing a classification model, the mineral images to be processed can be automatically classified, reducing the workload of manual identification and improving image classification efficiency. Attached Figure Description
[0076] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0077] Figure 1 A flowchart illustrating the mineral image classification method provided in this application embodiment. Figure 1 ;
[0078] Figure 2 A flowchart illustrating the mineral image classification method provided in this application embodiment. Figure 2 ;
[0079] Figure 3 Schematic diagram of the structure of the initial classification model provided in the embodiments of this application Figure 1 ;
[0080] Figure 4This is a schematic diagram of the structure of the cross-scale fusion unit provided in the embodiments of this application;
[0081] Figure 5 Schematic diagram of the structure of the initial classification model provided in the embodiments of this application Figure 2 ;
[0082] Figure 6 A schematic diagram of the sub-fusion layer provided in the embodiments of this application;
[0083] Figure 7 A schematic diagram of a numerical confusion matrix provided in an embodiment of this application;
[0084] Figure 8 A schematic diagram of the standard normalized confusion matrix provided for embodiments of this application;
[0085] Figure 9 A schematic diagram of the structure of a mineral image classification device provided in an embodiment of this application;
[0086] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0087] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0088] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0089] Before introducing the embodiments of this application, the application background of the embodiments of this application will be explained first:
[0090] Mineral image classification is a fundamental and crucial technical step in geological exploration, mineral processing, resource assessment, and geological research. In practical applications, geological prospectors need to perform microscopic or macroscopic image analysis on a large number of mineral samples to identify mineral types, assess ore grades, and formulate mining strategies. Because mineral images exhibit significant high intra-class variability (such as differences in crystal morphology and texture distribution among different samples of the same mineral) and low inter-class variability (such as similarities in color, luster, and other characteristics among different minerals), different mineral types can be classified through image analysis and processing.
[0091] Existing methods for classifying mineral images mainly rely on human experience or traditional deep learning models. Human identification methods determine mineral categories through visual analysis of features such as optical properties and crystal morphology in mineral images; while traditional deep learning models classify mineral images through simple feature extraction.
[0092] For example, a single Convolutional Neural Network (CNN) model can effectively capture the fine structures of mineral images, such as local textures and grain edges, by extracting local features through convolutional kernels. However, its inherent local receptive field characteristics limit its ability to model global structures and long-range dependencies, such as mineral crystal arrangement and aggregate morphology. A single Transformer model can model global long-range dependencies through a self-attention mechanism, but its computational complexity is high.
[0093] Existing hybrid architecture models combine CNN and Transformer models, but they often still use conventional convolutional modules and standard feature fusion structures, which are not well optimized in terms of lightweight design and efficient feature aggregation.
[0094] In summary, existing mineral image classification methods suffer from poor classification accuracy and low classification efficiency.
[0095] The mineral image classification method provided in this application aims to solve the aforementioned technical problems of existing technologies. The technical concept of this application is as follows: Existing mineral image classification methods suffer from incomplete feature modeling, resulting in poor accuracy and low efficiency in mineral image classification. Mineral image classification mainly involves feature extraction from image data and in-depth analysis of the extracted feature data to determine the mineral type corresponding to the image. To address the problems of existing methods, if multi-dimensional feature extraction of mineral images can be performed and the feature analysis process optimized, the accuracy and efficiency of mineral image classification can be effectively improved. Therefore, this application embodiment considers constructing a classification model based on multiple mineral images and the mineral type label corresponding to each mineral image. The classification model performs feature analysis on the mineral images. First, the mineral images to be processed are preprocessed to obtain standard mineral images to be processed, which are then used as input to the classification model to improve the efficiency of subsequent model training and inference. The classification model uses a dual-path approach to comprehensively extract global and local features, and performs cross-scale fusion and lightweight aggregation of global and local features to reduce the computational load of the model. The standard mineral images to be processed are directly input into the classification model. After in-depth feature analysis by the classification model, the mineral type corresponding to the mineral images to be processed is accurately obtained, thus achieving mineral image classification.
[0096] The execution subject of this application embodiment is an electronic device, which can be a terminal device, such as a laptop, desktop computer, or tablet computer, or a server. In practical applications, whether the electronic device is a terminal device or a server can be determined according to the actual situation, and no specific limitation is imposed on it.
[0097] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0098] Figure 1 A flowchart illustrating the mineral image classification method provided in this application embodiment. Figure 1 .like Figure 1 As shown, the classification method for this mineral image includes the following steps:
[0099] S110. Obtain the image of the mineral to be processed;
[0100] In this step, we acquire mineral images that clearly reflect the morphology and texture of the minerals, providing data for subsequent mineral image classification.
[0101] In one possible implementation, the source of the mineral image to be processed can be a microscopic thin section image collected at a geological exploration site, or an image of a macroscopic mineral sample. A high-definition industrial camera is used to photograph the mineral sample placed on the stage. During shooting, the camera's focal length and the distance to the sample are controlled to ensure high image resolution. The resolution of the mineral image to be processed can be set to 512×512 or higher to clearly reflect the mineral morphology or texture.
[0102] S120. Preprocess the mineral image to be processed to obtain a standard mineral image to be processed;
[0103] The preprocessing includes uniform size scaling and pixel normalization.
[0104] In this step, the mineral image to be processed is scaled to a uniform size. Then, the uniformly scaled mineral image is subjected to pixel normalization to eliminate interference caused by differences in acquisition equipment and environment, resulting in a standard mineral image to be processed.
[0105] For example, uniform size scaling can solve the problem of inconsistent image resolution, while pixel normalization can reduce the impact of lighting and device parameters on pixel values, thereby improving the efficiency of subsequent model training and inference.
[0106] In one possible implementation, a bilinear interpolation algorithm is used to uniformly scale the mineral image to a fixed size of 224×224. Then, the RGB three-channel pixel values of the scaled image are normalized, and the ratio of each pixel value to 255 is calculated to map the pixel values to the 0-1 range, generating a standard mineral image with uniform format and comparable features.
[0107] S130. Input the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image to be processed;
[0108] The classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image.
[0109] In this step, a classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image. The standard mineral image to be processed is used as the input of the classification model. The classification model extracts the feature information of the standard mineral image to be processed and performs mineral type classification to obtain the mineral type corresponding to the mineral image to be processed.
[0110] In one possible implementation, the classification model adopts the lightweight intelligent recognition Swin-LCNet model trained according to the embodiments of this application. This model incorporates a dual-path collaborative network for feature extraction, an adaptive gated cross-scale fusion mechanism for feature fusion, a lightweight bidirectional feature aggregation network for feature aggregation, and a coordinate attention enhancement mechanism for feature enhancement. Finally, it uses layer normalized residual fusion for classification to obtain the probability distribution of each category, and outputs the category with the highest probability as the mineral type corresponding to the mineral image to be processed.
[0111] The classification model can also use an improved convolutional neural network based on ResNet-50. This model is trained by using multiple sets of mineral images and corresponding type labels that have been labeled in the early stage. After the standard mineral image to be processed is input into the model, the model extracts deep features such as texture and edge of the image through convolutional layers and pooling layers in sequence. Finally, the model outputs a probability distribution through a fully connected layer and selects the category with the highest probability as the recognition result of the mineral.
[0112] The mineral image classification method provided in this application first acquires the mineral image to be processed, then preprocesses it to obtain a standard mineral image. The preprocessing includes uniform scaling and pixel normalization. The standard mineral image is then input into a classification model to obtain the mineral type corresponding to the image. The classification model is determined based on multiple mineral images and the corresponding mineral type label for each image. In this embodiment, by uniformly scaling the mineral images to be processed to the same size, the consistency of the mineral image size input to the model is ensured. Furthermore, pixel normalization eliminates the influence of image brightness and contrast, allowing the model to focus more on the texture and structural features of the image, thereby improving the training and inference efficiency of the subsequent classification model. The classification model trained based on multiple mineral images and the corresponding mineral type label for each image can learn the characteristics of various minerals, capture subtle features in the mineral images, and effectively classify the mineral images to be processed, improving the accuracy of mineral identification. By constructing a classification model, the mineral images to be processed can be automatically classified, reducing the workload of manual identification and improving image classification efficiency.
[0113] Based on the above embodiments, Figure 2 A flowchart illustrating the mineral image classification method provided in this application embodiment. Figure 2 .like Figure 2 As shown, prior to step S130 above, the mineral image classification method further includes the following steps:
[0114] S210. Preprocess multiple mineral images to obtain multiple standard mineral images;
[0115] In this step, multiple mineral images are uniformly scaled and pixel normalized to eliminate size differences between them, resulting in multiple standard mineral images of the same size, providing standardized training samples for subsequent model input.
[0116] In one possible implementation, preprocessing multiple mineral images is to provide standard training samples for subsequent model training. In order to increase the diversity of training samples, data augmentation processing can also be performed on multiple mineral images, such as random rotation, random flipping, color jitter, etc., which can simulate different placement angles and lighting conditions of minerals in real scenes, so as to improve the generalization ability of the model.
[0117] In addition, scaling multiple mineral images to a uniform size can be achieved by using bilinear interpolation to scale them to a fixed size of 224×224 (the specific size can be adjusted according to the actual situation). Then, each pixel channel of the mineral image of uniform size is normalized, converting the RGB pixel values from the range of 0-255 to the range of 0-1. Then, the mean and variance of all mineral images are used to complete the standardization, resulting in a standard mineral image with uniform specifications and consistent numerical distribution, which can be used for subsequent model training.
[0118] S220. Train the initial classification model based on multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model;
[0119] The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit.
[0120] In this step, the feature extraction unit in the initial classification model performs dual-path feature extraction, the cross-scale fusion unit performs cross-scale fusion of the extracted dual-path features, the lightweight aggregation unit and the feature enhancement unit sequentially fuse the features for lightweight aggregation and enhancement processing, the classification unit classifies and identifies the processed features to obtain the mineral type output by the model, and then the initial classification model is trained by combining the mineral type label corresponding to each mineral image to obtain the classification model.
[0121] In one possible implementation, multiple standard mineral images and the mineral type label corresponding to each mineral image are divided according to a preset ratio to obtain a training set, a validation set, and a test set. The initial classification model is trained using the training set, and the performance of the trained initial classification model is verified using the validation set to determine whether the classification model has converged. The classification efficiency of the classification model is then verified based on the test set.
[0122] Figure 3 Schematic diagram of the structure of the initial classification model provided in the embodiments of this application Figure 1 .like Figure 3 As shown, the initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit.
[0123] The standard mineral images in the training set are sequentially input into the feature extraction unit, cross-scale fusion unit, lightweight aggregation unit, feature enhancement unit, and classification unit to obtain the mineral types output by the model.
[0124] The difference between the mineral type output by the model and the mineral type label corresponding to each mineral image is calculated using the cross-entropy loss function. The gradient of the loss function with respect to all learnable parameters in the model is calculated using the backpropagation algorithm. Then, the AdamW optimizer is used to dynamically update the model parameters based on the calculated gradient. Training stops when the defect identification accuracy on the validation set is stable or the loss function value converges, and the classification model is obtained.
[0125] In one possible implementation, step S220 described above may include the following steps:
[0126] S1, For each standard mineral image, the standard mineral image is input into the feature extraction unit for dual-path feature extraction to obtain global feature data and local detail feature data;
[0127] Dual-path feature extraction includes global feature extraction and local detail feature extraction;
[0128] For example, a standard mineral image is input into the feature extraction unit to perform global feature extraction and local detail feature extraction respectively, to obtain global feature data and local detail feature data.
[0129] In one possible implementation, global feature extraction employs the Swin Transformer Tiny network. The input image is divided into non-overlapping patches through image patch partitioning. A hierarchical design and alternating stacks of non-overlapping window multi-head self-attention (W-MSA) and shifted window multi-head self-attention (SW-MSA) efficiently capture long-range spatial dependencies such as mineral crystals and texture distribution, outputting multi-scale global feature data. .
[0130] Local detail feature extraction employs the lightweight network MobileNetV3-Small as its basic framework. This network, with its core features of depthwise separable convolution (DSC) and inverted residual block (Bneck), utilizes 1×1 convolution for dimensionality upscaling, DSC, and 1×1 convolution for dimensionality reduction. While maintaining a relatively deep network, it accurately captures microscopic local details such as mineral surface luster, grain edges, and minute cracks with extremely low computational cost, outputting the same features as... Size-aligned multi-scale local detail feature data .
[0131] S2, input global feature data and local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data;
[0132] For example, the cross-scale fusion unit eliminates the dimensional and scale differences between global feature data and local detail feature data, fuses the two types of feature data, and fully preserves the global morphology and local detail information of the mineral to obtain multi-scale fused feature data.
[0133] In one possible implementation, Figure 4 This is a schematic diagram of the structure of the cross-scale fusion unit provided in the embodiments of this application, as shown below. Figure 4 As shown, after convolution processing of global feature data and local detail feature data, standard global feature data (feature A) and standard local detail feature data (feature B) with a unified dimension (both H×W×C) are obtained. Based on the preset feature correlation matrix, the global feature gating weight and local feature gating weight are determined. Then, the standard global feature data and standard local detail feature data are weighted and fused to obtain multi-scale fused feature data (dimension H×W×C).
[0134] In one possible implementation, step S2 described above may include the following steps:
[0135] S21. Perform convolution processing on global feature data and local detail feature data to obtain standard global feature data and standard local detail feature data of the same dimension.
[0136] For example, the initial dimensions of global feature data and local detail feature data are usually inconsistent. Direct fusion will lead to a mismatch in feature dimensions. Convolution processing is used to unify global feature data and local detail feature data to the same dimension, laying the foundation for subsequent weighted fusion.
[0137] In one possible implementation, the input global feature data... and local detail feature data A 1×1 convolution is used to unify the channel dimensions (e.g., all scales are unified to 128 channels); subsequently, layer normalization (LN) is introduced. The LN operation normalizes the dimension of each feature channel, effectively eliminating the differences and instabilities in the numerical distribution of feature data from two paths, ensuring statistical consistency before feature fusion, and obtaining standardized global feature data with unified dimensions. and standard local detail feature data .
[0138] S22. Based on the preset feature correlation matrix, extract key discrimination information from the standard local detail feature data;
[0139] Among them, key discrimination information is used to indicate the degree of contribution of standard local detail feature data to classification and recognition;
[0140] For example, the feature correlation matrix is a learnable parameter matrix (in 1×1 convolutional form) that is applied to standard local detail feature data. It reflects the degree of correlation between each dimension of local detail features and the mineral classification results. It can assess the feature saliency of local detail features at the current spatial location and dynamically adjust the fusion ratio of global and local information accordingly. Extracting key discrimination information can screen out local features that play a core role in mineral identification (such as crystal edges and grain texture dimensions), eliminate redundant information, and improve fusion efficiency.
[0141] In one possible implementation, a pre-defined feature correlation matrix is used. The weight matrix is 128×128, where each element represents the contribution of the corresponding standard local detail feature data dimension to the classification and recognition (values range from 0 to 1). The standard local detail feature data is multiplied element-wise with the feature correlation matrix, retaining feature dimensions with values greater than 0.5 (i.e., key discriminant information), filtering out redundant dimensions with low contribution, and focusing on core local features such as mineral crystal edges and grain density.
[0142] S23. Use activation functions to perform nonlinear mapping on key discrimination information to obtain global feature gating weights;
[0143] For example, the nonlinear mapping of the activation function is used to convert key discriminative information into weight values in the 0-1 range, namely global feature gating weights, which are used to characterize the importance of global features in the fusion process and provide a quantitative basis for subsequent weighted fusion.
[0144] In one possible implementation, the dynamic gating weights of the global features The calculation formula is as follows:
[0145]
[0146] in, Represents the feature correlation matrix. This represents standard local detail feature data, used only as a gating signal to guide the weight allocation of global features. This represents the convolution operation. Indicates key discrimination information, This indicates the Sigmoid activation function, which restricts the weight values to the range of [0, 1]. For example, if the key discrimination information focuses on the overall morphology of the mineral, the Sigmoid outputs a weight value of 0.7, indicating that the global features need to be allocated 70% of the weight during fusion.
[0147] S24. Based on the global feature gating weights and the complementary weight constraints, obtain the local feature gating weights;
[0148] Among them, the complementary weight constraint includes global feature gating weights and local feature gating weights that are complementary and have a sum of one;
[0149] For example, the complementary weight constraint ensures that the sum of the global feature gating weight and the local feature gating weight is 1, avoiding the imbalance of weight distribution that would lead to the excessive neglect of certain features, taking into account the recognition needs of both the global morphology and local details of minerals, and ensuring the integrity of the fused features.
[0150] In one possible implementation, local feature gating weights The calculation formula is as follows:
[0151]
[0152] in, The global feature gating weights and local feature gating weights satisfy a complementary constraint, ensuring a dynamic balance in the contributions of global and local features during fusion. This applies to standard local detail feature data. When significant, It will be appropriately suppressed, and conversely, it will be enhanced. This allows the model to adaptively focus on global structure or local details based on the image content.
[0153] S25. Based on the global feature gating weight and the local feature gating weight, the standard global feature data and the standard local detail feature data are weighted and fused to obtain multi-scale fused feature data.
[0154] For example, weighted fusion integrates standard global feature data and standard local detail feature data according to global feature gating weights and local feature gating weights. This allows the fused features to contain both global information about the overall morphology of the mineral and local information about the crystal details. The resulting multi-scale fused features can comprehensively characterize mineral features and improve classification accuracy.
[0155] In one possible implementation, the formula for calculating the weighted fusion is as follows:
[0156]
[0157] in, This represents multi-scale fused feature data. Represents the global feature gating weights. Represents the local feature gating weights. Represents standard global feature data. This represents standard local detail feature data.
[0158] S3, input the multi-scale fusion feature data into the lightweight aggregation unit for integration processing to obtain aggregated feature data;
[0159] For example, the lightweight aggregation unit performs lightweight aggregation processing on multi-scale fused feature data, reducing the model parameter scale and computational load without losing key information, thus adapting to lightweight deployment requirements.
[0160] In one possible implementation, step S3 described above may include the following steps:
[0161] S31. Perform depthwise separable convolution processing on the multi-scale fusion feature data to obtain basic fusion feature data with a preset number of channels;
[0162] For example, depthwise separable convolution is used to reduce the dimensionality of multi-scale fused feature data to a preset number of channels to obtain basic fused feature data.
[0163] Depthwise separable convolution breaks down standard convolution into two steps: depthwise convolution and pointwise convolution. While significantly reducing the computational cost and parameter size of the model, it can effectively preserve the core identification information of minerals (such as crystal texture and morphology) in multi-scale fused feature data.
[0164] The preset number of channels needs to be adapted to the input requirements of subsequent feature enhancement stages, taking into account both lightweight design and feature integrity.
[0165] In one possible implementation, if the multi-scale fusion feature data has 512 channels, the number of channels is compressed to a preset 128 channels by using a 1×1 depthwise separable convolution. The entire process uses the ReLU6 activation function to avoid gradient vanishing, and finally obtains 128 channels of basic fusion feature data. The parameter scale is reduced compared to the standard convolution, and the global and local fusion features of the mineral are fully preserved.
[0166] S32. Perform upsampling and downsampling processing on the basic fusion feature data to obtain aggregated feature data.
[0167] For example, the combined upsampling and downsampling processing method can integrate basic fusion feature data at different scales. Upsampling can restore the spatial resolution of mineral detail features, while downsampling can enhance the robustness of global features. The fusion of the two can make up for the lack of information in single-scale features and improve the ability of aggregated features to represent mineral features at different scales.
[0168] In one possible implementation, the upsampling process includes top-down semantic propagation: upsampling high-level semantic features through nearest-neighbor interpolation, and then adding them element-wise with adjacent low-level features to ensure that high-level semantic information can effectively guide the correction of low-level features.
[0169] Downsampling processing includes bottom-up detail enhancement: low-level features are downsampled using max pooling and then added element-wise with adjacent high-level features to ensure the regression and enhancement of accurate low-level detail information.
[0170] In addition, after each round of upsampling and downsampling, the features are enhanced using a 3×3 depthwise separable convolution.
[0171] Compared to the standard feature pyramid network and its enhanced versions, the lightweight aggregation unit significantly reduces unnecessary feature duplication by reducing redundant lateral connections and fusion branches, achieving a reduction in computational complexity of over 35% and ensuring an ultra-lightweight model.
[0172] S4, input the aggregated feature data into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data;
[0173] For example, spatial attention enhancement allows the model to automatically focus on key regions (such as crystal cores and textured areas) in a mineral image, suppressing interference from background or irrelevant regions and improving feature discriminative power. The enhancement process strengthens important features through weight allocation and weakens invalid information, further improving classification accuracy.
[0174] In one possible implementation, the feature enhancement unit employs a coordinate attention mechanism. First, it performs global average pooling along the channel dimension on the 128-dimensional aggregated feature data to capture spatial location information. Then, it generates horizontal and vertical attention weight maps through two 1×1 convolutions. These weight maps are then multiplied pixel-by-pixel with the aggregated feature data to strengthen the feature weights of the mineral crystal core region, ultimately outputting enhanced feature data. .
[0175] In one possible implementation, step S4 above may include the following steps:
[0176] S41. Perform global average pooling on the aggregated feature data along the horizontal and vertical axes respectively to obtain horizontal feature data and vertical feature data;
[0177] For example, the aggregated feature data is globally averaged along the horizontal and vertical axes respectively to capture the spatial distribution information of the aggregated features in the horizontal and vertical directions. The two-dimensional global information is decomposed into one-dimensional vectors in two directions to capture long-range spatial dependencies and retain accurate position coordinates. The distribution pattern of mineral features in the two axes is extracted to generate horizontal feature data and vertical feature data.
[0178] S42. The horizontal and vertical feature data are concatenated to obtain concatenated feature data.
[0179] For example, the splicing process integrates horizontal and vertical feature data into spliced feature data of a unified dimension, accurately mining the complementary information of mineral features in the spatial dimension, and providing a complete spatial feature basis for the generation of attention weights.
[0180] S43. Perform non-linear mapping on the spliced feature data to obtain horizontal attention weights and vertical attention weights;
[0181] For example, the concatenated feature data undergoes non-linear transformation and channel compression (feature interaction) through a shared 1×1 convolutional layer. Then, it is learned through batch normalization and the H-Swish activation function (consistent with the MobileNetV3 network) to re-split the concatenated feature data into horizontal and vertical branches. Each branch is then restored to its original number of channels through independent 1×1 convolutions. Finally, the horizontal attention weights are calculated using the Sigmoid activation function. and vertical attention weights .
[0182] S44. Based on the horizontal attention weights and vertical attention weights, spatial attention enhancement is applied to the aggregated feature data to obtain enhanced feature data.
[0183] For example, spatial attention enhancement strengthens the core features of minerals by weighting and suppressing interference from background or invalid regions, making the enhanced feature data more focused on key classification information and improving the accuracy of subsequent mineral type identification.
[0184] In one possible implementation, feature data is enhanced. The calculation formula is as follows:
[0185]
[0186] in, This represents aggregated feature data. Indicates horizontal attention weights. This represents the vertical attention weight.
[0187] By enhancing spatial attention on aggregated feature data, the synergistic effect of spatial information and channel weights is achieved, enabling the model to accurately focus on the specific spatial location of mineral crystals, thereby significantly improving the model's robustness to rotation, scaling, and minor occlusion.
[0188] S5, input the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image;
[0189] For example, the classification unit performs category mapping on the enhanced feature data, outputs the probability distribution of mineral types, and finally determines the mineral category corresponding to the image.
[0190] In one possible implementation, the enhanced feature data is input into the classification unit. The feature dimension is first mapped to the number of mineral categories through a fully connected layer, and then converted into the probability value of each category through a Softmax function. The category with the highest probability is selected as the mineral type result.
[0191] In one possible implementation, step S5 above may include the following steps:
[0192] S51. Perform global average pooling on the enhanced feature data to obtain a multi-scale integrated vector;
[0193] For example, the feature data of each layer of the enhanced feature data are subjected to global average pooling, and the pooled vectors of each layer are concatenated to obtain a multi-scale integrated vector that incorporates multi-scale global information. It integrates enhanced features of mineral images at different spatial locations, eliminates redundant spatial information, and retains the most critical global features for classification.
[0194] S52. Perform residual concatenation on the multi-scale integrated vector and the local high-dimensional vector to obtain residual feature data;
[0195] Among them, the local high-dimensional vector is obtained by extracting high-dimensional features from local detailed feature data;
[0196] For example, high-dimensional feature extraction is performed on local detail feature data to obtain local high-dimensional vectors, and the multi-scale integrated vector and the local high-dimensional vector are spatially aligned, and then residual concatenation is performed to obtain residual feature data.
[0197] Local high-dimensional vectors retain key local information such as mineral crystal edges and grain textures. When combined with global integrated vectors, they can utilize the holistic nature of global features while enhancing the discriminative power of local features, thus preventing the model from losing key classification information due to excessive feature compression.
[0198] In one possible implementation, local detail feature data High-dimensional feature extraction yields local high-dimensional vectors. Then, for local high-dimensional vectors Perform a linear projection and combine it with the multi-scale integrated vector. Perform spatial dimension alignment to obtain an aligned high-dimensional vector. .
[0199] Multi-scale integrated vector Perform LayerNorm normalization to eliminate and align high-dimensional vectors. The numerical scale difference between them will then be used to align the high-dimensional vectors. With multi-scale integrated vector Performing residual joins, i.e., adding element-wise, yields residual feature data. The calculation formula is as follows:
[0200]
[0201] in, Represents a multi-scale integrated vector. This represents aligning high-dimensional vectors and achieving feature complementarity through residual connections, ensuring the comprehensiveness of feature information and the stability of training during the classification stage.
[0202] S53. Input the residual feature data into the multilayer perceptron classifier in the classification unit to obtain the mineral type corresponding to the standard mineral image.
[0203] For example, a multilayer perceptron classifier accurately captures the complex relationship between features and mineral categories through multilayer nonlinear transformations, maps high-dimensional residual feature data into mineral category probabilities and determines mineral types, thus adapting to the classification needs of multi-category mineral images.
[0204] In one possible implementation, a 50% Dropout strategy is introduced into the multilayer perceptron classifier to prevent model overfitting by randomly deactivating some neurons.
[0205] S6. Update the parameters of the initial classification model according to the mineral type corresponding to the standard mineral image and the mineral type label corresponding to each mineral image. Repeat steps S1-S6 until the preset training stopping condition is met to obtain the classification model.
[0206] For example, training stopping conditions include: preset round conditions, convergence conditions, and early stopping mechanisms.
[0207] Preset number of rounds: The initial classification model reaches the preset maximum number of training iterations;
[0208] Validation set performance convergence: If the classification accuracy on the validation set no longer improves in multiple consecutive rounds, or the loss function value no longer decreases, the initial classification model is considered to have converged.
[0209] Early stopping mechanism: To prevent overfitting, training is terminated early when the loss on the validation set starts to rise.
[0210] In one possible implementation, the cross-entropy loss function is used to calculate the error between the predicted mineral type and the true label. The error is then backpropagated to all units such as feature extraction, fusion, and aggregation through the Adam optimizer. The parameters such as the convolution kernel and attention weight of each unit are updated until any training stopping condition is met, resulting in a convergent classification model with strong generalization ability.
[0211] Based on the above possible implementation methods Figure 5 Schematic diagram of the structure of the initial classification model provided in the embodiments of this application Figure 2 .like Figure 5 As shown, the entire process of a standard mineral image based on an initial classification model from input to classification result output is presented, including the dual-path extraction path of the feature extraction unit, the weighted fusion path of the cross-scale fusion unit, the aggregation path of the lightweight aggregation unit, the processing path of the feature enhancement unit, and the process of finally obtaining the classification result based on the classification unit.
[0212] The following provides a detailed explanation of each processing path:
[0213] 1) The feature extraction unit in the initial classification model includes a dual-path extraction path of local detail feature extraction and global feature extraction;
[0214] Local detail feature extraction employs the lightweight MobileNetV3 network path, comprising MobileNetV3 modules 1 through 5. Each MobileNetV3 module is essentially a lightweight feature extraction chain based on depthwise separable convolution and inverse residual structures. The extraction path includes: inputting a standard mineral image (H×W×3), which undergoes 2× downsampling by MobileNetV3 module 1 (outputting H / 2×W / 2×16), followed by progressive downsampling (4× downsampling, 8× downsampling, 16× downsampling, and 32× downsampling); MobileNetV3 module 2 outputs H / 4×W / 4×24; MobileNetV3 module 3 outputs H / 8×W / 8×40; and finally, MobileNetV3 module 4 outputs deep local features at H / 32×W / 32×160.
[0215] Global feature extraction employs the Win Transformer Tiny network, which contains five Win Transformer Block modules, performing multi-level downsampling based on each module. Win Transformer Block 1 maintains the original scale input, corresponding to H×W×C. SwinSubsequently, the spatial dimensions are compressed and the number of channels is doubled step by step: Swin Transformer module 2 (H / 2 scale), Swin Transformer module 3 (H / 4 scale), Swin Transformer module 4 (H / 8 scale), until Swin Transformer module 5 outputs H / 16×W / 16×16*C. Swin Global semantic features.
[0216] 2) The cross-scale fusion unit receives and fuses feature map L from the MobileNetV3 path and feature map R from the SwingTransformer path;
[0217] The cross-scale fusion unit includes three sub-fusion layers, which are deployed on multiple scale nodes such as H / 4, H / 8, and H / 16 to ensure information complementarity at different resolutions.
[0218] Figure 6 The structural diagram of the sub-fusion layer provided in the embodiments of this application is as follows: Figure 6 As shown, the weighted fusion path of each sub-fusion layer includes: extracting the correlation between feature map L and feature map R by the attention weight generation module in the cross-scale fusion unit to generate a two-dimensional attention map; then multiplying the attention map with the input features element-wise to achieve automatic screening of important features; and finally obtaining the fused feature data through element-wise addition.
[0219] Finally, the last sub-fusion layer, namely sub-fusion layer 3, outputs multi-scale fused feature data.
[0220] 3) The lightweight aggregation unit receives multi-scale fusion feature data output by the cross-scale fusion unit. The feature data of each scale level are efficiently processed by depthwise separable convolution before and after aggregation to reduce the number of parameters. Finally, it outputs aggregated feature data with three preset number of channels: P3 (H / 8×W / 8×256), P4 (H / 16×W / 16×256), and P5 (H / 32×W / 32×256).
[0221] Figure 5 The crosses shown clearly indicate the three redundant fusion branches that were actively removed in this embodiment. By comparing the paths (light gray lines) of traditional Feature Pyramid Network (FPN) or Path Aggregation Network (PANet), this embodiment reduces computational overhead by approximately 35% without sacrificing performance by simplifying the links.
[0222] 4) The feature enhancement unit receives aggregated feature data (P3, P4, and P5), performs dependency modeling on the aggregated feature data in the horizontal and vertical directions, and enhances the key spatial information of the mineral. The enhanced feature data is then residually superimposed with the global pooled features output by MobileNetV3 module 5 to ensure the deep unity of local details and global semantics.
[0223] Finally, the features after residual stacking are input into a classification unit containing a linear layer and a Softmax activation function to obtain the classification result, including the maximum probability value of the mineral type calculated from the initial classification, and then outputting the unique mineral type determination corresponding to the mineral image (such as plagioclase, olivine, etc.), thus completing the entire intelligent classification process.
[0224] Furthermore, the classification results on the test set are used to construct a numerical confusion matrix and a standard normalized confusion matrix to validate the model's performance. Figure 7 This is a schematic diagram of a numerical confusion matrix provided in an embodiment of this application. Figure 7 As shown, the horizontal axis represents the mineral type output by the classification model, and the vertical axis represents the mineral type label corresponding to the mineral image. In the numerical confusion matrix, the values on the main diagonal represent the actual number of samples that were correctly classified for each mineral type, intuitively demonstrating the model's ability to handle large-scale samples.
[0225] Figure 8 This is a schematic diagram of a standard normalized confusion matrix provided for an embodiment of this application. For example... Figure 8 As shown, the horizontal axis represents the mineral type output by the classification model, and the vertical axis represents the mineral type label corresponding to the mineral image. In the standard normalized confusion matrix, the values on the diagonal of the matrix represent the recognition accuracy of each mineral category, while the extremely low values in the off-diagonal region reflect the model's strong ability to distinguish similar minerals (such as feldspar and quartz) against interference.
[0226] The mineral image classification method provided in this application first preprocesses multiple mineral images to obtain multiple standard mineral images. Then, an initial classification model is trained based on these standard mineral images and the corresponding mineral type label for each image to obtain a classification model. The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit. In this embodiment, preprocessing multiple mineral images to generate standardized images ensures the consistency of input data, which helps improve the robustness and accuracy of the model. The feature extraction unit can effectively extract features at different scales from the standard mineral images, such as local and global features. The cross-scale fusion unit can effectively fuse features from different scales, preserving global features while dynamically adjusting to enhance the ability to express local details. The lightweight aggregation unit reduces computational complexity by centrally processing and simplifying feature information, making the model more efficient. The feature enhancement unit enhances effective features, further improving the model's sensitivity to mineral features, thereby improving classification accuracy. The classification unit maps the extracted and enhanced features to mineral types, effectively handling multiple outputs and improving classification accuracy.
[0227] Based on the above embodiments, the following are embodiments of the apparatus involved in this application:
[0228] Figure 9 This is a schematic diagram of the structure of a mineral image classification device provided in an embodiment of this application. Figure 9 As shown, the mineral image classification device 900 includes:
[0229] The acquisition module 910 is used to acquire images of the minerals to be processed;
[0230] The processing module 920 is used to preprocess the mineral image to be processed to obtain a standard mineral image to be processed. The preprocessing includes uniform size scaling and pixel normalization.
[0231] The classification module 930 is used to input standard mineral images to be processed into the classification model to obtain the mineral type corresponding to the mineral images to be processed. The classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image.
[0232] In one or more embodiments, before inputting a standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image, the classification module 930 is further configured to:
[0233] Multiple mineral images are preprocessed to obtain multiple standard mineral images;
[0234] The initial classification model is trained using multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model. The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit.
[0235] In one or more embodiments, the classification module 930 trains an initial classification model based on multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain a classification model, specifically used for:
[0236] S1, For each standard mineral image, the standard mineral image is input into the feature extraction unit for dual-path feature extraction to obtain global feature data and local detail feature data. The dual-path feature extraction includes global feature extraction and local detail feature extraction.
[0237] S2, input global feature data and local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data;
[0238] S3, input the multi-scale fusion feature data into the lightweight aggregation unit for integration processing to obtain aggregated feature data;
[0239] S4, input the aggregated feature data into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data;
[0240] S5, input the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image;
[0241] S6. Update the parameters of the initial classification model according to the mineral type corresponding to the standard mineral image and the mineral type label corresponding to each mineral image. Repeat steps S1-S6 until the preset training stopping condition is met to obtain the classification model.
[0242] In one or more embodiments, the classification module 930 inputs global feature data and local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data, specifically used for:
[0243] Convolutional processing is performed on global feature data and local detail feature data to obtain standard global feature data and standard local detail feature data with uniform dimensions;
[0244] Based on a preset feature correlation matrix, key discriminant information is extracted from standard local detail feature data. The key discriminant information is used to indicate the degree of contribution of standard local detail feature data to classification and recognition.
[0245] The activation function is used to perform nonlinear mapping on key discriminative information to obtain global feature gating weights;
[0246] Based on the global feature gating weights and the weight complementarity constraint, the local feature gating weights are obtained. The weight complementarity constraint includes the global feature gating weights and the local feature gating weights being complementary and having a sum of one.
[0247] Based on the global feature gating weight and the local feature gating weight, the standard global feature data and the standard local detail feature data are weighted and fused to obtain multi-scale fused feature data.
[0248] In one or more embodiments, the classification module 930 inputs multi-scale fusion feature data into a lightweight aggregation unit for integration processing to obtain aggregated feature data, specifically for:
[0249] The multi-scale fused feature data is processed by depthwise separable convolution to obtain basic fused feature data with a preset number of channels;
[0250] The basic fusion feature data is subjected to upsampling and downsampling processes respectively to obtain aggregated feature data.
[0251] In one or more embodiments, the classification module 930 inputs the aggregated feature data into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data, specifically for:
[0252] The aggregated feature data is globally averaged along the horizontal and vertical axes respectively to obtain horizontal feature data and vertical feature data.
[0253] The horizontal and vertical feature data are concatenated to obtain the concatenated feature data.
[0254] The concatenated feature data is non-linearly mapped to obtain horizontal attention weights and vertical attention weights.
[0255] Spatial attention enhancement is performed on the aggregated feature data based on horizontal and vertical attention weights to obtain enhanced feature data.
[0256] In one or more embodiments, the classification module 930 inputs enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image, specifically for:
[0257] Global average pooling is performed on the enhanced feature data to obtain a multi-scale integrated vector;
[0258] The residual feature data is obtained by performing a residual concatenation between the multi-scale integrated vector and the local high-dimensional vector. The local high-dimensional vector is obtained by extracting high-dimensional features from the local detailed feature data.
[0259] The residual feature data is input into the multilayer perceptron classifier in the classification unit to obtain the mineral type corresponding to the standard mineral image.
[0260] The mineral image classification device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0261] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 10 As shown, the electronic device 1000 includes: a processor 1010, a memory 1020, and a bus 1030;
[0262] The memory 1020 is used to store computer-executed instructions from the processor 910;
[0263] The processor 1010 is configured to execute the technical solutions of any of the foregoing method embodiments by executing computer execution instructions.
[0264] The specific implementation process of processor 1010 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0265] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0266] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0267] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0268] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0269] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0270] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0271] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an application-specific integrated circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0272] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0273] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0274] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0275] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory (RAM), magnetic disks, or optical disks.
[0276] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0277] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A method for classifying mineral images, characterized in that, include: Acquire images of the minerals to be processed; The mineral image to be processed is preprocessed to obtain a standard mineral image to be processed. The preprocessing includes uniform size scaling and pixel normalization. The standard mineral image to be processed is input into the classification model to obtain the mineral type corresponding to the mineral image to be processed. The classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image. Before inputting the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image, the method further includes: The multiple mineral images are preprocessed to obtain multiple standard mineral images; The initial classification model is trained based on the multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model. The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit. The step of training an initial classification model based on the multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model includes: S1, For each standard mineral image, the standard mineral image is input into the feature extraction unit for dual-path feature extraction to obtain global feature data and local detail feature data. The dual-path feature extraction includes global feature extraction and local detail feature extraction. S2, the global feature data and the local detail feature data are input into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data; S3, the multi-scale fusion feature data is input into the lightweight aggregation unit for integration processing to obtain aggregated feature data; S4, the aggregated feature data is input into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data; S5, input the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image; S6, update the parameters of the initial classification model according to the mineral type corresponding to the standard mineral image and the mineral type label corresponding to each mineral image, repeat steps S1-S6 until the preset training stopping condition is met, and obtain the classification model; The step of inputting the global feature data and the local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data includes: The global feature data and the local detail feature data are convolved to obtain standard global feature data and standard local detail feature data of the same dimension. Based on a preset feature correlation matrix, key discrimination information is extracted from the standard local detail feature data. The key discrimination information is used to indicate the degree of contribution of the standard local detail feature data to classification and recognition. The key discrimination information is nonlinearly mapped using an activation function to obtain global feature gating weights; Based on the global feature gating weights and the complementary weight constraints, local feature gating weights are obtained. The complementary weight constraints include the global feature gating weights and local feature gating weights being complementary and having a sum of one. Based on the global feature gating weights and the local feature gating weights, the standard global feature data and the standard local detail feature data are weighted and fused to obtain the multi-scale fused feature data; The step of inputting the multi-scale fused feature data into the lightweight aggregation unit for integration processing to obtain aggregated feature data includes: The multi-scale fused feature data is subjected to depthwise separable convolution processing to obtain basic fused feature data with a preset number of channels; The basic fusion feature data is subjected to upsampling and downsampling processes respectively to obtain the aggregated feature data.
2. The method according to claim 1, characterized in that, The step of inputting the aggregated feature data into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data includes: The aggregated feature data is subjected to global average pooling along the horizontal and vertical axes respectively to obtain horizontal feature data and vertical feature data; The horizontal feature data and the vertical feature data are concatenated to obtain concatenated feature data. The spliced feature data is non-linearly mapped to obtain horizontal attention weights and vertical attention weights. Based on the horizontal attention weights and the vertical attention weights, spatial attention enhancement is performed on the aggregated feature data to obtain the enhanced feature data.
3. The method according to claim 1, characterized in that, The step of inputting the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image includes: Global average pooling is performed on the enhanced feature data to obtain a multi-scale integrated vector; The multi-scale integrated vector and the local high-dimensional vector are residually connected to obtain residual feature data. The local high-dimensional vector is obtained by high-dimensional feature extraction of the local detail feature data. The residual feature data is input into the multilayer perceptron classifier in the classification unit to obtain the mineral type corresponding to the standard mineral image.
4. A mineral image classification device, characterized in that, The apparatus is configured to perform the method as described in any one of claims 1-3, the apparatus comprising: The acquisition module is used to acquire images of the minerals to be processed. The processing module is used to preprocess the mineral image to be processed to obtain a standard mineral image to be processed. The preprocessing includes uniform size scaling and pixel normalization processing. The classification module is used to input the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image to be processed. The classification model is determined based on multiple mineral images and the mineral type label corresponding to each mineral image. Before inputting the standard mineral image to be processed into the classification model to obtain the mineral type corresponding to the mineral image, the classification module is further configured to: The multiple mineral images are preprocessed to obtain multiple standard mineral images; The initial classification model is trained based on the multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model. The initial classification model includes a feature extraction unit, a cross-scale fusion unit, a lightweight aggregation unit, a feature enhancement unit, and a classification unit. The classification module trains an initial classification model based on the multiple standard mineral images and the mineral type label corresponding to each mineral image to obtain the classification model, specifically used for: S1, For each standard mineral image, the standard mineral image is input into the feature extraction unit for dual-path feature extraction to obtain global feature data and local detail feature data. The dual-path feature extraction includes global feature extraction and local detail feature extraction. S2, the global feature data and the local detail feature data are input into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data; S3, the multi-scale fusion feature data is input into the lightweight aggregation unit for integration processing to obtain aggregated feature data; S4, the aggregated feature data is input into the feature enhancement unit for spatial attention enhancement to obtain enhanced feature data; S5, input the enhanced feature data into the classification unit to obtain the mineral type corresponding to the standard mineral image; S6, update the parameters of the initial classification model according to the mineral type corresponding to the standard mineral image and the mineral type label corresponding to each mineral image, repeat steps S1-S6 until the preset training stopping condition is met, and obtain the classification model; The classification module inputs the global feature data and the local detail feature data into the cross-scale fusion unit for feature fusion to obtain multi-scale fused feature data, specifically used for: The global feature data and the local detail feature data are convolved to obtain standard global feature data and standard local detail feature data of the same dimension. Based on a preset feature correlation matrix, key discrimination information is extracted from the standard local detail feature data. The key discrimination information is used to indicate the degree of contribution of the standard local detail feature data to classification and recognition. The key discrimination information is nonlinearly mapped using an activation function to obtain global feature gating weights; Based on the global feature gating weights and the complementary weight constraints, local feature gating weights are obtained. The complementary weight constraints include the global feature gating weights and local feature gating weights being complementary and having a sum of one. Based on the global feature gating weights and the local feature gating weights, the standard global feature data and the standard local detail feature data are weighted and fused to obtain the multi-scale fused feature data; The classification module inputs the multi-scale fusion feature data into the lightweight aggregation unit for integration processing to obtain aggregated feature data, specifically used for: The multi-scale fused feature data is subjected to depthwise separable convolution processing to obtain basic fused feature data with a preset number of channels; The basic fusion feature data is subjected to upsampling and downsampling processes respectively to obtain the aggregated feature data.
5. An electronic device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-3.