Sandstone microscopic image classification method and system based on improved Swin Transform

Through the improved Swin Transformer model, combined with SAEM, LPB and BAM technology, the problem of complex texture and category imbalance in sandstone microscopic image classification is solved, efficient and accurate image classification is achieved, and the quality of geological scientific research and oil and gas exploration is improved. Accuracy and efficiency.

CN118570797AActive Publication Date: 2024-08-30NORTHEAST GASOLINEEUM UNIV

Patent Information

Application Number
CN202410562542.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-08
Publication Date
2024-08-30
Estimated Expiration
2044-05-08

AI Technical Summary

Technical Problem

Existing deep learning methods face the problems of complex texture characteristics, subtle differences between categories, and uneven distribution of training samples in the classification of sandstone microscopic images, resulting in low classification accuracy and efficiency.

Method used

Using the improved Swin Transformer model, integrating spatial adaptive enhancement module (SAEM), local perception block (LPB) and balanced adaptive mechanism (BAM), SAEM dynamically adjusts features, LPB strengthens local feature capture, and BAM balances category weights to improve The model’s recognition ability and generalization performance for complex images.

Benefits of technology

It has significantly improved the classification accuracy and efficiency of sandstone microscopic images, effectively dealt with the problem of class imbalance, improved the model's ability to identify complex textures and detailed features, and enhanced the accuracy and efficiency of geological scientific research and oil and gas exploration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570797A
    Figure CN118570797A
Patent Text Reader

Abstract

The invention discloses a sandstone microscopic image classification method and system based on an improved Swin Transform, and relates to the field of geology and oil gas exploration based on artificial intelligence. The sandstone microscopic image classification method based on the deep learning is provided for solving the problems that the sandstone microscopic images cannot be accurately classified through an existing deep learning method due to the complex texture characteristics of the sandstone images, subtle differences between categories and the imbalance of training sample distribution. According to the invention, by improving a Swinin-Transform framework and introducing three key technology modules, namely a spatial adaptive enhancement module, a local sensing module and a balanced adaptive mechanism, main problems encountered in a sandstone microscopic image classification task by a traditional deep learning method are effectively solved. The comprehensive application of the modules not only enhances the ability of the model to capture fine features in the sandstone microscopic image, but also optimizes the classification precision of the model in processing different sandstone class images, and shows better generalization ability in processing the sample imbalance problem. According to the method, the automatic classification performance of the sandstone microscopic image is remarkably improved, and a new technical scheme and a new research idea can be brought to the field of geological image processing and analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of geology and oil and gas exploration based on artificial intelligence, and in particular to a sandstone microscopic image classification method and system based on an improved SwinTransformer. Background Art

[0002] In the field of geological science and oil and gas exploration, accurate analysis and classification of sandstone microscopic images is a very basic and critical task. These images intuitively present information about sedimentary rock layers of a specific geological era through changes in their color, texture, and layers, providing direct support for understanding stratum characteristics, assessing 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, labor-intensive, and costly, but also its results are easily affected by personal experience and subjective judgment, which brings considerable uncertainty.

[0003] With the continuous advancement of technology, the application of electron microscopy and digital image processing technology has greatly improved the efficiency of image acquisition and the accuracy of analysis. However, when faced with massive amounts of sandstone microscopic image data, how to achieve fast and accurate classification and interpretation remains a major challenge. Although the development of computer vision and machine learning technologies has provided the possibility for automated image classification, these technologies still face many difficulties when dealing with specific problems in sandstone microscopic image classification. First, sandstone microscopic images often present highly complex texture features, and the image differences of different types of sandstone under the microscope are subtle, which places high demands on the resolution of the classification algorithm. Second, there is an imbalance in the categories between samples, that is, the number of samples of some sandstone types may be far greater than that of other types, which may cause the classification model to overfit to the categories with a larger number during training, while ignoring the categories with fewer samples. In addition, due to the high cost of acquiring geological image data, the high-quality annotated data available for training is relatively limited, which further limits the performance improvement 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. In particular, the outstanding performance of convolutional neural networks (CNNs) in image recognition and classification enables deep learning models to automatically extract high-level features of images by learning a large amount of labeled data, which can then be used for classification or regression tasks. Furthermore, since the Transformer model has made major breakthroughs in the field of natural language processing, its application in the field of image processing has also attracted widespread attention. As a new network architecture that combines the advantages of convolutional neural networks and Transformers, the Swin Transformer maintains high performance while reducing computational costs through its unique windowed self-attention mechanism, opening up a new way to process complex image tasks.

[0005] However, there are still many challenges in directly applying deep learning technology to sandstone microscopic image classification. On the one hand, existing deep learning models are highly dependent on a large amount of labeled data, while high-quality sandstone microscopic image labeled data is relatively scarce. On the other hand, traditional deep learning models still have problems with insufficient recognition accuracy and limited generalization ability when processing 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 are few studies on the classification of sandstone microscopic images. The prior art with document number CN113029899A discloses a sandstone permeability calculation method based on microscopic image processing, which includes obtaining a 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 network image after pore throat enhancement; determining the surface area ratio of the sandstone microscopic image according to the binary pore network image; determining the particle diameter according to the pore network image after pore throat enhancement; determining the pore tortuosity according to the pore network image after pore throat enhancement; and calculating the sandstone permeability according to the surface area ratio, particle diameter, and pore tortuosity determined above. In the case where it is difficult to obtain a large number of plunger cores, the present invention only uses easily obtained rock microscopic photographs taken from small fragment cores, extracts sandstone microscopic parameters through image processing, and calculates sandstone permeability, thereby making up for the lack of permeability data and better guiding the exploration and development of sandstone oil and gas reservoirs. The prior art with document number CN116612362A provides a method for dense sandstone image augmentation based on deep learning, which includes: obtaining labeled dense sandstone images and performing preprocessing; constructing a dense sandstone image generation model with StyleGAN network as the main body; training the constructed dense sandstone image generation model based on the acquired dense sandstone image; in the process of training, adjusting the augmentation strength according to the degree of overfitting, and dynamically adjusting the position for judging whether it is overfitting next time; using the trained dense sandstone image generation model to generate dense sandstone images. The present invention can generate high-quality dense sandstone images, improve data diversity, and augment dense sandstone image samples to provide support for realizing intelligent dense sandstone image segmentation. It can be seen that the prior art has not conducted in-depth research on sandstone microscopic image classification technology.

