{"id":407145,"date":"2024-06-29T19:23:03","date_gmt":"2024-06-29T19:23:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=407145"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=407145","title":{"rendered":"<span>\u0411\u044b\u0441\u0442\u0440\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 HTR \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/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<p><em>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Google Colab \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 HTR.<\/em><\/p>\n<p>\u00a0<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/966\/a0f\/4da\/966a0f4da901a329ba08cb3cf8ef24f8.png\" width=\"623\" height=\"351\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/966\/a0f\/4da\/966a0f4da901a329ba08cb3cf8ef24f8.png\"\/><figcaption><\/figcaption><\/figure>\n<p>OCR \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b OCR, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a FineReader, Tesseract \u0438 EasyOCR \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u2013 \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 (handwritten text recognition, HTR) &#8212; \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430. \u041e\u0446\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0438\u0434 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0431\u0438\u0437\u043d\u0435\u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u041e\u0442\u043c\u0435\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 HTR, \u043a\u0430\u043a \u043e\u0431\u0449\u0438\u0435, \u0442\u0430\u043a \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435:<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u043f\u043e\u0447\u0435\u0440\u043a \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0434\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0431\u0443\u043a\u0432\u0443 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0430\u043c\u0438 \u0438 \u0442.\u0434.;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u00ab\u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0438\u0432\u0430\u00bb \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0437\u0430\u0440\u0443\u0431\u0435\u0436\u043e\u043c &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0440\u0430\u0437\u0430 \u00ab\u043b\u0438\u0448\u0438\u0448\u044c \u043b\u0438\u043b\u0438\u0438\u00bb \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043a\u0443\u0440\u0441\u0438\u0432\u043e\u043c \u0432\u0432\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0443\u043f\u043e\u0440 \u043c\u043d\u043e\u0433\u0438\u0445;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0431\u0443\u043a\u0432\u0430\u043c\u0438 \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0431\u0443\u043a\u0432 \u0434\u043b\u044f \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u044b \u0442\u0440\u0443\u0434\u043d\u043e \u043d\u0430\u0439\u0442\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (\u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438) \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0435 \u0441\u0440\u043e\u043a\u0438 (\u043f\u0430\u0440\u0430 \u0447\u0430\u0441\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438) \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 HTR, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0448\u0435 \u0447\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 HTR \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435. \u0412 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043f\u043e\u0434\u0445\u043e\u0434, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/466565\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440<\/a>. \u0421\u0443\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0420\u0430\u0437\u0431\u0438\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0431\u0443\u043a\u0432\u0430\u043c\u0438;<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u2013 <u>\u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0431\u0443\u043a\u0432\u0430\u043c\u0438 \u0431\u0435\u0437 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439.<\/u><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Google Colab \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 HTR.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, CoMNIST. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0435\u0433\u043e, \u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0435\u043c \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b:<\/p>\n<pre><code># \u0441\u043a\u0430\u0447\u0430\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 CoMNIST ! wget https:\/\/github.com\/GregVial\/CoMNIST\/raw\/master\/images\/Cyrillic.zip ! unzip Cyrillic.zip # \u0443\u0434\u0430\u043b\u0438\u043c \u043f\u0430\u043f\u043a\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0431\u0443\u043a\u0432\u044b \"I\" \u0438 \"\u042a\" (\u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b) ! rm -R Cyrillic\/I # \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 from IPython.display import Image Image(filename=r'Cyrillic\/\u042f\/5a7747df79f11.png')<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043d\u0443\u0436\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<pre><code># \u0423\u0434\u0430\u043b\u0438\u043c \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 !pip uninstall keras tensorflow h5py \u2013y # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 !pip install keras==2.2.5 tensorflow==1.14.0 h5py==2.10.0<\/code><\/pre>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 keras \u0438 tensorflow \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u0443. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>import os import cv2 import time from tqdm import tqdm from PIL import Image, ImageFilter, ImageOps import numpy as np  import matplotlib.pyplot as plt import matplotlib.image as mpimg from sklearn.model_selection import train_test_split  from tensorflow import keras from keras.models import Sequential from keras import optimizers from keras.layers import Convolution2D, MaxPooling2D, Dropout, Flatten, Dense, Reshape, LSTM, BatchNormalization from keras.optimizers import SGD, RMSprop, Adam from keras import backend as K from keras.constraints import maxnorm import tensorflow as tf  def emnist_model(labels_num=None):     model = Sequential()     model.add(Convolution2D(filters=32, kernel_size=(3, 3), padding='valid', input_shape=(28, 28, 1), activation='relu'))     model.add(Convolution2D(filters=64, kernel_size=(3, 3), activation='relu'))     model.add(MaxPooling2D(pool_size=(2, 2)))     model.add(Dropout(0.25))     model.add(Flatten())     model.add(Dense(512, activation='relu'))     model.add(Dropout(0.5))     model.add(Dense(labels_num, activation='softmax'))     model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])     return model  def emnist_train(model, X_train, y_train_cat, X_test, y_test_cat):     t_start = time.time()     # Set a learning rate reduction     learning_rate_reduction = keras.callbacks.ReduceLROnPlateau(monitor='val_acc', patience=3, verbose=1, factor=0.5, min_lr=0.00001)     # Required for learning_rate_reduction:     keras.backend.get_session().run(tf.global_variables_initializer())     model.fit(X_train, y_train_cat, validation_data=(X_test, y_test_cat), callbacks=[learning_rate_reduction], batch_size=64, epochs=9)     print(\"Training done, dT:\", time.time() - t_start)<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<pre><code>def load_image_as_gray(path_to_image):     img = Image.open(path_to_image)     return np.array(img.convert(\"L\"))  def load_image(path_to_image):     img = Image.open(path_to_image)     return img  def convert_rgba_to_rgb(pil_img):     pil_img.load()     background = Image.new(\"RGB\", pil_img.size, (255, 255, 255))     background.paste(pil_img, mask = pil_img.split()[3])     return background  def prepare_rgba_img(img_path):     img = load_image(img_path)     if np.array(img).shape[2] == 4:       new_img = convert_rgba_to_rgb(img)       return new_img     return img  # \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if l != \".ipynb_checkpoints\":       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       blurImage = img.filter(ImageFilter.BoxBlur(15))       blurImage.save(f\"Cyrillic\/{lett}\/\"+\"blur_\"+l)  # \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 +20 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if (l != \".ipynb_checkpoints\") &amp; (\"blur_\" not in l):       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       rotImage = img.rotate(20)       rotImage.save(f\"Cyrillic\/{lett}\/\"+\"rot20_\"+l)  # \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 -20 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if (\".ipynb_checkpoints\" not in l) &amp; (\"rot20_\" not in l) &amp; (\"blur_\" not in l):       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       rotImage = img.rotate(-20)       rotImage.save(f\"Cyrillic\/{lett}\/\"+\"rot02_\"+l)  # \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043e 28x28 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if l != \".ipynb_checkpoints\":       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       resized = img.resize((28, 28))       resized.save(f\"Cyrillic\/{lett}\/\"+l)<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 CoMNIST \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 PNG RGBA, \u043f\u0440\u0438\u0447\u0451\u043c, \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u00ab\u043f\u0440\u043e\u043a\u0438\u043d\u0443\u0442\u044c\u00bb \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b \u043d\u0430 RGB:<\/p>\n<pre><code># \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 RGBA \u0432 RGB for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if l != \".ipynb_checkpoints\":       rgb_img = prepare_rgba_img(f\"Cyrillic\/{lett}\/\"+l)       rgb_img.save(f\"Cyrillic\/{lett}\/\"+l)<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430:<\/p>\n<pre><code>y_num = {l:i+1 for i, l in enumerate(np.unique(y_train))}  X_train = np.reshape(np.array(X_train), (np.array(X_train).shape[0], 28, 28, 1)) X_test = np.reshape(np.array(X_test), (np.array(X_test).shape[0], 28, 28, 1))  X_train = X_train.astype(np.float32) X_train \/= 255.0 X_test = X_test.astype(np.float32) X_test \/= 255.0  y_train_num = [y_num[i] for i in y_train] y_test_num = [y_num[i] for i in y_test]  y_train_cat = keras.utils.to_categorical(np.array(y_train_num), 33) y_test_cat = keras.utils.to_categorical(np.array(y_test_num), 33)<\/code><\/pre>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>model = emnist_model(len(y_num)+1) emnist_train(model, X_train, y_train_cat, X_test, y_test_cat)<\/code><\/pre>\n<p>\u0423 \u0430\u0432\u0442\u043e\u0440\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0432 Google Colab \u043d\u0430 \u0412\u041c \u0431\u0435\u0437 TPU \u0437\u0430\u043d\u044f\u043b\u043e ~40 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b51\/52d\/ee0\/b5152dee09a0b99341fc6af1bd890bfe.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1 \u2013 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1 \u2013 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c\" width=\"624\" height=\"128\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b51\/52d\/ee0\/b5152dee09a0b99341fc6af1bd890bfe.png\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1 \u2013 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0436\u0438\u0440\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u044f\u0449\u0438\u0445 (\u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c) \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0438\u0445 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432:<\/p>\n<pre><code># \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0443\u043a\u0432\u044b def letters_extract(image_file: str, out_size=28):     img = cv2.imread(image_file)     gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)     ret, thresh = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)     img_erode = cv2.erode(thresh, np.ones((3, 3), np.uint8), iterations=1)      # Get contours     contours, hierarchy = cv2.findContours(img_erode, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)      output = img.copy()      letters = []     for idx, contour in enumerate(contours):         (x, y, w, h) = cv2.boundingRect(contour)         if hierarchy[0][idx][3] == 0:             cv2.rectangle(output, (x, y), (x + w, y + h), (70, 0, 0), 1)             letter_crop = gray[y:y + h, x:x + w]             size_max = max(w, h)             letter_square = 255 * np.ones(shape=[size_max, size_max], dtype=np.uint8)             if w > h:                 y_pos = size_max\/\/2 - h\/\/2                 letter_square[y_pos:y_pos + h, 0:w] = letter_crop             elif w &lt; h:                 x_pos = size_max\/\/2 - w\/\/2                 letter_square[0:h, x_pos:x_pos + w] = letter_crop             else:                 letter_square = letter_crop              letters.append((x, w, cv2.resize(letter_square, (out_size, out_size), interpolation=cv2.INTER_AREA)))      # Sort array in place by X-coordinate     letters.sort(key=lambda x: x[0], reverse=False)     return letters<\/code><\/pre>\n<p>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u044b:<\/p>\n<pre><code>import matplotlib.pyplot as plt %matplotlib inline lttrs = letters_extract(\"test.png\", 28) plt.imshow(lttrs[0][2], cmap=\"gray\")<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ec\/469\/ea5\/0ec469ea5426afdb4413d62dea0de774.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2 \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2 \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\" width=\"142\" height=\"140\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ec\/469\/ea5\/0ec469ea5426afdb4413d62dea0de774.png\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2 \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0446\u0438\u0444\u0440\u044b \u2013 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0435 \u043d\u043e\u043c\u0435\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0434\u043e\u0431\u043d\u043e \u0431\u0443\u0434\u0435\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0434\u043b\u044f \u043e\u0431\u043b\u0435\u0433\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 (\u0437\u0434\u0435\u0441\u044c \u2013 y_num), \u043e\u0434\u043d\u0430\u043a\u043e, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0431\u0443\u043a\u0432\u0430 \u00ab\u0401\u00bb, \u043f\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0430\u043b\u0444\u0430\u0432\u0438\u0442 \u0438 \u0438\u0434\u0451\u0442 \u043f\u0435\u0440\u0432\u043e\u0439. \u0414\u0430\u043b\u0435\u0435, \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430:<\/p>\n<pre><code>def get_lettr(ind, y_num):   back_y = {v:k for k, v in y_num.items()}   return back_y[ind]  for i in range(len(lttrs)):   img_arr = lttrs[i][2]   img_arr = img_arr\/255.0   input_img_arr = img_arr.reshape((1, 28, 28, 1))   result = model.predict_classes([input_img_arr])   print(get_lettr(result[0], y_num))<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0434\u043b\u044f \u043f\u0430\u0440\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e65\/487\/03f\/e6548703f2265dac3ab4119ec0166574.png\" alt=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3 \u2013 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 HTR\" title=\"\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3 \u2013 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 HTR\" width=\"624\" height=\"231\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e65\/487\/03f\/e6548703f2265dac3ab4119ec0166574.png\"\/><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3 \u2013 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 HTR<\/figcaption><\/figure>\n<p>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 3 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430. \u041a\u0440\u0430\u0441\u043d\u044b\u043c \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u044b \u044f\u0432\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0436\u0451\u043b\u0442\u044b\u043c \u2013 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043b\u0435\u0435. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f, \u043e\u0434\u043d\u0430\u043a\u043e, \u0438\u0437-\u0437\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u043a\u0432\u0430 \u00ab\u042b\u00bb \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u043a\u0430\u043a \u0434\u0432\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u00ab\u042c\u00bb \u0438 \u00abI\u00bb \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u043e\u0434\u0430\u0451\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438. \u0422\u0430\u043a\u0436\u0435, \u043d\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0441\u043b\u043e\u0432\u0430\u043c\u0438.<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0437\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 HTR, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f. \u0421\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0441\u043c\u0435\u043d\u0438\u0442\u044c\/\u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0431\u0443\u043a\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0448\u0440\u0438\u0444\u0442\u044b \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <a href=\"http:\/\/handwritter.ru\" rel=\"noopener noreferrer nofollow\">handwritter.ru<\/a>;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"https:\/\/habr.com\/ru\/post\/535224\/\" rel=\"noopener noreferrer nofollow\">\u00ab\u041f\u0435\u0440\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0430 AI Journey 2020 Digital \u041f\u0435\u0442\u0440\u00bb<\/a>, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0441\u0442\u0440\u043e\u043a \u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0441 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c\u0438;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438 \u043e\u0440\u0444\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0448\u0438\u0431\u043e\u043a;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u0443\u044e \u043c\u0430\u0440\u043a\u043e\u0432\u0441\u043a\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430\/\u0441\u043b\u043e\u0432\u0430;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u043e\u0432\/\u0444\u0440\u0430\u0437, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0440\u0438\u0444\u0442\u043e\u0432 Handwriter.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/581516\/\"> https:\/\/habr.com\/ru\/articles\/581516\/<\/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<p><em>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Google Colab \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 HTR.<\/em><\/p>\n<p>\u00a0<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>OCR \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u043f\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c. \u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b OCR, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a FineReader, Tesseract \u0438 EasyOCR \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u2013 \u0432 \u043b\u0443\u0447\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 (handwritten text recognition, HTR) &#8212; \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430. \u041e\u0446\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0438\u0434 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u0438\u0435 \u0431\u0438\u0437\u043d\u0435\u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u041e\u0442\u043c\u0435\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 HTR, \u043a\u0430\u043a \u043e\u0431\u0449\u0438\u0435, \u0442\u0430\u043a \u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0447\u0435\u0441\u043a\u0438\u0435:<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u043f\u043e\u0447\u0435\u0440\u043a \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u0434\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u043c\u043e\u0436\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0431\u0443\u043a\u0432\u0443 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u043d\u0430\u043a\u043b\u043e\u043d\u0430\u043c\u0438 \u0438 \u0442.\u0434.;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u00ab\u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u043a\u0443\u0440\u0441\u0438\u0432\u0430\u00bb \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0437\u0430\u0440\u0443\u0431\u0435\u0436\u043e\u043c &#8212; \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0444\u0440\u0430\u0437\u0430 \u00ab\u043b\u0438\u0448\u0438\u0448\u044c \u043b\u0438\u043b\u0438\u0438\u00bb \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u0430\u044f \u043a\u0443\u0440\u0441\u0438\u0432\u043e\u043c \u0432\u0432\u043e\u0434\u0438\u0442 \u0432 \u0441\u0442\u0443\u043f\u043e\u0440 \u043c\u043d\u043e\u0433\u0438\u0445;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0431\u0443\u043a\u0432\u0430\u043c\u0438 \u043e\u0447\u0435\u043d\u044c \u0442\u0440\u0443\u0434\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c;<\/p>\n<p>&#8212;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0445 \u0431\u0443\u043a\u0432 \u0434\u043b\u044f \u043a\u0438\u0440\u0438\u043b\u043b\u0438\u0446\u044b \u0442\u0440\u0443\u0434\u043d\u043e \u043d\u0430\u0439\u0442\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 (\u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438) \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432) \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0435 \u0441\u0440\u043e\u043a\u0438 (\u043f\u0430\u0440\u0430 \u0447\u0430\u0441\u043e\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438) \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 HTR, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0448\u0435 \u0447\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435, \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 HTR \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0431\u043e\u0442\u0435. \u0412 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043f\u043e\u0434\u0445\u043e\u0434, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/466565\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0430 \u0425\u0430\u0431\u0440<\/a>. \u0421\u0443\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c:<\/p>\n<p>1.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u0420\u0430\u0437\u0431\u0438\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0431\u0443\u043a\u0432\u0430\u043c\u0438;<\/p>\n<p>2.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u2013 <u>\u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0431\u0443\u043a\u0432\u0430\u043c\u0438 \u0431\u0435\u0437 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439.<\/u><\/p>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Google Colab \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 HTR.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, CoMNIST. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0435\u0433\u043e, \u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0435\u043c \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b:<\/p>\n<pre><code># \u0441\u043a\u0430\u0447\u0430\u0435\u043c \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u0443\u0435\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442 CoMNIST ! wget https:\/\/github.com\/GregVial\/CoMNIST\/raw\/master\/images\/Cyrillic.zip ! unzip Cyrillic.zip # \u0443\u0434\u0430\u043b\u0438\u043c \u043f\u0430\u043f\u043a\u0443 \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0431\u0443\u043a\u0432\u044b \"I\" \u0438 \"\u042a\" (\u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0431\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b) ! rm -R Cyrillic\/I # \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 from IPython.display import Image Image(filename=r'Cyrillic\/\u042f\/5a7747df79f11.png')<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u043d\u0443\u0436\u043d\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430:<\/p>\n<pre><code># \u0423\u0434\u0430\u043b\u0438\u043c \u043d\u0435\u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 !pip uninstall keras tensorflow h5py \u2013y # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 !pip install keras==2.2.5 tensorflow==1.14.0 h5py==2.10.0<\/code><\/pre>\n<p>\u0416\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 keras \u0438 tensorflow \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0440\u0435\u0434\u0443. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code>import os import cv2 import time from tqdm import tqdm from PIL import Image, ImageFilter, ImageOps import numpy as np  import matplotlib.pyplot as plt import matplotlib.image as mpimg from sklearn.model_selection import train_test_split  from tensorflow import keras from keras.models import Sequential from keras import optimizers from keras.layers import Convolution2D, MaxPooling2D, Dropout, Flatten, Dense, Reshape, LSTM, BatchNormalization from keras.optimizers import SGD, RMSprop, Adam from keras import backend as K from keras.constraints import maxnorm import tensorflow as tf  def emnist_model(labels_num=None):     model = Sequential()     model.add(Convolution2D(filters=32, kernel_size=(3, 3), padding='valid', input_shape=(28, 28, 1), activation='relu'))     model.add(Convolution2D(filters=64, kernel_size=(3, 3), activation='relu'))     model.add(MaxPooling2D(pool_size=(2, 2)))     model.add(Dropout(0.25))     model.add(Flatten())     model.add(Dense(512, activation='relu'))     model.add(Dropout(0.5))     model.add(Dense(labels_num, activation='softmax'))     model.compile(loss='categorical_crossentropy', optimizer='adadelta', metrics=['accuracy'])     return model  def emnist_train(model, X_train, y_train_cat, X_test, y_test_cat):     t_start = time.time()     # Set a learning rate reduction     learning_rate_reduction = keras.callbacks.ReduceLROnPlateau(monitor='val_acc', patience=3, verbose=1, factor=0.5, min_lr=0.00001)     # Required for learning_rate_reduction:     keras.backend.get_session().run(tf.global_variables_initializer())     model.fit(X_train, y_train_cat, validation_data=(X_test, y_test_cat), callbacks=[learning_rate_reduction], batch_size=64, epochs=9)     print(\"Training done, dT:\", time.time() - t_start)<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u0438 \u0430\u0443\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<pre><code>def load_image_as_gray(path_to_image):     img = Image.open(path_to_image)     return np.array(img.convert(\"L\"))  def load_image(path_to_image):     img = Image.open(path_to_image)     return img  def convert_rgba_to_rgb(pil_img):     pil_img.load()     background = Image.new(\"RGB\", pil_img.size, (255, 255, 255))     background.paste(pil_img, mask = pil_img.split()[3])     return background  def prepare_rgba_img(img_path):     img = load_image(img_path)     if np.array(img).shape[2] == 4:       new_img = convert_rgba_to_rgb(img)       return new_img     return img  # \u0440\u0430\u0437\u043c\u044b\u0442\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if l != \".ipynb_checkpoints\":       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       blurImage = img.filter(ImageFilter.BoxBlur(15))       blurImage.save(f\"Cyrillic\/{lett}\/\"+\"blur_\"+l)  # \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 +20 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if (l != \".ipynb_checkpoints\") &amp; (\"blur_\" not in l):       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       rotImage = img.rotate(20)       rotImage.save(f\"Cyrillic\/{lett}\/\"+\"rot20_\"+l)  # \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 -20 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if (\".ipynb_checkpoints\" not in l) &amp; (\"rot20_\" not in l) &amp; (\"blur_\" not in l):       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       rotImage = img.rotate(-20)       rotImage.save(f\"Cyrillic\/{lett}\/\"+\"rot02_\"+l)  # \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0434\u043e 28x28 for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if l != \".ipynb_checkpoints\":       img = Image.open(f\"Cyrillic\/{lett}\/\"+l)       resized = img.resize((28, 28))       resized.save(f\"Cyrillic\/{lett}\/\"+l)<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 CoMNIST \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 PNG RGBA, \u043f\u0440\u0438\u0447\u0451\u043c, \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u00ab\u043f\u0440\u043e\u043a\u0438\u043d\u0443\u0442\u044c\u00bb \u0430\u043b\u044c\u0444\u0430-\u043a\u0430\u043d\u0430\u043b \u043d\u0430 RGB:<\/p>\n<pre><code># \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438\u0437 RGBA \u0432 RGB for lett in os.listdir(\"Cyrillic\/\"):   for l in os.listdir(f\"Cyrillic\/{lett}\"):     if l != \".ipynb_checkpoints\":       rgb_img = prepare_rgba_img(f\"Cyrillic\/{lett}\/\"+l)       rgb_img.save(f\"Cyrillic\/{lett}\/\"+l)<\/code><\/pre>\n<p>\u041f\u0440\u0435\u0434\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430:<\/p>\n<pre><code>y_num = {l:i+1 for i, l in enumerate(np.unique(y_train))}  X_train = np.reshape(np.array(X_train), (np.array(X_train).shape[0], 28, 28, 1)) X_test = np.reshape(np.array(X_test), (np.array(X_test).shape[0], 28, 28, 1))  X_train = X_train.astype(np.float32) X_train \/= 255.0 X_test = X_test.astype(np.float32) X_test \/= 255.0  y_train_num = [y_num[i] for i in y_train] y_test_num = [y_num[i] for i in y_test]  y_train_cat = keras.utils.to_categorical(np.array(y_train_num), 33) y_test_cat = keras.utils.to_categorical(np.array(y_test_num), 33)<\/code><\/pre>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>model = emnist_model(len(y_num)+1) emnist_train(model, X_train, y_train_cat, X_test, y_test_cat)<\/code><\/pre>\n<p>\u0423 \u0430\u0432\u0442\u043e\u0440\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0432 Google Colab \u043d\u0430 \u0412\u041c \u0431\u0435\u0437 TPU \u0437\u0430\u043d\u044f\u043b\u043e ~40 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<figure class=\"full-width\"><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1 \u2013 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u0440\u0443\u043a\u043e\u043f\u0438\u0441\u043d\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c<\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b. \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0436\u0438\u0440\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0442\u043e\u044f\u0449\u0438\u0445 (\u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c) \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u0438\u0445 \u043a\u043e\u043d\u0442\u0443\u0440\u043e\u0432:<\/p>\n<pre><code># \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u0443\u043a\u0432\u044b def letters_extract(image_file: str, out_size=28):     img = cv2.imread(image_file)     gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)     ret, thresh = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)     img_erode = cv2.erode(thresh, np.ones((3, 3), np.uint8), iterations=1)      # Get contours     contours, hierarchy = cv2.findContours(img_erode, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)      output = img.copy()      letters = []     for idx, contour in enumerate(contours):         (x, y, w, h) = cv2.boundingRect(contour)         if hierarchy[0][idx][3] == 0:             cv2.rectangle(output, (x, y), (x + w, y + h), (70, 0, 0), 1)             letter_crop = gray[y:y + h, x:x + w]             size_max = max(w, h)             letter_square = 255 * np.ones(shape=[size_max, size_max], dtype=np.uint8)             if w > h:                 y_pos = size_max\/\/2 - h\/\/2                 letter_square[y_pos:y_pos + h, 0:w] = letter_crop             elif w &lt; h:                 x_pos = size_max\/\/2 - w\/\/2                 letter_square[0:h, x_pos:x_pos + w] = letter_crop             else:                 letter_square = letter_crop              letters.append((x, w, cv2.resize(letter_square, (out_size, out_size), interpolation=cv2.INTER_AREA)))      # Sort array in place by X-coordinate     letters.sort(key=lambda x: x[0], reverse=False)     return letters<\/code><\/pre>\n<p>\u0414\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u044b:<\/p>\n<pre><code>import matplotlib.pyplot as plt %matplotlib inline lttrs = letters_extract(\"test.png\", 28) plt.imshow(lttrs[0][2], cmap=\"gray\")<\/code><\/pre>\n<figure class=\"\"><figcaption>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2 \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c<\/p>\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-407145","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407145","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=407145"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/407145\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=407145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=407145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=407145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}