segment_sem_images
This is a repository with the code for the segmentation of Slurry Coatings Using Machine Learning Techniques
In the present study, the thickness and presence of the coating layers Fe2Al5 and FeAl, the pores in the Fe2Al5 layer, and their concentration in %, the pore line parallel to the surface and its distance to surface as well as the concentration of Cr-precipitates are determined.
Installation
Clone the repository on your disk. Then, use the Conda package and environment management system for Python. Using the *.yaml files, you can create a Python environment on your system and install the required modules. There are two versions: a regular CPU (environment_cpu.yaml) and a GPU (environment_gpu.yaml). If you have a CUDA-compatible GPU, use the GPU yaml file to install the GPU support. It will provide faster segmentation of image data.
To create a CPU environment, use:
conda env create -f environment_cpu.yml
To create a GPU environment, use:
conda env create -f environment_gpu.yml
Segment the images
To segment the images, use the evaluation.py python script file.
Update the following variables in the evaluation.py python script:
images_path, masks_path, and weights_file. The path should be provided as an absolute path. Individual arguments should be provided as strings, i.e. in quotes. All the results are stored in the newly created sub-folder inside the results folder.
If masks are not available, then put empty string in masks_path.
Example:
masks_path = ""
To segment all 6 labels together, use weight file which has "_6" in it's name.
To segment only chromium precipitates, use weight file which has "_crpr" in it's name.
To use model trained only on synthetic data, use weight file which has "_synth_class" in it's name.
To use model trainedd on mix of synthetic and real data, use weight file which has "_synth_real_mix_class" in it's name.
Example:
python evaluation.py
Creating masks/labels
One mask per image
To create masks, use the data_convert_color_to_number_mask.py script.
Update the following variables in the data_convert_color_to_number_mask.py python script:
input_path, output_path, and color_dict.
Note: Make sure the color_dict variable matches the colors of your image.
Multiple masks per image
If you have multiple masks of same image, and would like to convert to number mask and also add other masks to it, then use data_convert_and_add_separate_masks.py script.
Update the following variables in the data_convert_and_add_separate_masks.py python script:
layers_mask_path, pores_mask_path, crpr_mask_path, layers_numbers_path, layers_pores_numbers_path, layers_pores_crpr_numbers_path, and color_dict.
Note: Make sure the color_dict variable matches the colors of your image.
Also change the path variables specific to your need and masks.
License
The model is licensed under the MIT License.