Rock slice image classification method based on domain self-adaption

By developing a rock thin section image classification method based on domain-adaptive DINOv3 and attention mechanism, the problems of insufficient domain adaptability and inadequate utilization of multi-scale features in core thin section image recognition are solved, achieving accurate classification of rock thin sections and improving recognition accuracy and reliability.

CN121999296APending Publication Date: 2026-05-08CNOOC ENERGY TECHNOLOGY & SERVICES LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CNOOC ENERGY TECHNOLOGY & SERVICES LTD
Filing Date
2026-01-30
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Existing core thin section image recognition methods suffer from insufficient adaptability to different domains, inadequate utilization of multi-scale features, and a single classification level, resulting in limited ability to characterize mineral optical properties and crystal morphology, and limited accuracy in identifying fine-grained lithology.

Method used

A rock thin section image classification method based on domain-adaptive DINOv3 and attention mechanism is adopted. Through multi-scale data preprocessing, geological domain data augmentation, geological domain adaptive module, dual-path attention mechanism and progressive hierarchical classification structure, accurate identification of rock thin section images is achieved.

Benefits of technology

It significantly improves the accuracy and reliability of rock thin section identification, especially in fine-grained lithology identification, with an accuracy increase of approximately 15.3%, and has good generalization ability, providing technical support for oil and gas reservoir evaluation and geological research.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121999296A_ABST
    Figure CN121999296A_ABST
Patent Text Reader

Abstract

The invention discloses a rock slice image classification method based on domain self-adaption, and the method comprises the steps: collecting rock slice image data, the method comprises the following steps: acquiring a rock slice image, performing multi-scale data preprocessing and geological field data enhancement, extracting multi-level visual features of the rock slice image by utilizing a pre-trained DINOv3 model, performing field specialized adaptation on general visual features through a geological field adaptive Adapter module, and enhancing rock slice discriminative feature representation by adopting a double-path attention mechanism. Constructing a progressive hierarchical classification head to realize coarse-to-fine rock classification; and designing a multi-stage progressive training strategy to optimize the overall performance of the model. According to the method, mineral composition and structural features of the rock slices under different scales can be accurately captured, and multi-scale features and an attention mechanism are fully utilized, so that accurate classification of the rock slices is realized, and the accuracy and reliability of rock slice identification are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of geological exploration and lithology identification technology, specifically involving a rock thin section image classification method based on domain-adaptive DINOv3 and attention mechanism. Background Technology

[0002] In oil and gas exploration and development, core thin section identification is a key technical means to identify reservoir lithology, analyze mineral composition, and assess reservoir space characteristics. Traditional core thin section identification mainly relies on manual observation and description by geologists using polarized light microscopes. Through comprehensive analysis of mineral composition, structure, diagenesis, and other characteristics, rock type and its genetic mechanism are determined. With the development of digital imaging technology, computer vision-based rock thin section image analysis methods have gradually been applied. Image processing algorithms extract visual features such as color, texture, and shape, and combined with traditional machine learning algorithms such as support vector machines and random forests, automatic rock type identification is achieved. In recent years, deep learning technology has been introduced into the geological field, using models such as convolutional neural networks (CNNs) to automatically learn the deep features of rock thin sections, which has improved the automation level of identification to a certain extent.

[0003] However, existing core thin section image recognition methods still have the following three prominent problems: (1) Insufficient domain adaptability: Most current methods use general models pre-trained on natural image datasets, which fail to fully consider the significant differences between rock thin section images and natural images in terms of imaging mechanisms and feature distribution, resulting in limited model representation capabilities for professional features such as mineral optical properties and crystal morphology; (2) Insufficient utilization of multi-scale features: Rock thin sections contain both macroscopic rock structure and microscopic mineral composition information. Existing methods often focus on single-scale feature analysis and fail to effectively establish a multi-scale feature fusion mechanism from the mineral grain level to the rock structure level; (3) Lack of hierarchical classification strategy: Rock classification itself has a strict hierarchical system (from the three major rock types to specific lithologies), while existing methods mostly adopt a flat classification architecture, which fails to fully utilize the hierarchical correlation information in the petrological classification system, resulting in limited accuracy in fine-grained lithology identification.

[0004] Therefore, there is an urgent need for a new intelligent recognition method for core thin section images that can effectively solve the above-mentioned technical bottlenecks, achieve accurate and efficient identification from mineral composition to rock type, and provide reliable technical support for oil and gas reservoir evaluation and geological research. Summary of the Invention

[0005] This invention addresses the technical shortcomings of existing methods, such as insufficient domain adaptability, inadequate utilization of multi-scale features, and a single classification level. Its purpose is to provide a rock thin section image classification method based on domain-adaptive DINOv3 and attention mechanism.

[0006] This invention is achieved through the following technical solution: A rock thin section image classification method based on DINOv3 and attention mechanism includes the following steps: S1. Collect rock thin section image data and perform multi-scale data preprocessing and geological data augmentation; S2. Input the polarization-enhanced and multi-scale aligned rock thin section image into the pre-trained Transformer feature extraction network and freeze the encoder; extract multi-layer output features, fuse the last layer CLS token and patch token to obtain lithology discrimination characterization; S3, Adaptive technology in the geological field The module performs domain-specific adaptations to general visual features; S4. Employing a dual-path attention mechanism to enhance the discriminative feature representation of rock thin sections; S5. Construct a progressive hierarchical classification structure to achieve rock classification from coarse to fine. S6. Design a multi-stage progressive training strategy to optimize the overall performance of the model.

