Rock slice classification method and device

By comparing and learning a pre-trained image encoder, combining the perspective data of single-polarized and multiple orthogonally polarized images, sharing the image encoder and using different projection heads, the problem of high-cost annotation in rock thin section classification is solved, achieving higher classification accuracy and lower memory consumption.

CN121640113APending Publication Date: 2026-03-10PETROCHINA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing rock thin section classification methods require manual annotation of all images, resulting in high annotation costs and limiting the improvement of dataset size and classification accuracy.

Method used

A contrastive learning method was used to conduct self-supervised pre-training of the image encoder. A large number of unlabeled rock thin section images were used as positive and negative samples, and a small number of labeled images were used for fine-tuning. The image encoder was shared and trained using different projection heads, and the perspective data composed of single-polarized light and multiple orthogonally polarized light images were combined.

Benefits of technology

It improves the accuracy of rock thin section classification, reduces the need for manual annotation, and decreases memory consumption and learning difficulty during training, making it suitable for rock thin section classification in actual production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121640113A_ABST
    Figure CN121640113A_ABST
Patent Text Reader

Abstract

The invention discloses a rock slice classification method and device. The method comprises the following steps: pre-establishing a sample data set and a rock slice classification model; wherein the rock slice classification model comprises an image encoder and a classifier based on a neural network architecture; pre-training the image encoder by using the sample data set and a comparative learning method; manually labeled training sample data are selected from the sample data set to train the rock slice classification model, and a trained rock slice classification model is obtained; and inputting the orthogonal polarized light image and the single polarized light image corresponding to the rock slice to be classified into the trained rock slice classification model, and outputting the category of the rock slice from the classifier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This article relates to the field of rock thin section image classification technology, and in particular to a method and apparatus for classifying rock thin sections. Background Technology

[0002] Lithology identification has always been a crucial and fundamental issue in geology, resource exploration, geotechnical investigation, rock mechanics, and engineering, serving as an indispensable link in the process. Thin section identification is a relatively traditional lithology identification technique. This technique involves preparing thin sections of rock and using a polarizing microscope to observe the crystal and optical properties of the minerals within the sample to determine the rock type. Currently, the most commonly used methods include physical methods, chemical methods, spectroscopic methods, and probe methods. However, these rock and mineral classification methods have certain limitations: First, classification methods are specific and may only be suitable for a particular type of rock or mineral; second, some classification methods require advanced technology and instruments, limiting the classification of certain rocks or minerals to certain units or departments. Both of these limitations can affect the classification results.

[0003] With the advancement of artificial intelligence technology, lithological thin section classification is gradually evolving towards intelligent identification. Intelligent rock thin section classification involves collecting and labeling massive amounts of thin section images, establishing a label sample library for deep learning through manual labeling, and training an intelligent rock thin section classification model using this library. This intelligent classification model not only makes the classification results more accurate but also reduces the need for manual labor and increases the classification speed.

[0004] However, for neural networks, the generalization ability after training is significantly positively correlated with the amount of data in the training set. Therefore, increasing the dataset size is an excellent choice for achieving better classification results. However, current rock thin-section image classification methods all require all rock thin-section images to have correctly labeled categories by humans. The cost of human annotation is relatively high compared to taking rock thin-section images, as it requires sophisticated instruments and the time investment of experts. Therefore, current classification methods are difficult to scale to larger rock thin-section datasets, limiting further improvements in classification accuracy.

[0005] Therefore, how to develop a rock thin section classification method that can more accurately predict rock thin sections based on a small amount of manually labeled dataset is an urgent problem to be solved. Summary of the Invention

[0006] This application provides a method and apparatus for classifying rock thin sections. By using a large number of unlabeled images and employing a contrastive learning method to perform self-supervised pre-training of an image encoder, and then using a small amount of labeled image data to train a rock thin section classification model, the accuracy of rock thin section classification is improved, facilitating the rock thin section classification problem in actual production.

[0007] In a first aspect, this application provides a method for classifying rock thin sections, the method comprising:

[0008] A sample dataset and a rock thin section classification model are pre-established; wherein, the rock thin section classification model includes an image encoder and a classifier based on a neural network architecture;

[0009] The image encoder is pre-trained using the sample dataset and a contrastive learning method.

[0010] The rock thin section classification model is trained by selecting manually labeled training sample data from the sample dataset to obtain a trained rock thin section classification model.

[0011] The orthogonally polarized light image and the single-polarized light image corresponding to the rock thin section to be classified are input into the trained rock thin section classification model, and the classifier outputs the category of the rock thin section.

[0012] Optionally, the process of establishing the sample dataset is as follows:

[0013] Obtain multiple rock thin section samples;

[0014] Multiple orthogonally polarized images and single-polarized images were acquired for each rock thin section;

