General segmentation method for alloy microstructure image in combination with preliminary identification of SAM model and automatic feature extraction of pre-training model
By combining the Segment Anything Model and the pre-trained model, the eigenvector distance calculation is used to determine the threshold, which solves the problem of insufficient model generalization ability in the segmentation of the microstructure of alloy materials, and achieves efficient and accurate automatic segmentation of the microstructure of general alloy materials, reducing the cost Computing resource requirements.
Patent Information
- Application Number
- CN202410892504.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-10-08
AI Technical Summary
Existing deep learning models have problems in segmenting the microstructure of alloy materials, such as limited model generalization capabilities, the need for a large amount of annotated data and model tuning, and high dependence on the quality of training data, which results in their inability to segment the microstructure of different types of alloy materials. Inadequate efficiency and accuracy.
Using the open source Segment Anything Model (SAM) combined with a variety of pre-trained models, through contrast and brightness adjustment, grid point division, initial recognition result processing of the SAM model, and calculation of the feature vector distance between the feature vector provided by the user and the initial recognition result , determine the threshold to complete the automated segmentation of the microstructure of alloy materials.
It achieves high-accuracy and universal automatic segmentation of the microstructure of alloy materials, reduces segmentation time, reduces computing resource requirements, and eliminates the need to independently formulate screening rules for different types of alloy materials.
Smart Images