[0007] In the above technical solution, step S1 specifically includes the following steps: S11. Collect polarized light microscope images of rock thin sections at different magnifications, construct a labeled dataset, and build a multi-scale image pyramid for each rock thin section polarized light microscope image to cover full-scale features from macroscopic rock structure to microscopic mineral composition. The magnification factors include 4×, 10×, 20× and 40×; The labeled dataset includes sedimentary rocks, sedimentary rock subclasses, igneous rocks, igneous rock subclasses, metamorphic rocks, and metamorphic rock subclasses; S12. Perform image preprocessing on the original rock thin section polarized light microscope image acquired in step S11; The image preprocessing includes illumination normalization, color correction, and noise filtering. The calculation formula for the image preprocessing is as follows: In the formula: This represents the pixel intensity of the normalized polarized light microscope image of a rock thin section; Represents the pixel intensity of the original polarized light microscopy image of the rock thin section; This represents the average pixel intensity of the original rock thin section polarized light microscope image; The standard deviation of pixel intensity represents the original polarized light microscopy image of the rock thin section; , Indicates the normalization parameter; S13. Enhance geological data based on the principle of polarization optics, and use the polarization rotation simulation formula to simulate the changes in optical characteristics of rock thin sections under different polarization angles; The formula for simulating polarized light rotation is: In the formula: Indicates the rotation angle as Polarization image at time; Represents the polarization rotation matrix. Indicates the deflection angle. This represents the normalized input image after preprocessing in step S12; This represents the matrix transpose operation; S14. Spatial alignment and resolution unification of features at different scales in the multi-scale image pyramid of each rock thin section polarized light microscope image; The formula for spatial alignment is: In the formula: This indicates the features after spatial alignment; Indicates the number of scales; Indicates the first Scale weights for each scale; Indicates the first Individual scale features; Indicates the target scale.

[0008] In the above technical solution, step S2 specifically includes the following steps: S21. Load the weights of the DINOv3 model pre-trained on a large-scale natural image dataset and freeze all parameters of the Transformer encoder. S22. Extract multi-level features from different depths of the DINOv3 model; The feature extraction formula is: In the formula: Indicates the first layer Features of the layer output; Indicates the first indivual layer, Indicates the upper level Features of the layer output; express The number of layers; S23. Simultaneously extract global image features and local patch features, and perform feature fusion; The feature fusion formula is as follows: In the formula: Indicates the characteristics after fusion; Presentation layer normalization operation; This represents the learnable weights of global features; This represents learnable weights for local features; Represents global features; Show local features; Indicates the bias term; S24. Standardize the dimensions and scale of the fusion features extracted in step S23. The standardized formula is: In the formula: Represents the standardized features; Represents input features; Represents the characteristic mean; Represents the characteristic variance; To represent a small constant, preventing division by zero; Indicates the learnable scaling factor; This represents the learnable bias coefficient.

[0009] In the above technical solution, step S3 specifically includes the following steps: S31. Insert parallel processing after each Transformer layer in the DINOv3 model. The structure is derived using low-rank decomposition techniques. Parallel insertion after the Transformer layer The formula for calculating the structure is: In the formula: This indicates the characteristics after the parallel Adapter structure is inserted and adapted. Indicates the first layer The characteristics of the layer output are consistent with those in step S22; This represents the dimensionality reduction weight matrix, which reduces the feature dimension from d to a low rank r; This represents the dimension-upgrading weight matrix, which increases the feature dimension from low rank r to d; S32. Inject prior knowledge of petrology into the adaptive Adapter module of the geological field through comparative learning; The contrastive loss function used is: In the formula: Represents the contrastive loss function; Indicates the first The normalized vector obtained after each sample is encoded; Indicates and Another embedding vector that constitutes a positive sample pair; This represents the embedding vector of all other samples in the batch; Indicates the number of samples in the batch; This indicates the calculation of cosine similarity. The temperature parameter represents the comparison learning; Indicates an indicator function; S33. Adaptively weighted fusion of the original DINOv3 features and the Adapter-enhanced features; The formula for adaptive weighted fusion is: In the formula: This represents the final fused feature, which serves as input for subsequent modules. Indicates the adaptive weight parameters; This indicates the original DINOv3 characteristics of the corresponding layer when bypassing the Adapter, i.e., the characteristics of step S22. Or the final output features; This represents the features after parallel adapter adaptation in step S31, i.e., the output of step S31. S34. Use knowledge distillation techniques to extract domain features from professional geological annotations; The distillation loss expression for knowledge distillation technology is: In the formula: Indicates distillation loss; express Divergence; This represents the probability of the student model's output. This represents the probability of the teacher model's output. This indicates the distillation temperature parameter.

[0010] In the above technical solution, the low-rank decomposition technique refers to the parallel adapter structure adopting a low-rank bottleneck form, decomposing the linear transformation that could originally be equivalent to d×d into W using two low-rank matrices. down ∈R d×r With W up ∈R r×d , The Adapter is added to the Transformer layer output using a residual bypass method, while the Transformer backbone parameters remain frozen, and only the Adapter parameters are trained.