[0007] In contemporary research on geological science and oil and gas exploration, the classification and interpretation of sandstone microscopic images occupy a vital position. With the rapid advancement of deep learning technology, especially its outstanding ability 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 particular field, including the complex texture characteristics of sandstone images themselves, subtle differences between categories, and the imbalance of training sample distribution. In summary, the research and progress of sandstone microscopic image classification technology is of vital significance to promoting geological science research and the effective development of oil and gas resources. Therefore, it is urgent to provide a sandstone microscopic image classification method and system. Summary of the invention

[0008] The technical problem to be solved by the present invention is: due to 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. The present invention provides a sandstone microscopic image classification method and system based on (utilizing) an improved Swin Transformer.

[0009] The technical solution adopted by the present invention to solve the above technical problems is:

[0010] A sandstone microscopic image classification method based on an improved Swin Transformer comprises the following steps:

[0011] Step 1: Build and apply a high-quality sandstone microscopic image dataset covering multiple geological regions for model training and evaluation to improve the accuracy and efficiency of classification tasks;

[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 dynamically adjusts the features of the sandstone microscopic image (texture, color, shape of the sandstone) through global average pooling, 1*1 (1 times 1) convolution and adaptive depth-separable convolution, and is used to capture the overall features of the sandstone microscopic image, finely process the local details of the sandstone microscopic image through convolution operations, and respond 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 the sandstone microscopic image;

[0015] Step 3: Use the local perception block (LPB) as a high-level preprocessing unit before each Swin Transformer block;

[0016] 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 (to solve the sample imbalance problem and improve the generalization ability and classification accuracy of the model).

[0017] Step 5: During the training phase, the model is evaluated. The model evaluation includes multiple indicators such as accuracy, recall rate, 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 improve the spatial adaptive enhancement module, local perception block, and balanced adaptive mechanism in turn until the evaluation meets the standard. The structural improvement method 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, the spatial adaptive enhancement module (SAEM) is integrated into the Swin Transformer block and placed between the self-attention module and the multi-layer perceptron, which provides several key advantages to significantly improve the recognition of image details and textures. First, SAEM dynamically adjusts features through global average pooling, 1x1 convolution, and adaptive depthwise separable convolution. This process not only captures the overall context, but also finely processes local textures and details through convolution operations, especially when the convolution kernel size is dynamically adjusted to adapt to different input features, it can respond more sensitively to different spatial locations. In addition, SAEM further strengthens the focus on local features on the features extracted by the self-attention module, and accurately enhances the expression of key textures and structures in the image through the attention weights converted by the sigmoid activation function. This structure optimizes feature expression and enables the model to deeply parse and highlight important image details, resulting in better adaptability and accuracy when processing complex images.

[0019] In step three, the local perception block (LPB) serves as an advanced preprocessing unit before each Swin Transformer block. It captures a wide range of spatial features through its deep and dilated convolutional layers, and the multi-head attention mechanism enhances the interpretation of different subspaces of the data. At the same time, the optimized SE block effectively recalibrates the features. This configuration allows LPB to enhance the representation of key local features before the data flows into the Swin Transformer block, providing richer and more refined feature inputs for the subsequent Transformer structure. This move not only significantly improves the performance of the model in processing image details and complex patterns, but also optimizes the learning process, allowing the network to show better adaptability and accuracy in visual tasks that rely on fine spatial details.

[0020] Furthermore, the SAEM generates a global descriptor for each channel through global average pooling, and uses a one-dimensional convolutional network to adjust the channel to adaptively adjust the attention paid to different pixel positions in the sandstone microscopic image.

[0021] The structure of SAEM includes a global average pooling layer, 1x1 convolution, adaptive depthwise separable convolution and Sigmoid activation function. The collaborative work of these components enables SAEM to adaptively adjust the attention to different spatial positions; the global average pooling layer is used to quickly capture the overall features, the 1x1 convolution performs feature conversion, and the adaptive depthwise separable convolution dynamically adjusts the kernel size according to the input features to optimize the processing of local details of the sandstone microscopic image to obtain 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 and is used to significantly improve the model's image feature recognition and classification performance. SAEM generates a global contextual descriptor for each channel through global average pooling and uses a one-dimensional convolutional network to adjust the importance of the channel, thereby enhancing the model's ability to express key features. The module strengthens the capture of key details and texture information by adaptively adjusting the attention to different spatial (pixel) locations of the image. In addition, it dynamically assigns attention weights based on the unique texture and morphological features of the geological structure and mineral components in the image, allowing the model to focus on information-rich areas that are critical for classification judgment. The structure of SAEM includes global average pooling, 1x1 convolution, adaptive depthwise separable convolution, and sigmoid activation function. The collaborative work of these components enables SAEM to adaptively adjust the attention to different spatial locations. 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 detail processing. 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 inter-channel dependencies in a lightweight and efficient way, 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 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 and provide feature maps with rich details; the multi-head attention mechanism is used to enhance the parsing ability of different pixel positions (subspaces) of sandstone microscopic image data, and the SE block strengthens important features and suppresses unimportant information by recalibrating channel features;

[0024] When LPB processes input features, it combines local window and spatial offset window technology to optimize the capture of local spatial information and generate more representative feature maps through fusion, convolution or attention mechanism operations;

[0025] In addition, LPB specifically targets the unique distribution of mineral composition and texture features in local areas of sandstone microscopic images, carefully analyzes these 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 neighboring information, achieving a deep understanding of image spatial information. Through this method of combining local window technology with spatial offset window strategy, LPB significantly improves the efficiency of capturing and parsing spatial information, thereby enhancing the model's ability to parse complex textures and geological structures in images.

[0026] Furthermore, the balanced adaptive mechanism (BAM) is used to optimize the processing of difficult-to-classify samples and category imbalance by combining weighted cross entropy, dual focus loss and online hard example mining (OHEM) technology, and the dynamic class weights are used to alleviate the impact of category imbalance; the dual focus loss part more effectively trains difficult-to-classify samples and reduces the impact of easy-to-classify samples; and the OHEM part strengthens Geo-Swin-Transformer's learning of difficult samples by focusing on samples with the largest loss.

[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] 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;

[0031] The dynamic class weight is given by the following formula:

[0032] WeightedCELoss=CELoss×W(y)

[0033] Among them, W(y) is the weight of the corresponding category selected according to the true label y; the dynamic class weight can dynamically adjust the attention to different categories;

[0034] The calculation formula for bifocal loss is:

[0035] DualFocalLoss=α·(1-p t ) γ ·WeightedCELoss

[0036] Among them, p t is the model's predicted probability for the correct category, α and γ are hyperparameters used for adjustment;

[0037] The online difficult sample mining (OHEM) loss is calculated by selecting a portion of 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, ω DualFocalLoss and ω OHEMLoss Adaptive adjustment is based on the following strategies:

[0042]

[0043]

[0044] If one of the loss components is relatively high, DualFocalLoss and ω OHEMLoss It will get a bigger weight 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 the performance comparison of subsequent modules; then, in order to systematically explore the specific contribution 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 the image. Then, the training enters the combined module stage to examine the synergistic effect 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 deal with the problem of class imbalance; 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 were used to analyze the recognition ability and misclassification behavior of the Geo-Swin-Transformer model in each category. The training phase was accompanied by a detailed model evaluation, including multiple indicators such as accuracy, recall, and F1 score, to comprehensively evaluate the model performance. During the evaluation process, special attention was paid to the performance of the model in dealing with class imbalance and complex texture recognition. In addition, statistical tools such as confusion matrix and ROC curve were used to further analyze the recognition ability and misclassification behavior of the model in each category. 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 ensured through detailed logging and performance monitoring to ensure the repeatability and scientificity of the experimental results.

[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, and corresponding algorithm modules for implementing SAEM, LPB and BAM strategies; the system executes the steps of the sandstone microscopic image classification method based on the improved Swin Transformer during operation.

[0048] A computer-readable storage medium stores a computer program, wherein the computer program is configured to implement the steps of the above-mentioned sandstone microscopic image classification method based on the improved Swin Transformer when called by a processor.

[0049] The technical points of the present invention are further described as follows:

[0050] This paper improves the Swin-Transformer framework and introduces three key technical modules - spatial adaptive enhancement module (SAEM), local perception block (LPB) and balanced adaptive mechanism (BAM) - to effectively address the main problems encountered by traditional deep learning methods in sandstone microscopic image classification tasks. The comprehensive use of these modules not only enhances the model's ability to capture subtle features in sandstone microscopic images, but also optimizes the model's classification accuracy when processing images of different sandstone categories, and demonstrates better generalization ability in dealing with sample imbalance problems.

[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, allowing the model to focus more 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 microscopic images, LPB focuses on improving the model's ability to process local spatial information, thereby improving the recognition accuracy of complex textures and structures. Through a special local window mechanism, this module strengthens the model's learning of local image features to improve classification performance.

[0053] Balanced Adaptive Mechanism (BAM): To address the class imbalance problem in sandstone microscopic image data, BAM introduces dynamic weight adjustment in the loss function to balance the model's learning of samples of different categories. This mechanism automatically optimizes the weights and improves the model's ability to recognize minority categories, thereby improving the overall classification accuracy and generalization performance.

[0054] The technical solution of the present invention not only has breakthroughs in feature extraction capability, category imbalance processing and model structure, but also shows broad application potential in the fields of geological science research and oil and gas resource exploration. By realizing an efficient and accurate automatic classification technology, the efficiency and accuracy of geological sample analysis are significantly improved, the pace of geological research is accelerated, and a more accurate scientific basis is provided for the exploration and development of oil and gas resources, which has great economic and social value.

[0055] The system of the present invention consists of the following main modules to support the whole process from image input to final classification decision:

[0056] Data preprocessing module: preprocess the input sandstone microscopic images, including image denoising, enhancement and standardization, to optimize the input quality of 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 uses advanced deep learning technology to achieve efficient feature extraction and classification based on the characteristics of sandstone microscopic images.

[0058] Classification evaluation module: Comprehensively evaluate the classification performance of the model, using indicators such as accuracy, recall, and F1 score to ensure the high performance of the model.

[0059] Result interpretation and visualization module: Visualizes the classification results and provides in-depth explanations of the model's decision basis to help users understand how the model works.

[0060] The present invention has the following beneficial technical effects:

[0061] The present invention proposes an improved Swin-Transformer framework, which integrates a spatial adaptive enhancement module (SAEM), a local perception block (LPB) and a balanced adaptive mechanism (BAM), to provide 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 by integrating modules, and the sandstone microscopic image classification method and system of the improved Swin Transformer provide strong technical support for geological science research.

[0062] In the present invention (this study), the training process strictly follows a set of phased experimental designs to ensure that the effect of each module can be accurately evaluated. In the initial stage, the basic Swin Transformer model is trained as a baseline for the performance comparison of subsequent modules. Subsequently, in order to systematically explore the specific contribution 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 the image.

[0063] Next, the experiment entered the combined module stage to examine the synergistic effects of different module combinations. Specifically, SAEM and LPB were combined to optimize the recognition accuracy of complex geological textures; SAEM was combined with the balanced adaptive mechanism (BAM) to adjust the class weights in classification to deal with the class imbalance problem; and LPB was combined with BAM to simultaneously enhance local feature recognition and improve class balance.

[0064] Each training phase is accompanied by a detailed model evaluation, including multiple indicators such as accuracy, recall, and F1 score, to comprehensively evaluate the model performance. During the evaluation process, special attention is paid to the model's performance in dealing with class imbalance and complex texture recognition. In addition, statistical tools such as confusion matrix and ROC curve are used to further analyze the model's recognition ability and misclassification behavior in each category.

[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 sandstone microscopic image classification tasks by integrating the advantages of each module. The entire training and evaluation process is ensured by detailed logging and performance monitoring to ensure the repeatability and scientificity of the experimental results.

[0066] The application of this technical solution in the field of sandstone microscopic image classification has brought significant beneficial effects, including:

[0067] 1. Significantly improve classification accuracy: SAEM module, through its spatial adaptive enhancement capability, combined with LPB module's fine capture of local features, greatly improves the model's ability to identify complex textures and detailed features in sandstone microscopic images. This improvement is crucial in fields such as geological research and oil and gas exploration, because their decisions are often based on accurate classification and in-depth interpretation of rock samples.

[0068] 2. Effectively deal with the problem of category imbalance: Through the introduction of the BAM module, the present invention effectively deals with the problem of category imbalance in sandstone microscopic image data. The module dynamically adjusts the weights of each category in the loss function to ensure that the model remains highly sensitive and accurately identifies all categories, especially for categories with a small number, thereby enhancing the generalization of the model.

[0069] 3. Improve 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 makes the model more computationally efficient when processing complex image data, suitable for performing large-scale sandstone microscopic image analysis in resource-constrained environments, and can meet the needs of real-time or near real-time processing.

[0070] 4. Promote the progress of geological science research and resource exploration: This invention has strongly promoted the development of geological science research and oil and gas resource exploration by providing a more accurate and efficient sandstone microscopic image classification method. Accurate rock classification information helps geologists and exploration engineers to deeply understand the characteristics of the formation, providing a solid scientific basis for resource assessment and development decisions, and has great economic and social value. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] Figure 1 Extract map for core image;

[0072] Figure 2 is a data sample;

[0073] Figure 3Quantity chart for each category;

[0074] Figure 4 This is the sandstone classification scheme adopted in this paper. 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 Schematic diagram of the Improved Swin-Transformer model, in which: (a) is the Improved Swin-Transformer, which means Patch Partition, Patch Merging, and Linear Embedding in English; (b) is the Improved Swin-Transformer Block, which means LN: layer normalization WMSA: window multi-head self-attention MLP: multi-layer perceptron SAEM: spatial adaptive enhancement module SWMSA: shifted window multi-head self-attention;

[0076] Figure 6 This 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 (S-type function) LayerNorm (layer normalization) GELU (Gaussian error linear unit) OUTPUT (output);

[0077] Figure 7This is a schematic diagram of the local perception block (LPB). The English meaning in the figure is Depthwise Conv (depth convolution) 2. Pointwise Conv (point-by-point convolution) Depthwise Conv Spatial (spatial depth convolution) Pointwise ConvSpatial (spatial point-by-point 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-type function);

[0079] Figure 8 This is the Improved Swin-Transformer training curve. The English meaning of the horizontal axis in the figure is the number of training rounds (Epoch), and the English meaning of the vertical axis in the figure is the result indicator (Metrics);

[0080] Fig. 9 This is a comparison chart of model effects. The English meaning of the horizontal axis in the figure is the various models currently available, and the English meaning of the vertical axis in the figure is Accuracy;

[0081] Fig.10 To test the heat map, the English meaning of the horizontal axis in the figure is the predicted category (Predicted Category), and the English meaning of the vertical axis in the figure is the actual category (Actual Category). DETAILED DESCRIPTION

[0082] In order 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 specific embodiments is only for a better understanding of the present invention, and they should not be understood as limitations of 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 understood as indicating or implying relative importance.

[0083] The following is combined with Figures 1 to 10 It should be noted that the embodiments of the present invention are not limited to the following description; for those skilled in the art, all embodiments according to the concept of the present invention will fall within the protection scope of the present invention.

[0084] Example 1: Data preparation and preprocessing

[0085] In the core practice of geological science and oil and gas exploration, the accurate interpretation and classification of sandstone microscopic images play a vital role, which provides direct support for the understanding of stratigraphic characteristics, the assessment of resource potential and the formulation of effective resource development strategies. Figure 1 The core column and the corresponding core microsection images shown in the figure intuitively display the information of sedimentary rock layers in a specific geological period through their color, texture and bedding changes, reflecting the changes in sedimentary environment and differences in rock composition. Through these microscopic images, geological experts can rely on their professional knowledge and practical experience to finely analyze the core columns and core microsections directly extracted from underground rock layers, and extract valuable geological information, including the sedimentary history, composition, pore structure, sedimentary environment, diagenesis, stratigraphic continuity and other geological characteristics of the rock. 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. Faced with complex geological challenges and exploration needs, new technologies are urgently needed to improve the accuracy, efficiency and objectivity of analysis. Therefore, the development of efficient and automated sandstone microscopic image interpretation and classification technology is of far-reaching 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 covers a wide range of geological periods and regions, and is selected from multiple public datasets to meet the development needs of automatic classification and analysis technology in the field of sandstone microscopic images. The datasets are selected from various geological backgrounds, including Cretaceous terrigenous clastic rocks in the Shigatse forearc basin in southern Tibet, Cretaceous terrigenous clastic rocks in the central and northern Lhasa terrane, Late Cretaceous to Eocene thin-section polarized micrographs of rocks in the western Tarim Basin in Xinjiang, Early to Middle Jurassic thin-section polarized micrographs of rocks in the Tethyan Himalayas in Tibet, Mesozoic metamorphic lithic sandstones in the Central Yangtze area, Upper Paleozoic He-8 sandstones in the northeastern margin of the Ordos Basin, Permian volcanic lithic sandstones in southwestern China, Upper Paleozoic tight sandstones in the Linxing block in the eastern margin of the Ordos Basin, Upper Devonian to Lower Carboniferous terrigenous clastic rocks of the Wutong Group in the southern Lower Yangtze, thin sections of rocks from the Middle Cambrian Xuzhuang Formation in the Ordos Basin, microscopic image datasets of buried hills and overlying conglomerates in the Bozhong Sag of the Bohai Bay Basin, and other microscopic images from multiple geological periods and regions.

[0088] The dataset contains 21,825 microscopic images of sandstone cores, covering multiple geological periods, including the Late Cretaceous to Eocene, Cretaceous, Mesozoic metamorphic lithic sandstones, Upper Paleozoic, Permian volcanic lithic sandstones, Upper Devonian to Lower Carboniferous Wutong Group terrigenous clastic rocks, and Middle Cambrian Xuzhuang Formation. Figure 2Each image shown is accurately labeled to ensure the accuracy and consistency of the data, providing a solid foundation for model training and evaluation, and providing valuable resources for subsequent research. In order to more intuitively show the distribution of each category of data in the sandstone microscopic image dataset constructed in this paper, Figure 3 The number of images of sandstone categories in different geological periods in the dataset is shown. The figure clearly reflects the data imbalance between categories, where the number of images of some categories is much larger than that of other categories. This imbalance has an important impact on the training and performance of the model and needs to be specially considered and handled in the subsequent model design and training process. This figure intuitively shows the diversity and category imbalance of the dataset, highlighting the challenges that need to be addressed in the process of model training and performance optimization.

[0089] The classification of sandstone is mainly based on its mineral composition, especially the proportion of lithics (L), feldspar (F), and quartz (Q). Usually, this classification is presented through the QFL triangle diagram, such as Figure 4 As shown. The three corners of the QFL triangle diagram represent the percentage content of rock fragments, feldspar and quartz, respectively. The location of each sample point reveals the specific type of sandstone. Different types of sandstone can be intuitively distinguished by the proportional relationship between rock fragments, feldspar and quartz. This classification method is of great significance for understanding the diagenetic environment, provenance characteristics and potential reservoir properties of sandstone. For example, sandstone with high quartz content usually indicates high maturity and long-distance transport of source rocks. Such sandstone may have good porosity and reservoir properties. Sandstone with high rock fragment content may originate from near-source erosion, showing lower maturity, and its reservoir properties may be affected by rock fragment composition (such as soluble rock fragments or easily compacted mudstone fragments). The proportion of feldspar can reflect the degree of chemical weathering and the rock type in the source area.

[0090] Step 2: Image Preprocessing

[0091] In the study of sandstone microscopic image classification, in order 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 to the model has both high consistency and necessary diversity, thus laying a solid foundation for the smooth progress of the classification task.

[0092] The 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 diversity of the data by introducing position transformations. Next, in order to enhance the model's robustness to changes in image orientation, we use random horizontal flipping to expand the dataset. This process not only increases the orientation diversity of the image, but also enriches the dataset in a probabilistic way. In addition, we also standardize the images according to a predetermined mean and standard deviation, in order to promote rapid convergence of the training process and reduce the model's sensitivity to the distribution of original image values.

[0093] For the preprocessing of the validation set, a slightly different strategy was adopted to ensure that key information was not lost during the cropping process. The specific operations include first resizing the image to be slightly larger than the target size, and then performing center cropping 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 of the validation set were also converted to tensors and normalized to ensure consistency in image format and value range.

[0094] Through the above series of carefully designed and implemented preprocessing steps, we provide high-quality and diverse data for the classification task of sandstone microscopic images, thereby effectively improving the generalization ability and recognition accuracy of the model. These preprocessing measures reflect the importance and complexity of data preprocessing when performing high-precision image classification tasks, and provide important references and inspirations 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, it still faces a series of challenges in specific application scenarios, such as the classification of sandstone microscopic images. The subtle texture changes, grain size differences and category imbalance problems unique to these images require the model to have a keener ability to perceive details and a more balanced learning strategy. In order to overcome these challenges, this study specifically introduced two core modules into the Swin Transformer network structure - the spatial adaptive enhancement module (SAEM) and the local perception block (LPB), as well as the balanced adaptive mechanism (BAM). The overall structure is based on Figure 5 shown.

[0097] In view of the limitations of the original Swin Transformer architecture in processing sandstone microscopic images with rich detail features, especially its inadequacy in capturing subtle textures and granularity changes in images, the Spatial Adaptive Enhancement Module (SAEM) was introduced for targeted optimization. The design of the SAEM module is based on further refinement of the features extracted by the self-attention mechanism, and enhances the detailed expression of the image by adaptively adjusting the importance of the channels. This module is placed after the first multi-layer perceptron (MLP) of the SwinTransformer Block. This strategic layout ensures that SAEM can directly process the extracted features and enhance the model's ability to recognize complex textures in sandstone microscopic images, thereby effectively improving the classification accuracy.

[0098] In addition, in order to improve the model's ability to capture and process local spatial information, a local perception block (LPB) was designed as a preprocessing module and placed before each Swin Transformer Block to address the limitations of Swin Transformer in understanding and parsing complex structures and patterns in sandstone microscopic images. The LPB module optimizes and enhances the input features before entering the deep learning module, especially 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 improving the overall performance of the model.

[0099] Considering the common class imbalance problem in sandstone microscopic image datasets, a balanced adaptive mechanism (BAM) is designed and introduced. By dynamically adjusting the weights of each category in the loss function, the BAM mechanism balances the model's learning focus on each category during training, especially reinforcing learning for categories with fewer samples. This strategy effectively reduces the impact of class imbalance on model performance, ensures the model's high sensitivity and recognition accuracy for all categories, and further optimizes the generalization ability and performance of sandstone microscopic image classification tasks.

[0100] Step 2: In the design of deep learning models, effectively capturing the detailed features in the image is crucial to improving the classification accuracy. Aiming at the complex texture and morphological features in sandstone microscopic images, an innovative module, the Spatial Adaptive Enhancement Module (SAEM), is introduced. Figure 6 This module is dedicated to adaptively adjusting the model's attention to different spatial locations, highlighting key details and texture information in the image, thereby improving the model's image feature capture ability and classification performance.

[0101] The design of SAEM is based on the fact that the unique texture and morphological features of different geological structures and mineral components in sandstone microscopic images are crucial to the classification task. However, these detailed features are often extremely uneven in spatial distribution, resulting in much more information in some areas than in other areas. Traditional attention mechanisms often pay equal attention to the entire image, failing to fully utilize the internal heterogeneity of the image, which may lead to the neglect of key information. SAEM uses an adaptive learning method to assign different attention weights to each spatial position, dynamically adjust the attention distribution, and make the model more focused on those areas that are rich in information and critical to classification judgment.

[0102] SAEM enhances the model's channel attention mechanism through a sophisticated design, so that it can effectively capture channel dependencies without complex parameters. It first compresses the spatial dimensions of the feature map through global average pooling to generate a global context descriptor for each channel. These descriptors are then fed into a specially designed one-dimensional convolutional network that dynamically adjusts its convolution kernel size according to the number of channels to accommodate feature dependencies of different scales. This adaptive kernel size allows SAEM to learn a wider range of channel relationships without the burden of additional parameters. Through this process, each channel is assigned a weight and is ultimately normalized by a Sigmoid function to determine the contribution of each channel to the final output. SAEM's lightweight and efficient design makes it excel in enhancing the model's ability to capture key features, especially in resource-constrained situations.

[0103] The design of the Spatial Adaptive Enhancement Module (SAEM) demonstrates the potential of deep learning technology in the field of geological image analysis and provides a new strategy for improving the model's ability to recognize complex images and classification accuracy. In the future, we will further explore the application of SAEM in other geological images and a wider range of image processing tasks 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, the 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 starting point of LPB is that the mineral composition and texture features in sandstone microscopic images show unique spatial distribution patterns in local areas, which 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 is able to analyze local areas of the image in more detail and extract detailed features that are helpful for classification. LPB adopts a processing strategy that combines local windows and spatially offset windows to innovatively enhance the model's ability to understand spatial information. Specifically, it captures the details of the image and information about neighboring areas through local windows, and expands the model's field of view through spatially offset windows to capture a wider range of contextual 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 is that it can flexibly balance the capture of local and global information, making the model more accurate and efficient in tasks that require a high degree of spatial perception, such as image segmentation or object detection.

[0106] LPB integrates local and global information analysis to enable the model to more accurately identify key geological features when processing sandstone microscopic images with complex textures and geological structures, significantly improving classification accuracy. Experimental results show that integrating LPB into the Swin Transformer-based model framework achieves significant performance improvements in multiple sandstone microscopic image classification tasks, verifying the effectiveness of LPB in enhancing the model's local perception capabilities and understanding complex image textures. Figure 7 Revealing how the LPB module enhances the model's capture and processing of local spatial information. The figure shows how the module, after receiving image feature input, enhances its 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 recognize local features in sandstone microscopic images, thereby achieving better performance in complex image classification tasks.

[0107] Step 4: Balanced Adaptive Mechanism (BAM): To address the challenges of deep learning in dealing with problems with high class imbalance and sample diversity, a novel loss function, Balanced Adaptive Mechanism (BAM), is designed. BAM combines the advantages of weighted cross entropy loss, dual focus loss, and online hard example mining (OHEM), and introduces a mechanism to dynamically adjust the loss weight based on the training progress, aiming to more effectively deal with sample imbalance and distribution problems of easy and difficult samples during training.

[0108] BAM innovatively solves the problems of class imbalance and distribution of difficult and easy samples by combining weighted cross entropy, dual focus loss and OHEM technology. The dynamic class weight is intended to alleviate the impact of class imbalance; the dual focus loss part is more effective in training difficult-to-classify samples and reducing the impact of easy-to-classify samples; and the online hard example mining part further enhances the model's learning of difficult samples by focusing on the samples with the largest loss.

[0109] First, define the basic cross entropy loss:

[0110]

[0111] Among them, y is the hot encoding of the true label, is the probability distribution predicted by the model and C is the total number of categories.

[0112] The dynamic class weight is given by the following formula:

[0113] WeightedCELoss=CELoss×W(y)

[0114] Among them, W(y) is the weight of the corresponding category selected according to the true label y. This allows the model to dynamically adjust the attention paid to different categories.

[0115] The calculation formula for bifocal loss is:

[0116] DualFocalLoss = α·(1-p t ) γ ·WeightedCELoss

[0117] Among them, p t is the model’s predicted probability for the correct category, and α and γ are hyperparameters used for tuning.

[0118] The online difficult sample mining (OHEM) loss is calculated by selecting a portion of samples with the largest weighted cross entropy loss:

[0119]

[0120] The total loss is 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 strategies:

[0123]

[0124]

[0125] In this way, if a certain loss part is relatively high, it will get a larger weight in the next round of training. This approach allows the model to automatically focus on the more "difficult" parts of the current training stage, resulting in a more balanced and effective training.

[0126] Compared with traditional loss functions, BAM provides a more flexible and effective way to deal with key challenges in deep learning, especially for complex data distribution and extreme class imbalance. Through the dynamic weight adjustment mechanism and innovative design of 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] In order to comprehensively evaluate the performance of the model, several key evaluation indicators are used, including accuracy, recall, precision and F1-Score. These indicators can comprehensively reflect the performance of the model on the classification task from different angles, as shown in Table 2.

[0129] Accuracy: This is a basic indicator to measure 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 indicators.

[0130] Recall: reflects the model's ability to correctly identify positive samples, which is particularly important for avoiding missing important classifications in geological research.

[0131] Precision: It evaluates the proportion of samples that are actually in the positive class among the samples predicted by the model. It is particularly important for reducing misclassification.

[0132] F1-Score: The harmonic average of precision and recall, providing a performance measure that takes both precision and recall into account.

[0133] Table 1 Model evaluation indicators

[0134]

[0135] Step 6: Experimental Design

[0136] All experiments were conducted on a high-performance server equipped with NVIDIA RTX 4090 GPU and 24GB RAM to ensure high efficiency of data processing and model training during the experiment. This configuration provides powerful computing power, especially for the training of deep learning models, which is crucial for processing and analyzing large-scale sandstone microscopic image datasets.

[0137] The 8:1:1 ratio distribution principle 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 adjustment during model training; finally, the remaining 10% of the images constituted the test set, which was used to ultimately evaluate the generalization ability and accuracy of the model on unseen data.

[0138] Table 2 Training configuration information

[0139]

[0140]

[0141] Step 7: Experimental results analysis

[0142] The basic Swin Transformer model has an accuracy of 86.71% on the test set, and the macro-average precision, recall, and F1 score are 0.684, 0.868, and 0.720, respectively. By introducing the Spatial Adaptive Enhancement Module (SAEM), the accuracy is improved to 87.66%, and when the Local Perception Block (LPB) is used, the accuracy is 87.16%. Combining the techniques of SAEM and LPB further improves the accuracy to 91.06%. In addition, optimizing the loss function alone, that is, using the Balanced Adaptive Mechanism (BAM), also achieves an accuracy of 87.95%. When LPB and BAM are used simultaneously, the accuracy is 90.06%. The Improved Swin-Transformer model, with the combined effect of SAEM, LPB, and BAM, achieves an accuracy of 92.54%, and the macro-average precision, recall, and F1 score are improved to 0.786, 0.934, and 0.827, respectively.

[0143] Table 3 Performance comparison of different models on sandstone microscopic image dataset

[0144]

[0145] With the combined effect 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. Figure 8The training curve of Improved Swin-Transformer is shown.

[0146] Both Coca and ConvNext were proposed in 2022 and showed excellent performance on their test datasets, with Coca achieving a Top-1 accuracy of 92.4% on the ImageNet dataset and ConvNext achieving an F1 score of 93.47% on the InDL dataset.

[0147] However, in the application of sandstone microscopic image classification task, Improved Swin-Transformer shows better performance. Fig. 9 As shown in the figure, the Improved Swin-Transformer model shows excellent accuracy of 92.54% on the test set, which exceeds the performance of Coca and ConvNext in the same task. From the scatter plot, the performance of the Improved Swin-Transformer model surpasses several other models including the most advanced model (SOTA). The efficient channel attention mechanism of the SAEM module enhances the model's ability to express detailed features while keeping the model lightweight; the LPB module strengthens the recognition ability of complex image structures by optimizing local features; the BAM mechanism improves the balance and robustness of the model in each category by balancing the category weights. These modules and mechanisms improve the overall performance of the Improved Swin-Transformer model, and perform well in the performance comparison scatter plot.

[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 been specifically adjusted and optimized for sandstone microscopic images to better adapt to the characteristics of geological images, such as the details of texture and color distribution, thereby ensuring maximum performance on specific tasks. At the same time, by targeted training on a dataset optimized for sandstone microscopic images, the Improved Swin-Transformer can deeply learn and understand the characteristics of this type of specific images, further improving classification accuracy.

[0149] By deeply analyzing the confusion matrix of the model and drawing a heat map such as Fig.10, further revealing the classification performance of ImprovedSwin-Transformer on nine sandstone categories. The heat map shows that most predictions are accurately focused on the diagonal, indicating that in most cases, the model can correctly identify each category. It is particularly noteworthy that for the "feldspar quartz sandstone" category, the model shows extremely high recognition accuracy. Nevertheless, misclassification between some categories, such as the confusion between "lithic feldspar sandstone" and other categories, is more prominent, providing valuable insights for model optimization and performance improvement.

[0150] In-depth analysis of the confusion matrix helps to gain insight into the model's weaknesses in certain specific categories, and then implement targeted improvement strategies. The diagonal highlights in the heat map show the number of correct predictions of the model for each category. This observation supports the effectiveness of innovative modules such as SAEM, LPB, and BAM. SAEM enhances the expression of key features by adjusting channel importance, and LPB improves the model's understanding of complex structures by strengthening the learning of local features. BAM solves the problem of data imbalance by balancing the learning focus of different categories. These integrated innovative mechanisms not only improve the accuracy of the model in classification tasks, but also enhance its ability to recognize subtle differences between specific categories.

[0151] In order to make each step of the sandstone microscopic image classification system more detailed and feasible, we can further enrich the content of each step. The following is an extended description of each step:

[0152] Example 3: Sandstone Microscopic Image Classification System

[0153] This system uses the improved Swin Transformer technology to achieve automatic classification of sandstone microscopic images. The system is designed to improve the accuracy and efficiency of sandstone classification. The following are the detailed implementation steps:

[0154] Step 1: Data Collection

[0155] Determine the source of sandstone microscopic images, which can be existing geological research databases, original images collected by laboratories, or image data obtained through cooperative institutions. Perform a preliminary quality assessment on the collected images, exclude blurry, damaged, or unclassifiable images, and ensure 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 data diversity during model training and improve the generalization ability of the model.

[0156] Step 2: Preprocessing

[0157] The images are standardized, including unifying the image size, adjusting the contrast and brightness, etc., to adapt to the model input requirements. The dataset is divided 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, appropriate improvements are made to Swin Transformer, such as adjusting the network hierarchy, optimizing the attention mechanism, etc. The feature extraction capability of the improved Swin Transformer on sandstone microscopic images is evaluated to ensure that key geological features can be captured.

[0160] Step 4: Classifier Design

[0161] According to the possible classification of sandstone microscopic images, a suitable multi-classification strategy is designed, and the softmax function is considered. The classifier performance is optimized by adjusting the classifier parameters and using regularization techniques to reduce overfitting.

[0162] Step 5: Model training

[0163] Batch training is used to adjust model parameters through optimization algorithms such as stochastic gradient descent. The hyperparameters of the model are adjusted through methods such as cross-validation to find the best model configuration.

[0164] Step 6: Model Validation

[0165] Develop a reasonable verification strategy, including the selection of evaluation indicators such as accuracy and recall. Based on the verification results, further adjust the model structure and parameters to optimize model performance.

[0166] Step 7: Image Classification

[0167] Optimize the system to support real-time image classification and ensure that the system can quickly respond to user classification requests. Evaluate the classification results, including indicators such as classification accuracy and speed, to ensure that they meet actual application needs.

[0168] Step 8: Output the results

[0169] The classification results, including sandstone images and their classification information, are displayed through a graphical interface to improve user experience. The classification results can be exported and shared to facilitate further analysis and research.

[0170] This example describes the design and implementation of a sandstone microscopic image classification system in detail, and shows how the system uses the improved Swin Transformer technology to efficiently and accurately classify sandstone images. In addition, this example also emphasizes the key steps and optimization strategies in system design to ensure the practicality and reliability of the system.

[0171] This paper proposes a sandstone microscopic image classification method based on an improved Swin-Transformer framework, aiming to improve the accuracy and efficiency of sandstone microscopic image classification. By introducing the spatial adaptive enhancement module (SAEM), the local perception block (LPB) and the balanced adaptive mechanism (BAM), the present invention significantly improves the performance of the model in processing complex geological image tasks. Figures 1 to 10 According to the detailed description, the present invention not only puts a lot of effort into the construction and preprocessing of the data set to ensure high-quality and diverse data input, but also innovates in the design of the model structure and optimizes the key technical modules to adapt to the particularity and complexity of sandstone microscopic images. After experimental verification, the improved Swin-Transformer framework shows excellent performance in the sandstone microscopic image classification task, which is significantly higher than the traditional deep learning model and the original Swin-Transformer model. The present invention is not only technically innovative, but also has broad application prospects in the fields of geological science research, oil and gas resource exploration, etc., and provides 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 improved Swin Transformer, It is 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 the sandstone microscopic image through global average pooling, 1*1 convolution and adaptive depth-separable convolution, and is used to capture the overall features of the sandstone microscopic image, finely process the local details of the sandstone microscopic image through convolution operations, and respond to different pixel positions when 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 the sandstone microscopic image; 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. The model evaluation includes multiple indicators such as accuracy, recall rate and F1 score to comprehensively evaluate the model performance. If the evaluation does not meet the standards, return to steps 2, 3 and 4 to improve the spatial adaptive enhancement module, local perception block and balanced adaptive mechanism in turn until the evaluation meets the standards.

2. The classification method according to claim 1, It is characterized in that The SAEM generates a global descriptor for each channel by global average pooling, and uses a one-dimensional convolutional network to adjust the channel adaptively to adjust the attention paid 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 Sigmoid activation function. The collaborative work of these components enables SAEM to adaptively adjust the attention to different spatial positions; the global average pooling layer is used to quickly capture the overall features, the 1x1 convolution performs feature conversion, and the adaptive depthwise separable convolution dynamically adjusts the kernel size according to the input features to optimize the processing of local details of the sandstone microscopic image to obtain the 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, It is 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 and provide feature maps with rich details; the multi-head attention mechanism is used to enhance the parsing ability of different pixel positions (subspaces) of sandstone microscopic image data, and 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 generates more representative feature maps through fusion, convolution or attention mechanism operations.

4. The classification method according to claim 3, It is characterized in that The Balanced Adaptive Mechanism (BAM) is used to optimize the processing of difficult-to-classify samples and category imbalance by combining weighted cross entropy, dual focus loss and online hard example mining (OHEM) technology. Dynamic class weights are used to alleviate the impact of category imbalance; the dual focus loss part more effectively trains difficult-to-classify samples and reduces the impact of easy-to-classify samples; and the OHEM part strengthens Geo-Swin-Transformer's learning of difficult samples by focusing on samples with the largest loss.

5. The classification method according to claim 4, It is characterized in that The specific implementation process of the Balanced 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; the dynamic class weight can dynamically adjust the attention 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 γ are hyperparameters used for adjustment; The online difficult sample mining (OHEM) loss 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 sum 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 one of the loss components is relatively high, DualFocalLoss and ω OHEMLoss It will get a bigger weight in the next round of training.

6. The classification method according to claim 5, It is characterized in that In step 4, the training process includes: At the beginning, the basic Swin Transformer model is trained as the baseline for the performance comparison of subsequent modules. Then, in order to systematically explore the specific contribution 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 the image. Next, the training entered 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 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.

7. The classification method according to claim 6, It is 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.

8. A sandstone microscopic image classification system based on improved Swin Transformer, Features: The system has program modules corresponding to the steps of any one of claims 1 to 7 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 runtime.

9. A computer-readable storage medium, Features: 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 described in any one of claims 1 to 7 when called by a processor.

Citation Information

Patent Citations

  • Remote sensing image classification method based on machine learning and local and global feature fusion

    CN116258914A

  • TransUNet-based rock slice image granularity identification method, electronic equipment and storage medium

    CN116543256A

  • Lung CT image classification system based on domain knowledge and parallel separable convolution Swin Transform

    CN117058448A

  • Remote sensing image segmentation method and system based on improved SwinTransform

    CN117095168A

  • Remote sensing image scene classification method fusing Swin Transform and visual image neural network

    CN117392547A

Cited By

  • Multi-scale digital rock core rapid reconstruction method based on proxy model

    CN119540665A

  • Lightweight network-based Mars surface stone extraction method and system

    CN119625501A

  • A Method and System for Extracting Mars Surface Rocks Based on a Lightweight Network

    CN119625501B

  • Iron-carbon alloy microscopic structure identification method based on deep learning

    CN119625728A

  • Rock slice mineral identification method, medium and equipment

    CN119723582A