[0015] Manually label a subset of samples from multiple rock thin section samples.

[0016] The manually labeled rock thin section samples were divided into training sample data and test sample data according to a predetermined ratio.

[0017] Optionally, the image encoder is an image encoder employing a ResNet-50 neural network architecture;

[0018] The classifier consists of a linear fully connected layer (Linear) and an activation function (Softmax).

[0019] Optionally, before pre-training the image encoder using the sample dataset and a contrastive learning method, the method further includes:

[0020] Set the training hyperparameters for the rock thin section classification model;

[0021] The data batch is determined based on the set batch size and the sample dataset;

[0022] The training hyperparameters include: batch size, learning rate, and maximum number of training epochs.

[0023] Optionally, the step of pre-training a neural network-based image encoder using a sample dataset and a contrastive learning method includes:

[0024] S51. Initialize the number of training epochs and data batches in the training hyperparameters;

[0025] S52. Select the m-th batch of images from the sample dataset and extract all images corresponding to the k-th rock thin section in the batch of images;

[0026] S53. The image corresponding to the t-th polarization angle of the k-th rock thin section is encoded by an image encoder to obtain a representation vector, and the representation vector is used to obtain a feature vector using a projection head.

[0027] S54. Repeat S52-S53 until all images in the batch of sample data have been traversed.

[0028] S55. Calculate pairwise similarity until all feature vectors are combined in pairs.

[0029] S56. Calculate the pairwise loss and the sum of pairwise losses;

[0030] S57. Calculate the error parameters based on the sum of the paired losses, and update the parameters of the image encoder and the projection head based on the error parameters;

[0031] S58. Repeat S53-S57 until all data batches have been traversed;

[0032] S59. Repeat S51-S58 until the number of training epochs reaches the set upper limit.

[0033] Optionally, the formula for calculating the pairwise similarity is:

[0034]

[0035] Among them, s ij,pq For vector z ij and z pq The included angle, i and p are the labels of the rock thin section samples, and j and q are the labels of the polarization angles in each rock thin section sample, with values ​​of 1, 2, ..., 7, z. ij For the image corresponding to the j-th type of polarization angle of the i-th rock thin section, ||z ij || is the vector z ij The model.

[0036] Optionally, the formula for calculating the pairwise loss is:

[0037]

[0038] In the above formula, 1 [ij≠pq] The value is 1 when ij≠pq, and 0 when ij=pq; τ is the temperature coefficient, and the numerator is z. ij and z pqThe pairwise similarity, with denominator z ij The sum of similarities with other vectors.

[0039] Optionally, the sum of the pairwise losses is:

[0040]

[0041] In the above formula, l(i,j,i,q) represents the pairwise loss function for two positive samples, i and p are the sample numbers, j and q are the numbers of different polarized images for the same sample, N is the total number of the sample dataset, and n is the total number of images with different polarizations for each sample.

[0042] Optionally, manually labeled training sample data is selected from the sample dataset to train the rock thin section classification model, resulting in a trained rock thin section classification model, including:

[0043] The rock thin section classification model is trained by selecting manually labeled training sample data from the sample dataset to obtain an initial rock thin section classification model.

[0044] The classification results of the test samples are obtained using the test sample data and the initial rock thin section classification model;

[0045] Calculate the test classification accuracy based on the classification results;

[0046] Determine whether the classification accuracy meets the predetermined conditions;

[0047] If the classification accuracy meets the predetermined conditions, the initial rock thin section classification model will be used as the trained rock thin section classification model.

[0048] Optionally, the method further includes:

[0049] If the classification accuracy does not meet the predetermined conditions, adjust the training hyperparameters;

[0050] The contrastive learning method was re-used to pre-train the image encoder;

[0051] Retrain the rock thin section classification model.

[0052] Secondly, embodiments of the present invention provide an apparatus for semi-supervised classification of rock thin sections based on contrastive learning pre-training. The apparatus includes a memory and a processor. The memory is used to store a program for performing semi-supervised classification of rock thin sections based on contrastive learning pre-training, and the processor is used to read and execute the program for performing semi-supervised classification of rock thin sections based on contrastive learning pre-training, and execute the method described in any one of the above embodiments.

[0053] Thirdly, embodiments of the present invention provide a computer-readable storage medium storing a data processing program, wherein the data processing program is executed by a processor using any of the methods for semi-supervised classification of rock thin sections based on contrastive learning pre-training.