[0011] In the above technical solution, step S4 specifically includes the following steps: S41. Evaluate the importance of different feature channels based on channel attention mechanism; The formula for calculating channel attention is: In the formula: Indicates channel attention weights; This represents the sigmoid activation function; This represents a multilayer perceptron; Indicates average pooling; Indicates max pooling; Indicate steps ; S42. Locate key regions in thin-slice images using spatial attention mechanisms; The formula for calculating spatial attention is: In the formula: Indicates spatial attention weights; express convolution; Indicates channel splicing; S43. Design a mechanism for the fusion of cross-attention between passageways and spaces; The cross-attention fusion formula is as follows: In the formula: This represents the features enhanced by cross-attention; Indicate steps ; Indicates channel attention weights; Indicates spatial attention weights; This represents element-wise multiplication; S44. Apply cross-attention fusion mechanism on feature maps of different scales to achieve integration of multi-scale attention results; The integrated formula is: In the formula: Represents multi-scale integrated features; Indicates the first Scale weights for each scale; Indicates the first A cross-attention fusion mechanism at multiple scales Indicates the first Features at each scale Indicates the number of scales.

[0012] In the above technical solution, step S5 specifically includes the following steps: S51. Progressive hierarchical classification structure design: The formula for calculating the classification probability of a progressive hierarchical classification structure is: In the formula: Indicates the first Classification probability; Indicates the first The weight of the level; Indicates the first Level bias; Represents input features; Indicates the probability of the higher-level category; Indicates the category level; S52. Refine the feature representation progressively during the classification process; The refining formula is: In the formula: Indicates the first Features after refinement; Indicates the feature increment; Represents the gated function; S53. Introduce temperature scaling technology to calibrate the uncertainty of classification results; The formula for uncertainty calibration is: In the formula: Indicates the probability after uncertainty calibration; Represents the original logits; Indicates temperature parameter; S54. Integrate the outputs from multiple classification levels to generate the final comprehensive classification decision; The fusion formula for multiple classification-level outputs is: In the formula: Indicates the final classification probability; Indicates level weight; Indicates the first Classification probability.

[0013] In the above technical solution, step S6 specifically includes the following steps: S61. Employ a phased training strategy to gradually unlock and optimize the parameters of different modules; The three-stage training loss function of the phased training strategy is: In the above formula: , , These represent the total losses in the three stages respectively; Indicates classification loss; , These represent the balance coefficients; This represents the contrastive learning loss function described in step S32; This represents the distillation loss function described in step S34; S62. Design a joint learning framework for the main and auxiliary tasks of rock classification; The total loss function of the joint learning framework is: In the formula: Represents the total loss function; Indicates task weight; Indicates the first The loss of one task; Indicates the number of tasks; S63. Dynamically adjust the weighting coefficients of multi-task loss based on task difficulty and importance; The adjustment formula for the weighting coefficients of the multi-task loss is as follows: In the formula: Indicates the first The weight of each task; Indicates learnable parameters; This represents the learnable parameters corresponding to the j-th task; S64. Implement an early stopping mechanism based on the performance of the validation set and select the best model.

[0014] The beneficial effects of this invention are: This invention provides a rock thin section image classification method based on domain-adaptive DINOv3 and attention mechanism, which can accurately capture the mineral composition and structural features of rock thin sections at different scales. By making full use of multi-scale features and attention mechanism, it can achieve accurate classification of rock thin sections, significantly improve the accuracy and reliability of rock thin section identification, and provide efficient technical support for oil and gas reservoir evaluation and geological research.

[0015] This invention constructs a complete intelligent recognition system for rock thin section images by introducing a geological domain adaptive Adapter module, a dual-path attention mechanism, and a progressive hierarchical classification architecture, effectively solving three major technical challenges faced by traditional methods in rock thin section image classification. First, addressing the significant domain differences between natural images and rock thin section images, the geological domain adaptive Adapter module designed in this invention, through low-rank decomposition technology, maintains the powerful feature extraction capabilities of DINOv3 while achieving parameter-efficient adaptation of visual features to the geological domain, solving the domain distribution mismatch problem in traditional transfer learning methods. Second, considering the complex mineral composition and diverse structural features in rock thin section images, the dual-path attention mechanism, through the synergistic effect of channel attention and spatial attention, can automatically focus on discriminative mineral regions and structural features, significantly improving the model's ability to represent complex petrological features. Third, addressing the hierarchical structure of rock classification systems, the progressive classification architecture, through a coarse-to-fine hierarchical decision-making process, effectively models the hierarchical relationships between rock categories, subcategories, and specific lithologies, overcoming the limitations of traditional flat classification methods in fine-grained lithology identification. Practical applications show that the method of this invention improves accuracy by approximately 15.3% compared to traditional deep learning methods on multiple geological datasets, with a particularly significant improvement in accuracy for fine-grained lithology identification tasks. Furthermore, the method exhibits good generalization ability, demonstrating stable identification performance on rock samples from different geological ages and sedimentary environments, providing reliable technical support for the intelligent development of geological exploration. Attached Figure Description

[0016] Figure 1 This is a flowchart of the method of the present invention.

[0017] For those skilled in the art, other related figures can be obtained from the above figures without any creative effort. Detailed Implementation