Figure CN118747802A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of alloy material microstructure segmentation and deep learning universal semantic large model, and is a method for automatically segmenting alloy material microstructure based on Segment Anything Model (SAM) and a pre-trained model. Background Art
[0002] Alloy materials, as an indispensable material basis for contemporary industry and society, are widely used in transportation, construction, and heavy industry. With the development of the times, we have higher and higher requirements for the performance of materials, and the performance of alloy materials depends largely on their microstructure. There are many types of alloy materials and the microstructures of different types of materials are complex, so being able to accurately analyze and identify their microstructures is of great significance to improving the macroscopic properties of alloy materials.
[0003] In recent years, with the rapid development of computers, many deep learning models have excellent performance in the field of image analysis, so it has become a trend to use deep learning technology to study tissues. At present, foreign scholars have achieved some results in the field of material microstructure segmentation using deep learning technology; in 2019, DeCost et al. used visual feature packages to extract image features and combined support vector machines to classify and identify seven microstructures including brass, bronze, ductile iron, gray cast iron, hypoeutectoid steel, malleable cast iron, and high-temperature alloys, with an accuracy of 80%. In 2019, Gola et al. combined support vector machines with pixel-based and morphological parameters to classify and identify the microstructures of three different steels with an accuracy of 97.47%. In 2018, Dmitry S. Bulgarevich et al. used random forest algorithms for machine learning to automatically segment the microstructure of steel, and their segmentation results were very consistent with the expert-level manual segmentation results, although there were slight inconsistencies in small microstructure areas. In April 2024, Andi Wijaya et al. segmented porous copper based on machine learning, and the accuracy of microscopic pore segmentation was as high as 95%. In general, the use of deep learning algorithms for microstructural analysis of alloy materials has the advantages of high efficiency, accuracy, and speed, and automated analysis is feasible; however, at the same time, the method has limited model generalization ability, requires data annotation and model tuning, and the performance of the model is highly dependent on the quality of training data.
[0004] In 2023, MetaAI released a new semantic segmentation model, Segment anything model (SAM), which has the unique characteristics of zero-sample learning, powerful segmentation capabilities for general images, and multiple user semantic recognition functions. It provides feasibility for establishing a universal segmentation method for the microstructure of alloy materials. Summary of the invention
[0005] The technical problem to be solved by the present invention is to obtain preliminary recognition results based on the open source SegmentAnything Model (SAM) in view of the shortcomings of the above-mentioned prior art. Combined with a variety of pre-trained models, the feature vectors of different positions of the input image corresponding to the preliminary recognition results are extracted, and the vector distance is calculated with the feature vector prompted by the user. The threshold is determined according to the distribution of the vector distance, and the part less than the threshold is the part required by the user, thereby completing the recognition of the microstructure of the alloy material and the image segmentation processing.
[0006] The technical solution adopted by the present invention is:
[0007] A general segmentation method for alloy microstructure images combining preliminary recognition by a SAM model and automatic feature extraction by a pre-trained model comprises the following steps:
[0008] Step 1: Collect the microstructure image data of the alloy material and pre-process the images that need to be identified;
[0009] The specific steps of step 1 are:
[0010] Step 1.1: Adjust the contrast and brightness of all images to obtain microscopic images with clearer tissue boundaries;
[0011] Step 1.2: Crop the tissue image to retain the area that needs to be identified.
[0012] Step 2: Divide the training set and test set according to a certain ratio. The training set should fully include samples in various situations and reflect the characteristics of the samples.
[0013] Step 3: Process the training samples and test samples again, import them into the SAM model, and output the initial recognition results;
[0014] The specific steps of step 3 are:
[0015] Step 3.1: Automatically add grid points to the image; grid points refer to points in the image divided at fixed intervals. The positions of these points are usually represented by coordinates, that is, the intersection of the horizontal coordinate and the vertical coordinate;
[0016] Step 3.2: The SAM model has a streamlined architecture, consisting of three parts: image encoder, hint encoder, and mask decoder; the training set of the SAM model exceeds 11 million mask data, and its training process goes through three stages, namely: 1. Model-assisted manual stage 2. Semi-automatic stage of automatic mask prediction plus auxiliary annotation 3. Fully automatic stage of full model mask generation. The streamlined architecture, large data set, and three-step training method enable SAM to achieve a significant reduction in segmentation time while achieving accurate segmentation results;
[0017] The SAM pre-trained model can be directly obtained at https: / / github.com / facebookresearch / segment-anything, without any additional training and fine-tuning operations;
[0018] Step 3.3: Input the image and grid points into SAM to obtain the initial recognition result. Different areas of the initial recognition result are marked with different colors.
[0019] Step 4: The microscopic tissue image areas corresponding to the different colors of the initial recognition results of the training set and the test set are cut out by their circumscribed rectangles, which we call small blocks, and the redundant cutout parts outside the area are filled with black;
[0020] Step 5: The user needs to provide a single area mask for a training sample. The area marked in white is the area that the user needs to identify, and the area outside the area is black, which is the part that the user does not need, that is, the background part;
[0021] Step 6: The area of the mask image provided by the user corresponding to the original image is also intercepted with its circumscribed rectangle, and the redundant intercepted part outside the area is also filled with black;
[0022] Step 7: Obtain the feature vector of the small block marked by the user and the feature vectors of all small blocks of the initial recognition result;
[0023] The specific steps of step 7 are:
[0024] Step 7.1: Input the user-annotated small blocks and all the small blocks of the initial recognition results into the pre-trained model, such as resnet50, VGG19, etc. to extract feature vectors; the recommended pre-trained model is Siamsim;
[0025] Step 7.2: All pre-trained models select the results of the last layer of their feature extraction layer as the feature vectors of the initial recognition result patch and the user prompt patch.
[0026] Step 8: In the training set, the user-prompted feature vector and all small-block feature vectors are compared to screen out all small blocks required by the user to complete the processing of the alloy microstructure segmentation image.
[0027] The specific steps of step 8 are:
[0028] Step 8.1: Calculate the Manhattan distance of the small block feature vector and the user prompt feature vector respectively, and draw the distance frequency distribution diagram of the training set;
[0029] Step 8.2: Determine the distance threshold according to the distance frequency distribution diagram of the training set;
[0030] Step 8.3: In the training set and the test set, the image is processed according to the determined threshold. The corresponding small blocks with a distance less than the threshold are retained and regarded as the area that the user needs to segment. The corresponding small blocks outside the threshold are screened and discarded to obtain the final processed alloy material microstructure segmentation image.
[0031] The beneficial effects of adopting the above technical solution are:
[0032] The present invention provides a method for automatically segmenting the microstructure of alloy materials based on SegmentAnything Model (SAM); through the basic processing of the SAM large model and the data calculation of multiple pre-trained models, the user prompt features and image block features are analyzed and screened to complete the automatic segmentation of the microstructure of general alloy materials. Compared with traditional deep learning models and microstructure segmentation methods, this method is more versatile and has a more accurate recognition effect. In addition, based on the characteristic advantage of zero-sample learning possessed by SAM, the segmentation time of this method is much shorter than other segmentation methods; at the same time, the feature extraction method uses vector distance to screen image processing solutions for different types of alloy materials without the need to independently formulate screening rules, which can greatly reduce the processing time and computer performance requirements for the segmentation of microstructure images of different types of alloy materials, and provides an effective way for the automatic segmentation of microstructure images of general alloy materials. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 The general flow chart of the general segmentation method of alloy material microstructure image of the present invention is as follows DETAILED DESCRIPTION
[0034] In order to further explain the technical methods and results adopted by the present invention to achieve the expected effects, the specific implementation methods, structural features and effects of the present invention are described in more detail below in conjunction with the accompanying drawings.
[0035] Step 1: Establish the original data set of alloy materials and pre-process the images that need to be identified;
[0036] The specific steps of step 1 are:
[0037] Step 1.1: Contrast and brightness adjustment. Use the image processing software Photoshop to uniformly process all images as follows, increase the clarity of image details to obtain images with clearer tissue boundaries, and improve the accuracy of subsequent model processing;
[0038] Step 1.2: Crop the tissue image to retain the area that needs to be identified.
[0039] Step 2: Divide the training set and test set into multiple ratios such as 1:1, 4:3, 16:9, etc. The training set should fully include samples in various situations to reflect the characteristics of the samples.
[0040] Step 3: Process the training samples and test samples again, import them into the SAM model, and output the initial recognition results;
[0041] The specific steps of step 3 are:
[0042] Step 3.1: Automatically add grid points to the image. Grid points refer to points in the image that are divided at fixed intervals. The positions of these points are usually represented by coordinates, such as (14, 35), which is the intersection of the horizontal coordinate and the vertical coordinate;
[0043] Step 3.2: The basic architecture of SAM is very concise, which includes three parts: accurate image encoder (ImageEncoder), flexible prompt encoder (Prompt Encoder) and fast mask decoder (Mask Decoder); Image encoder (Image Encoder) is responsible for converting the input image into a high-dimensional feature representation; it uses an architecture based on Vision Transformer (ViT) that can capture local and global features in the image. Its function is to input an image and gradually convert the image into a high-dimensional feature map through a series of Transformer layers; each position in the feature map contains rich information about the image area corresponding to the position; Prompt Encoder is responsible for converting the prompts input by the user into feature representations, combining them with the output features of the image encoder to guide the model to perform specific segmentation tasks; it supports multiple types of prompts, such as points, boxes, text descriptions, etc.; Mask Decoder (MaskDecoder) is responsible for combining the features output by the image encoder and the prompt encoder to generate the final segmentation mask;
[0044] SAM's training set contains more than 11 million mask data, and its training process includes three stages: 1. Model-assisted manual stage 2. Semi-automatic stage of automatic mask prediction and auxiliary annotation 3. Fully automatic stage of full model mask generation. The streamlined architecture, large data set, and three-step training method enable SAM to significantly reduce segmentation time while achieving accurate segmentation results;
[0045] The SAM pre-trained model can be directly obtained at https: / / github.com / facebookresearch / segment-anything, without any additional training and fine-tuning operations. The official website also provides 3 different sizes of pre-trained parameters, and users can freely choose according to the performance of the device;
[0046] Step 3.3: Input the image and grid points into SAM to obtain the initial recognition result. Different areas of the initial recognition result are marked with different colors for easy distinction.
[0047] Step 4: The microscopic tissue image areas corresponding to the different color areas of the initial recognition results of the training set and the test set are cut out by their circumscribed rectangles, which we call small blocks. The redundant cutout parts outside the area are filled with black to eliminate the influence of color on the features.
[0048] Step 5: The user needs to provide a mask image for a single area of a training sample. The area marked in white is the area that the user needs to identify, and the area outside the area is black, which is the part that the user does not need, that is, the background part.
[0049] Step 6: The area of the microstructure image corresponding to the mask image provided by the user is also cut out with its circumscribed rectangle, and the redundant cut-out part outside the area is also filled with black.
[0050] Step 7: Obtain the feature vector of the small block marked by the user and the feature vectors of all small blocks of the initial recognition result;
[0051] The specific steps of step 7 are:
[0052] Step 7.1: Input the user-annotated small blocks and all the small blocks of the initial recognition results into the pre-trained model, such as resnet50, VGG19, etc. to extract feature vectors. The recommended pre-trained model is Siamsim;
[0053] Step 7.2: All pre-trained models select the results of the last layer of their feature extraction layer as the feature vectors of the initial recognition result patch and the user prompt patch.
[0054] Step 8: In the training set, the user-prompted feature vector and all small-block feature vectors are compared. The smaller the distance between the two groups of feature vectors, the closer the features of the two groups are. In this way, all small blocks required by the user are screened to complete the processing of the alloy microstructure segmentation image.
[0055] The specific steps of step 8 are:
[0056] Step 8.1: Calculate the Manhattan distance of the small block feature vector and the user prompt feature vector respectively, and draw the distance frequency distribution diagram of the training set;
[0057] Step 8.2: Determine the distance threshold according to the distance frequency distribution diagram of the training set, that is, the distance frequency distribution diagram shows that at a certain horizontal axis, the frequency of the two columns before and after has a very intuitive data difference, and this horizontal axis data is determined as the threshold;
[0058] Step 8.3: In the training set and the test set, the image is processed according to the determined threshold. The corresponding small blocks with a distance less than the threshold are retained and regarded as the area that the user needs to segment. The corresponding small blocks outside the threshold are screened and discarded to obtain the final processed microstructure segmentation image of the alloy material.
[0059] The above overall process, such as Figure 1 shown.
Claims
1. A general segmentation method for alloy microstructure images combining preliminary recognition of SAM model and automatic feature extraction of pre-trained model, characterized by: The following steps are involved: Step 1: Collect the microstructure image data of the alloy material and pre-process the images that need to be identified; Step 1.1: Adjust the contrast and brightness of all images to obtain microscopic images with clearer tissue boundaries; Step 1.2: Crop the tissue image to retain the area that needs to be identified. Step 2: Divide the training set and test set according to a certain ratio. The training set should fully include samples in various situations and reflect the characteristics of the samples. Step 3: Process the training samples and test samples again, import them into the SAM model, and output the initial recognition results; Step 4: The microscopic tissue image areas corresponding to the different colors of the initial recognition results of the training set and the test set are cut out by their circumscribed rectangles, which we call small blocks, and the redundant cutout parts outside the area are filled with black; Step 5: The user needs to provide a single area mask for a training sample. The area marked in white is the area that the user needs to identify, and the area outside the area is black, which is the part that the user does not need, that is, the background part; Step 6: The area of the mask image provided by the user corresponding to the original image is also intercepted with its circumscribed rectangle, and the redundant intercepted part outside the area is also filled with black; Step 7: Obtain the feature vector of the small block marked by the user and the feature vectors of all small blocks of the initial recognition result; Step 8: In the training set, the user-prompted feature vector and all small-block feature vectors are compared to screen out all small blocks required by the user to complete the processing of the alloy microstructure segmentation image.
2. According to claim 1, a general segmentation method for alloy microstructure images combining SAM model preliminary recognition and pre-training model automatic feature extraction is characterized in that: The step 3 specifically includes: Step 3.1: Automatically add grid points to the image; grid points refer to points in the image divided at fixed intervals. The positions of these points are usually represented by coordinates, that is, the intersection of the horizontal coordinate and the vertical coordinate; Step 3.2: The SAM model has a streamlined architecture, consisting of three parts: image encoder, hint encoder, and mask decoder; the training set of the SAM model exceeds 11 million mask data, and its training process goes through three stages, namely:
1. Model-assisted manual stage 2. Semi-automatic stage of automatic mask prediction plus auxiliary annotation 3. Fully automatic stage of full model mask generation. The streamlined architecture, large data set, and three-step training method enable SAM to achieve a significant reduction in segmentation time while achieving accurate segmentation results; The SAM pre-trained model can be directly obtained at https: / / github.com / facebookresearch / segment-anything, without any additional training and fine-tuning operations; Step 3.3: Input the image and grid points into SAM to obtain the initial recognition result. Different areas of the initial recognition result are marked with different colors.
3. According to claim 1, a general segmentation method for alloy microstructure images combining SAM model preliminary recognition and pre-training model automatic feature extraction is characterized in that: The step 7 specifically includes: Step 7.1: Input the user-annotated small blocks and all the small blocks of the initial recognition results into the pre-trained model, such as resnet50, VGG19, etc. to extract feature vectors; the recommended pre-trained model is Siamsim; Step 7.2: All pre-trained models select the results of the last layer of their feature extraction layer as the feature vectors of the initial recognition result patch and the user prompt patch.
4. The general segmentation method of alloy microstructure image combining SAM model preliminary recognition and pre-training model automatic feature extraction according to claim 1 is characterized in that: The step 8 specifically includes: Step 8.1: Calculate the Manhattan distance of the small block feature vector and the user prompt feature vector respectively, and draw the distance frequency distribution diagram of the training set; Step 8.2: Determine the distance threshold according to the distance frequency distribution diagram of the training set; Step 8.3: In the training set and the test set, the image is processed according to the determined threshold. The corresponding small blocks with a distance less than the threshold are retained and regarded as the area that the user needs to segment. The corresponding small blocks outside the threshold are screened and discarded to obtain the final processed alloy material microstructure segmentation image.
Citation Information
Cited By
A material microstructure segmentation method and device based on orientation frequency domain gating
CN123094102A