[0054] Compared with related technologies, this application provides a method and apparatus for classifying rock thin sections. The method includes: pre-establishing a sample dataset and a rock thin section classification model, wherein the rock thin section classification model includes an image encoder and a classifier based on a neural network architecture; pre-training the image encoder based on the neural network architecture using a contrastive learning method with the sample dataset; training the rock thin section classification model with manually labeled training sample data selected from the sample dataset to obtain a trained rock thin section classification model; inputting the orthogonally polarized image and a single-polarized image corresponding to the rock thin section to be classified into the trained rock thin section classification model, and outputting the category of the rock thin section from the classifier. This application improves the classification accuracy of rock thin sections by using a large number of unlabeled images, employing a contrastive learning method for self-supervised pre-training of the image encoder, and then using a small amount of labeled image data to train the rock thin section classification model, thus facilitating the rock thin section classification problem in actual production.

[0055] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. Other advantages of this application can be realized and obtained by means of the solutions described in the description and the accompanying drawings. Attached Figure Description

[0056] The accompanying drawings are used to provide an understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.

[0057] Figure 1 This is a flowchart of a rock thin section classification method according to an embodiment of this application;

[0058] Figure 2 This is a schematic diagram of a rock thin section sorting device according to an embodiment of this application;

[0059] Figure 3 This is a flowchart of a semi-supervised classification method for rock thin sections based on contrastive learning pre-training in an exemplary embodiment.

[0060] Figure 4 A flowchart illustrating a contrastive learning self-supervised pre-trained image encoder in an exemplary embodiment;

[0061] Figure 5 A flowchart illustrating the training of an image encoder and a lightweight classifier in an exemplary embodiment;

[0062] Figure 6 This is a schematic diagram of the contrastive learning pre-training stage in an exemplary embodiment;

[0063] Figure 7 This is a schematic diagram illustrating the training of a rock thin section classification model with a small number of samples in an exemplary embodiment.

[0064] Figure 8 This is a schematic diagram of the contrastive learning pre-training stage in an exemplary embodiment;

[0065] Figure 9 This is a schematic diagram illustrating the training of a rock thin section classification model with a small number of samples in an exemplary embodiment. Detailed Implementation

[0066] This application describes several embodiments, but these descriptions are exemplary and not restrictive, and it will be apparent to those skilled in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with, or may replace, any feature or element of any other embodiment.

[0067] This application includes and contemplates combinations of features and elements known to those skilled in the art. The embodiments, features, and elements disclosed in this application may also be combined with any conventional features or elements to form a unique inventive scheme as defined by the claims. Any feature or element of any embodiment may also be combined with features or elements from other inventive schemes to form another unique inventive scheme as defined by the claims. Therefore, it should be understood that any feature shown and / or discussed in this application may be implemented individually or in any suitable combination. Therefore, the embodiments are not limited except by the limitations imposed by the appended claims and their equivalents. Furthermore, various modifications and changes may be made within the scope of the appended claims.

[0068] Furthermore, in describing representative embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to the specific order of steps described herein, to the extent that it does not depend on such a specific order. As will be understood by those skilled in the art, other sequences of steps are also possible. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Moreover, the claims concerning the method and / or process should not be limited to the steps performed in the written order, and those skilled in the art will readily understand that these orders can be varied and still remain within the spirit and scope of the embodiments of this application.

[0069] In some techniques, rock thin-section image classification methods require all rock thin-section images to have correctly labeled categories by humans. Rock thin-section data needs manual labeling of category information before it can be used as samples for training. The cost of human labeling is significantly higher than that of photographing rock thin sections, due to the need for sophisticated instruments and the time commitment of experts. Theoretically, the more data and the richer the diversity, the higher the classification accuracy of the trained model. Currently, the high cost of labeling means that simply having a large amount of data without sufficient labeled information limits model training and thus restricts the improvement of accuracy.

[0070] Semi-supervised learning, which utilizes a large amount of unlabeled data for learning while using only a few labeled data points, is a method that leverages a large amount of unlabeled data for self-supervised pre-training followed by supervised fine-tuning using a small amount of labeled data. An efficient method for self-supervised pre-training is contrastive learning. Contrastive learning is a commonly used self-supervised learning approach that uses different enhancements, different parts, or different perspectives of the same image as positive samples, and other images as negative samples. The goal of contrastive learning is to minimize the distance between positive sample representations while maximizing the distance between positive and negative sample representations. Compared to methods that focus on predicting pixels (such as autoencoders), contrastive learning can ignore less useful background information or other details in the image, focusing more on the parts that are more relevant to humans, thus removing useless information and retaining only information beneficial to downstream tasks.

[0071] In contrastive learning methods, there are various ways to create positive samples, such as: using artificial augmentation to transform an image in different ways to obtain positive samples; cutting an image into multiple blocks to obtain positive samples; or using images of the same scene from different perspectives as positive samples.

[0072] Regarding the above analysis, the inventor proposes a general vision task that uses a single polarized image and multiple orthogonally polarized images to form positive samples, which is different from the above methods. This application does not use different enhancements of the same image, but directly captures multiple images of the same object but with different polarizations.

