{"id":335669,"date":"2022-07-13T15:00:16","date_gmt":"2022-07-13T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335669"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335669","title":{"rendered":"<span>\u0420\u0430\u0437\u0431\u043e\u0440 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0434\u043e\u0440\u043e\u0436\u043d\u043e\u0439 \u043a\u043e\u043b\u0435\u0438 \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u0441 \u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u041f\u0440\u043e\u0440\u044b\u0432\u0430<\/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\/r\/w780q1\/getpro\/habr\/upload_files\/162\/823\/fe3\/162823fe3a4659741200d17c4c8f8b04.jpg\" alt=\"ruDALL-E Kandinsky \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a. \u0418 \u0432 \u0447\u0435\u043c-\u0442\u043e \u043e\u043d \u043f\u0440\u0430\u0432...\" title=\"ruDALL-E Kandinsky \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a. \u0418 \u0432 \u0447\u0435\u043c-\u0442\u043e \u043e\u043d \u043f\u0440\u0430\u0432...\" width=\"2048\" height=\"2048\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/162\/823\/fe3\/162823fe3a4659741200d17c4c8f8b04.jpg\" data-blurred=\"true\"\/><figcaption>ruDALL-E Kandinsky \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a. \u0418 \u0432 \u0447\u0435\u043c-\u0442\u043e \u043e\u043d \u043f\u0440\u0430\u0432&#8230;<\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0442\u0430\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f (\u0430\u0432\u0442\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430\u00a0<a href=\"https:\/\/t.me\/hahatons\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u0439\u0446\u0435\u043c \u043f\u043e \u0425\u0430\u0425\u0430\u0442\u043e\u043d\u0430\u043c<\/a>) \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043e \u0437\u0430\u0434\u0430\u0447\u0430\u0445\u00a0<a href=\"https:\/\/hacks-ai.ru\/championships\/758453\" rel=\"noopener noreferrer nofollow\">\u0412\u0441\u0435\u0440\u043e\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430 \u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u041f\u0440\u043e\u0440\u044b\u0432\u0430<\/a>, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f (baseline) \u0438 \u0434\u0430\u044e \u0441\u043e\u0432\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u044b\u0448\u0435 \u043f\u043e \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043a\u0435\u0439\u0441 \u043e\u0442 \u041d\u0418\u0418\u0410\u0421-\u0420\u0416\u0414, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0434\u043e\u0440\u043e\u0436\u043d\u043e\u0439 \u043a\u043e\u043b\u0435\u0438 \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043d\u0430 \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0435.<\/p>\n<p>\u0421\u043f\u043e\u0439\u043b\u0435\u0440: \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0442\u044b \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u041f\u0440\u043e\u0440\u044b\u0432<\/h2>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0432\u0441\u0435 \u0438 \u0442\u0430\u043a \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/hacks-ai.ru\" rel=\"noopener noreferrer nofollow\">\u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u041f\u0440\u043e\u0440\u044b\u0432<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u043e\u0439 \u0441\u0442\u0430\u043b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442. \u0418 \u0441\u0435\u0437\u043e\u043d \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0432 \u0441\u0430\u043c\u043e\u043c \u0440\u0430\u0437\u0433\u0430\u0440\u0435!<\/p>\n<p>\u0425\u043e\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0439 \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u0430, \u0432\u043f\u0435\u0440\u0435\u0434\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0436\u0434\u0435\u0442 \u0435\u0449\u0451 19 \u0440\u0435\u0433\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u043e\u0432, 5 \u043e\u043a\u0440\u0443\u0436\u043d\u044b\u0445 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u043e\u0432 \u0438 3 \u0432\u0441\u0435\u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430. \u0421\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a\u043e \u043c\u043d\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0438\u0433\u0440\u0430\u0442\u044c \u0434\u0435\u043d\u0435\u0436\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u044b \u0438 \u043a\u0440\u0443\u0442\u044b\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u0430 \u043d\u0430 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445.<\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0434\u043e\u0440\u043e\u0436\u043d\u043e\u043c \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0435.<\/p>\n<p>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0438. \u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0438\u0434\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0435\u0437\u0434\u043e\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0443\u0442\u044c \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043c\u0435\u0440 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0444\u043e\u043a\u0443\u0441\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u0438, \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0433\u043e\u0434\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 (\u043d\u043e\u0447\u044c, \u0434\u043e\u0436\u0434\u044c, \u0441\u043d\u0435\u0433, \u0442\u0443\u043c\u0430\u043d, \u0437\u0430\u0434\u044b\u043c\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043b\u0435\u043f\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043b\u043d\u0435\u0447\u043d\u044b\u043c \u0441\u0432\u0435\u0442\u043e\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0438\u0437 \u0437\u0430\u0442\u0435\u043c\u043d\u0435\u043d\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043d\u0430 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u044b\u0435).<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e\u0449\u0438\u0445 \u043c\u0430\u0448\u0438\u043d\u0438\u0441\u0442\u0430 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0430\u0441\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0435\u0438 \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0430.<\/p>\n<h2>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u0440\u043e\u0436\u043d\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: \u043a\u043e\u043b\u0435\u044e (\u0440\u0435\u043b\u044c\u0441\u043e\u0448\u043f\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0448\u0435\u0442\u043a\u0443) \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432 (\u043b\u043e\u043a\u043e\u043c\u043e\u0442\u0438\u0432\u044b, \u0433\u0440\u0443\u0437\u043e\u0432\u044b\u0435 \u0432\u0430\u0433\u043e\u043d\u044b, \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0441\u043a\u0438\u0435 \u0432\u0430\u0433\u043e\u043d\u044b).<\/p>\n<h3>\u0414\u0430\u043d\u043d\u044b\u0435<\/h3>\n<ul>\n<li>\n<p>train\/images \u2014 \u043f\u0430\u043f\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f 8203 \u0442\u0440\u0435\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0445 RGB \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>train\/mask \u2014 \u043f\u0430\u043f\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f 8203 \u043c\u0430\u0441\u043e\u043a \u0442\u043e\u0439 \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 .<\/p>\n<\/li>\n<li>\n<p>test\/\u2014 \u043f\u0430\u043f\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f 1000 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<\/ul>\n<h3>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f 1000 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0442\u0430\u0442\u044c 1000 \u043c\u0430\u0441\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e 1000, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0448\u0438\u0431\u043a\u0438. \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u043a\u0438 \u0438\u043c\u0435\u043b\u0438 \u0442\u0435 \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0438 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u201c.png\u201c<\/p>\n<h3>\u041d\u0430 \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0441 \u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0438 \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0433\u043e\u0434\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445: \u043d\u043e\u0447\u044c\u044e, \u0432 \u0434\u043e\u0436\u0434\u044c, \u0432 \u0441\u043d\u0435\u0433, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0442\u0443\u043c\u0430\u043d\u0430, \u0437\u0430\u0434\u044b\u043c\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u041c\u0435\u0442\u0440\u0438\u043a\u0430<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0446\u0435\u043d\u043a\u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0436\u0435\u00a0<strong>MIoU. <\/strong>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0435 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/medium.com\/@cyborg.team.nitr\/miou-calculation-4875f918f4cb\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442<\/a>.<\/p>\n<h2>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0438<\/h2>\n<h3>\u041c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h3>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b<\/h3>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<pre><code class=\"python\"># Catalyst !pip install catalyst==20.12  # for augmentations !pip install albumentations==0.4.3  # for pretrained segmentation models for PyTorch !pip install segmentation-models-pytorch==0.1.0   # for TTA !pip install ttach==0.0.2  # for tensorboard !pip install tensorflow  # if Your machine support Apex FP16, uncomment this 3 lines below # !git clone https:\/\/github.com\/NVIDIA\/apex # !pip install -v --no-cache-dir --global-option=\"--cpp_ext\" --global-option=\"--cuda_ext\" .\/apex # is_fp16_used = True<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430\u043c \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438. \u0418 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c <em>random_seed<\/em>, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u043c\u0438.<\/p>\n<p>\u0418\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>torch &#8212; \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (\u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439)<\/p>\n<\/li>\n<li>\n<p>catalyst &#8212; \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>segmentation_models_pytorch &#8212; \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u043d\u0430\u0448\u0438\u043c \u0441\u043e\u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u043c)<\/p>\n<\/li>\n<li>\n<p>albumentations &#8212; \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">from typing import Callable, List, Tuple  import random import collections import matplotlib.pyplot as plt import numpy as np from skimage.io import imread as gif_imread from sklearn.model_selection import train_test_split  from pathlib import Path  import os import torch from torch.utils.data import Dataset, DataLoader from torch import nn from torch import optim import catalyst from catalyst import utils from catalyst.contrib.nn import DiceLoss, IoULoss from catalyst.contrib.nn import RAdam, Lookahead from catalyst.dl import SupervisedRunner from catalyst.dl import DiceCallback, IouCallback, \\   CriterionCallback, MetricAggregationCallback from catalyst.contrib.callbacks import DrawMasksCallback  import segmentation_models_pytorch as smp  import albumentations as albu from albumentations.pytorch import ToTensor  print(f\"torch: {torch.__version__}, catalyst: {catalyst.__version__}\")  SEED = 42 utils.set_global_seed(SEED) utils.prepare_cudnn(deterministic=True)  import warnings warnings.filterwarnings(\"ignore\")<\/code><\/pre>\n<h3>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430<\/h3>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0443\u0442\u0438 \u0434\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043f\u0443\u0442\u0438 \u0434\u043e \u0432\u0441\u0435\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u043c\u0430\u0441\u043e\u043a \u0438\u0437 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<pre><code class=\"python\">ROOT = Path(\"\/content\/\")  train_image_path = ROOT \/ \"train\" train_mask_path = ROOT \/ \"train_masks\" test_image_path = ROOT \/ \"test\"  ALL_IMAGES = sorted(train_image_path.glob(\"*.png\")) print('Images:', len(ALL_IMAGES))  ALL_MASKS = sorted(train_mask_path.glob(\"*.png\")) print('Masks:', len(ALL_MASKS))<\/code><\/pre>\n<h3>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">def show_examples(name: str, image: np.ndarray, mask: np.ndarray):     plt.figure(figsize=(10, 14))     plt.subplot(1, 2, 1)     plt.imshow(image)     plt.title(f\"Image: {name}\")      plt.subplot(1, 2, 2)     plt.imshow(mask)     plt.title(f\"Mask: {name}\")   def show(index: int, images: List[Path], masks: List[Path], transforms=None) -> None:     image_path = images[index]     name = image_path.name      image = utils.imread(image_path)     mask = gif_imread(masks[index])      if transforms is not None:         temp = transforms(image=image, mask=mask)         image = temp[\"image\"]         mask = temp[\"mask\"]      show_examples(name, image, mask)  def show_random(images: List[Path], masks: List[Path], transforms=None) -> None:     length = len(images)     index = random.randint(0, length - 1)     show(index, images, masks, transforms)<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">show_random(ALL_IMAGES, ALL_MASKS)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/748\/649\/ed5\/748649ed59d0589b66aee75835cade7e.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445  \u0421\u043b\u0435\u0432\u0430 - \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0421\u043f\u0440\u0430\u0432\u0430 - \u043c\u0430\u0441\u043a\u0430\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445  \u0421\u043b\u0435\u0432\u0430 - \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0421\u043f\u0440\u0430\u0432\u0430 - \u043c\u0430\u0441\u043a\u0430\" width=\"613\" height=\"212\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/748\/649\/ed5\/748649ed59d0589b66aee75835cade7e.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445  \u0421\u043b\u0435\u0432\u0430 &#8212; \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0421\u043f\u0440\u0430\u0432\u0430 &#8212; \u043c\u0430\u0441\u043a\u0430<\/figcaption><\/figure>\n<h3>\u0410\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0410\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0432\u044b\u0441\u0438\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u044b \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u0432\u044b\u0440\u0435\u0437\u043a\u0438 \u043a\u0443\u0441\u043e\u0447\u043a\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0448\u0443\u043c\u044b, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a, \u043a\u0440\u043e\u043f\u044b.<\/p>\n<pre><code class=\"python\">def pre_transforms(image_size=224):     return [albu.Resize(image_size, image_size, p=1)]   def hard_transforms():     result = [       albu.RandomRotate90(),       albu.Cutout(),       albu.RandomBrightnessContrast(           brightness_limit=0.2, contrast_limit=0.2, p=0.3       ),       albu.GridDistortion(p=0.3),       albu.HueSaturationValue(p=0.3)     ]      return result     def resize_transforms(image_size=224):     BORDER_CONSTANT = 0     pre_size = int(image_size * 1.5)      random_crop = albu.Compose([       albu.SmallestMaxSize(pre_size, p=1),       albu.RandomCrop(           image_size, image_size, p=1       )      ])      rescale = albu.Compose([albu.Resize(image_size, image_size, p=1)])      random_crop_big = albu.Compose([       albu.LongestMaxSize(pre_size, p=1),       albu.RandomCrop(           image_size, image_size, p=1       )      ])      # Converts the image to a square of size image_size x image_size     result = [       albu.OneOf([           random_crop,           rescale,           random_crop_big       ], p=1)     ]      return result    def post_transforms():     # we use ImageNet image normalization     # and convert it to torch.Tensor     return [albu.Normalize(), ToTensor()]    def compose(transforms_to_compose):     # combine all augmentations into single pipeline     result = albu.Compose([       item for sublist in transforms_to_compose for item in sublist     ])     return result<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">train_transforms = compose([     resize_transforms(),      hard_transforms(),      post_transforms() ]) valid_transforms = compose([pre_transforms(), post_transforms()])  show_transforms = compose([resize_transforms(), hard_transforms()])<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">show_random(ALL_IMAGES, ALL_MASKS, transforms=show_transforms)<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/343\/76b\/fe2\/34376bfe2960763d745a12edc74c867c.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0448\u0443\u043c.\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0448\u0443\u043c.\" width=\"617\" height=\"315\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/343\/76b\/fe2\/34376bfe2960763d745a12edc74c867c.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0448\u0443\u043c.<\/figcaption><\/figure>\n<h3>\u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <em>SegmentationDataset<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. <\/p>\n<pre><code class=\"python\">class SegmentationDataset(Dataset):     def __init__(         self,         images: List[Path],         masks: List[Path] = None,         transforms=None     ) -> None:         self.images = images         self.masks = masks         self.transforms = transforms      def __len__(self) -> int:         return len(self.images)      def __getitem__(self, idx: int) -> dict:         image_path = self.images[idx]         image = utils.imread(image_path)                  result = {\"image\": image}                  if self.masks is not None:             mask = gif_imread(self.masks[idx])             result[\"mask\"] = mask                  if self.transforms is not None:             result = self.transforms(**result)                  result[\"filename\"] = image_path.name          return result<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 (dataloader).<\/p>\n<pre><code class=\"python\">def get_loaders(     images: List[Path],     masks: List[Path],     random_state: int,     valid_size: float = 0.5,     batch_size: int = 32,     num_workers: int = 4,     train_transforms_fn = None,     valid_transforms_fn = None, ) -> dict:      indices = np.arange(len(images))      # Let's divide the data set into train and valid parts.     train_indices, valid_indices = train_test_split(       indices, test_size=valid_size, random_state=random_state, shuffle=True     )      np_images = np.array(images)     np_masks = np.array(masks)      # Creates our train dataset     train_dataset = SegmentationDataset(       images = np_images[train_indices].tolist(),       masks = np_masks[train_indices].tolist(),       transforms = train_transforms_fn     )      # Creates our valid dataset     valid_dataset = SegmentationDataset(       images = np_images[valid_indices].tolist(),       masks = np_masks[valid_indices].tolist(),       transforms = valid_transforms_fn     )      # Catalyst uses normal torch.data.DataLoader     train_loader = DataLoader(       train_dataset,       batch_size=batch_size,       shuffle=True,       num_workers=num_workers,       drop_last=True,     )      valid_loader = DataLoader(       valid_dataset,       batch_size=batch_size,       shuffle=False,       num_workers=num_workers,       drop_last=True,     )      # And excpect to get an OrderedDict of loaders     loaders = collections.OrderedDict()     loaders[\"train\"] = train_loader     loaders[\"valid\"] = valid_loader      return loaders<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c <em>batch_size<\/em> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">batch_size = 16  print(f\"batch_size: {batch_size}\")  loaders = get_loaders(     images=ALL_IMAGES,     masks=ALL_MASKS,     random_state=SEED,     train_transforms_fn=train_transforms,     valid_transforms_fn=valid_transforms,     batch_size=batch_size )<\/code><\/pre>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u044d\u0442\u0430\u043f\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0438\u0437 <a href=\"https:\/\/segmentation_models.pytorch\" rel=\"noopener noreferrer nofollow\">segmentation_models_pytorch<\/a>.  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c \u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0432 \u0433\u0438\u0442\u0445\u0430\u0431\u0435 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>\u0412 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b FPN &#8212; Feature Pyramid Network \u0441 resnext50 \u0432 backbone.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0441 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c \u0441\u043b\u043e\u0435\u043c \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0421\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u043c\u043e\u0433\u0443 \u0432 \u0441\u0438\u043b\u0443 \u043f\u0440\u0430\u0432\u0438\u043b \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u043e \u0434\u043b\u044f \u0431\u043e\u0435\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430 3.<\/p>\n<pre><code class=\"python\"># We will use Feature Pyramid Network with pre-trained ResNeXt50 backbone model = smp.FPN(encoder_name=\"resnext50_32x4d\", classes=1)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0442\u0435\u0440\u044c, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 DiceLoss, IoULoss \u0438 BinaryCrossEntropy.<\/p>\n<pre><code class=\"python\"># we have multiple criterions criterion = {     \"dice\": DiceLoss(),     \"iou\": IoULoss(),     \"bce\": nn.BCEWithLogitsLoss() }<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 &#8212; <em>RAdam<\/em>, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f <em>learning_rate<\/em> &#8212; <em>ReduceLROnPlateau<\/em>.<\/p>\n<pre><code class=\"python\">learning_rate = 0.001 encoder_learning_rate = 0.0005  # Since we use a pre-trained encoder, we will reduce the learning rate on it. layerwise_params = {\"encoder*\": dict(lr=encoder_learning_rate, weight_decay=0.00003)}  # This function removes weight_decay for biases and applies our layerwise_params model_params = utils.process_model_params(model, layerwise_params=layerwise_params)  # Catalyst has new SOTA optimizers out of box base_optimizer = RAdam(model_params, lr=learning_rate, weight_decay=0.0003) optimizer = Lookahead(base_optimizer)  scheduler = optim.lr_scheduler.ReduceLROnPlateau(optimizer, factor=0.25, patience=2)<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0431\u0443\u0447\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u0441\u0435\u0433\u043e \u043d\u0430 3 \u044d\u043f\u043e\u0445\u0430\u0445.<\/p>\n<pre><code class=\"python\">num_epochs = 3 logdir = \".\/logs\/segmentation\"  device = utils.get_device() print(f\"device: {device}\")  #fp16_params = dict(opt_level=\"O1\") # params for FP16 fp16_params = None  print(f\"FP16 params: {fp16_params}\")  # by default SupervisedRunner uses \"features\" and \"targets\", # in our case we get \"image\" and \"mask\" keys in dataset __getitem__ runner = SupervisedRunner(device=device, input_key=\"image\", input_target_key=\"mask\")<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c <em>callbacks <\/em>\u0434\u043b\u044f \u0440\u0430\u0441\u0441\u0447\u0435\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0442\u0435\u0440\u044c. \u0418 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">callbacks = [     # Each criterion is calculated separately.     CriterionCallback(         input_key=\"mask\",         prefix=\"loss_dice\",         criterion_key=\"dice\"     ),     CriterionCallback(         input_key=\"mask\",         prefix=\"loss_iou\",         criterion_key=\"iou\"     ),     CriterionCallback(         input_key=\"mask\",         prefix=\"loss_bce\",         criterion_key=\"bce\"     ),      # And only then we aggregate everything into one loss.     MetricAggregationCallback(         prefix=\"loss\",         mode=\"weighted_sum\", # can be \"sum\", \"weighted_sum\" or \"mean\"         # because we want weighted sum, we need to add scale for each loss         metrics={\"loss_dice\": 1.0, \"loss_iou\": 1.0, \"loss_bce\": 0.8},     ),      # metrics     DiceCallback(input_key=\"mask\"),     IouCallback(input_key=\"mask\"),     # visualization     DrawMasksCallback(output_key='logits',                       input_image_key='image',                       input_mask_key='mask',                       summary_step=50     ) ]  runner.train(     model=model,     criterion=criterion,     optimizer=optimizer,     scheduler=scheduler,     # our dataloaders     loaders=loaders,     # We can specify the callbacks list for the experiment;     callbacks=callbacks,     # path to save logs     logdir=logdir,     num_epochs=num_epochs,     # save our best checkpoint by IoU metric     main_metric=\"iou\",     # IoU needs to be maximized.     minimize_metric=False,     # for FP16. It uses the variable from the very first cell     fp16=fp16_params,     # prints train logs     verbose=True, )<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/9ac\/705\/eb3\/9ac705eb335f96970657faf36af0feae.jpeg\" alt=\"\u0422\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043b\u043e\u0433 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438\" title=\"\u0422\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043b\u043e\u0433 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438\" width=\"1280\" height=\"566\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9ac\/705\/eb3\/9ac705eb335f96970657faf36af0feae.jpeg\" data-blurred=\"true\"\/><figcaption>\u0422\u0430\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043b\u043e\u0433 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438<\/figcaption><\/figure>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043c\u043e\u0434\u0435\u043b\u0438<\/h3>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u043e\u0431\u0443\u0447\u0438\u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0440\u043e\u0433\u043e\u043d\u0438\u043c \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u043e\u0434\u0435\u043b\u044c.<\/p>\n<pre><code class=\"python\">TEST_IMAGES = sorted(test_image_path.glob(\"*.png\"))  # create test dataset test_dataset = SegmentationDataset(     TEST_IMAGES,      transforms=valid_transforms )  num_workers: int = 4  infer_loader = DataLoader(     test_dataset,     batch_size=batch_size,     shuffle=False,     num_workers=num_workers )  # this get predictions for the whole loader predictions = np.vstack(list(map(     lambda x: x[\"logits\"].cpu().numpy(),      runner.predict_loader(loader=infer_loader, resume=f\"logs\/segmentation\/checkpoints\/best.pth\") )))<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0430\u0441\u0441. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u044f \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0430\u0441\u043a\u0438 \u0438\u0437 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u044b\u043b \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u043c.<\/p>\n<pre><code class=\"python\">threshold = 0.5 max_count = 1  for i, (features, logits) in enumerate(zip(test_dataset, predictions)):     image = utils.tensor_to_ndimage(features[\"image\"])      mask_ = torch.from_numpy(logits[0]).sigmoid()     #mask = utils.detach(mask_ > threshold).astype(\"float\")              show_examples(name=\"\", image=image, mask=mask_)          if i >= max_count:         break<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b7c\/078\/3ae\/b7c0783aeac4fe517861769ebe98afd1.png\" alt=\"\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0441\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0445\u0438\u0442\u043c\u0430\u043f, \u0432\u0435\u0434\u044c \u0447\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c.\" title=\"\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0441\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0445\u0438\u0442\u043c\u0430\u043f, \u0432\u0435\u0434\u044c \u0447\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c.\" width=\"614\" height=\"292\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b7c\/078\/3ae\/b7c0783aeac4fe517861769ebe98afd1.png\"\/><figcaption>\u041f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0441\u043a\u0430 \u0441\u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0445\u0438\u0442\u043c\u0430\u043f, \u0432\u0435\u0434\u044c \u0447\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c.<\/figcaption><\/figure>\n<h2>\u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h2>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/663\/2ec\/53b\/6632ec53be605385909e132c2d1cf618.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e\" width=\"922\" height=\"192\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/663\/2ec\/53b\/6632ec53be605385909e132c2d1cf618.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0431\u043e\u043b\u0435\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e<\/figcaption><\/figure>\n<ul>\n<li>\n<p>\u041d\u0430\u0447\u0430\u0442\u044c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u0441\u0442\u043e\u0438\u0442 \u0441 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 1 \u043d\u0430 3. \u042d\u0442\u043e \u0434\u0430\u0441\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u0441\u044b\u043b\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u044f \u0431\u044b \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u043f\u043e\u0445 \u0438 \u0434\u043e\u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u0442\u0430\u043a \u043a\u0430\u043a 3 \u044d\u043f\u043e\u0445 \u044f\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 Unet.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043d\u0441\u0430\u043c\u0431\u043b\u044c \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 TTA.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u0443\u0447\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u0430\u043a-\u0442\u043e \u0438\u0445 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u043f\u043e\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0418\u0442\u043e\u0433\u0438<\/h3>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u0435\u0439\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0431\u0440\u0430\u0442\u044c \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043e\u0440\u0435\u0432\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u0441 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0448\u0430\u043d\u0441\u044b, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u0440\u0430\u0439\u043d\u0435 \u0432\u044b\u0441\u043e\u043a.<\/p>\n<p>\u0412 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043d\u0430\u00a0<a href=\"https:\/\/t.me\/hahatons\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043d\u0430\u043b\u0435 \u0417\u0430\u0439\u0446\u0435\u043c \u043f\u043e \u0425\u0430\u0425\u0430\u0442\u043e\u043d\u0430\u043c<\/a>\u00a0\u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0430 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u044f \u0441 \u0440\u0430\u0437\u0431\u043e\u0440\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0434\u0430\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u044b.<\/p>\n<p>\u0412\u0441\u0435\u043c \u0443\u0434\u0430\u0447\u0438 \u043d\u0430 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430\u0445 \u0438 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0430\u0445!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/676044\/\"> https:\/\/habr.com\/ru\/post\/676044\/<\/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\"><figcaption>ruDALL-E Kandinsky \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0442\u0430\u043a. \u0418 \u0432 \u0447\u0435\u043c-\u0442\u043e \u043e\u043d \u043f\u0440\u0430\u0432&#8230;<\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0441\u0442\u0430\u0442\u0435\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f (\u0430\u0432\u0442\u043e\u0440 \u043a\u0430\u043d\u0430\u043b\u0430\u00a0<a href=\"https:\/\/t.me\/hahatons\" rel=\"noopener noreferrer nofollow\">\u0417\u0430\u0439\u0446\u0435\u043c \u043f\u043e \u0425\u0430\u0425\u0430\u0442\u043e\u043d\u0430\u043c<\/a>) \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043e \u0437\u0430\u0434\u0430\u0447\u0430\u0445\u00a0<a href=\"https:\/\/hacks-ai.ru\/championships\/758453\" rel=\"noopener noreferrer nofollow\">\u0412\u0441\u0435\u0440\u043e\u0441\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430 \u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0433\u043e \u041f\u0440\u043e\u0440\u044b\u0432\u0430<\/a>, \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u044e \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f (baseline) \u0438 \u0434\u0430\u044e \u0441\u043e\u0432\u0435\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0434\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u044b\u0448\u0435 \u043f\u043e \u0440\u0435\u0439\u0442\u0438\u043d\u0433\u0443. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u043a\u0435\u0439\u0441 \u043e\u0442 \u041d\u0418\u0418\u0410\u0421-\u0420\u0416\u0414, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0434\u043e\u0440\u043e\u0436\u043d\u043e\u0439 \u043a\u043e\u043b\u0435\u0438 \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0430 \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043d\u0430 \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0435.<\/p>\n<p>\u0421\u043f\u043e\u0439\u043b\u0435\u0440: \u0432 \u043a\u043e\u043d\u0446\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u0435\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0442\u044b \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<h2>\u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u041f\u0440\u043e\u0440\u044b\u0432<\/h2>\n<p>\u0414\u0443\u043c\u0430\u044e, \u0432\u0441\u0435 \u0438 \u0442\u0430\u043a \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/hacks-ai.ru\" rel=\"noopener noreferrer nofollow\">\u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u041f\u0440\u043e\u0440\u044b\u0432<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e, \u043d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0442\u0435\u043c\u0430\u0442\u0438\u043a\u043e\u0439 \u0441\u0442\u0430\u043b \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442. \u0418 \u0441\u0435\u0437\u043e\u043d \u044d\u0442\u043e\u0433\u043e \u0433\u043e\u0434\u0430 \u0432 \u0441\u0430\u043c\u043e\u043c \u0440\u0430\u0437\u0433\u0430\u0440\u0435!<\/p>\n<p>\u0425\u043e\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u043c\u0435\u0440\u043e\u043f\u0440\u0438\u044f\u0442\u0438\u0439 \u0443\u0436\u0435 \u043f\u0440\u043e\u0448\u043b\u0430, \u0432\u043f\u0435\u0440\u0435\u0434\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u043e\u0432 \u0436\u0434\u0435\u0442 \u0435\u0449\u0451 19 \u0440\u0435\u0433\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u043e\u0432, 5 \u043e\u043a\u0440\u0443\u0436\u043d\u044b\u0445 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u043e\u0432 \u0438 3 \u0432\u0441\u0435\u0440\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0438\u0445 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430. \u0421\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a\u043e \u043c\u043d\u0435 \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0443\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0438\u0433\u0440\u0430\u0442\u044c \u0434\u0435\u043d\u0435\u0436\u043d\u044b\u0435 \u043f\u0440\u0438\u0437\u044b \u0438 \u043a\u0440\u0443\u0442\u044b\u0435 \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u0430 \u043d\u0430 \u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447\u0430\u0445.<\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 \u0441\u0447\u0435\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u044f \u0443\u0440\u043e\u0432\u043d\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0434\u043e\u0440\u043e\u0436\u043d\u043e\u043c \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u0435.<\/p>\n<p>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0438 \u0438 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u043e\u0432 \u0436\u0435\u043b\u0435\u0437\u043d\u043e\u0439 \u0434\u043e\u0440\u043e\u0433\u0438. \u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0439 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0438\u0434\u0435\u043e\u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0435\u0437\u0434\u043e\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0443\u0442\u044c \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u0430\u043c\u0435\u0440 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0430 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0444\u043e\u043a\u0443\u0441\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0437\u0440\u0435\u043d\u0438\u044f \u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u0438, \u0434\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u0438\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043f\u043e\u0433\u043e\u0434\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 (\u043d\u043e\u0447\u044c, \u0434\u043e\u0436\u0434\u044c, \u0441\u043d\u0435\u0433, \u0442\u0443\u043c\u0430\u043d, \u0437\u0430\u0434\u044b\u043c\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c, \u043e\u0441\u043b\u0435\u043f\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043b\u043d\u0435\u0447\u043d\u044b\u043c \u0441\u0432\u0435\u0442\u043e\u043c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u0438\u0437 \u0437\u0430\u0442\u0435\u043c\u043d\u0435\u043d\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u043e\u0432 \u043d\u0430 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u043d\u044b\u0435).<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e\u0449\u0438\u0445 \u043c\u0430\u0448\u0438\u043d\u0438\u0441\u0442\u0430 \u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u043c \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u043f\u0430\u0441\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0435\u0438 \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0430.<\/p>\n<h2>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0447\u0435\u043c\u043f\u0438\u043e\u043d\u0430\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043e\u0440\u043e\u0436\u043d\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b: \u043a\u043e\u043b\u0435\u044e (\u0440\u0435\u043b\u044c\u0441\u043e\u0448\u043f\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0435\u0448\u0435\u0442\u043a\u0443) \u0438 \u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u0430\u0432 (\u043b\u043e\u043a\u043e\u043c\u043e\u0442\u0438\u0432\u044b, \u0433\u0440\u0443\u0437\u043e\u0432\u044b\u0435 \u0432\u0430\u0433\u043e\u043d\u044b, \u043f\u0430\u0441\u0441\u0430\u0436\u0438\u0440\u0441\u043a\u0438\u0435 \u0432\u0430\u0433\u043e\u043d\u044b).<\/p>\n<h3>\u0414\u0430\u043d\u043d\u044b\u0435<\/h3>\n<ul>\n<li>\n<p>train\/images \u2014 \u043f\u0430\u043f\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f 8203 \u0442\u0440\u0435\u0445\u043a\u0430\u043d\u0430\u043b\u044c\u043d\u044b\u0445 RGB \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>train\/mask \u2014 \u043f\u0430\u043f\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f 8203 \u043c\u0430\u0441\u043e\u043a \u0442\u043e\u0439 \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0441\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 .<\/p>\n<\/li>\n<li>\n<p>test\/\u2014 \u043f\u0430\u043f\u043a\u0430, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f 1000 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438;<\/p>\n<\/li>\n<\/ul>\n<h3>\u041e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u043e\u0434\u0430\u0435\u0442\u0441\u044f 1000 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a, \u043e\u0442\u0432\u0435\u0442\u043e\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0442\u0430\u0442\u044c 1000 \u043c\u0430\u0441\u043e\u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u0412\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e 1000, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0448\u0438\u0431\u043a\u0438. \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u043c\u0430\u0441\u043a\u0438 \u0438\u043c\u0435\u043b\u0438 \u0442\u0435 \u0436\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u0447\u0442\u043e \u0438 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u201c.png\u201c<\/p>\n<h3>\u041d\u0430 \u0447\u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0445\u043e\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0441 \u043e\u0434\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0438 \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u0432\u044b\u0441\u043e\u0442\u0435, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043c\u0435\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u044b \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043e\u0433\u043e\u0434\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445: \u043d\u043e\u0447\u044c\u044e, \u0432 \u0434\u043e\u0436\u0434\u044c, \u0432 \u0441\u043d\u0435\u0433, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0442\u0443\u043c\u0430\u043d\u0430, \u0437\u0430\u0434\u044b\u043c\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h3>\u041c\u0435\u0442\u0440\u0438\u043a\u0430<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u0446\u0435\u043d\u043a\u0438 \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0436\u0435\u00a0<strong>MIoU. <\/strong>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0435 \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/medium.com\/@cyborg.team.nitr\/miou-calculation-4875f918f4cb\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442<\/a>.<\/p>\n<h2>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0438<\/h2>\n<h3>\u041c\u0435\u0442\u043e\u0434\u043e\u043b\u043e\u0433\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h3>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b<\/h3>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438.<\/p>\n<pre><code class=\"python\"># Catalyst !pip install catalyst==20.12  # for augmentations !pip install albumentations==0.4.3  # for pretrained segmentation models for PyTorch !pip install segmentation-models-pytorch==0.1.0   # for TTA !pip install ttach==0.0.2  # for tensorboard !pip install tensorflow  # if Your machine support Apex FP16, uncomment this 3 lines below # !git clone https:\/\/github.com\/NVIDIA\/apex # !pip install -v --no-cache-dir --global-option=\"--cpp_ext\" --global-option=\"--cuda_ext\" .\/apex # is_fp16_used = True<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0430\u043c \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438. \u0418 \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c <em>random_seed<\/em>, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c\u044b\u043c\u0438.<\/p>\n<p>\u0418\u0437 \u0432\u0430\u0436\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>torch &#8212; \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (\u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0439)<\/p>\n<\/li>\n<li>\n<p>catalyst &#8212; \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/p>\n<\/li>\n<li>\n<p>segmentation_models_pytorch &#8212; \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 (\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u0430 \u043d\u0430\u0448\u0438\u043c \u0441\u043e\u043e\u0442\u0435\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0438\u043a\u043e\u043c)<\/p>\n<\/li>\n<li>\n<p>albumentations &#8212; \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0434\u043b\u044f \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"python\">from typing import Callable, List, Tuple  import random import collections import matplotlib.pyplot as plt import numpy as np from skimage.io import imread as gif_imread from sklearn.model_selection import train_test_split  from pathlib import Path  import os import torch from torch.utils.data import Dataset, DataLoader from torch import nn from torch import optim import catalyst from catalyst import utils from catalyst.contrib.nn import DiceLoss, IoULoss from catalyst.contrib.nn import RAdam, Lookahead from catalyst.dl import SupervisedRunner from catalyst.dl import DiceCallback, IouCallback, \\   CriterionCallback, MetricAggregationCallback from catalyst.contrib.callbacks import DrawMasksCallback  import segmentation_models_pytorch as smp  import albumentations as albu from albumentations.pytorch import ToTensor  print(f\"torch: {torch.__version__}, catalyst: {catalyst.__version__}\")  SEED = 42 utils.set_global_seed(SEED) utils.prepare_cudnn(deterministic=True)  import warnings warnings.filterwarnings(\"ignore\")<\/code><\/pre>\n<h3>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430<\/h3>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c \u043f\u0443\u0442\u0438 \u0434\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043f\u0443\u0442\u0438 \u0434\u043e \u0432\u0441\u0435\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u043c\u0430\u0441\u043e\u043a \u0438\u0437 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<pre><code class=\"python\">ROOT = Path(\"\/content\/\")  train_image_path = ROOT \/ \"train\" train_mask_path = ROOT \/ \"train_masks\" test_image_path = ROOT \/ \"test\"  ALL_IMAGES = sorted(train_image_path.glob(\"*.png\")) print('Images:', len(ALL_IMAGES))  ALL_MASKS = sorted(train_mask_path.glob(\"*.png\")) print('Masks:', len(ALL_MASKS))<\/code><\/pre>\n<h3>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">def show_examples(name: str, image: np.ndarray, mask: np.ndarray):     plt.figure(figsize=(10, 14))     plt.subplot(1, 2, 1)     plt.imshow(image)     plt.title(f\"Image: {name}\")      plt.subplot(1, 2, 2)     plt.imshow(mask)     plt.title(f\"Mask: {name}\")   def show(index: int, images: List[Path], masks: List[Path], transforms=None) -> None:     image_path = images[index]     name = image_path.name      image = utils.imread(image_path)     mask = gif_imread(masks[index])      if transforms is not None:         temp = transforms(image=image, mask=mask)         image = temp[\"image\"]         mask = temp[\"mask\"]      show_examples(name, image, mask)  def show_random(images: List[Path], masks: List[Path], transforms=None) -> None:     length = len(images)     index = random.randint(0, length - 1)     show(index, images, masks, transforms)<\/code><\/pre>\n<p>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">show_random(ALL_IMAGES, ALL_MASKS)<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445  \u0421\u043b\u0435\u0432\u0430 &#8212; \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0421\u043f\u0440\u0430\u0432\u0430 &#8212; \u043c\u0430\u0441\u043a\u0430<\/figcaption><\/figure>\n<h3>\u0410\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u0410\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u0437\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u0432\u044b\u0441\u0438\u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u044b \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432, \u0432\u044b\u0440\u0435\u0437\u043a\u0438 \u043a\u0443\u0441\u043e\u0447\u043a\u043e\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0430\u044f \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c, \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u0448\u0443\u043c\u044b, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a, \u043a\u0440\u043e\u043f\u044b.<\/p>\n<pre><code class=\"python\">def pre_transforms(image_size=224):     return [albu.Resize(image_size, image_size, p=1)]   def hard_transforms():     result = [       albu.RandomRotate90(),       albu.Cutout(),       albu.RandomBrightnessContrast(           brightness_limit=0.2, contrast_limit=0.2, p=0.3       ),       albu.GridDistortion(p=0.3),       albu.HueSaturationValue(p=0.3)     ]      return result     def resize_transforms(image_size=224):     BORDER_CONSTANT = 0     pre_size = int(image_size * 1.5)      random_crop = albu.Compose([       albu.SmallestMaxSize(pre_size, p=1),       albu.RandomCrop(           image_size, image_size, p=1       )      ])      rescale = albu.Compose([albu.Resize(image_size, image_size, p=1)])      random_crop_big = albu.Compose([       albu.LongestMaxSize(pre_size, p=1),       albu.RandomCrop(           image_size, image_size, p=1       )      ])      # Converts the image to a square of size image_size x image_size     result = [       albu.OneOf([           random_crop,           rescale,           random_crop_big       ], p=1)     ]      return result    def post_transforms():     # we use ImageNet image normalization     # and convert it to torch.Tensor     return [albu.Normalize(), ToTensor()]    def compose(transforms_to_compose):     # combine all augmentations into single pipeline     result = albu.Compose([       item for sublist in transforms_to_compose for item in sublist     ])     return result<\/code><\/pre>\n<p>\u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">train_transforms = compose([     resize_transforms(),      hard_transforms(),      post_transforms() ]) valid_transforms = compose([pre_transforms(), post_transforms()])  show_transforms = compose([resize_transforms(), hard_transforms()])<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"python\">show_random(ALL_IMAGES, ALL_MASKS, transforms=show_transforms)<\/code><\/pre>\n<figure class=\"full-width\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438 \u043c\u0430\u0441\u043a\u0438 \u0441 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0438\u0434\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0448\u0443\u043c.<\/figcaption><\/figure>\n<h3>\u0417\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>\u041d\u0430 \u0432\u0445\u043e\u0434 \u0432 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <em>SegmentationDataset<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442. <\/p>\n<pre><code class=\"python\">class SegmentationDataset(Dataset):     def __init__(         self,         images: List[Path],         masks: List[Path] = None,         transforms=None     ) -> None:         self.images = images         self.masks = masks         self.transforms = transforms      def __len__(self) -> int:         return len(self.images)      def __getitem__(self, idx: int) -> dict:         image_path = self.images[idx]         image =<\/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-335669","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335669","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=335669"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335669\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335669"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335669"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335669"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}