A Sandstone Microscopic Image Classification Method and System Based on Improved Swin Transformer
By improving the Swin Transformer framework and combining SAEM, LPB and BAM modules, the complex texture and category imbalance in sandstone microscopic image classification is solved, efficient and accurate image classification is achieved, and the development of geological scientific research and oil and gas resource exploration has been promoted.
Patent Information
- Application Number
- CN202410562542.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2044-05-08
AI Technical Summary
The existing deep learning methods face problems such as complex texture characteristics, subtle differences between categories, and uneven distribution of training samples in sandstone microscopic image classification, resulting in inaccuracy of classification and inefficient efficiency.
Using the improved Swin Transformer framework, the integrated spatial adaptive enhancement module (SAEM), local perception block (LPB) and balanced adaptive mechanism (BAM) are used to optimize model performance by dynamically adjusting the size of the convolution kernel, enhancing local feature capture and balancing category weights.
It significantly improves the classification accuracy and efficiency of sandstone microscopy images, can effectively deal with the problem of category imbalance, and improves the generalization ability of the model and the recognition ability of complex textures.
Smart Images

Figure CN118570797B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of geological and oil and gas exploration based on artificial intelligence, and specifically relates to a sandstone microscopic image classification method and system based on an improved Swin Transformer. Background Art
[0002] In the fields of geological science and oil and gas exploration, accurate analysis and classification of sandstone microscopic images are extremely basic and crucial tasks. These images visually present the information of sedimentary rock layers in a specific geological era through changes in their color, texture, and stratification, providing direct support for understanding formation characteristics, evaluating resource potential, and formulating effective resource development strategies. Traditional methods mainly rely on geological experts to observe and interpret through optical microscopes. This process is not only time-consuming, laborious, and costly, but its results are also extremely vulnerable to personal experience and subjective judgment, bringing a certain degree of uncertainty.
[0003] With the continuous progress of technology, the application of electron microscopy technology and digital image processing technology has greatly improved the efficiency of image acquisition and the accuracy of analysis. However, when faced with a large amount of sandstone microscopic image data, how to achieve rapid and accurate classification and interpretation remains a major challenge. Although the development of computer vision and machine learning technologies has provided the possibility of automated image classification, these technologies still face many problems when dealing with specific problems of sandstone microscopic image classification. One is that sandstone microscopic images often exhibit highly complex texture features, and the images of different types of sandstones under the microscope are subtly different, posing high requirements for the resolution of classification algorithms. The second is the class imbalance between samples, that is, the number of samples of some sandstone types may be much more than that of other types, which may lead to overfitting of the classification model to the categories with a large number of samples during the training process and ignore the categories with fewer samples. In addition, due to the high cost of obtaining geological image data, the relatively limited high-quality labeled data available for training further restricts the improvement of the performance of deep learning models.
[0004] In recent years, the rapid development of deep learning technology has provided a new perspective for the automatic classification and interpretation of sandstone microscopic images. Especially the excellent performance of convolutional neural networks (CNNs) in image recognition and classification. By learning a large amount of labeled data, deep learning models can automatically extract high-level features of images and then be used for classification or regression tasks. Further, after the Transformer model has achieved a major breakthrough in the field of natural language processing, its application in the field of image processing has also attracted extensive attention. As a new network architecture that combines the advantages of convolutional neural networks and Transformers, Swin Transformer has opened up a new way for processing complex image tasks by its unique windowed self-attention mechanism, while reducing the computational cost and maintaining high performance.
[0005] However, directly applying deep learning techniques to the classification of sandstone microscopic images still faces many challenges. On the one hand, existing deep learning models rely heavily on a large amount of labeled data, while high-quality labeled data of sandstone microscopic images is relatively scarce. On the other hand, traditional deep learning models still have problems of insufficient recognition accuracy and limited generalization ability when dealing with images with complex textures and detailed features. Therefore, how to design and optimize deep learning models to improve the accuracy and efficiency of sandstone microscopic image classification has become an important focus in the research field.
[0006] There is relatively little research on the classification of sandstone microscopic images. The prior art with the document number CN113029899A discloses a method for calculating the sandstone permeability based on microscopic image processing, which includes obtaining the sandstone microscopic image of the target sandstone; performing binary segmentation processing on the sandstone microscopic image to obtain a binary pore network image and a pore-throat enhanced pore network image; determining the areal porosity of the sandstone microscopic image according to the binary pore network image; determining the particle diameter according to the pore-throat enhanced pore network image; determining the pore tortuosity according to the pore-throat enhanced pore network image; and calculating the sandstone permeability based on the determined areal porosity, particle diameter, and pore tortuosity. In the case where it is difficult to obtain a large number of plug cores, the present invention only uses the rock microscopic photos taken from small pieces of cores that are easily obtained, extracts the sandstone microscopic parameters through image processing, and calculates the sandstone permeability, compensating for the lack of permeability data and better guiding the exploration and development of sandstone oil and gas reservoirs. The prior art with the document number CN116612362A provides a method for augmenting dense sandstone images based on deep learning, which includes: obtaining labeled dense sandstone images and performing preprocessing; constructing a dense sandstone image generation model with a StyleGAN network as the main body; training the constructed dense sandstone image generation model based on the obtained dense sandstone images; during the training process, adjusting the augmentation intensity according to the degree of overfitting, and dynamically adjusting the position for the next determination of overfitting; and generating dense sandstone images using the trained dense sandstone image generation model. The present invention can generate high-quality dense sandstone images, improve data diversity, augment dense sandstone image samples, and provide support for realizing intelligent dense sandstone image segmentation. It can be seen that the prior art has not conducted in-depth research on the sandstone microscopic image classification technology.
[0007] In contemporary research in geoscience and oil and gas exploration, the classification and interpretation techniques of sandstone microscopic images hold a crucial position. With the rapid advancement of deep learning techniques, especially their outstanding capabilities demonstrated in image processing and classification tasks, it provides a new idea for the automatic classification of sandstone microscopic images. Nevertheless, current deep learning methods still face huge challenges in dealing with the complexity of this specific field, including the complex texture characteristics of sandstone images themselves, the subtle differences between categories, and the imbalance in the distribution of training samples. In summary, the research and progress of sandstone microscopic image classification technology are of crucial significance for promoting geoscience research and the effective development of oil and gas resources. Therefore, there is an urgent need to provide a sandstone microscopic image classification method and system. Summary of the Invention
[0008] The technical problem to be solved by this invention is: aiming at the complex texture characteristics of sandstone images themselves, the subtle differences between categories, and the imbalance in the distribution of training samples, the existing deep learning methods cannot accurately classify sandstone microscopic images. This invention provides a sandstone microscopic image classification method and system based on (utilizing) an improved Swin Transformer.
[0009] The technical solution adopted by this invention to solve the above technical problem is:
[0010] A sandstone microscopic image classification method based on an improved Swin Transformer includes the following steps:
[0011] Step 1: Construct and apply a high-quality sandstone microscopic image dataset covering multiple geological regions for the training and evaluation of the model to improve the accuracy and efficiency of the classification task;
[0012] Step 2: Integrate the Spatial Adaptive Enhancement Module (SAEM) into the Swin Transformer block and place it between the self-attention module and the multi-layer perceptron.
[0013] The SAEM realizes the dynamic adjustment of the features (texture, color, shape of sandstone) of sandstone microscopic images through global average pooling, 1*1 (1 by 1) convolution, and adaptive depthwise separable convolution, is used to capture the overall features of sandstone microscopic images, finely processes the local details of sandstone microscopic images through convolution operations, and responds to different pixel positions when dynamically adjusting the convolution kernel size to adapt to different input features;
[0014] The SAEM transforms the attention weights through the Sigmoid activation function to enhance the expression of key textures in sandstone microscopic images;
[0015] Step 3: Use the Local Perception Block (LPB) as an advanced preprocessing unit before each Swin Transformer block;
[0016] Step 4: Train the Geo - Swin - Transformer model obtained in Steps 2 and 3 using the sandstone microscopic image dataset in Step 1. Apply the Balanced Adaptive Mechanism (BAM) during training to dynamically adjust the class weights in the total loss BAMLOSS (to solve the problem of sample imbalance, improve the generalization ability and classification accuracy of the model);
[0017] Step 5: During the training stage, accompany it with model evaluation. The model evaluation includes multiple metrics such as accuracy, recall, and F1 - score to comprehensively evaluate the model performance. If the evaluation does not meet the standard, return to Steps 2, 3, and 4 to sequentially improve the structures of the spatial adaptive enhancement module, local perception block, and balanced adaptive mechanism until the evaluation meets the standard. The way of structure improvement is to adjust the depth and width of the network layer, modify the activation function, or optimize the connection method between layers.
[0018] In Step 2, integrate the Spatial Adaptive Enhancement Module (SAEM) into the Swin Transformer block and place it between the self - attention module and the multi - layer perceptron, providing several key advantages to significantly improve the ability to recognize image details and textures. First, SAEM realizes the dynamic adjustment of features through global average pooling, 1x1 convolution, and adaptive depth - separable convolution. This process not only captures the overall context but also finely processes local textures and details through convolution operations. Especially when dynamically adjusting the convolution kernel size to adapt to different input features, it can respond more sensitively to different spatial positions. In addition, SAEM further strengthens the attention to local features on the features extracted by the self - attention module. The attention weights transformed by the Sigmoid activation function precisely enhance the expression of key textures and structures in the image. This structure optimizes the feature expression and enables the model to deeply analyze and highlight important image details, thus having better adaptability and accuracy when processing complex images.
[0019] In step 3, the Local Perception Block (LPB) serves as an advanced preprocessing unit before each Swin Transformer block. It widely captures spatial features through its depth and dilated convolutional layers. The multi-head attention mechanism enhances the interpretation of different subspaces of the data, and at the same time, the optimized SE block effectively performs feature recalibration. This configuration enables the LPB to enhance the representation of key local features before the data flows into the Swin Transformer block, providing a richer and more refined feature input for the subsequent Transformer structure. This not only significantly improves the model's performance in processing image details and complex patterns but also optimizes the learning process, enabling the network to exhibit better adaptability and accuracy in visual tasks that rely on fine spatial details.
[0020] Furthermore, the SAEM generates global descriptors for each channel through global average pooling and uses a one-dimensional convolutional network to adaptively adjust the attention to different pixel positions in the sandstone microscopic image.
[0021] The structure of the SAEM includes a global average pooling layer, 1x1 convolution, an adaptive depthwise separable convolution, and a Sigmoid activation function. The collaborative work of these components enables the SAEM to adaptively adjust the attention to different spatial positions. The global average pooling layer is used to quickly capture overall features, the 1x1 convolution performs feature transformation, the adaptive depthwise separable convolution dynamically adjusts the kernel size according to the input features to optimize the processing of local details in the sandstone microscopic image, obtaining the processed features. The Sigmoid activation function converts the processed features into attention weights to enhance the focus on important features.
[0022] The Spatial Adaptive Enhancement Module (SAEM) is tailored for the complex texture and morphological features in sandstone microscopic images, aiming to significantly improve the image feature recognition and classification performance of the model. SAEM generates global context descriptors for each channel through global average pooling and utilizes a one-dimensional convolutional network to adjust the importance of channels, thereby enhancing the model's ability to express key features. This module strengthens the capture of key details and texture information by adaptively adjusting the attention to different spatial (pixel) positions in the image. Additionally, it dynamically assigns attention weights according to the unique textures and morphological features of geological structures and mineral compositions in the image, enabling the model to focus on information-rich regions crucial for classification judgment. The structure of SAEM includes global average pooling, 1x1 convolution, adaptive depthwise separable convolution, and the Sigmoid activation function. The collaborative work of these components enables SAEM to adaptively adjust the attention to different spatial positions. Global average pooling quickly captures overall features, 1x1 convolution performs feature transformation, and adaptive depthwise separable convolution dynamically adjusts the kernel size according to the input features to optimize the handling of details. Finally, the Sigmoid activation function converts the processed features into attention weights, further enhancing the model's focus on important features. This design enables SAEM to capture the dependencies between channels in a lightweight and efficient manner, strengthening the model's channel attention mechanism.
[0023] Furthermore, the Local Perception Block (LPB) is used to improve the model's recognition of complex textures and geological structures in sandstone microscopic images; the composition of LPB includes depth and dilated convolutional layers, multi-head attention mechanism, and SE block; the depth and dilated convolutional layers capture complex textures and structures through extensive spatial coverage, providing feature maps rich in details; the multi-head attention mechanism is used to enhance the parsing ability of different pixel positions (sub-spaces) in the sandstone microscopic image data, and the SE block strengthens important features and suppresses unimportant information by recalibrating channel features;
[0024] When processing input features, LPB combines local window and spatial offset window techniques to optimize the capture of local spatial information, and generates more representative feature maps through operations such as fusion, convolution, or attention mechanism;
[0025] In addition, LPB specifically analyzes the unique distribution of mineral compositions and texture features in local regions of sandstone microscopic images, carefully analyzes this local information to improve the classification performance of the model, and expands the field of view to obtain broader feature information by capturing local details and adjacent information, achieving an in-depth understanding of the spatial information in the image. By this method of combining local window technology with spatial offset window strategy, LPB significantly improves the capture and parsing efficiency of spatial information, thereby enhancing the model's ability to analyze complex textures and geological structures in the image.
[0026] Furthermore, the Balanced Adaptive Mechanism (BAM) is used to optimize difficult-to-classify samples and class imbalance by combining weighted cross-entropy, dual focal loss, and online hard example mining (OHEM) techniques. Dynamic class weights are used to mitigate the impact of class imbalance; the dual focal loss part trains difficult-to-classify samples more effectively and reduces the impact of easy-to-classify samples; while the OHEM part focuses on the samples with the largest loss to strengthen the learning of Geo-Swin-Transformer for difficult-to-separate samples.
[0027] Furthermore, the specific implementation process of the Balanced Adaptive Mechanism (BAM) is as follows:
[0028] First, define the basic cross-entropy loss:
[0029]
[0030] where y is the one-hot encoding of the true label, is the probability distribution predicted by the model, and C is the total number of classes;
[0031] The dynamic class weights are given by the following formula:
[0032] WeightedCELoss = CELoss × W(y)
[0033] where W(y) is the weight of the corresponding class selected according to the true label y; the dynamic class weights can dynamically adjust the attention to different classes;
[0034] The calculation formula for the dual focal loss is:
[0035] DualFocalLoss = α · (1 - p t ) γ · WeightedCELoss
[0036] where p t is the predicted probability of the model for the correct class, and α and γ are hyperparameters used for adjustment;
[0037] The online hard example mining (OHEM) loss is calculated by selecting a part of the samples with the largest weighted cross-entropy loss:
[0038]
[0039] The total loss BAMLoss is the result of the weighted sum of DualFocalLoss and OHEMLoss:
[0040] BAMLoss = ω DualFocalLoss · DualFocalLoss + ω OHEMLoss·OHEM Loss
[0041] where ω DualFocalLoss and ω OHEMLoss are the weights of DualFocalLoss and OHEMLoss respectively, and ω DualFocalLoss and ω OHEMLoss are adaptively adjusted according to the following strategy:
[0042]
[0043]
[0044] If a certain loss part is relatively high, ω DualFocalLoss and ω OHEMLoss will obtain greater weights in the next round of training.
[0045] Furthermore, in step 4, the training process includes: in the initial stage, the basic Swin Transformer model is trained as the baseline for subsequent module performance comparison; then, to systematically explore the specific contributions of each enhancement module to the model performance, the Spatial Adaptive Enhancement Module (SAEM) and the Local Perception Block (LPB) are separately integrated; SAEM aims to adaptively enhance the expression of image detail features, while LPB focuses on improving the model's ability to capture local features of images. Then, the training enters the combined module stage to examine the synergistic effects of different module combinations: combining SAEM and LPB to optimize the recognition accuracy of complex geological textures; combining SAEM with the Balanced Adaptive Mechanism (BAM) to adjust the class weights in classification to address the class imbalance problem; combining LPB with BAM to simultaneously enhance local feature recognition and improve class balance.
[0046] Furthermore, in step five, the confusion matrix and ROC curve statistical tools are used to analyze the recognition ability and misclassification behavior of the Geo-Swin-Transformer model for each category. The training phase is accompanied by detailed model evaluation, including multiple metrics such as accuracy, recall, and F1 score, to comprehensively evaluate the model performance. Special attention is paid to the model's performance in handling class imbalance and complex texture recognition during the evaluation process. In addition, statistical tools such as the confusion matrix and ROC curve are used to further analyze the recognition ability and misclassification behavior of the model for each category. Finally, SAEM, LPB, and BAM are integrated into an improved Swin Transformer model to form Geo-Swin-Transformer. The Geo-Swin-Transformer model aims to achieve the optimal performance for the sandstone microscopic image classification task by integrating the advantages of each module. The entire training and evaluation process is ensured to be reproducible and scientific through detailed logging and performance monitoring.
[0047] A sandstone microscopic image classification system based on an improved Swin Transformer, the system having program modules corresponding to the steps of the above technical solution: a data preprocessing module, a model training module, and a performance evaluation module, as well as corresponding algorithm modules for implementing the SAEM, LPB, and BAM strategies; when running, executing the steps in the sandstone microscopic image classification method based on the improved Swin Transformer.
[0048] A computer-readable storage medium storing a computer program configured to implement the steps of the above sandstone microscopic image classification method based on an improved Swin Transformer when called by a processor.
[0049] Regarding the technical points of the present invention, the following explanations are further provided:
[0050] The present invention effectively addresses the main problems encountered by traditional deep learning methods in the sandstone microscopic image classification task by improving the Swin-Transformer framework and introducing three key technical modules - the Spatial Adaptive Enhancement Module (SAEM), the Local Perception Block (LPB), and the Balance Adaptive Mechanism (BAM). The comprehensive application of these modules not only enhances the model's ability to capture subtle features in sandstone microscopic images but also optimizes the classification accuracy of the model when processing images of different sandstone categories and demonstrates better generalization ability in handling the sample imbalance problem.
[0051] Spatial Adaptive Enhancement Module (SAEM): By adding an adaptive spatial attention mechanism to the Swin-Transformer framework, SAEM significantly enhances the model's ability to recognize key texture and detail features in images. This module automatically adjusts the model's attention to different spatial regions, making the model more focused on image regions that contribute significantly to classification decisions.
[0052] Local Perception Block (LPB): Considering the local characteristics of complex textures and structures in sandstone micrographs, LPB focuses on improving the model's ability to process local spatial information, thereby enhancing the recognition accuracy of complex textures and structures. Through a special local window mechanism, this module strengthens the model's learning of local features in images to improve classification performance.
[0053] Balanced Adaptive Mechanism (BAM): Aiming at the class imbalance problem in sandstone micrograph data, BAM balances the model's learning of different class samples by introducing dynamic weight adjustment in the loss function. This mechanism automatically optimizes the weights, enhancing the model's ability to recognize minority classes, thereby improving the overall classification accuracy and generalization performance.
[0054] The technical solution of this invention not only makes breakthroughs in feature extraction ability, class imbalance handling, and model structure, but also demonstrates broad application potential in fields such as geological science research and oil and gas resource exploration. By implementing an efficient and accurate automatic classification technology, it significantly improves the efficiency and accuracy of geological sample analysis, accelerates the pace of geological research, and provides a more precise scientific basis for the exploration and development of oil and gas resources, with great economic and social value.
[0055] The system of this invention consists of the following main modules to support the entire process from image input to final classification decision:
[0056] Data Preprocessing Module: Preprocesses the input sandstone micrographs, including image denoising, enhancement, and normalization, to optimize the input quality for subsequent processing steps.
[0057] Improved Swin Transformer Model Training Module: An improved Swin Transformer framework that integrates three key technical modules (SAEM, LPB, BAM) for model training and optimization. This module utilizes advanced deep learning techniques to achieve efficient feature extraction and classification for the characteristics of sandstone micrographs.
[0058] Classification Evaluation Module: Comprehensively evaluates the classification performance of the model, using metrics such as accuracy, recall rate, and F1 score to ensure the high performance of the model.
[0059] Result Interpretation and Visualization Module: Visualize the classification results and provide in-depth explanations of the model's decision-making basis to help users understand how the model works.
[0060] The present invention has the following beneficial technical effects:
[0061] By proposing an improved Swin-Transformer framework, the present invention integrates a Spatial Adaptive Enhancement Module (SAEM), a Local Perception Block (LPB), and a Balance Adaptive Mechanism (BAM), providing an efficient and accurate method for the classification of sandstone microscopic images. By adopting and improving deep learning models, especially in combination with the improved Swin Transformer framework, not only can the automatic classification performance of sandstone microscopic images be significantly improved, but also new technical solutions and research ideas can be brought to the field of geological image processing and analysis. The present invention significantly improves the accuracy and efficiency of sandstone microscopic image classification through the integrated module. The method and system for classifying sandstone microscopic images by improving Swin Transformer provide strong technical support for geological scientific research.
[0062] In the present invention (this study), the training process strictly follows a phased experimental design to ensure that the effects of each module can be accurately evaluated. In the initial stage, the basic Swin Transformer model is trained as a baseline for comparing the performance of subsequent modules. Subsequently, in order to systematically explore the specific contributions of each enhancement module to the model performance, the Spatial Adaptive Enhancement Module (SAEM) and the Local Perception Block (LPB) are separately integrated. SAEM aims to adaptively enhance the expression of image detail features, while LPB focuses on improving the model's ability to capture local features of images.
[0063] Next, the experiment enters the combined module stage to examine the synergistic effects of different module combinations. Specifically, SAEM and LPB are combined to optimize the recognition accuracy of complex geological textures; the combination of SAEM and the Balance Adaptive Mechanism (BAM) is used to adjust the class weights in classification to address the class imbalance problem; and the combination of LPB and BAM aims to enhance local feature recognition and improve class balance simultaneously.
[0064] Each training stage is accompanied by a detailed model evaluation, including multiple metrics such as accuracy, recall, and F1 score, to comprehensively evaluate the model performance. Special attention is paid to the model's performance in dealing with class imbalance and complex texture recognition during the evaluation process. In addition, statistical tools such as confusion matrices and ROC curves are used to further analyze the model's recognition ability and misclassification behavior for each class.
[0065] Finally, SAEM, LPB, and BAM were integrated into an improved Swin Transformer model to form Geo-Swin-Transformer. The Geo-Swin-Transformer model aims to achieve optimal performance in the sandstone microscopic image classification task by integrating the advantages of each module. The entire training and evaluation process was carried out through detailed logging and performance monitoring, ensuring the repeatability and scientific nature of the experimental results.
[0066] The application of this technical solution in the field of sandstone microscopic image classification has brought significant beneficial effects, specifically including:
[0067] 1. Significantly improved classification accuracy: The SAEM module, through its spatial adaptive enhancement ability, combined with the fine capture of local features by the LPB module, greatly enhances the model's ability to recognize complex textures and detailed features in sandstone microscopic images. This improvement is crucial for fields such as geological research and oil and gas exploration, as decisions are often based on the accurate classification and in-depth interpretation of rock samples.
[0068] 2. Effectively addressing the problem of class imbalance: By introducing the BAM module, the present invention effectively addresses the problem of class imbalance in sandstone microscopic image data. This module dynamically adjusts the weights of each class in the loss function, ensuring that the model remains highly sensitive and accurately identifies all classes, especially effectively identifying classes with a small number, thereby enhancing the generalization of the model.
[0069] 3. Improved processing efficiency: This technical improvement not only makes progress in classification accuracy but also shows obvious advantages in processing efficiency. The optimized Swin-Transformer architecture enables the model to have higher computational efficiency when processing complex image data, being suitable for performing large-scale sandstone microscopic image analysis in resource-constrained environments and capable of meeting the requirements of real-time or near-real-time processing.
[0070] 4. Promoting the progress of geological science research and resource exploration: By providing a more accurate and efficient sandstone microscopic image classification method, the present invention strongly promotes the development of geological science research and oil and gas resource exploration. Precise rock classification information helps geologists and exploration engineers deeply understand formation characteristics, providing a solid scientific basis for resource assessment and development decisions, and having great economic and social value. Brief Description of the Drawings
[0071] Figure 1 It is a drawing for core image extraction;
[0072] Figure 2 It is a data sample;
[0073] Figure 3It is a graph of the quantity for each category;
[0074] Figure 4 It is the sandstone classification scheme adopted in this article. The English meanings in the figure are Quartz Sandstone, Quartzose Feldspathic Sandstone, Lithic Quartz Sandstone, Feldspathic Sandstone, Lithic Feldspathic Sandstone, Lithic Sandstone, Quartzose Lithic Sandstone, Feldspathic Lithic Sandstone, Quartzose Feldspathic Lithic Sandstone.
[0075] Figure 5 It is a schematic diagram of the Improved Swin-Transformer model. In the figure: (a) is the Improved Swin-Transformer, and the English meanings are Patch Partition, Patch Merging, Linear Embedding. (b) is the Improved Swin-Transformer Block, and the English meanings are LN: Layer Normalization, WMSA: Window Multi-Head Self-Attention, MLP: Multi-Layer Perceptron, SAEM: Spatial Adaptive Enhancement Module, SWMSA: Shift Window Multi-Head Self-Attention.
[0076] Figure 6 It is a schematic diagram of the Spatial Adaptive Enhancement Module (SAEM). The English meanings in the figure are 1.INPUT (Input), GAP (Global Average Pooling), 1x1Conv (1x1 Convolution), Sigmoid (Sigmoid Function), LayerNorm (Layer Normalization), GELU (Gaussian Error Linear Unit), OUTPUT (Output).
[0077] Figure 7Schematic diagram of the local perception block (LPB). The English meanings in the figure are Depthwise Conv (depth convolution), 2. Pointwise Conv (pointwise convolution), Depthwise Conv Spatial (spatial depth convolution), Pointwise Conv Spatial (spatial pointwise convolution), Multi-head Attention (multi-head attention), 1x1Conv Combined (combined 1x1 convolution), Adaptive Avg Pooling (adaptive average pooling), 1x1Conv (1x1 convolution), GELU (Gaussian error linear unit), LayerNorm (layer normalization), 1x1Conv (1x1 convolution).
[0078] Sigmoid (S-shaped function);
[0079] Figure 8 Training curve of the Improved Swin-Transformer. The English meaning of the abscissa in the figure is the number of training epochs, and the English meaning of the ordinate in the figure is the result metric (Metrics);
[0080] Figure 9 Comparison diagram of model effects. The English meaning of the abscissa in the figure is various existing models, and the English meaning of the ordinate in the figure is Accuracy;
[0081] Figure 10 Test heatmap. The English meaning of the abscissa in the figure is the predicted category (Predicted Category), and the English meaning of the ordinate in the figure is the actual category (Actual Category). Specific implementation manners
[0082] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention is described in detail through specific embodiments. However, it should be understood that the provision of the specific implementation manners is only for better understanding the present invention, and they should not be construed as limitations on the present invention. In the description of the present invention, it should be understood that the terms used are only for the purpose of description and cannot be construed as indicating or implying relative importance.
[0083] The following combines the attached Figures 1 to 10 and specific embodiments to further elaborate on the present invention. It should be noted that the implementation manners of the present invention are not limited to the following description; for those skilled in the art, according to the idea of the present invention, they will all fall within the protection scope of the present invention.
[0084] Example 1: Data preparation and preprocessing
[0085] In the core practices of geological science and oil and gas exploration, the accurate interpretation and classification of sandstone microscopic images play a crucial role, providing direct support for understanding formation characteristics, assessing resource potential, and formulating effective resource development strategies. As Figure 1 shown by the core column and the corresponding core microscopic slice images, they visually display information about sedimentary rock layers during specific geological periods through their colors, textures, and bedding changes, reflecting changes in sedimentary environments and differences in rock compositions. Through these microscopic images, geological experts can rely on their professional knowledge and practical experience to carefully analyze the core columns and core microscopic slices directly extracted from underground rock layers, and extract valuable geological information, including various geological characteristics such as the sedimentary history, composition, pore structure, sedimentary environment, diagenesis, and formation continuity of the rocks. This information is crucial for oil and gas exploration and geological research, helping geologists and exploration engineers understand the physical and chemical properties of rocks, predict the distribution and quality of oil and gas reservoirs, and guide exploration and development decisions. However, traditional manual analysis methods are time-consuming and subjective. Facing complex geological challenges and exploration requirements, there is an urgent need for new technologies to improve analysis accuracy, efficiency, and objectivity. Therefore, the development of efficient and automated sandstone microscopic image interpretation and classification technologies is of profound significance for promoting geological science research and the effective development of oil and gas resources.
[0086] Step 1: Dataset construction
[0087] The constructed sandstone microscopic image dataset widely covers various geological periods and regions, and is selected from multiple public datasets to meet the development needs of automatic classification and analysis technologies in the field of sandstone microscopic images. The dataset is selected from diverse geological backgrounds, including Cretaceous terrigenous clastic rocks in the Quxu Forearc Basin, southern Tibet; Cretaceous terrigenous clastic rocks in the central and northern Lhasa terrane; polarized microscopy of rock thin sections from the late Cretaceous to Eocene in the western Tarim Basin, Xinjiang; polarized microscopy of rock thin sections from the early to middle Jurassic in the Tethys Himalayas, Tibet; Mesozoic meta-lithic fragment sandstones in the central Yangtze region; sandstones of the He 8 Member in the Upper Paleozoic in the northeastern margin of the Ordos Basin; Permian volcanic lithic fragment sandstones in the southwestern region of China; tight sandstones of the Upper Paleozoic in the Linxing block on the eastern margin of the Ordos Basin; terrigenous clastic rocks of the Wutong Group from the Upper Devonian to Lower Carboniferous in the southern part of the Lower Yangtze region; rock thin sections of the Xuzhuang Formation in the Middle Cambrian of the Ordos Basin; microscopic image datasets of buried hills and overlying gravelly sandstones in the Bozhong Sag of the Bohai Bay Basin, and microscopic images from other geological periods and regions.
[0088] This dataset consists of a total of 21,825 sandstone core microscopic images, covering multiple geological periods such as the late Cretaceous to Eocene, Cretaceous, Mesozoic meta-lithic fragment sandstones, Upper Paleozoic, Permian volcanic lithic fragment sandstones, terrigenous clastic rocks of the Wutong Group from the Upper Devonian to Lower Carboniferous, and the Xuzhuang Formation in the Middle Cambrian. As Figure 2Each of the images shown is precisely annotated, ensuring the accuracy and consistency of the data, providing a solid foundation for model training and evaluation, and serving as a valuable resource for subsequent research. To more intuitively display the distribution of various types of data in the sandstone microscopic image dataset constructed in this paper, Figure 3 shows the number of images of different sandstone categories in the dataset. The figure clearly reflects the data imbalance between different categories, where the number of images in some categories is much larger than that in other categories. This imbalance has an important impact on model training and performance and needs to be specially considered and addressed in the subsequent model design and training processes. This figure is to visually display the diversity and category imbalance of the dataset, highlighting the challenges that need to be addressed in the model training and performance optimization processes.
[0089] The classification criteria of sandstone mainly rely on its mineral composition, especially the proportions of lithic fragments (L), feldspar (F), and quartz (Q). Usually, this classification method is presented through the QFL triangular diagram, as Figure 4 shown. The three corners of the QFL triangular diagram represent the percentage contents of lithic fragments, feldspar, and quartz respectively, and the position of each sample point reveals the specific type of sandstone. By the proportional relationship among lithic fragments, feldspar, and quartz, different types of sandstone can be visually distinguished. This classification method is of great significance for understanding the diagenetic environment, provenance characteristics, and potential reservoir properties of sandstone. For example, sandstone with a high quartz content usually indicates a high maturity of the source rock and a long-distance transportation, and this kind of sandstone may have good porosity and reservoir properties. While sandstone with a high lithic fragment content may originate from near-source erosion, showing a lower maturity, and its reservoir properties may be affected by the lithic fragment composition (such as soluble lithic fragments or argillaceous lithic fragments that are easy to be compacted). The proportion of feldspar can reflect the degree of chemical weathering and the type of source area rock.
[0090] Step 2: Image preprocessing
[0091] In the research on sandstone microscopic image classification, to improve the generalization ability and recognition accuracy of the model, we implemented a series of refined preprocessing steps on the image dataset. These steps ensure that the image data input into the model is both highly consistent and maintains the necessary diversity, thus laying a solid foundation for the smooth progress of the classification task.
[0092] First is random size cropping. By randomly cropping the image and adjusting it to a preset size, this step improves the model's adaptability to image size differences and increases the data diversity by introducing position transformations. Next, to enhance the model's robustness to image orientation changes, we adopted the method of random horizontal flipping to expand the dataset. This processing not only increases the orientation diversity of the images but also enriches the dataset in a probabilistic way. In addition, we also performed normalization on the images, normalizing the images according to the predetermined mean and standard deviation, aiming to promote the rapid convergence of the training process and reduce the sensitivity of the model to the original image value distribution.
[0093] For the preprocessing of the validation set, a slightly different strategy was adopted to ensure that key information is not lost during the cropping process. The specific operations include first adjusting the image size to be slightly larger than the target size and then performing central cropping, so as to ensure that the model can focus on analyzing the information-rich area in the center of the image. Similar to the processing of the training set, the images in the validation set were also converted to tensors and normalized, ensuring the consistency of the image format and numerical range.
[0094] Through the above series of carefully designed and implemented preprocessing steps, we provided high-quality and diverse data for the classification task of sandstone microscopic images, thus effectively improving the generalization ability and recognition accuracy of the model. These preprocessing measures reflect the importance and complexity of data preprocessing in high-precision image classification tasks, providing important reference and inspiration for subsequent research.
[0095] Example 2: Improved Swin-Transformer Framework
[0096] Step 1: In the original architecture of Swin Transformer, although its innovative windowed self-attention mechanism provides an effective way to process complex visual data, in specific application scenarios, such as the classification of sandstone microscopic images, it still faces a series of challenges. The unique subtle texture changes, grain size differences, and class imbalance problems in these images require the model to have more sensitive detail perception ability and a more balanced learning strategy. To overcome these challenges, this study specifically introduced two core modules - Spatial Adaptive Enhancement Module (SAEM) and Local Perception Block (LPB), as well as Balance Adaptive Mechanism (BAM) into the Swin Transformer network structure. The overall structure is as Figure 5 shown.
[0097] Regarding the limitations of the original Swin Transformer architecture in processing sandstone microscopic images with rich detailed features, especially its insufficiency in capturing subtle textures and grain size variations in images, a Spatial Adaptive Enhancement Module (SAEM) was introduced for targeted optimization. The design of the SAEM module is based on further refinement of feature extraction by the self-attention mechanism, enhancing the detailed expression of images by adaptively adjusting the importance of channels. This module is placed after the first multi-layer perceptron (MLP) in the Swin Transformer Block. This strategic layout ensures that SAEM can directly process the extracted features, strengthening the model's ability to recognize complex textures in sandstone microscopic images, thereby effectively improving the classification accuracy.
[0098] In addition, to enhance the model's ability to capture and process local spatial information and address the limitations of Swin Transformer in understanding and analyzing complex structures and patterns in sandstone microscopic images, a Local Perception Block (LPB) was designed as a preprocessing module and placed before each Swin Transformer Block. The LPB module optimizes and enhances the input features before entering the deep learning module, especially strengthening the local spatial information. This design not only improves the model's recognition accuracy of local image features but also provides a more efficient solution for complex image classification tasks, significantly enhancing the overall performance of the model.
[0099] Considering the prevalent class imbalance problem in the sandstone microscopic image dataset, a Balanced Adaptive Mechanism (BAM) was also designed and introduced. By dynamically adjusting the weights of each class in the loss function, the BAM mechanism balances the model's learning focus on each class during training, especially strengthening the learning of classes with fewer samples. This strategy effectively reduces the impact of class imbalance on the model's performance, ensuring the model's high sensitivity and recognition accuracy for all classes, and further optimizing the generalization ability and performance of the sandstone microscopic image classification task.
[0100] Step 2: In the design of the deep learning model, effectively capturing the detailed features in the image is crucial for improving the classification accuracy. For the complex texture and morphological features in sandstone microscopic images, an innovative module - the Spatial Adaptive Enhancement Module (SAEM) is introduced as Figure 6 shown. This module is dedicated to adaptively adjusting the model's attention to different spatial positions, highlighting the key details and texture information in the image, thereby enhancing the model's image feature capture ability and classification performance.
[0101] The design of SAEM is based on the unique texture and morphological features exhibited by different geological structures and mineral compositions in sandstone microscopic images, which are crucial for classification tasks. However, these detailed features are often extremely uneven in spatial distribution, resulting in much more information in some areas than in others. Traditional attention mechanisms tend to pay equal attention to the entire image and fail to fully utilize the unevenness within the image, which may lead to the omission of key information. SAEM assigns different attention weights to each spatial position through an adaptive learning method, dynamically adjusting the attention distribution, enabling the model to focus more on those regions rich in information and crucial for classification judgment.
[0102] SAEM enhances the channel attention mechanism of the model through a sophisticated design, enabling it to effectively capture the dependencies between channels without complex parameters. It first compresses the spatial dimension of the feature map through global average pooling to generate a global context descriptor for each channel. Then, these descriptors are fed into a specially designed one-dimensional convolutional network, which dynamically adjusts the size of its convolutional kernel according to the number of channels to adapt to different scales of feature dependencies. This adaptive kernel size allows SAEM to learn broader channel relationships without an additional parameter burden. Through this process, each channel is assigned a weight, which is finally normalized through the Sigmoid function to determine the contribution of each channel to the final output. This lightweight and efficient design of SAEM makes it excellent in enhancing the model's ability to capture key features, especially suitable for resource-constrained situations.
[0103] The design of the Spatial Adaptive Enhancement Module (SAEM) demonstrates the application potential of deep learning technology in the field of geological image analysis, providing a new strategy for improving the model's ability to recognize complex images and classification accuracy. In the future, further exploration of the application of SAEM in other geological images and broader image processing tasks will be carried out to promote the development of deep learning technology in geological research and related fields.
[0104] Step 3: To improve the performance of the deep learning model in the sandstone microscopic image classification task, a Local Perception Block (LPB) is introduced. The role of this module is to enhance the model's understanding of the complex textures and geological structures in the image. The design of LPB is based on the fact that the mineral compositions and texture features in sandstone microscopic images exhibit unique spatial distribution patterns in local regions, and these patterns are crucial for correct classification. Therefore, enhancing the model's perception ability at the local spatial scale is extremely important for capturing these key features and improving classification accuracy.
[0105] By embedding a specific local perception structure in the model, LPB can analyze the local regions of images more meticulously and extract detailed features that contribute to classification. LPB adopts a processing strategy that combines local windows and spatially offset windows, innovatively enhancing the model's ability to understand spatial information. Specifically, it captures the details of the image and information in neighboring regions through local windows, and expands the model's field of view through spatially offset windows to capture more extensive context information. The outputs of these two strategies are then combined and optimized and adjusted through a series of operations such as fusion, convolution, or attention mechanisms to generate richer and more representative feature maps. The advantage of LPB lies in its ability to flexibly balance the capture of local and global information, enabling the model to perform more precisely and efficiently in tasks that require high spatial perception, such as image segmentation or object detection.
[0106] By comprehensively analyzing local and global information, LPB enables the model to more accurately identify key geological features when processing sandstone microscopic images with complex textures and geological structures, significantly improving the classification accuracy. Experimental results show that integrating LPB into the model framework based on Swin Transformer achieves significant performance improvements in multiple sandstone microscopic image classification tasks, verifying the effectiveness of LPB in enhancing the model's local perception ability and understanding complex image textures. Figure 7 Reveal how the LPB module strengthens the model's capture and processing of local spatial information. The figure shows how the module, after receiving the input of image features, enhances the understanding of complex structures and patterns in the image through local processing. The introduction of the LPB module significantly improves the model's ability to identify local features in sandstone microscopic images, thus achieving better performance in complex image classification tasks.
[0107] Step 4: Balanced Adaptive Mechanism (BAM): To address the challenges faced by deep learning in dealing with highly class-imbalanced and sample-diverse problems, a novel loss function - Balanced Adaptive Mechanism (BAM) is designed. BAM combines the advantages of weighted cross-entropy loss, dual focal loss, and online hard example mining (OHEM), and introduces a mechanism for dynamically adjusting the loss weights based on the training progress, aiming to more effectively handle the sample imbalance and the distribution of easy and hard samples during the training process.
[0108] BAM innovatively solves the problems of class imbalance and the distribution of easy and hard samples by combining weighted cross-entropy, dual focal loss, and OHEM techniques. The dynamic class weights aim to mitigate the impact of class imbalance; the dual focal loss part trains hard-to-classify samples more effectively and reduces the influence of easy-to-classify samples; while the online hard example mining part further enhances the model's learning of hard-to-separate samples by focusing on the samples with the largest losses.
[0109] First, define the basic cross-entropy loss:
[0110]
[0111] where y is the one-hot encoding of the true label, is the probability distribution predicted by the model, and C is the total number of classes.
[0112] The dynamic class weights are given by the following formula:
[0113] WeightedCELoss = CELoss × W(y)
[0114] where W(y) is the weight corresponding to the class selected according to the true label y. This enables the model to dynamically adjust its attention to different classes.
[0115] The calculation formula for the dual focal loss is:
[0116] DualFocalLoss = α · (1 - p t ) γ · WeightedCELoss
[0117] where p t is the predicted probability of the model for the correct class, and α and γ are hyperparameters used for adjustment.
[0118] The online hard example mining (OHEM) loss is calculated by selecting a part of the samples with the largest weighted cross-entropy loss:
[0119]
[0120] The total loss is the result of the weighted sum of DualFocalLoss and OHEMLoss:
[0121] BAM = ω DFL · DFL + ω OHEML · OHEML
[0122] where ω DFL and ω OHEML are the weights of DFL and OHEML respectively, and they are adaptively adjusted according to the following strategy:
[0123]
[0124]
[0125] Thus, if a certain loss part is relatively high, it will receive a greater weight in the next round of training. This method enables the model to automatically focus on the more "difficult" parts in the current training stage, thus achieving a more balanced and effective training.
[0126] Compared with traditional loss functions, BAM provides a more flexible and effective method for dealing with key challenges in deep learning, especially suitable for complex data distributions and extreme class imbalance situations. Through the dynamic weight adjustment mechanism and the innovative design of the loss function, BAM significantly improves the generalization ability and classification performance of the model, and is particularly suitable for application scenarios that require fine sample processing, such as medical image analysis, text classification, and speech recognition.
[0127] Step 5: Evaluation Metrics
[0128] To comprehensively evaluate the model performance, several key evaluation metrics are adopted, including Accuracy, Recall, Precision, and F1-Score. These metrics can comprehensively reflect the performance of the model in the classification task from different perspectives, as shown in Table 2.
[0129] Accuracy: This is a basic metric for measuring the overall classification accuracy of the model, calculated as the ratio of the number of images correctly classified by the model to the total number of images. A high accuracy means that the model has good classification performance overall. It is one of the most intuitive performance metrics.
[0130] Recall: It reflects the ability of the model to correctly identify positive class samples, which is particularly crucial for avoiding missing important classifications in geological research.
[0131] Precision: It evaluates the proportion of samples that are truly positive among the samples predicted as positive by the model, which is particularly important for reducing misclassifications.
[0132] F1-Score: The harmonic mean of Precision and Recall, providing a performance measure that comprehensively considers Precision and Recall.
[0133] Table 1 Model Evaluation Metrics
[0134]
[0135] Step 6: Experimental Design
[0136] All experiments were conducted on a high-performance server equipped with an NVIDIA RTX 4090 GPU and 24 GB of RAM to ensure high efficiency in data processing and model training during the experiment. This configuration provides powerful computing capabilities, especially for the training of deep learning models, which is crucial for processing and analyzing large-scale sandstone microscopic image datasets.
[0137] The principle of 8:1:1 ratio allocation was adopted. That is, 80% of the images in the dataset were randomly selected as the training set for model training and adjustment; 10% of the images were used as the validation set for performance verification and parameter tuning during model training; finally, the remaining 10% of the images constituted the test set for evaluating the generalization ability and accuracy of the model on unseen data.
[0138] Table 2 Training configuration information
[0139]
[0140]
[0141] Step 7: Analysis of experimental results
[0142] The accuracy of the basic Swin Transformer model on the test set was 86.71%, and the macro-average precision, recall, and F1-score were 0.684, 0.868, and 0.720 respectively. By introducing the Spatial Adaptive Enhancement Module (SAEM), the accuracy was increased to 87.66%; when using the Local Perception Block (LPB), the accuracy was 87.16%. Combining the techniques of SAEM and LPB further improved the accuracy to 91.06%. In addition, optimizing the loss function alone, that is, using the Balanced Adaptive Mechanism (BAM), also achieved an accuracy of 87.95%. When using LPB and BAM simultaneously, the accuracy was 90.06%. The Improved Swin-Transformer model, under the combined action of SAEM, LPB, and BAM, achieved an accuracy of 92.54%, and the macro-average precision, recall, and F1-score were improved to 0.786, 0.934, and 0.827 respectively.
[0143] Table 3 Performance comparison of different models on the sandstone microscopic image dataset
[0144]
[0145] Under the combined action of SAEM, LPB, and BAM, the Improved Swin-Transformer model achieved an accuracy of 92.54%, and the macro-average precision, recall, and F1-score were 0.786, 0.934, and 0.827 respectively. As Figure 8The training curve of the Improved Swin-Transformer shown.
[0146] Both Coca and ConvNext were proposed in 2022 and demonstrated excellent performance on their test datasets. Coca achieved a Top-1 accuracy of 92.4% on the ImageNet dataset, while ConvNext reached an F1 score of 93.47% on the InDL dataset.
[0147] However, in the application of sandstone microscopic image classification tasks, the Improved Swin-Transformer demonstrated superior performance. As Figure 9 shown, the Improved Swin-Transformer model showed excellent accuracy on the test set, reaching 92.54%, exceeding the performance of Coca and ConvNext in the same task. By observing the scatter plot, the performance of the Improved Swin-Transformer model surpassed several other models, including the state-of-the-art model (SOTA). The efficient channel attention mechanism of the SAEM module enhanced the model's ability to express detailed features while maintaining its lightweight nature; the LPB module strengthened the recognition ability of complex image structures by optimizing local features; the BAM mechanism improved the balance and robustness of the model across different classes by balancing class weights. These modules and mechanisms enhanced the overall performance of the Improved Swin-Transformer model, standing out in the scatter plot of performance comparison.
[0148] In addition, the advantage of the Improved Swin-Transformer model lies in its targeted optimization. Compared with general deep learning models such as Coca and ConvNext, the Improved Swin-Transformer has specifically adjusted and optimized its architecture for sandstone microscopic images, better adapting to the characteristics of geological images, such as details of texture and color distribution, thus ensuring maximum performance on specific tasks. At the same time, by training specifically on a dataset optimized for sandstone microscopic images, the Improved Swin-Transformer can deeply learn and understand the features of such specific images, further improving the classification accuracy.
[0149] By deeply analyzing the confusion matrix of the model and plotting a heatmap as Figure 10, further reveals the classification performance of the Improved Swin-Transformer on nine sandstone categories. The heatmap shows that most of the predictions are accurately focused on the diagonal, indicating that in most cases, the model can correctly identify each category. Notably, for the "feldspar quartz sandstone" category, the model demonstrates extremely high recognition accuracy. Nevertheless, misclassifications between some categories, such as the confusion between "lithic arkose" and other categories, are prominent, providing valuable insights for model optimization and performance improvement.
[0150] In-depth analysis of the confusion matrix helps to gain insights into the performance weaknesses of the model on certain specific categories, and then implement targeted improvement strategies. The highlighting of the diagonal in the heatmap shows the number of correct predictions of the model for each category, and this observation supports the effectiveness of these innovative modules such as SAEM, LPB, and BAM. SAEM enhances the expression of key features by adjusting channel importance, LPB improves the model's understanding of complex structures by strengthening the learning of local features, and BAM solves the data imbalance problem by balancing the learning priorities of different categories. These integrated innovative mechanisms not only improve the accuracy of the model in classification tasks but also enhance its ability to identify subtle differences between specific categories.
[0151] To make each step of the sandstone microscopic image classification system more detailed and specifically feasible, we can further enrich the content of each step. The following is an extended description for each step:
[0152] Example 3: Sandstone Microscopic Image Classification System
[0153] This system utilizes the improved Swin Transformer technology to achieve automatic classification of sandstone microscopic images. The design of the system aims to improve the accuracy and efficiency of sandstone classification. The following are the detailed implementation steps:
[0154] Step 1: Data Collection
[0155] Determine the sources of sandstone microscopic images, which can be existing geological research databases, original images collected in the laboratory, or image materials obtained through cooperative institutions. Conduct a preliminary quality assessment of the collected images, excluding blurred, damaged, or images that cannot be clearly classified, ensuring that the data entering the system has a certain quality baseline. Enhance the images through technical means such as rotation, mirroring, and scaling to increase the data diversity during model training and improve the generalization ability of the model.
[0156] Step 2: Preprocessing
[0157] Normalize the images, including unifying the image size, adjusting the contrast and brightness, etc., to adapt to the model input requirements. Divide the dataset into training set, validation set and test set to ensure the effectiveness of model training and evaluation.
[0158] Step 3: Feature extraction layer design
[0159] According to the characteristics of sandstone microscopic images, appropriately improve the Swin Transformer, such as adjusting the network hierarchy and optimizing the attention mechanism. Evaluate the feature extraction ability of the improved Swin Transformer on sandstone microscopic images to ensure that key geological features can be captured.
[0160] Step 4: Classifier design
[0161] Design applicable multi-classification strategies for possible multiple classifications of sandstone microscopic images, considering using functions such as the softmax function. Optimize the classifier performance by adjusting classifier parameters, using regularization techniques, etc., to reduce the overfitting phenomenon.
[0162] Step 5: Model training
[0163] Adopt batch training mode and adjust model parameters through optimization algorithms such as stochastic gradient descent. Adjust the hyperparameters of the model through methods such as cross-validation to find the best model configuration.
[0164] Step 6: Model validation
[0165] Formulate a reasonable validation strategy, including the selection of evaluation metrics such as accuracy and recall. According to the validation results, further adjust the model structure and parameters to optimize the model performance.
[0166] Step 7: Image classification
[0167] Optimize the system to support real-time image classification, ensuring that the system can quickly respond to the user's classification requests. Evaluate the classification results, including metrics such as classification accuracy and speed, to ensure that the actual application requirements are met.
[0168] Step 8: Result output
[0169] Display the classification results through a graphical interface, including sandstone images and their classification information, to improve the user experience. Support the export and sharing functions of the classification results to facilitate further analysis and research by users.
[0170] This embodiment details the design and implementation process of the sandstone microscopic image classification system, demonstrating how the system uses the improved Swin Transformer technology to classify sandstone images efficiently and accurately. In addition, this embodiment also emphasizes the key steps and optimization strategies in the system design to ensure the practicality and reliability of the system.
[0171] An improved Swin-Transformer framework-based sandstone microscopic image classification method proposed by this invention aims to improve the accuracy and efficiency of sandstone microscopic image classification. By introducing a Spatial Adaptive Enhancement Module (SAEM), a Local Perception Block (LPB), and a Balanced Adaptive Mechanism (BAM), this invention significantly enhances the performance of the model in processing complex geological image tasks. Combined with Figures 1 to 10 the detailed elaboration, this invention not only makes great efforts in the construction and preprocessing of the dataset to ensure high-quality and diverse data input, but also innovates in the design of the model structure, optimizing the key technology modules to adapt to the particularity and complexity of sandstone microscopic images. Through experimental verification, the improved Swin-Transformer framework shows excellent performance in the sandstone microscopic image classification task, significantly higher than traditional deep learning models and the original Swin-Transformer model. This invention is not only innovative in technology but also has broad application prospects in fields such as geological science research and oil and gas resource exploration, providing an efficient and accurate technical solution for the automatic classification and analysis of geological images.
Claims
1. A sandstone microscopic image classification method based on an improved Swin Transformer, characterized in that: The following steps are involved: Step 1: Build and apply a high-quality sandstone microscopic image dataset covering multiple geological regions for model training and evaluation; Step 2: Integrate the Spatial Adaptive Enhancement Module (SAEM) into the Swin Transformer block and place it between the self-attention module and the multi-layer perceptron. The SAEM dynamically adjusts the features of sandstone microscopic images through global average pooling, 1*1 convolution, and adaptive depthwise separable convolution. It is used to capture the overall features of sandstone microscopic images, finely process local details of sandstone microscopic images through convolution operations, and respond to different pixel positions while dynamically adjusting the convolution kernel size to adapt to different input features. The SAEM transforms the attention weights through the Sigmoid activation function to enhance the expression of key textures in sandstone microscopic images; Step 3: Use the local perception block LPB as a high-level preprocessing unit before each Swin Transformer block; Step 4: The Geo-Swin-Transformer model obtained in Steps 2 and 3 is trained using the sandstone microscopic image dataset in Step 1. During the training, the balanced adaptive mechanism BAM is applied to dynamically adjust the category weights in the total loss BAMLOSS. Step 5: During the training phase, the model is evaluated. This evaluation includes multiple metrics, including accuracy, recall, and F1 score, to comprehensively assess the model performance. If the evaluation fails to meet the standards, the model returns to steps 2, 3, and 4, and structural improvements are made to the spatial adaptive enhancement module, local perception block, and balance adaptive mechanism in sequence until the evaluation meets the standards. The balanced adaptive mechanism (BAM) is used to optimize difficult-to-classify samples and class imbalance by combining weighted cross entropy, dual focus loss, and online hard example mining (OHEM). Dynamic class weights are used to mitigate the impact of class imbalance. The dual focus loss part more effectively trains difficult-to-classify samples and reduces the impact of easy-to-classify samples. The OHEM part strengthens Geo-Swin-Transformer's learning of difficult samples by focusing on the samples with the largest loss. The specific implementation process of the balance adaptive mechanism BAM is as follows: First, define the basic cross entropy loss: Among them, y is the one-hot encoding of the true label, is the probability distribution predicted by the model, and C is the total number of categories; The dynamic class weight is given by the following formula: WeightedCELoss = CELoss × W(y) Among them, W(y) is the weight of the corresponding category selected according to the true label y; dynamic class weight can dynamically adjust the attention paid to different categories; The calculation formula for bifocal loss is: DualFocalL oss=α·(1-p t ) γ ·WeightedCELoss Among them, p t is the model's predicted probability for the correct category, and α and γ are hyperparameters used for adjustment; The OHEM loss for online difficult sample mining is calculated by selecting a portion of samples with the largest weighted cross entropy loss: The total loss BAMLoss is the result of the weighted summation of DualFocalLoss and OHEMLoss: BAMLoss=ω DualFocalLoss ·DualFocalLoss+ω OHEMLoss ·OHEMLoss where ω DualFocalLoss and ω OHEMLoss are the weights of DualFocalLoss and OHEMLoss, ω DualFocalLoss and ω OHEMLoss Adaptive adjustment is based on the following strategies: If a certain loss part is relatively high, ω DualFocalLoss or ω OHEMLoss It will receive a larger weight in the next round of training.
2. The classification method according to claim 1, characterized in that The SAEM generates a global descriptor for each channel through global average pooling and uses a one-dimensional convolutional network to adjust the channel adaptively adjust the attention to different pixel positions in the sandstone microscopic image; The structure of SAEM includes a global average pooling layer, 1x1 convolution, adaptive depthwise separable convolution, and a sigmoid activation function. The collaborative work of these components within SAEM enables SAEM to adaptively adjust the attention to different spatial locations. The global average pooling layer is used to quickly capture overall features, the 1x1 convolution performs feature transformation, and the adaptive depthwise separable convolution dynamically adjusts the kernel size according to the input features to optimize the processing of local details in sandstone microscopic images to obtain processed features. The sigmoid activation function converts the processed features into attention weights to enhance the focus on important features.
3. The classification method according to claim 1 or 2, characterized in that: The local perception block (LPB) is used to improve the model's recognition of complex textures and geological structures in sandstone microscopic images. The LPB consists of deep and dilated convolutional layers, a multi-head attention mechanism, and a SE block. The deep and dilated convolutional layers capture complex textures and structures through extensive spatial coverage, providing detailed feature maps. The multi-head attention mechanism is used to enhance the ability to analyze different pixel locations in sandstone microscopic image data. The SE block strengthens important features and suppresses unimportant information by recalibrating channel features. When LPB processes input features, it combines local window and spatial offset window techniques to optimize the capture of local spatial information and generate more representative feature maps through fusion, convolution or attention mechanism operations.
4. The classification method according to claim 1, characterized in that In step 4, the training process includes: Initially, the basic Swin Transformer model was trained as a baseline for performance comparison of subsequent modules. Subsequently, to systematically explore the specific contributions of each enhancement module to model performance, the spatially adaptive enhancement module (SAEM) and the local perception block (LPB) were separately integrated. SAEM aims to adaptively enhance the representation of image details, while LPB focuses on improving the model's ability to capture local image features. Next, the training entered the combined module stage, examining the synergistic effects of different module combinations: combining SAEM and LPB to optimize the recognition accuracy of complex geological textures; combining SAEM with the balanced adaptive mechanism BAM to adjust the category weights in classification to address the problem of category imbalance; and combining LPB with BAM to simultaneously enhance local feature recognition and improve category balance.
5. The classification method according to claim 4, characterized in that: In step five, the confusion matrix and ROC curve statistical tools are used to analyze the recognition ability and misclassification behavior of the Geo-Swin-Transformer model in each category.
6. A sandstone microscopic image classification system based on an improved Swin Transformer, characterized by: The system has program modules corresponding to the steps of any one of claims 1 to 5 above: a data preprocessing module, a model training module, and a performance evaluation module, as well as corresponding algorithm modules for implementing SAEM, LPB, and BAM strategies; and executes the steps in the sandstone microscopic image classification method based on the improved Swin Transformer during operation.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is configured to implement the steps of the sandstone microscopic image classification method based on the improved Swin Transformer according to any one of claims 1 to 5 when called by a processor.
Citation Information
Patent Citations
Sandstone permeability calculation method based on microscopic image processing
CN113029899A
Deep learning-based compact sandstone image augmentation method
CN116612362A
TransUNet-based rock slice image granularity identification method, electronic equipment and storage medium
CN116543256A
Remote sensing image scene classification method fusing Swin Transform and visual image neural network
CN117392547A