[0073] For rock identification tasks, to better visualize rock thin sections from all angles, multiple orthogonally polarized images are often captured in addition to single-polarized images when acquiring the dataset. The single-polarized image and the orthogonally polarized images from different angles of transmission for the same rock thin section constitute different viewpoints (or modalities) of that rock thin section. These viewpoints form the positive sample set for that rock thin section, while arbitrary viewpoints from other rock thin sections constitute the negative sample set. Therefore, a self-supervised pre-training image encoder can be performed using a large amount of unlabeled data based on contrastive learning to obtain a low-dimensional representation. A lightweight classifier is then added after the image encoder, and fine-tuning of the encoder and classifier using a small amount of labeled data yields the classification model for the rock thin section. For self-supervised pre-training, the more different viewpoints (orthogonal polarization angles), the better the pre-training effect. However, previous pre-training methods required a different image encoder for each viewpoint. The more viewpoints, the larger the number of parameters in the image encoder, which significantly increases memory consumption and training difficulty.

[0074] Considering that both single-polarized images and orthogonally polarized images from different angles are RGB natural images of the same rock thin section, the visual difference between different images is much smaller than that in multimodal data. Therefore, this invention applies the same encoder to different viewpoints, and the encoder parameters are shared among viewpoints during training. Simultaneously, considering the regular differences between single-polarized and orthogonally polarized images from different angles, this invention adds different projection heads after the same encoder for different viewpoints. The training objective of contrastive learning is that the output after passing through the projection head should be close between positive samples and far apart between positive and negative samples. During fine-tuning and actual classification, the projection head is removed, and the encoder output representation is directly connected to a lightweight classifier. Compared to previous contrastive learning methods that used the same projection head, this invention introduces an inductive bias by using different projection heads determined by the angle of single-polarized orthogonal polarization. This incorporates information about the differences in representations obtained from single-polarized orthogonal polarization angles and angle-related information into the model, preventing the model from failing to map to similar positions due to differences in the single-polarized orthogonal polarization angles of positive sample images. The inductive bias reduces the learning difficulty of the model, thus achieving better learning results.

[0075] This invention provides a semi-supervised classification method for rock thin sections based on contrastive learning pre-training, such as... Figure 1 As shown, the method includes steps S100-S130:

[0076] S100: Pre-establish sample datasets and rock thin section classification models;

[0077] S110: Using the aforementioned sample dataset, a contrastive learning method is employed to pre-train an image encoder based on a neural network architecture;

[0078] S120: Select manually labeled training sample data from the sample dataset to train the rock thin section classification model, and obtain a trained rock thin section classification model;

[0079] S130: Input the orthogonal polarized light image and the single polarized light image corresponding to the rock thin section to be classified into the trained rock thin section classification model, and output the category of the rock thin section from the classifier.

[0080] In one exemplary embodiment, the process of building the training dataset is as follows:

[0081] Step 1: Obtain multiple rock thin section samples;

[0082] Step 2: For each rock thin section, acquire multiple orthogonally polarized light images and single-polarized light images;

[0083] In step 2, multiple rock thin section samples are acquired, ensuring that each sample has one transmitted single-polarized light photograph and six transmitted cross-polarized light photographs. If there are insufficient photographs for a given rock thin section sample, it is photographed under a polarizing microscope. The specific photographing process is as follows: multiple cross-polarized light and single-polarized light images are generated by photographing the rock thin section sample from the same angle. For example, after selecting a representative field of view, transmitted single-polarized light and transmitted cross-polarized light photographs are taken at the 0° position. Then, under transmitted cross-polarized light, one photograph is taken every 15° of rotation. Each core thin section is photographed with a total of one transmitted single-polarized light photograph and six transmitted cross-polarized light photographs. Figure 6 As shown, the figure includes one polarized image and six orthogonally polarized angle images from different perspectives of the same rock thin section.

[0084] Among them, the representative field of view is the physical angle of the microscope, and different polarized images are determined by the angles of the polarizer and the analyzer.

[0085] Step 3: Manually label the single-polarized and cross-polarized images of some rock thin sections from multiple rock thin section samples;

[0086] In this step, for example, the sample dataset contains 1000 rock thin section samples; select a portion of the rock thin section samples from the 1000 rock thin section samples, for example, select 100 rock thin section samples for manual category labeling, the labeling categories include 36 types, the standard categories are such as: shale, sandstone, limestone, etc.

[0087] Step 4: Divide the manually labeled rock thin section samples into training sample data and test samples according to a predetermined ratio.

[0088] The manually labeled rock thin section samples can be used to determine the training set and the test set in a ratio of 8:2 or 7:3.