[0018] To enable those skilled in the art to better understand the technical solution of the present invention, the technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0019] Example 1 like Figure 1 As shown, a rock thin section image classification method based on domain-adaptive DINOv3 and attention mechanism includes the following steps: S1. Collect rock thin section image data and perform multi-scale data preprocessing and geological data augmentation; Step S1 specifically includes the following steps: S11. Multi-scale rock thin section image acquisition: acquire rock thin section polarized light microscope images at different magnifications, construct a labeled dataset, and build a multi-scale image pyramid for each rock thin section polarized light microscope image, covering full-scale features from macroscopic rock structure to microscopic mineral composition. The magnification factors include 4×, 10×, 20× and 40×; The labeled dataset includes sedimentary rocks, sedimentary rock subclasses, igneous rocks, igneous rock subclasses, metamorphic rocks, and metamorphic rock subclasses; In this embodiment, the constructed labeled dataset contains 1,500 samples, covering 3 major categories, 15 subcategories, and 50 specific lithologies, including granite, basalt, limestone, sandstone, and gneiss. In this embodiment, the labeled dataset is constructed as follows: Labeling objects: Using "thin section samples (or core segments / outcrops)" as the basic labeling objects, multiple field-of-view images are acquired for each thin section sample at different magnifications; Labeling system: Each sample is labeled based on its source information (such as well number / depth, stratigraphic position, sampling location), thin section identification record / report, and petrological nomenclature. The labeling adopts a three-level labeling system, namely rock type (sedimentary rock / igneous rock / metamorphic rock) - subtype - specific lithology, which is consistent with the subsequent progressive hierarchical classification head. Labeling process: Each sample is labeled by at least two geological experts with experience in thin section identification. If the labels of the two experts are inconsistent, a third expert will review and make a decision to improve the reliability of the labeling. Metadata and format: Record metadata such as sample number, well depth / location, magnification, polarization mode / polarization information, and acquisition date, and save the tags and metadata in CSV / JSON format. Image files adopt the same naming rules as the sample number. Data partitioning: The training / validation / test sets are partitioned into layers according to "sample number" to avoid different fields of view of the same slice appearing in both the training and test sets at the same time, and to avoid data leakage between different fields of view of the same slice.

[0020] In this embodiment, each rock thin section polarized light microscope image is downsampled using a Gaussian pyramid to generate an image pyramid with three scales: 1024×1024, 512×512, and 256×256. The specific method for constructing the multi-scale image pyramid is as follows: first, the resolution of the rock thin section polarized light microscope image is unified to 2048×2048 pixels as the original layer of the pyramid; then, the previous layer image is first Gaussian smoothed, and then downsampled by a factor of 2 to sequentially generate 1024×1024, 512×512, and 256×256 images. The image pyramid is composed of three scales: 512 and 256×256, forming a four-layer multi-scale image pyramid (2048×2048, 1024×1024, 512×512, 256×256). The 2048×2048 and 1024×1024 scales in the multi-scale image pyramid mainly retain fine-grained details such as mineral grain boundaries and interference colors. The 512×512 scale represents grain combination and texture features, while the 256×256 scale highlights the macroscopic structure and overall composition features. S12. Preprocessing of rock thin section images: Image preprocessing is performed on the original rock thin section polarized light microscope image acquired in step S11; The image preprocessing includes illumination normalization, color correction, and noise filtering. The calculation formula for the image preprocessing (illuminance normalization) is as follows: In the formula: This represents the pixel intensity of the normalized polarized light microscope image of a rock thin section; Represents the pixel intensity of the original polarized light microscopy image of the rock thin section; This represents the average pixel intensity of the original rock thin section polarized light microscope image; The standard deviation of pixel intensity represents the original polarized light microscopy image of the rock thin section; , Indicates the normalization parameter; , Statistics can be performed "image by image and channel by channel", which is more in line with engineering implementation and color consistency processing; Pixel intensity can be understood as light intensity / grayscale intensity, or the intensity of each RGB channel; In this embodiment, the preprocessing of the rock thin section image specifically involves: performing illumination normalization on the original rock thin section polarized light microscope image acquired in step S11, and setting normalization parameters. This is to eliminate color deviation caused by unstable light sources.

