The article proposes an approach to metallographic research based on solving the problem of semantic segmentation using a trained neural network classifier. To solve the problem of isolating grains in micrographs of longitudinal and transverse slices of metal, the neural network model U-Net was adapted. In order to obtain closed image contours, a post-processing algorithm was developed using the OpenCV open source computer vision library. The article describes the training of a neural network and the conversion of its results, as well as the comparative analysis of the histograms between the reference grain area distribution and the distribution obtained using the proposed algorithm.