[0089] In one exemplary embodiment, after acquiring multiple orthogonally polarized and single-polarized images for each rock thin section in step 2, the images in the dataset need to be cropped according to the parameter requirements of the image encoder used. For example, an image encoder using a ResNet-50 neural network architecture needs to crop all images to 224×224×3, where 224*224 pixels (the image's length and width are both 224 pixels), each pixel is a number from 0 to 255, and 3 represents the three channels of red, green, and blue (RGB). That is, the image size is 224*224, but each pixel is described by three numbers from 0 to 255, and these three numbers can form a variety of colors.

[0090] In one exemplary embodiment, the rock thin section classification model includes an image encoder and a classifier based on a neural network architecture. The image encoder, denoted as f(·), can be an image encoder with a ResNet-50 neural network architecture or an image encoder with a ResNet-10 neural network architecture. The classifier consists of a linear fully connected layer (Linear) and an activation function (Softmax).

[0091] like Figure 7 As shown, the image is processed by encoder f(·) to obtain a representation vector, which is then processed by a lightweight classifier to obtain the classification result.

[0092] In one exemplary embodiment, Figure 9 As shown, in this rock thin section classification model, the image is encoded by the encoder f(·) using the ResNet-50 neural network architecture. In this rock thin section classification model, the classifier c(·) is a linear fully connected layer with 2048 dimensions to 36 categories. After the linear fully connected layer, there is an activation layer Softmax.

[0093] In one exemplary embodiment, the process of training a rock thin section classification model includes:

[0094] Step 1. Initialize training hyperparameters;

[0095] The training hyperparameters are: batch size, learning rate, and maximum number of training epochs.

[0096] For example: the batch size is 16×7, where 16 is the number of rocks included in the batch, 7 is the 7 images from 7 different perspectives for each rock, the learning rate is 0.0001, and the maximum number of training epochs is 100.

[0097] Step 2. Comparative learning of self-supervised training of the image encoder;

[0098] Step 3. Train the image encoder and classifier using manually labeled images;

[0099] Step 4. Test the classification accuracy on the test set;

[0100] Step 5. Determine whether the classification accuracy meets the predetermined conditions;

[0101] Step 6. If the classification accuracy does not meet the predetermined conditions, readjust the training hyperparameters and repeat steps 2-5.

[0102] Step 7. Once the classification accuracy meets the predetermined conditions, the trained rock thin section classification model is obtained.

[0103] In one exemplary embodiment, a contrastive learning self-supervised training image encoder includes:

[0104] S21. Set the image encoder; Set the image encoder to ResNet-50, denoted as f(·);

[0105] S22. Set the number of training epochs and the data batch; set the number of training epochs to 0; set the data batch to 1.

[0106] S23. Select the m-th batch of images from the sample dataset and extract all images corresponding to the k-th rock thin section in the batch of images;

[0107] S24. The image corresponding to the t-th polarization angle of the k-th rock thin section is processed by f(·) to obtain the characterization vector, and then the characterization vector is processed by the projection head gt(·) to obtain the feature vector zkt.

[0108] like Figure 6 The diagram shown illustrates the pre-training stage of comparative learning. The process of this step is as follows: images of the same thin slice from different perspectives are encoded by the encoder f(·) to obtain the representation vector h, and then the representation vector h is passed through their respective projection heads gt(·) to obtain the feature vector z.

[0109] S24 is as follows: The image corresponding to the t-th polarization angle of the k-th rock thin section is processed by f(·) to obtain the representation hkt, which is a 2048-dimensional vector. The representation is then processed by the angle-dependent projection head gt(·), which is a linear fully connected layer from 2048 to 128, plus a Batch norm layer and a ReLU activation layer, to obtain the feature vector zkt, which is a 128-dimensional vector.

[0110] like Figure 8 As shown, the images of the k-th rock thin section are presented from seven different perspectives: single-polarized image, 0° orthogonal polarized image, 15° orthogonal polarized image, 30° orthogonal polarized image, 45° orthogonal polarized image, 60° orthogonal polarized image, and 75° orthogonal polarized image. The hyperparameters of each perspective are the same and can be shared. Each image is processed by a ResNet-50 image encoder to obtain a representation vector hkt, which is a 2048-dimensional vector. Each representation vector passes through a linear fully connected layer (Linear) from 2048 to 128 in the angle-dependent projection head gt(·), then through a batch normalization layer (BN), and then through a ReLU activation layer to obtain a feature vector zkt, which is a 128-dimensional vector.

[0111] S25. Repeat S23-S24 until all images in this data batch have been traversed;

[0112] S26. Calculate pairwise similarity until all feature vectors are combined in pairs.

[0113] The formula for calculating pairwise similarity is as follows:

[0114]

[0115] Among them, s ij,pq For vector z ij and z pq The included angle, here we use the included angle to represent vector z. ij and z pq The smaller the angle between the two vectors, the more similar they are.

[0116] In the above formula, i and p are the labels of the rock thin section samples, and j and q are the labels of the polarization angles in each rock thin section sample, with values ​​of 1, 2, ..., 7, z. ij For the image corresponding to the j-th type of polarization angle of the i-th rock thin section, ||z ij || is the vector z ij The model.

[0117] S27. Calculate the pairwise loss and the sum of pairwise losses;

[0118] The formula for calculating pairwise loss is:

[0119]

[0120] In the above formula, 1 [ij≠pq] The value is 1 when ij ≠ pq, and 0 when ij = pq; τ is the temperature coefficient, which is a hyperparameter and is a value set in advance based on experience, generally taken as 0.1; the numerator is z. ij and z pq The pairwise similarity, with denominator z ij The sum of similarities with all other vectors except itself.

[0121] The sum of paired losses is as follows:

[0122]

[0123] Where l(i,j,i,q) represents the pairwise loss function for two positive samples, i and p are the labels of the rock thin section samples, and j and q are the labels of the polarization angles in each rock thin section sample, with values ​​of 1, 2, ... 7.

[0124] The goal of contrastive learning is to maximize the similarity between positive samples and minimize the similarity between negative samples. Let l(i,j,i,q) represent the pairwise loss function for two positive samples, with the numerator being the similarity between positive samples and the denominator representing the similarity between both positive and negative samples. Therefore, maximizing the pairwise loss means maximizing the similarity between positive samples while minimizing the similarity between negative samples. The summary of the pairwise losses above is the average of the pairwise loss functions for all positive sample pairs.

[0125] S28. Backpropagation of the error yields the parameter updates for encoder f(·) and all projectors gt(·) (t=1,2,…,7);

[0126] Parameters can be updated using the Adam optimizer, or other optimizers such as SGD can be used.

[0127] S29. Repeat S23-S28 until all data batches have been traversed;

[0128] S210, repeat S22-S29 until the number of training epochs reaches the set upper limit of 100.

[0129] In one exemplary embodiment, the process of training a rock thin section classification model (image encoder and classifier) ​​using manually labeled images is as follows:

[0130] S31. Obtain a pre-established rock thin section classification model;

[0131] The rock thin section classification model consists of an image encoder f(·) plus a lightweight classifier c(·), which is a linear fully connected layer plus a Softmax layer.

[0132] S32. Take 80 rock thin section samples from 100 manually labeled rock thin section samples to train the rock thin section classification model f(c(·)).

[0133] S33. The rock thin section classification model is trained using 80 manually labeled training sample data to obtain the initial rock thin section classification model.

[0134] S34. Using the remaining 20 manually labeled test sample data and the initial rock thin section classification model, obtain the classification results of the test samples;

[0135] S35. Calculate the test classification accuracy based on the classification results;

[0136] S36. Determine whether the classification accuracy meets the predetermined conditions;

[0137] S37. If the classification accuracy meets the predetermined conditions, the initial rock thin section classification model is used as the trained rock thin section classification model.

[0138] S38. If the classification accuracy does not meet the predetermined conditions, adjust the training hyperparameters.

[0139] The image encoder based on the neural network architecture was retrained using a contrastive learning method; the rock thin section classification model was retrained.

[0140] The semi-supervised classification method for rock thin sections based on contrastive learning pre-training implemented in this embodiment has the following technical effects:

[0141] 1. This application addresses the difficulty of manual annotation of rock thin section images. Combining the characteristics of polarization microscopy imaging of rock thin sections, it realizes a semi-supervised classification of rock thin sections based on contrastive learning pre-training. It can use a large number of unlabeled images to self-supervised pre-train the image encoder, and then use only a small amount of labeled data to fine-tune the encoder and lightweight classifier, thereby improving the classification accuracy of rock thin sections and facilitating the classification problem of rock thin sections in actual production.

[0142] 2. This application uses a single image encoder with shared parameters across multiple viewpoints and a simple projection head to replace the different image encoders used for different viewpoints in the original multi-view contrastive learning. This significantly reduces memory usage during model training, making it easier to apply in real-world production. Simultaneously, this invention uses different projection heads for different viewpoints, introducing inductive bias, which reduces the learning difficulty of the model and enables it to achieve better learning results.

[0143] Secondly, embodiments of the present invention provide a device for semi-supervised classification of rock thin sections based on contrastive learning pre-training, such as... Figure 2As shown, the device includes a memory 200 and a processor 210; the memory is used to store a program for performing semi-supervised classification of rock thin sections based on contrastive learning pre-training, and the processor is used to read and execute the program for performing semi-supervised classification of rock thin sections based on contrastive learning pre-training, and to execute the method described in any of the above embodiments.

[0144] Thirdly, embodiments of the present invention provide a computer-readable storage medium storing a data processing program, wherein the data processing program is executed by a processor using any of the methods for semi-supervised classification of rock thin sections based on contrastive learning pre-training.

[0145] Example 1

[0146] This example demonstrates a semi-supervised classification method for rock thin sections based on contrastive learning pre-training. The specific process is as follows: Figure 3 As shown, it includes the following steps:

[0147] S301. Determine if there are enough rock thin section images with single polarization and cross polarization for training the classification model.

[0148] S302. If the existing dataset meets the requirements, proceed directly to step 303. Otherwise, take pictures of the rock thin section samples under a polarizing microscope. Take pictures of each thin section from the same angle to generate multiple orthogonal polarized images and single polarized images to form a dataset.

[0149] S303. Manually label the single-polarized and cross-polarized images corresponding to a small number of rock thin section samples in the dataset;

[0150] S304. Select the neural network architecture of the image encoder. Based on the required input image size of the architecture, crop the images in the dataset to match the required size, and determine the training set and test set proportionally.

[0151] S305. Initialize training hyperparameters;

[0152] S306, Contrastive learning self-supervised pre-trained image encoder;

[0153] S307. A rock thin section classification model f(c(·)) is trained using images with manually labeled categories. The rock thin section classification model includes an image encoder and a classifier.

[0154] S308. Test the classification accuracy on the test set;

[0155] S309. Determine whether the classification accuracy meets the requirements;

[0156] S310. If the requirements are not met, adjust the training hyperparameters and return to step S306; otherwise, end the process.

[0157] Further: the implementation process of step S306, which involves contrastive learning of a self-supervised pre-trained image encoder, is as follows: Figure 4 As shown, it includes the following steps:

[0158] S61. Different viewpoints use the same image encoder, denoted as f(·);

[0159] S62. Set the number of training epochs to 0;

[0160] S63, Set the data batch to 1;

[0161] The English word for data batch is "Batch," and mini-batch training is a fundamental practice in the field of deep learning. The batch is the inner loop, and the epoch is the outer loop; there are two loops. If there are 1000 data points and the batch size is 100 data points, then 1000 / 100 = 10 batches need to be executed within one epoch.

[0162] S64. Sample the m-th batch of images from the dataset;

[0163] S65. Extract all images corresponding to the kth rock thin section from the batch of images;

[0164] S66. The image corresponding to the t-th polarization angle of the k-th rock thin section is processed by f(·) to obtain the characterization hkt. The characterization is then processed by the angle-dependent projection head gt(·) to obtain the feature vector zkt.

[0165] S67. Repeat S64, S65, and S66 until all images in the data batch have been traversed.

[0166] S68. Calculate pairwise similarity until all feature vectors are combined in pairs.

[0167] S69. Calculate the loss function value of each pairwise combination of feature vectors;

[0168] S610. Calculate the sum of paired losses;

[0169] S611. Backpropagation of error yields the parameter update values ​​for encoder f(·) and all projectors gt(·) (t=1,2,…,n);

[0170] S612, Repeat S64-S611 until all data batches have been traversed;

[0171] S613. Repeat S63-S612 until the number of training epochs reaches the set upper limit.

[0172] In one exemplary embodiment, step S307 trains the image encoder and the lightweight classifier, such as... Figure 5 As shown, it includes the following steps:

[0173] S71. Add a lightweight classifier c(·) after the image encoder f(·);

[0174] S72. Train a rock thin section classification model f(c(·)) using a small amount of labeled data.

[0175] In this example, to address the high cost of manual labeling of rock thin section images, a semi-supervised classification method for rock thin sections is adopted. This method pre-trains an image encoder using a large number of unlabeled rock thin section images based on contrastive learning. Positive samples are single-polarized images and orthogonally polarized images of the same rock thin section from different angles, while negative samples are formed from any viewpoint across different rock thin sections. After pre-training, a lightweight classifier is added after the encoder. The encoder and classifier are then fine-tuned using a small number of labeled rock thin section images to obtain a classification model for the rock thin section images.

[0176] To address the issue of high memory consumption caused by using different encoders for different viewpoints in multi-view contrastive learning, this invention proposes a method that uses the same encoder for different viewpoints. Since only the parameters of one encoder and the optimizer state need to be stored during training, the memory usage during training is significantly reduced. To solve the problem of difficulty in mapping images from different viewpoints to similar positions after passing through the same encoder, this invention introduces a projection head after the encoder during the training phase. Furthermore, different projection heads are used for images with different single-polarized or orthogonal polarization angles. This incorporates the distinct representations obtained from single-polarized or orthogonal polarization angles, along with angle-dependent inductive biases, into the model, reducing the learning difficulty and thus achieving better learning results.

[0177] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

Claims

1. A method of classifying rock thin sections, characterized by, The method comprises: pre-establishing a sample data set and a rock slice classification model; wherein the rock slice classification model comprises an image encoder and a classifier based on a neural network architecture; pre-training the image encoder using a contrast learning method with the sample data set; training the rock slice classification model using manually annotated training sample data selected from the sample data set to obtain a trained rock slice classification model; inputting orthogonal polarized images and single polarized images corresponding to the rock slices to be classified into the trained rock slice classification model, and outputting the categories of the rock slices from the classifier.

2. The rock slice classification method according to claim 1, wherein the sample data set is established by: obtaining a plurality of rock slice samples; obtaining a plurality of orthogonal polarized images and single polarized images for each rock slice; manually annotating the categories of selected samples in the plurality of rock slice samples; dividing the manually annotated rock slice samples into training sample data and test sample data according to a predetermined proportion.

3. The rock slice classification method according to claim 1, wherein the image encoder is a ResNet-50 neural network architecture image encoder; and the classifier is composed of a linear fully connected layer Linear and an activation function Softmax.

4. The rock slice classification method according to claim 2, wherein before pre-training the image encoder using a contrast learning method with the sample data set, the method further comprises: setting training hyperparameters of the rock slice classification model; determining data batches according to the set batch quantity and the sample data set; the training hyperparameters include batch quantity, learning rate, and maximum training epoch number.

5. The rock slice classification method according to claim 4, wherein pre-training the image encoder using a contrast learning method with the sample data set comprises: S51, initializing the training epoch number and data batches in the training hyperparameters; S52, selecting the mth batch of images from the sample data set, and extracting all images corresponding to the kth rock slice in the batch of images; S53, the image corresponding to the tth polarized angle of the kth rock slice is input into the image encoder to obtain a feature vector; S54, repeating S52-S53 until all images in the sample data batch are traversed; S55, calculating the pair-wise similarity until all feature vectors are combined in pairs; S56, calculating the pair-wise loss and the summary of the pair-wise loss; S57, calculating the error parameter according to the summary of the pair-wise loss, and updating the parameters of the image encoder and the projection head according to the error parameter; S58, repeating S53-S57 until all data batches are traversed; S59, repeating S51-S58 until the training epoch number reaches the set upper limit.

6. The rock slice classification method according to claim 5, wherein the calculation formula of the pair-wise similarity is: ​ ​ ​ ​ ​ ​ where s ij,pq is the angle between vectors z ij and z pq , i and p are the labels of the rock slice samples, j and q are the labels of the polarizing angles in each rock slice sample, taking values 1, 2, …, 7, z ij is the image corresponding to the jth polarizing angle of the ith rock slice, and ||z ij || is the norm of vector z ij .

7. The rock slice classification method according to claim 5, wherein the pair loss is calculated according to the following formula:

8. The rock slice classification method according to claim 7, wherein the pair loss is aggregated according to the following formula: In the above equation, 1 [ij≠pq] is 1 for ij≠pq and 0 for ij=pq; τ is the temperature coefficient, the numerator is the z ij pair similarity of the z pq th and z ij th vectors, and the denominator is the sum of the similarities of the z th vector with other vectors. In the above formula, l(i,j,i,q) represents the pair loss function of two positive samples, i and p are the numbers of the samples, j and q are the numbers of different polarized images for the same sample, N is the total number of the sample data set, and n is the total number of different polarized images of each sample.

9. The rock slice classification method according to claim 4, wherein the rock slice classification model is trained by selecting the manually annotated training sample data from the sample data set, and the trained rock slice classification model is obtained, and the method comprises the following steps: The rock slice classification model is trained by selecting the manually annotated training sample data from the sample data set, and an initial rock slice classification model is obtained. The classification result of the test sample is obtained by using the test sample data and the initial rock slice classification model. The test classification accuracy is calculated according to the classification result. It is determined whether the classification accuracy meets the predetermined condition. If the classification accuracy meets the predetermined condition, the initial rock slice classification model is taken as the trained rock slice classification model. The method further comprises: If the classification accuracy does not meet the predetermined condition, the training hyperparameters are adjusted. The pre-trained image encoder is re-trained by using the contrastive learning method.

10. The method of classifying rock thin sections according to claim 9, wherein, The rock slice classification model is re-trained. The device comprises a memory and a processor, the memory is used to save the program for classifying rock slices, and the processor is used to read and execute the program for classifying rock slices, and the method according to any one of claims 1-10 is executed. The computer readable storage medium stores a data processing program, and the data processing program is executed by the processor to execute the rock slice classification method according to any one of claims 1-10. ​ 11. A rock slice classification apparatus, characterized by, ​ 12. A computer-readable storage medium, characterized in that, ​