[0021] S13, Geological Data Enhancement: Based on the principle of polarization optics, geological data is enhanced by using a polarization rotation simulation formula to simulate the changes in optical characteristics of rock thin sections under different polarization angles. The formula for simulating polarized light rotation is: In the formula: Indicates the rotation angle as Polarization image at time; Represents the polarization rotation matrix. Indicates the deflection angle. This represents the normalized input image after preprocessing in step S12; This represents the matrix transpose operation; In this embodiment, geological data enhancement specifically involves implementing data enhancement based on polarization optics principles, including polarization rotation angle. The optical characteristics of the thin film under different polarization angles were simulated by randomly selecting four angles: 0°, 45°, 90°, and 135°. At the same time, random horizontal flipping and random rotation within ±10° were applied to enhance the rotation invariance of the model. S14, Multi-scale Feature Alignment: Spatial alignment and resolution unification of features at different scales in the multi-scale image pyramid of each rock thin section polarized light microscope image; The formula for spatial alignment is: In the formula: This indicates the features after spatial alignment; Indicates the number of scales; Indicates the first Scale weights for each scale; Indicates the first Individual scale features; Indicates the target scale; The feature representations / feature maps obtained by the feature extraction network for each scale of image input are thus closed in the logical chain of "pyramid → feature → alignment and fusion". In this embodiment, the multi-scale feature alignment specifically involves: using bilinear interpolation to upsample features of different scales in the image pyramid to a target scale of 1024×1024, with scale weights... The image information entropy is adaptively calculated, and the higher the information entropy, the greater the weight is assigned to the scale. In this embodiment, the resolution of the rock thin section polarized light microscope image is uniformly set to 2048×2048 pixels; S2. Extract multi-level visual features of rock thin section images using a pre-trained DINOv3 model: Input the polarization-enhanced and multi-scale aligned rock thin section images into a pre-trained Transformer feature extraction network and freeze the encoder; extract multi-level output features, fuse the final layer CLS token and patch token to obtain lithology discrimination characterization; Step S2 specifically includes the following steps: S21, DINOv3 backbone network initialization: Load the weights of the DINOv3 model pre-trained on a large-scale natural image dataset and freeze all parameters of the Transformer encoder; The natural image data used in this application for training DINOv3 is an open-source dataset, which can be downloaded by those skilled in the art. DINOv3 has been released as a model family in Hugging Face Transformers, with a clear release date and usage method; it belongs to the publicly released existing technology model system; Hugging Face's pre-training method is also publicly available: the DINOv3 paper publicly describes its large-scale self-supervised training framework (mixing multiple self-supervised objectives, using multi-crop strategies, AdamW optimization, etc.), which is a publicly available technical route that can be understood and reproduced by those skilled in the art, and this application will not describe it in detail; The “DINOv3 model weights” referred to in this application refer to the corresponding model checkpoint weights released by the official website (i.e., the weight files released after the paper has been trained and solidified); the official GitHub repository explains the process of obtaining all model weights (applying for / obtaining the weight URL list through the official link, then downloading and loading it), which is publicly available prior art; S22, Multi-level feature extraction: Extracting multi-level features from different depths of the DINOv3 model; The feature extraction formula is: In the formula: Indicates the first layer Features of the layer output; Indicates the first indivual layer, Indicates the upper level Features of the layer output; express The number of layers; S23, Fusion of global and local features: Simultaneously extract global image features and local patch features, and perform feature fusion; The global image feature Fglobal can be obtained by representing the CLS token in the token sequence output by the last layer; the local patch feature Flocal is the set of patch tokens in the output of the last layer, where the CLS token is usually used for global representations such as classification / retrieval, and the patch token is used for dense representations such as segmentation. The feature fusion formula is as follows: In the formula: Indicates the characteristics after fusion; Presentation layer normalization operation; This represents the learnable weights of global features; This represents learnable weights for local features; Represents global features; Show local features; Indicates the bias term; S24. Feature Dimension Standardization: Standardize the dimensions and scale of the fusion features extracted in step S23. The standardized formula is: In the formula: Represents the standardized features; Represents input features; Represents the characteristic mean; Represents the characteristic variance; To represent a small constant, preventing division by zero; Indicates the learnable scaling factor; This represents the learnable paranoia coefficient; In this embodiment, the fusion feature extracted in step S23 is preferably Ffused, which is standardized to obtain Fstd, and used as input for subsequent domain adaptation and attention modules; In this embodiment, the feature dimension standardization specifically involves setting a small constant in the standardization formula. Learnable scaling factor Initialized to 1, learnable paranoia coefficient Initialize to 0; S3, Adaptive technology in the geological field The module performs domain-specific adaptations to general visual features; Step S3 specifically includes the following steps: S31, Lightweight Geological Adaptive Module design: Parallelism is inserted after each Transformer layer in the DINOv3 model. The structure is derived using low-rank decomposition techniques. "Using low-rank decomposition technology" means that the parallel adapter structure adopts a low-rank bottleneck form, decomposing the linear transformation that could originally be equivalent to d×d into W using two low-rank matrices. down ∈R d×r With W up ∈R r×d ( This allows for domain specialization with fewer parameters; the Adapter is added to the Transformer layer output via residual bypass, the Transformer backbone parameters are kept frozen, and only the Adapter parameters are trained. Parallel insertion after the Transformer layer The formula for calculating the structure is: In the formula: This indicates the characteristics after the parallel Adapter structure is inserted and adapted. Indicates the first layer The characteristics of the layer output are consistent with those in step S22; This represents the dimensionality reduction weight matrix, which reduces the feature dimension from d to a low rank r; This represents the dimension-upgrading weight matrix, which increases the feature dimension from low rank r to d; In this embodiment, the lightweight geological adaptive The module design specifically involves inserting parallel processing after each Transformer layer in DINOv3. The structure is set with the original feature dimension d=1024, the low-rank dimension r=64, and the dimension reduction scaling factor k=16; S32, Injection of Petrological Knowledge: Comparative learning is used to inject prior knowledge of petrology into the adaptive adapter module for the geological field. The "injection of prior knowledge in petrology" refers to the process of constructing "different enhanced views of the same lithological sample" as positive sample pairs and "different lithological samples" as negative sample pairs, so that the network learns a feature space in which the characteristics of the same lithology are closer and the characteristics of different lithologies are more separated, thereby injecting the prior constraint of "lithological consistency / difference" into the trainable parameters of the adapter. That is, encoding two (or two enhanced view) images of the same lithology into a vector. and The positive sample pairs are used as the encoding vectors of other samples with different lithologies; the negative sample pairs are used as the encoding vectors of other samples with different lithologies. By comparing losses Get bigger, make By reducing the size, the petrological prior constraint that "the same lithology is more similar and different lithology is more different" is implemented in the trainable Adapter parameters (achieving the effect of "knowledge injection"). The contrastive loss function is: In the formula: Represents the contrastive loss function; Indicates the first The normalized vector obtained after each sample is encoded; Indicates and Another embedding vector that constitutes a positive sample pair; This represents the embedding vector of all other samples in the batch; Indicates the number of samples in the batch; This indicates the calculation of cosine similarity. The temperature parameter represents the comparison learning; This indicates an indicator function that ensures the denominator does not contain itself. In this embodiment, the petrological knowledge injection specifically refers to: in comparative learning training, batch size... Set to 32, temperature parameter Set to 0.07; positive sample pairs are different enhanced views of the same lithology, and negative sample pairs are samples of different lithologies; S33, Multi-source feature fusion: Adaptive weighted fusion of the original DINOv3 features and the Adapter-enhanced features; The formula for adaptive weighted fusion is: In the formula: This represents the final fused feature, which serves as input for subsequent modules. Indicates the adaptive weight parameters; This indicates the original DINOv3 characteristics of the corresponding layer when bypassing the Adapter, i.e., the characteristics of step S22. Or the final output features; This represents the features after parallel adapter adaptation in step S31, i.e., the output of step S31. In this embodiment, the multi-source feature fusion specifically refers to: adaptive weight parameters. Initialized to 0.5, and dynamically adjusted during training based on feature quality using a lightweight network, with an adjustment range of [value missing]. between; S34, Domain Feature Distillation: Use knowledge distillation techniques to extract domain features from specialized geological annotations; The distillation loss expression for knowledge distillation technology is: In the formula: Indicates distillation loss; express Divergence; This represents the probability of the student model's output. This represents the probability of the teacher model's output. This indicates the distillation temperature parameter; Temperature parameters in the above formula With the temperature parameters in step S32 Different It is a temperature parameter used in contrastive learning for softening cosine similarity (typically around 0.07). (Distillation temperature) refers to the temperature at which the softmax (logits / T) is measured in knowledge distillation (commonly around 2~4). In this embodiment, the domain characteristic distillation specifically refers to: temperature parameters. Set to 3.0, use a professional model trained on an authoritative geological dataset as the teacher model to guide the training of student models; S4. Employing a dual-path attention mechanism to enhance the discriminative feature representation of rock thin sections; Step S4 specifically includes the following steps: S41. Channel attention path construction: Evaluating the importance of channels with different features based on channel attention mechanisms; The formula for calculating channel attention is: In the formula: Indicates channel attention weights; This represents the sigmoid activation function; This represents a multilayer perceptron; Indicates average pooling; This indicates max pooling; Indicates input features, That is, the input features of this step. The final fusion feature output in step S33; S42. Spatial Attention Path Construction: Key regions in thin-slice images are located using spatial attention mechanisms; The formula for calculating spatial attention is: In the formula: Indicates spatial attention weights; express convolution; This indicates channel splicing, that is, adding... and The results are spliced ​​in the channel dimension; S43, Cross-Attention Fusion: Design a mechanism for the integration of cross-attention between passageways and spaces; The cross-attention fusion formula is as follows: In the formula: This represents the features enhanced by cross-attention; express ,Right now ; Indicates channel attention weights; Indicates spatial attention weights; This represents element-wise multiplication; S44, Multi-scale attention integration: Attention mechanisms are applied to feature maps at different scales to achieve the integration of multi-scale attention results; The integrated formula is: In the formula: Represents multi-scale integrated features; Indicates the first Scale weights for each scale; Indicates the first A cross-attention fusion mechanism at multiple scales Indicates the first Features at each scale Indicates the number of scales; In this embodiment, the multi-scale attention integration specifically involves setting the number of scales. There are three feature layers: shallow, medium, and deep; scale weights. Generated through a learnable Softmax layer, with initial values ​​set to... ; S5. Construct a progressive hierarchical classification structure to achieve rock classification from coarse to fine. Step S5 specifically includes the following steps: S51. Progressive hierarchical classification structure design: Build Hierarchical progressive classification architecture; The formula for calculating the classification probability of a progressive hierarchical classification structure is: In the formula: Indicates the first Classification probability; Indicates the first The weight of the level; Indicates the first Level bias; Represents input features; Indicates the probability of the higher-level category; Indicates the classification level, preferred. ; Petrological classification commonly uses a three-level system: "rock type - subtype - specific lithology". However, in actual projects, there may be only two levels (major category / specific lithology) or more than three levels (including genesis, structural and tectonic levels, etc.). In this embodiment, a three-level progressive classification framework is constructed. S52, Progressive Feature Refinement: The feature representation is refined progressively during the classification process; The refining formula is: In the formula: Indicates the first Features after refinement; Indicates the feature increment; Represents the gate function; S53, Uncertainty Calibration: Temperature scaling technology is introduced to calibrate the uncertainty of classification results; The formula for uncertainty calibration is: In the formula: Indicates the probability after uncertainty calibration; Represents the original logits; Indicates temperature parameter; In this embodiment, the uncertainty calibration specifically involves: after model training is completed, using the validation set to calibrate the temperature parameters. Perform a grid search to find the optimal The value is usually in the range of 1.5 to 2.5; S54, Classification Decision Fusion: By integrating the outputs from multiple classification levels, a final comprehensive classification decision is generated; The fusion formula for multiple classification-level outputs is: In the formula: Indicates the final classification probability; Indicates level weight; Indicates the first Classification probability; In this embodiment, the classification decision fusion specifically refers to: level weights. Set as The most granular classification results are given the highest weight, while also taking into account hierarchical consistency. S6. Design a multi-stage progressive training strategy to optimize the overall model performance: Step S6 specifically includes the following steps: S61, Three-stage progressive training: A phased training strategy is adopted to gradually unlock and optimize the parameters of different modules; The three-stage training loss function of the phased training strategy is: In the above formula: , , These represent the total losses in the three stages respectively; Indicates classification loss; , These represent the balance coefficients; The contrastive learning loss function described in step S32 is used to constrain the representations of the same lithological sample to be more similar and the representations of different lithological samples to be more distinct, thereby realizing the injection of petrological priors. The distillation loss function described in step S34 is used to make the output distribution of the student model approximate the output distribution of the teacher model, thereby extracting domain knowledge. In this embodiment, the three-stage progressive training steps are specifically as follows: Phase 1: Train only the progressive classifier head, with a learning rate of 1e-3, using CrossEntropyLoss, for 50 epochs. Phase 2: Freeze the DINOv3 backbone, train the adapter and attention modules, add contrastive learning loss, and balance the coefficients. The learning rate dropped to 5e-4 after 30 training rounds; Phase 3: Fine-tune all parameters end-to-end with a very small learning rate of 1e-5, incorporating distillation losses and balancing coefficients. 20 rounds of training; S62, Multi-task joint optimization: Design a joint learning framework for the main and auxiliary tasks of rock classification; The total loss function of the joint learning framework is: In the formula: Represents the total loss function; Indicates task weight; Indicates the first The loss of one task; Indicates the number of tasks; In this embodiment, the multi-task joint optimization specifically refers to the task weights in the total loss function. Initialize to These correspond to the main task of rock classification, the auxiliary task of mineral identification, and the auxiliary task of structural feature prediction, respectively. S63, Adaptive Loss Balancing: The weighting coefficients of multi-task loss are dynamically adjusted based on task difficulty and importance. The adjustment formula for the weighting coefficients of the multi-task loss is as follows: In the formula: Indicates the first The weight of each task; Indicates learnable parameters; Indicates the first Learnable parameters corresponding to each task; S64. Early Stopping and Model Selection: Implement an early stopping mechanism based on validation set performance and select the best model.

