{"id":350012,"date":"2023-07-09T15:01:53","date_gmt":"2023-07-09T15:01:53","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350012"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350012","title":{"rendered":"<span>\u0421\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b U-Net \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/229\/e8a\/a20\/229e8aa200b9b439f5fe07e56e4084dc.gif\" width=\"544\" height=\"306\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/229\/e8a\/a20\/229e8aa200b9b439f5fe07e56e4084dc.gif\"\/><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0431\u044b\u0442\u043e\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u0430 \u0438\u0434\u0435\u044f \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u043a\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 (<a href=\"https:\/\/habr.com\/ru\/articles\/738720\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u043a\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Computer Vision<\/a>), \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0434\u043e\u0440\u043e\u0433\u0438, \u0442\u0440\u043e\u0442\u0443\u0430\u0440\u0430 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u0437 \u043f\u0430\u0440\u043a\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u043c\u0435\u0441\u0442, \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u044f\u0442 \u043d\u0430 \u0433\u0430\u0437\u043e\u043d\u0435 (\u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043d\u0435\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0447\u0451\u0442).<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0438 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0443\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:\u00a0<br \/><em>\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u043a\u043e\u0442, \u0441\u0442\u0443\u043b, \u0441\u0442\u043e\u043b, \u0442\u0430\u0440\u0435\u043b\u043a\u0430 \u0441 \u043a\u043e\u0442\u043b\u0435\u0442\u0430\u043c\u0438 \u0438\u0442\u0434) \u0438 \u043f\u0440\u0438 \u0441\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (\u043a\u043e\u0442 &#8212; \u0442\u0430\u0440\u0435\u043b\u043a\u0430) \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430. <\/em><\/p>\n<p><strong>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f!<\/strong><\/p>\n<pre><code class=\"python\">#\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 import os import glob import cv2  import pandas as pd import numpy as np import requests  import tensorflow as tf  from skimage import measure from skimage.io import imread, imsave, imshow from skimage.transform import resize from skimage.morphology import dilation, disk from skimage.draw import polygon, polygon_perimeter  from livelossplot.tf_keras import PlotLossesCallback<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043d\u0443\u043b\u044f \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u042f \u0441\u0434\u0435\u043b\u0430\u043b \u0431\u043e\u043b\u0435\u0435 40 <s>\u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u044b\u0445<\/s> \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0438 \u0440\u0430\u0437\u043c\u0435\u0442\u0438\u043b \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 Supervisely.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/12d\/00c\/ad4\/12d00cad4928b23e71065adeebc6eaec.png\" width=\"1872\" height=\"384\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/12d\/00c\/ad4\/12d00cad4928b23e71065adeebc6eaec.png\"\/><\/figure>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (\u0435\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 CVAT). \u0422\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Supervisely \u043a\u0430\u043a \u0440\u0430\u0437 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043c\u0435\u0442\u0438\u0442\u044c \u0432 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u0430 50 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u043d\u0430 6-8 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0421\u0435\u0440\u0432\u0438\u0441 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438.<\/p>\n<p>\u0421\u043f\u0443\u0441\u0442\u044f \u0447\u0430\u0441 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 (\u043d\u0435 \u043e\u0447\u0435\u043d\u044c) \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u043e\u0439, \u0432\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/77e\/531\/d0b\/77e531d0bd72e62815eb1a460e95d43d.png\" alt=\"\u0420\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (7 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 + 1 \u0444\u043e\u043d)\" title=\"\u0420\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (7 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 + 1 \u0444\u043e\u043d)\" width=\"2560\" height=\"960\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/77e\/531\/d0b\/77e531d0bd72e62815eb1a460e95d43d.png\"\/><\/p>\n<div><figcaption>\u0420\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (7 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 + 1 \u0444\u043e\u043d)<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u043c\u043e\u0433, \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \ud83d\ude42<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0442\u043e\u0432\u0430, \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u043c \u043d\u0430 train \u0438 test (\u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0430). \u0412 \u043e\u0431\u0449\u0435\u043c \u0438\u0442\u043e\u0433\u0435, \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 2000 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0438\u0437 \u043d\u0438\u0445 1800 \u043f\u043e\u0439\u0434\u0443\u0442 \u0432 train \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432 test.<\/p>\n<pre><code class=\"python\">#\u0420\u0430\u0437\u043c\u0435\u0440 train \u0432\u044b\u0431\u043e\u0440\u043a\u0438 train_size = 1800  #\u0414\u0435\u043b\u0438\u043c \u043d\u0430 train \u0438 test train_dataset = dataset.take(train_size).cache() test_dataset = dataset.skip(train_size).take(len(dataset) - train_size).cache()  train_dataset = train_dataset.batch(BATCH_SIZE) test_dataset = test_dataset.batch(BATCH_SIZE)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/838\/fb3\/a2e\/838fb3a2ed9be57f2d605250f2335628.png\" alt=\"\u0427\u0442\u043e \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" title=\"\u0427\u0442\u043e \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" width=\"963\" height=\"236\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/838\/fb3\/a2e\/838fb3a2ed9be57f2d605250f2335628.png\"\/><\/p>\n<div><figcaption>\u0427\u0442\u043e \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0441\u0435\u0431\u044f \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fc0\/345\/9ae\/fc03459ae49b260a2f114d8cc338cc82.png\" alt=\"\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\" title=\"\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430\" width=\"2034\" height=\"1358\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc0\/345\/9ae\/fc03459ae49b260a2f114d8cc338cc82.png\"\/><\/p>\n<div><figcaption>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u042f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u043b \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0431\u043b\u043e\u043a\u043e\u0432-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0431\u043e\u0439 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0439 \u0441\u043c\u043e\u0433 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c39\/0cf\/32c\/c390cf32cb88953523e79d40179eea6f.png\" alt=\"\u041c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f U-Net\" title=\"\u041c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f U-Net\" width=\"3836\" height=\"1069\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c39\/0cf\/32c\/c390cf32cb88953523e79d40179eea6f.png\"\/><\/p>\n<div><figcaption>\u041c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f U-Net<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 U-Net \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: \u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440. \u041c\u044b \u043f\u043e\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u0442\u0440\u0435\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 256\u0445256 \u0438 \u0434\u0430\u043b\u0435\u0435 \u0434\u0435\u043b\u0430\u0435\u043c downsampling, \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u044b \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u0440\u0442\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0444\u043e\u0440\u043c\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u0446\u0432\u0435\u0442\u0430 \u0438\u0442\u0434). <\/p>\n<pre><code class=\"python\">def unet_model(image_size, output_classes):      #\u0412\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439     input_layer = tf.keras.layers.Input(shape=image_size + (3,))     conv_1 = tf.keras.layers.Conv2D(64, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                     strides=2, padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(input_layer)     #\u0421\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c     conv_1_1 = tf.keras.layers.Conv2D(128, 4,                                        activation=tf.keras.layers.LeakyReLU(),                                        strides=2,                                       padding='same',                                        kernel_initializer='glorot_normal',                                       use_bias=False)(conv_1)     batch_norm_1 = tf.keras.layers.BatchNormalization()(conv_1_1)      #2     conv_2 = tf.keras.layers.Conv2D(256, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_1)     batch_norm_2 = tf.keras.layers.BatchNormalization()(conv_2)      #3     conv_3 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_2)     batch_norm_3 = tf.keras.layers.BatchNormalization()(conv_3)      #4     conv_4 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_3)     batch_norm_4 = tf.keras.layers.BatchNormalization()(conv_4)      #5     conv_5 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_4)     batch_norm_5 = tf.keras.layers.BatchNormalization()(conv_5)      #6     conv_6 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_5)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u043c upsampling \u0438 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u043c \u0441 \u043a\u0430\u0440\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430.<\/p>\n<pre><code class=\"python\">    #\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c     #1     up_1 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(512, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(conv_6), conv_5])     batch_up_1 = tf.keras.layers.BatchNormalization()(up_1)      #\u0414\u043e\u0431\u0430\u0432\u0438\u043c Dropout \u043e\u0442 \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f     batch_up_1 = tf.keras.layers.Dropout(0.25)(batch_up_1)      #2     up_2 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(512, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_1), conv_4])     batch_up_2 = tf.keras.layers.BatchNormalization()(up_2)     batch_up_2 = tf.keras.layers.Dropout(0.25)(batch_up_2)         #3     up_3 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(512, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_2), conv_3])     batch_up_3 = tf.keras.layers.BatchNormalization()(up_3)     batch_up_3 = tf.keras.layers.Dropout(0.25)(batch_up_3)         #4     up_4 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(256, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_3), conv_2])     batch_up_4 = tf.keras.layers.BatchNormalization()(up_4)       #5     up_5 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(128, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_4), conv_1_1])     batch_up_5 = tf.keras.layers.BatchNormalization()(up_5)       #6     up_6 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(64, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_5), conv_1])     batch_up_6 = tf.keras.layers.BatchNormalization()(up_6)       #\u0412\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439     output_layer = tf.keras.layers.Conv2DTranspose(output_classes, 4, activation='sigmoid', strides=2,                                                    padding='same',                                                    kernel_initializer='glorot_normal')(batch_up_6)      model = tf.keras.Model(inputs=input_layer, outputs=output_layer)     return model<\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 loss \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043c\u0435\u0441\u044c\u044e \u0438\u0437 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u0440\u043e\u0441\u0441\u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438 \u0438 DICE (DICE \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043a\u0440\u043e\u0441\u0441\u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c).\u00a0<\/p>\n<pre><code class=\"python\"># Binary crossentropy + 0.25 * DICE def dice_bce_loss(y_pred, y_true):     total_loss = 0.25 * dice_loss(y_pred, y_true) + tf.keras.losses.binary_crossentropy(y_pred, y_true)     return total_loss<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f 5, 10, 25 \u044d\u043f\u043e\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/156\/77a\/d60\/15677ad6032b4247ad4e28d74413e48d.png\" alt=\"5 \u044d\u043f\u043e\u0445\" title=\"5 \u044d\u043f\u043e\u0445\" width=\"1676\" height=\"879\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/156\/77a\/d60\/15677ad6032b4247ad4e28d74413e48d.png\"\/><\/p>\n<div><figcaption>5 \u044d\u043f\u043e\u0445<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f7f\/a1b\/f4a\/f7fa1bf4a22991004207f7b24a628d5e.png\" alt=\"10 \u044d\u043f\u043e\u0445\" title=\"10 \u044d\u043f\u043e\u0445\" width=\"1660\" height=\"889\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f7f\/a1b\/f4a\/f7fa1bf4a22991004207f7b24a628d5e.png\"\/><\/p>\n<div><figcaption>10 \u044d\u043f\u043e\u0445<\/figcaption><\/div>\n<\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/30f\/95e\/051\/30f95e0516c7a9104e8705def6a2a873.png\" alt=\"25 \u044d\u043f\u043e\u0445\" title=\"25 \u044d\u043f\u043e\u0445\" width=\"1661\" height=\"874\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/30f\/95e\/051\/30f95e0516c7a9104e8705def6a2a873.png\"\/><\/p>\n<div><figcaption>25 \u044d\u043f\u043e\u0445<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e 5 \u044d\u043f\u043e\u0445 \u2013 \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0435 \u0434\u043e\u043e\u0431\u0443\u0447\u0435\u043d\u0430, 25 \u044d\u043f\u043e\u0445 \u2013 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0430. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 10 \u044d\u043f\u043e\u0445\u0430\u0445 \u0441 dropout.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/80f\/e6f\/b9c\/80fe6fb9c532c0d138efcefba400238a.png\" alt=\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 10 \u044d\u043f\u043e\u0445\u0430\u0445, \u043f\u043e\u0441\u043b\u0435 8 \u044d\u043f\u043e\u0445\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043b\u0430\u0442\u043e\" title=\"\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 10 \u044d\u043f\u043e\u0445\u0430\u0445, \u043f\u043e\u0441\u043b\u0435 8 \u044d\u043f\u043e\u0445\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043b\u0430\u0442\u043e\" width=\"1189\" height=\"790\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/80f\/e6f\/b9c\/80fe6fb9c532c0d138efcefba400238a.png\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 10 \u044d\u043f\u043e\u0445\u0430\u0445, \u043f\u043e\u0441\u043b\u0435 8 \u044d\u043f\u043e\u0445\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043f\u043b\u0430\u0442\u043e<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0441\u0442\u043e\u043b\u0435\u0448\u043d\u0438\u0446\u0430, \u0442\u0430\u0440\u0435\u043b\u043a\u0430) \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e \u0446\u0432\u0435\u0442\u0443 \u0438 \u0444\u043e\u0440\u043c\u0435, \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e, \u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u043d\u0430 \u0440\u044b\u0436\u0443\u044e \u0441\u0442\u043e\u043b\u0435\u0448\u043d\u0438\u0446\u0443 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u0440\u044b\u0436\u0435\u0433\u043e \u043a\u043e\u0442\u0430, \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438 \u0434\u0440\u0443\u0433\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0442\u0430\u043a\u0436\u0435 \u0431\u044b \u043f\u0443\u0442\u0430\u043b\u0430 \u043a\u043b\u0430\u0441\u0441\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0448\u0438\u043b\u043e \u0431\u044b \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0431\u044b\u0442\u043e\u0432\u043e\u0439 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0445\u0432\u0430\u0442\u0438\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0433\u043e\u0442\u043e\u0432\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0432 \u043a\u0430\u0434\u0440\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b: \u0441\u0442\u043e\u043b\u0435\u0448\u043d\u0438\u0446\u0443, \u043d\u043e\u0436\u043a\u0438 \u0441\u0442\u043e\u043b\u0430, \u0441\u0442\u0443\u043b, \u043d\u043e\u0436\u043a\u0438 \u0441\u0442\u0443\u043b\u0430, \u043a\u043e\u0442\u0430, \u0442\u0430\u0440\u0435\u043b\u043a\u0443 \u0441 \u043a\u043e\u0442\u043b\u0435\u0442\u0430\u043c\u0438, \u0444\u043e\u043d.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0444\u0438\u0447\u0443 \u043f\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. <\/p>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c73\/023\/eec\/c73023eec0bb713a777b8cea185c1f4e.png\" alt=\"\u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\" title=\"\u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\" width=\"1200\" height=\"827\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c73\/023\/eec\/c73023eec0bb713a777b8cea185c1f4e.png\"\/><\/p>\n<div><figcaption>\u0415\u0432\u043a\u043b\u0438\u0434\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0431\u0435\u0440\u0435\u043c \u0442\u043e\u0447\u043a\u0443 \u043f\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0442\u0430\u0440\u0435\u043b\u043a\u0438 \u0438 \u043a\u0440\u0430\u0439\u043d\u044e\u044e \u0442\u043e\u0447\u043a\u0443 \u043a\u043e\u043d\u0442\u0443\u0440\u0430 \u043c\u0430\u0441\u043a\u0438 \u043a\u043e\u0442\u0430 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438. \u041a\u0430\u043a \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438, \u044f \u0434\u0443\u043c\u0430\u044e, \u043d\u0438\u043a\u043e\u043c\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u043d\u0430\u0434\u043e (\u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0430\u0441\u0447\u0451\u0442\u0430 Euclid distance).<\/p>\n<pre><code class=\"python\">def distance_between_p(p1, p2):     dis = ((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) ** 0.5     return dis<\/code><\/pre>\n<p>\u0414\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e &#171;\u0443\u0440\u043e\u0432\u043d\u0435\u0439&#187; \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f: \u043a\u043e\u0442 \u043d\u0430 \u0441\u0442\u043e\u043b\u0435, \u043a\u043e\u0442 \u043c\u043e\u0440\u0434\u043e\u0439 \u0432 \u043a\u043e\u0442\u043b\u0435\u0442\u0430\u0445 (\u044d\u0442\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438). \u0412\u043e\u0442 \u0447\u0442\u043e \u0432\u0438\u0434\u0438\u0442 \u043d\u0430\u0448\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/56e\/f49\/404\/56ef4940467d079023ac5da92a7d4916.gif\" alt=\"\u0421\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438 \u0440\u0430\u0441\u0447\u0451\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438\" title=\"\u0421\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438 \u0440\u0430\u0441\u0447\u0451\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438\" width=\"544\" height=\"306\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/56e\/f49\/404\/56ef4940467d079023ac5da92a7d4916.gif\"\/><\/p>\n<div><figcaption>\u0421\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438 \u0440\u0430\u0441\u0447\u0451\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439. \u041c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043a\u0430\u0434\u0440\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0442\u0430. \u041a\u0443\u0441\u043e\u043a \u0440\u044b\u0436\u0435\u0439 \u0441\u0442\u0435\u043d\u044b \u0432 \u0443\u0433\u043b\u0443 \u043a\u0430\u0434\u0440\u0430 (\u0438\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0430), \u0438 \u0440\u0430\u0441\u0447\u0451\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <\/p>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/114\/708\/d62\/114708d62411d91735eb5537742eef2c.png\" alt=\"\u041e\u0448\u0438\u0431\u043a\u0438 \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" title=\"\u041e\u0448\u0438\u0431\u043a\u0438 \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\" width=\"1252\" height=\"921\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/114\/708\/d62\/114708d62411d91735eb5537742eef2c.png\"\/><\/p>\n<div><figcaption>\u041e\u0448\u0438\u0431\u043a\u0438 \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u0441\u0442\u044b\u043b\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u0438\u043c: \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0440\u0435\u0437\u043a\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 (\u0435\u0441\u043b\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u0430\u0440\u0435\u043b\u043a\u043e\u0439 \u0438 \u043a\u043e\u0442\u043e\u043c \u0431\u044b\u043b\u043e 100 \u0438 \u0440\u0435\u0437\u043a\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0441\u044f \u0432 5 \u0440\u0430\u0437, \u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439).<\/p>\n<p>\u041d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u0442\u0430\u043f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0434\u043e\u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u043e\u0451 \u043b\u044e\u0431\u0438\u043c\u043e\u0435: \u041f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e &#171;\u0443\u0440\u043e\u0432\u043d\u044f&#187; \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \ud83d\ude42<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03b\/b00\/ec0\/03bb00ec0877a8fa78b6b7b7ea64fca4.gif\" alt=\"\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438\" title=\"\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438\" width=\"544\" height=\"306\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03b\/b00\/ec0\/03bb00ec0877a8fa78b6b7b7ea64fca4.gif\"\/><\/p>\n<div><figcaption>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0451. \u041f\u043e \u0438\u0442\u043e\u0433\u0443 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u0442\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u0442\u0430 \u0432 \u043a\u0430\u0434\u0440\u0435 \u0438 \u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0435 \u043a \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u043c (\u0438  \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u043c) \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c. \u0412 \u0446\u0435\u043b\u043e\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0433\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432 \u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0445 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a \u043c\u043e\u0434\u0435\u043b\u0438. \u0422\u0430\u043a\u0430\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u044c \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a, \u043f\u043e\u0435\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u043c \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043a\u043e\u043c\u043d\u0430\u0442\u0435, \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0438  \u0446\u0432\u0435\u0442\u043e\u0432, \u0430 \u0432 \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u0438 \u0448\u0435\u0440\u0441\u0442\u044f\u043d\u043e\u0433\u043e \u043e\u0442 \u044f\u0434\u043e\u0432\u0438\u0442\u044b\u0445 \u0440\u0430\u0441\u0442\u0435\u043d\u0438\u0439 (\u0410\u043b\u043e\u044d \u0441\u043c\u0435\u0440\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0440\u0435\u0434\u043d\u044b \u0434\u043b\u044f \u043a\u043e\u0442\u0438\u043a\u043e\u0432, \u043d\u043e \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u043c\u043d\u043e\u0433\u043e \u0443 \u043a\u043e\u0433\u043e), \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0432 \u0434\u043e\u043c\u0430 \u0432\u0435\u0431-\u043a\u0430\u043c\u0435\u0440\u0443 \u0438 \u0440\u0430\u0437\u043c\u0435\u0442\u0438\u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u043f\u0443\u0448\u0438\u0441\u0442\u044b\u043c \u0432 \u0432\u0430\u0448\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u2013 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u0441 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u0430 U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435. \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 \u043c\u043e\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0435 \u043d\u0430 GitHub (<a href=\"https:\/\/github.com\/Mazepov\/Cat_Segmentation\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/Mazepov\/Cat_Segmentation<\/a>)<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0451. \u0412\u043f\u0435\u0440\u0435\u0434\u0438 \u0436\u0434\u0443\u0442 \u0435\u0449\u0451 \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438\u0437 \u043c\u043e\u0435\u0439 \u0433\u043e\u043b\u043e\u0432\u044b (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e) \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439!<\/p>\n<p>P.S. \u041a\u043e\u0442\u0430 \u0432 \u0438\u0442\u043e\u0433\u0435 \u043f\u043e\u043a\u043e\u0440\u043c\u0438\u043b\u0438, \u043d\u0435 \u043f\u0435\u0440\u0435\u0436\u0438\u0432\u0430\u0439\u0442\u0435 \ud83d\ude42<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/746842\/\"> https:\/\/habr.com\/ru\/articles\/746842\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!<\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0431\u044b\u0442\u043e\u0432\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u044b\u0445 \u0441\u0435\u0442\u0435\u0439, \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u043b\u0430 \u0438\u0434\u0435\u044f \u0443\u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0435\u0442\u0435\u043a\u0446\u0438\u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u043a\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u043c\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 (<a href=\"https:\/\/habr.com\/ru\/articles\/738720\/\" rel=\"noopener noreferrer nofollow\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u043a\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Computer Vision<\/a>), \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0434\u043e\u0440\u043e\u0433\u0438, \u0442\u0440\u043e\u0442\u0443\u0430\u0440\u0430 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u0437 \u043f\u0430\u0440\u043a\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u043c\u0435\u0441\u0442, \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0442\u043e\u044f\u0442 \u043d\u0430 \u0433\u0430\u0437\u043e\u043d\u0435 (\u0431\u044b\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u043d\u0435\u0432\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0441\u0447\u0451\u0442).<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u043c\u044b\u0448\u043b\u0435\u043d\u0438\u0439, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u0440\u0438\u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0438 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421\u0443\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:\u00a0<br \/><em>\u041c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0431\u0430\u0437\u0435 U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u043a\u043e\u0442, \u0441\u0442\u0443\u043b, \u0441\u0442\u043e\u043b, \u0442\u0430\u0440\u0435\u043b\u043a\u0430 \u0441 \u043a\u043e\u0442\u043b\u0435\u0442\u0430\u043c\u0438 \u0438\u0442\u0434) \u0438 \u043f\u0440\u0438 \u0441\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (\u043a\u043e\u0442 &#8212; \u0442\u0430\u0440\u0435\u043b\u043a\u0430) \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0438\u0433\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430. <\/em><\/p>\n<p><strong>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f!<\/strong><\/p>\n<pre><code class=\"python\">#\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 import os import glob import cv2  import pandas as pd import numpy as np import requests  import tensorflow as tf  from skimage import measure from skimage.io import imread, imsave, imshow from skimage.transform import resize from skimage.morphology import dilation, disk from skimage.draw import polygon, polygon_perimeter  from livelossplot.tf_keras import PlotLossesCallback<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043d\u0443\u043b\u044f \u2014 \u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u042f \u0441\u0434\u0435\u043b\u0430\u043b \u0431\u043e\u043b\u0435\u0435 40 <s>\u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u044b\u0445<\/s> \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0438 \u0440\u0430\u0437\u043c\u0435\u0442\u0438\u043b \u0438\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 Supervisely.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u042d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 (\u0435\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 CVAT). \u0422\u0440\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Supervisely \u043a\u0430\u043a \u0440\u0430\u0437 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043c\u0435\u0442\u0438\u0442\u044c \u0432 \u043e\u0434\u0438\u043d \u0434\u0435\u043d\u044c \u043f\u043e\u0440\u044f\u0434\u043a\u0430 50 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u043d\u0430 6-8 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0421\u0435\u0440\u0432\u0438\u0441 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u0439, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438.<\/p>\n<p>\u0421\u043f\u0443\u0441\u0442\u044f \u0447\u0430\u0441 \u0443\u0432\u043b\u0435\u043a\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439 (\u043d\u0435 \u043e\u0447\u0435\u043d\u044c) \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u043e\u0439, \u0432\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0430\u0437\u043c\u0435\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (7 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 + 1 \u0444\u043e\u043d)<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u043c\u043e\u0433, \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e \ud83d\ude42<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0442\u043e\u0432\u0430, \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u043c \u043d\u0430 train \u0438 test (\u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0430). \u0412 \u043e\u0431\u0449\u0435\u043c \u0438\u0442\u043e\u0433\u0435, \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 2000 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0438\u0437 \u043d\u0438\u0445 1800 \u043f\u043e\u0439\u0434\u0443\u0442 \u0432 train \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0432 test.<\/p>\n<pre><code class=\"python\">#\u0420\u0430\u0437\u043c\u0435\u0440 train \u0432\u044b\u0431\u043e\u0440\u043a\u0438 train_size = 1800  #\u0414\u0435\u043b\u0438\u043c \u043d\u0430 train \u0438 test train_dataset = dataset.take(train_size).cache() test_dataset = dataset.skip(train_size).take(len(dataset) - train_size).cache()  train_dataset = train_dataset.batch(BATCH_SIZE) test_dataset = test_dataset.batch(BATCH_SIZE)<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0427\u0442\u043e \u0432\u0438\u0434\u0438\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u043e\u0439 \u0441\u0435\u0442\u0438. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0443\u044e U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430 \u0441\u0435\u0431\u044f \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f U-Net \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u042f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u043b \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0431\u043b\u043e\u043a\u043e\u0432-\u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438, \u0447\u0442\u043e\u0431\u044b \u043b\u044e\u0431\u043e\u0439 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0439 \u0441\u043c\u043e\u0433 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041c\u043e\u044f \u0432\u0435\u0440\u0441\u0438\u044f U-Net<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e \u0441\u0443\u0442\u0438 U-Net \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: \u044d\u043d\u043a\u043e\u0434\u0435\u0440 \u0438 \u0434\u0435\u043a\u043e\u0434\u0435\u0440. \u041c\u044b \u043f\u043e\u0434\u0430\u0435\u043c \u043d\u0430 \u0432\u0445\u043e\u0434 \u0442\u0440\u0435\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 256\u0445256 \u0438 \u0434\u0430\u043b\u0435\u0435 \u0434\u0435\u043b\u0430\u0435\u043c downsampling, \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435 \u043c\u044b \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043a\u0430\u0440\u0442\u0443 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0444\u043e\u0440\u043c\u044b, \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u0446\u0432\u0435\u0442\u0430 \u0438\u0442\u0434). <\/p>\n<pre><code class=\"python\">def unet_model(image_size, output_classes):      #\u0412\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439     input_layer = tf.keras.layers.Input(shape=image_size + (3,))     conv_1 = tf.keras.layers.Conv2D(64, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                     strides=2, padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(input_layer)     #\u0421\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c     conv_1_1 = tf.keras.layers.Conv2D(128, 4,                                        activation=tf.keras.layers.LeakyReLU(),                                        strides=2,                                       padding='same',                                        kernel_initializer='glorot_normal',                                       use_bias=False)(conv_1)     batch_norm_1 = tf.keras.layers.BatchNormalization()(conv_1_1)      #2     conv_2 = tf.keras.layers.Conv2D(256, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_1)     batch_norm_2 = tf.keras.layers.BatchNormalization()(conv_2)      #3     conv_3 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_2)     batch_norm_3 = tf.keras.layers.BatchNormalization()(conv_3)      #4     conv_4 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_3)     batch_norm_4 = tf.keras.layers.BatchNormalization()(conv_4)      #5     conv_5 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_4)     batch_norm_5 = tf.keras.layers.BatchNormalization()(conv_5)      #6     conv_6 = tf.keras.layers.Conv2D(512, 4,                                      activation=tf.keras.layers.LeakyReLU(),                                      strides=2,                                     padding='same',                                      kernel_initializer='glorot_normal',                                     use_bias=False)(batch_norm_5)<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0435\u043b\u0430\u0435\u043c upsampling \u0438 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0438\u0440\u0443\u0435\u043c \u0441 \u043a\u0430\u0440\u0442\u0430\u043c\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u0432 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u044d\u0442\u0430\u043f\u0430.<\/p>\n<pre><code class=\"python\">    #\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c     #1     up_1 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(512, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(conv_6), conv_5])     batch_up_1 = tf.keras.layers.BatchNormalization()(up_1)      #\u0414\u043e\u0431\u0430\u0432\u0438\u043c Dropout \u043e\u0442 \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f     batch_up_1 = tf.keras.layers.Dropout(0.25)(batch_up_1)      #2     up_2 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(512, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_1), conv_4])     batch_up_2 = tf.keras.layers.BatchNormalization()(up_2)     batch_up_2 = tf.keras.layers.Dropout(0.25)(batch_up_2)         #3     up_3 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(512, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_2), conv_3])     batch_up_3 = tf.keras.layers.BatchNormalization()(up_3)     batch_up_3 = tf.keras.layers.Dropout(0.25)(batch_up_3)         #4     up_4 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(256, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_3), conv_2])     batch_up_4 = tf.keras.layers.BatchNormalization()(up_4)       #5     up_5 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(128, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_4), conv_1_1])     batch_up_5 = tf.keras.layers.BatchNormalization()(up_5)       #6     up_6 = tf.keras.layers.Concatenate()([tf.keras.layers.Conv2DTranspose(64, 4, activation='relu', strides=2,                                                                           padding='same',                                                                           kernel_initializer='glorot_normal',                                                                           use_bias=False)(batch_up_5), conv_1])     batch_up_6 = tf.keras.layers.BatchNormalization()(up_6)       #\u0412\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0441\u043b\u043e\u0439     output_layer = tf.keras.layers.Conv2DTranspose(output_classes, 4, activation='sigmoid', strides=2,                                                    padding='same',                                                    kernel_initializer='glorot_normal')(batch_up_6)      model = tf.keras.Model(inputs=input_layer, outputs=output_layer)     return model<\/code><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 loss \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043c\u0435\u0441\u044c\u044e \u0438\u0437 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0439 \u043a\u0440\u043e\u0441\u0441\u044d\u043d\u0442\u0440\u043e\u043f\u0438\u0438 \u0438 DICE (DICE \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439, \u0430 \u0431\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043a\u0440\u043e\u0441\u0441\u044d\u043d\u0442\u0440\u043e\u043f\u0438\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0443\u044e \u0441\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c).\u00a0<\/p>\n<pre><code class=\"python\"># Binary crossentropy + 0.25 * DICE def dice_bce_loss(y_pred, y_true):     total_loss = 0.25 * dice_loss(y_pred, y_true) + tf.keras.losses.binary_crossentropy(y_pred,<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-350012","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=350012"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350012\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}