[0022] In this embodiment, the early cessation and model selection specifically involve: setting the observation window size. =10. When the accuracy of the validation set no longer improves for 10 consecutive rounds, the early stop mechanism is triggered, and the model parameters that perform best on the validation set are rolled back.

[0023] The applicant declares that the above description is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Those skilled in the art should understand that any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention fall within the protection and disclosure scope of the present invention.

Claims

1. A domain-adaptive rock thin section image classification method, characterized in that: Includes the following steps: S1. Collect rock thin section image data and perform multi-scale data preprocessing and geological data augmentation; S2. Input the rock thin section image after polarization enhancement and multi-scale alignment into the pre-trained visual Transformer feature extraction network and freeze its encoder parameters; extract features from the output of multiple Transformer layers, and fuse the global features represented by the last layer CLStoken with the local features represented by the patch token to obtain a fused representation for subsequent lithology discrimination. S3, Adaptive technology in the geological field The module performs domain-specific adaptations to general visual features; S4. Employing a dual-path attention mechanism to enhance the discriminative feature representation of rock thin sections; S5. Construct a progressive hierarchical classification structure to achieve rock classification from coarse to fine. S6. Design a multi-stage progressive training strategy to optimize the overall performance of the model.

2. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: Step S1 specifically includes the following steps: S11. Collect polarized light microscope images of rock thin sections at different magnifications, construct a labeled dataset, and build a multi-scale image pyramid for each rock thin section polarized light microscope image to cover full-scale features from macroscopic rock structure to microscopic mineral composition. The magnification factors include 4×, 10×, 20× and 40×; The labeled dataset includes sedimentary rocks, sedimentary rock subclasses, igneous rocks, igneous rock subclasses, metamorphic rocks, and metamorphic rock subclasses; S12. Perform image preprocessing on the original rock thin section polarized light microscope image acquired in step S11; The image preprocessing includes illumination normalization, color correction, and noise filtering. The calculation formula for the image preprocessing is as follows: In the formula: This represents the pixel intensity of the normalized polarized light microscope image of a rock thin section; Represents the pixel intensity of the original polarized light microscopy image of the rock thin section; This represents the average pixel intensity of the original rock thin section polarized light microscope image; The standard deviation of pixel intensity represents the original polarized light microscopy image of the rock thin section; , Indicates the normalization parameter; S13. Enhance geological data based on the principle of polarization optics, and use the polarization rotation simulation formula to simulate the changes in optical characteristics of rock thin sections under different polarization angles; The formula for simulating polarized light rotation is: In the formula: Indicates the rotation angle as Polarization image at time; Represents the polarization rotation matrix. Indicates the deflection angle. This represents the normalized input image after preprocessing in step S12; This represents the matrix transpose operation; S14. Spatial alignment and resolution unification of features at different scales in the multi-scale image pyramid of each rock thin section polarized light microscope image; The formula for spatial alignment is: In the formula: This indicates the spatially aligned features; Indicates the number of scales; Indicates the first Scale weights for each scale; Indicates the first Individual scale features; Indicates the target scale.

3. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: Step S2 specifically includes the following steps: S21. Load the weights of the DINOv3 model pre-trained on a large-scale natural image dataset and freeze all parameters of the Transformer encoder. S22. Extract multi-level features from different depths of the DINOv3 model; The feature extraction formula is: In the formula: Indicates the first layer Features of the layer output; Indicates the first indivual layer, Indicates the upper level Features of the layer output; express The number of layers; S23. Simultaneously extract global image features and local patch features, and perform feature fusion; The feature fusion formula is as follows: In the formula: Indicates the characteristics after fusion; Presentation layer normalization operation; This represents the learnable weights of global features; This represents learnable weights for local features; Represents global features; Show local features; Indicates the bias term; S24. Standardize the dimensions and scale of the fusion features extracted in step S23. The standardized formula is: In the formula: Represents the standardized features; Represents input features; Represents the characteristic mean; Represents the characteristic variance; To represent a small constant, preventing division by zero; Indicates the learnable scaling factor; This represents the learnable bias coefficient.

4. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: Step S3 specifically includes the following steps: S31. Insert parallel processing after each Transformer layer in the DINOv3 model. The structure is derived using low-rank decomposition techniques. Parallel insertion after the Transformer layer The formula for calculating the structure is: In the formula: This indicates the characteristics after the parallel Adapter structure is inserted and adapted. Indicates the first layer The characteristics of the layer output are consistent with those in step S22; This represents the dimensionality reduction weight matrix, which reduces the feature dimension from d to a low rank r; This represents the dimension-upgrading weight matrix, which increases the feature dimension from low rank r to d; S32. Inject prior knowledge of petrology into the adaptive Adapter module of the geological field through comparative learning; The contrastive loss function used is: In the formula: Represents the contrastive loss function; Indicates the first The normalized vector obtained after each sample is encoded; Indicates and Another embedding vector that constitutes a positive sample pair; This represents the embedding vector of all other samples in the batch; Indicates the number of samples in the batch; This indicates the calculation of cosine similarity. The temperature parameter represents the comparison learning; Indicates an indicator function; S33. Adaptively weighted fusion of the original DINOv3 features and the Adapter-enhanced features; The formula for adaptive weighted fusion is: In the formula: This represents the final fused feature, which serves as input for subsequent modules. Indicates the adaptive weight parameters; This indicates the original DINOv3 characteristics of the corresponding layer when bypassing the Adapter, i.e., the characteristics of step S22. Or the final output features; This represents the features after parallel adapter adaptation in step S31, i.e., the output of step S31. S34. Use knowledge distillation techniques to extract domain features from professional geological annotations; The distillation loss expression for knowledge distillation technology is: In the formula: Indicates distillation loss; express Divergence; This represents the probability of the student model's output. This represents the probability of the teacher model's output. This indicates the distillation temperature parameter.

5. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: The use of low-rank decomposition technology refers to the parallel adapter structure adopting a low-rank bottleneck form, decomposing the linear transformation that could originally be equivalent to d×d into W using two low-rank matrices. down ∈R d×r With W up ∈R r×d , The Adapter is added to the Transformer layer output using a residual bypass method, while the Transformer backbone parameters remain frozen, and only the Adapter parameters are trained.

6. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: Step S4 specifically includes the following steps: S41. Evaluate the importance of different feature channels based on channel attention mechanism; The formula for calculating channel attention is: In the formula: Indicates channel attention weights; This represents the sigmoid activation function; This represents a multilayer perceptron; Indicates average pooling; This indicates max pooling; This represents the final fused feature output from step S33. ; S42. Locate key regions in thin-slice images using spatial attention mechanisms; The formula for calculating spatial attention is: In the formula: Indicates spatial attention weights; express convolution; Indicates channel splicing; S43. Design a mechanism for the fusion of cross-attention between passageways and spaces; The cross-attention fusion formula is as follows: In the formula: This represents the features enhanced by cross-attention; Indicate steps ; Indicates channel attention weights; Indicates spatial attention weights; This represents element-wise multiplication; S44. Apply cross-attention fusion mechanism on feature maps of different scales to achieve integration of multi-scale attention results; The integrated formula is: In the formula: Represents multi-scale integrated features; Indicates the first Scale weights for each scale; Indicates the first A cross-attention fusion mechanism at multiple scales Indicates the first Features at each scale Indicates the number of scales.

7. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: Step S5 specifically includes the following steps: S51. Progressive hierarchical classification structure design: The formula for calculating the classification probability of a progressive hierarchical classification structure is: In the formula: Indicates the first Classification probability; Indicates the first The weight of the level; Indicates the first Level bias; Represents input features; Indicates the probability of the higher-level category; Indicates the category level; S52. Refine the feature representation progressively during the classification process; The refining formula is: In the formula: Indicates the first Features after refinement; Indicates the feature increment; Represents the gated function; S53. Introduce temperature scaling technology to calibrate the uncertainty of classification results; The formula for uncertainty calibration is: In the formula: Indicates the probability after uncertainty calibration; Represents the original logits; Indicates temperature parameter; S54. Integrate the outputs from multiple classification levels to generate the final comprehensive classification decision; The fusion formula for multiple classification-level outputs is: In the formula: Indicates the final classification probability; Indicates level weight; Indicates the first Classification probability.

8. The domain-adaptive rock thin section image classification method according to claim 1, characterized in that: Step S6 specifically includes the following steps: S61. Employ a phased training strategy to gradually unlock and optimize the parameters of different modules; The three-stage training loss function of the phased training strategy is: In the above formula: , , These represent the total losses in the three stages respectively; Indicates classification loss; , These represent the balance coefficients; This represents the contrastive learning loss function described in step S32; This represents the distillation loss function described in step S34; S62. Design a joint learning framework for the main and auxiliary tasks of rock classification; The total loss function of the joint learning framework is: In the formula: Represents the total loss function; Indicates task weight; Indicates the first The loss of one task; Indicates the number of tasks; S63. Dynamically adjust the weighting coefficients of multi-task loss based on task difficulty and importance; The adjustment formula for the weighting coefficients of the multi-task loss is as follows: In the formula: Indicates the first The weight of each task; Indicates learnable parameters; This represents the learnable parameters corresponding to the j-th task; S64. Implement an early stopping mechanism based on the performance of the validation set and select the best model.