{"id":318919,"date":"2021-03-02T21:00:36","date_gmt":"2021-03-02T21:00:36","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=318919"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=318919","title":{"rendered":"\u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0446\u0438\u0439 \u043d\u0430 \u043b\u0438\u0446\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 TensorFlow.js. \u0427\u0430\u0441\u0442\u044c 2"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/510\/0d0\/a69\/5100d0a69d68a4778133a4c9923f2e44.jpg\" width=\"1000\" height=\"600\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/544846\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0418\u0418 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b \u043b\u0438\u0446. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u044b \u043b\u0438\u0446\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043b\u0438\u0446\u0435 \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u044b \u043b\u0438\u0446\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043b\u0438\u0446\u0435 \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u0446\u0430\u0445 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 FER+ \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u043c\u043e\u0446\u0438\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u043e \u0442\u043e\u0447\u043a\u0430\u043c \u043b\u0438\u0446\u0430 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TensorFlow.js.<\/p>\n<p>\u0421\u043e\u0435\u0434\u0438\u043d\u0438\u0432 \u043d\u0430\u0448 \u043a\u043e\u0434 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0441 <a href=\"https:\/\/github.com\/microsoft\/FERPlus\">\u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431 \u044d\u043c\u043e\u0446\u0438\u044f\u0445 \u043d\u0430 \u043b\u0438\u0446\u0435 FER<\/a>, \u043c\u044b \u043e\u0431\u0443\u0447\u0438\u043c \u0432\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u043c\u043e\u0446\u0438\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c.<\/p>\n<hr>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0435\u043c\u043e\u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0432\u0435\u0431-\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 WebGL. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c <a href=\"https:\/\/www.codeproject.com\/KB\/AI\/5293492\/AIFaceFilters.zip\">\u043a\u043e\u0434 \u0438 \u0444\u0430\u0439\u043b\u044b<\/a> \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0431 \u044d\u043c\u043e\u0446\u0438\u044f\u0445 \u043d\u0430 \u043b\u0438\u0446\u0435 FER2013<\/h2>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0418\u0418 \u043d\u0430 \u0442\u043e\u0447\u043a\u0430\u0445 \u043e\u0442\u0441\u043b\u0435\u0436\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u0446 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 FER, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0451 \u043a \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0451 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043e \u043b\u0438\u0446\u0430\u0445. \u041d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 FER2013 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0438\u0437 28 \u0442\u044b\u0441\u044f\u0447 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043b\u0438\u0446; \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/www.kaggle.com\/c\/challenges-in-representation-learning-facial-expression-recognition-challenge\/data\">Kaggle<\/a>. \u041c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 <a href=\"https:\/\/www.kaggle.com\/msambare\/fer2013\">\u044d\u0442\u0443 \u0432\u0435\u0440\u0441\u0438\u044e<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0436\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 \u0444\u0430\u0439\u043b\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0435\u0451 \u0432 \u043f\u0430\u043f\u043a\u0443 <em>web\/fer2013<\/em><strong>.<\/strong> \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 NodeJS \u0432 <em>index.js<\/em>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:8080\/data\/\">http:\/\/localhost:8080\/data\/<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 JSON, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 JSON \u0432 \u0444\u0430\u0439\u043b\u0435 <em>web\/fer2013.js<\/em>, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"javascript\">&lt;script src=\"web\/fer2013.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>\u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043d\u0435 \u0441 \u0432\u0438\u0434\u0435\u043e \u0441 \u0432\u0435\u0431-\u043a\u0430\u043c\u0435\u0440\u044b (\u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0442\u0435\u0441\u044c, \u043c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u0432\u0438\u0434\u0435\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442<code>&lt;video&gt;<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c <code>&lt;img&gt;<\/code>\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e ID \u0432 \u00abimage\u00bb. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>setupWebcam<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<pre><code class=\"javascript\">&lt;img id=\"image\" style=\"     visibility: hidden;     width: auto;     height: auto;     \"\/&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0441\u0435\u0433\u043e 48&#215;48 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c 500 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0446 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 canvas. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043b\u0438\u043d\u0438\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"javascript\">async function setImage( url ) {     return new Promise( res =&gt; {         let image = document.getElementById( \"image\" );         image.src = url;         image.onload = () =&gt; {             res();         };     }); }  function shuffleArray( array ) {     for( let i = array.length - 1; i &gt; 0; i-- ) {         const j = Math.floor( Math.random() * ( i + 1 ) );         [ array[ i ], array[ j ] ] = [ array[ j ], array[ i ] ];     } }  const OUTPUT_SIZE = 500;<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u044d\u043c\u043e\u0446\u0438\u0439, \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 FER \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<pre><code class=\"javascript\">const emotions = [ \"angry\", \"disgust\", \"fear\", \"happy\", \"neutral\", \"sad\", \"surprise\" ]; let ferData = []; let setIndex = 0;<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 async \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 FER \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 canvas \u0434\u043e 500&#215;500 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439:<\/p>\n<pre><code class=\"javascript\">const minSamples = Math.min( ...Object.keys( fer2013 ).map( em =&gt; fer2013[ em ].length ) ); Object.keys( fer2013 ).forEach( em =&gt; {     shuffleArray( fer2013[ em ] );     for( let i = 0; i &lt; minSamples; i++ ) {         ferData.push({             emotion: em,             file: fer2013[ em ][ i ]         });     } }); shuffleArray( ferData );  let canvas = document.getElementById( \"output\" ); canvas.width = OUTPUT_SIZE; canvas.height = OUTPUT_SIZE;<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u043a\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0418\u0418 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>trackFace<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c image, \u0430 \u043d\u0435 video. \u0422\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u043a\u0438 \u0434\u043b\u044f \u043b\u0438\u0446\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 canvas. \u041c\u044b \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u0440\u0430\u0449\u0435\u043d\u0438\u0435 <code>setIndex<\/code> \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">async function trackFace() {     \/\/ Set to the next training image     await setImage( ferData[ setIndex ].file );     const image = document.getElementById( \"image\" );     const faces = await model.estimateFaces( {         input: image,         returnTensors: false,         flipHorizontal: false,     });     output.drawImage(         image,         0, 0, image.width, image.height,         0, 0, OUTPUT_SIZE, OUTPUT_SIZE     );      const scale = OUTPUT_SIZE \/ image.width;      faces.forEach( face =&gt; {         \/\/ Draw the bounding box         const x1 = face.boundingBox.topLeft[ 0 ];         const y1 = face.boundingBox.topLeft[ 1 ];         const x2 = face.boundingBox.bottomRight[ 0 ];         const y2 = face.boundingBox.bottomRight[ 1 ];         const bWidth = x2 - x1;         const bHeight = y2 - y1;         drawLine( output, x1, y1, x2, y1, scale );         drawLine( output, x2, y1, x2, y2, scale );         drawLine( output, x1, y2, x2, y2, scale );         drawLine( output, x1, y1, x1, y2, scale );          \/\/ Draw the face mesh         const keypoints = face.scaledMesh;         for( let i = 0; i &lt; FaceTriangles.length \/ 3; i++ ) {             let pointA = keypoints[ FaceTriangles[ i * 3 ] ];             let pointB = keypoints[ FaceTriangles[ i * 3 + 1 ] ];             let pointC = keypoints[ FaceTriangles[ i * 3 + 2 ] ];             drawTriangle( output, pointA[ 0 ], pointA[ 1 ], pointB[ 0 ], pointB[ 1 ], pointC[ 0 ], pointC[ 1 ], scale );         }     });      setText( `${setIndex + 1}. Face Tracking Confidence: ${face.faceInViewConfidence.toFixed( 3 )} - ${ferData[ setIndex ].emotion}` );     setIndex++;     requestAnimationFrame( trackFace ); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0433\u043e\u0442\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0432\u0435 \u043a\u043e\u043f\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443&nbsp;<a href=\"https:\/\/www.codeproject.com\/KB\/AI\/5293492\/AIFaceFilters.zip\"><strong>\u2013<\/strong><\/a> \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>1. \u0413\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0446\u0438\u0439 \u043d\u0430 \u043b\u0438\u0446\u0435<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u0434\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u0435\u0451 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0435\u0441\u0430 \u0432 \u0444\u0430\u0439\u043b. \u0412 \u043a\u043e\u0434 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c (\u0441\u043c. \u043f\u0430\u043f\u043a\u0443 <em>web\/model<\/em>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0447\u0430\u0441\u0442\u0438&nbsp;2.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u043a \u044d\u043c\u043e\u0446\u0438\u0439 \u0432 \u0443\u043d\u0438\u0442\u0430\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"javascript\">let trainingData = [];  function emotionToArray( emotion ) {     let array = [];     for( let i = 0; i &lt; emotions.length; i++ ) {         array.push( emotion === emotions[ i ] ? 1 : 0 );     }     return array; }<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>trackFace<\/code> \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0447\u0435\u0440\u0442\u044b \u043b\u0438\u0446\u0430, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0432 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u043e. \u041c\u044b \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0435\u0440\u0442\u044b \u043b\u0438\u0446\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0435, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">\/\/ Add just the nose, cheeks, eyes, eyebrows &amp; mouth const features = [     \"noseTip\",     \"leftCheek\",     \"rightCheek\",     \"leftEyeLower1\", \"leftEyeUpper1\",     \"rightEyeLower1\", \"rightEyeUpper1\",     \"leftEyebrowLower\", \/\/\"leftEyebrowUpper\",     \"rightEyebrowLower\", \/\/\"rightEyebrowUpper\",     \"lipsLowerInner\", \/\/\"lipsLowerOuter\",     \"lipsUpperInner\", \/\/\"lipsUpperOuter\", ]; let points = []; features.forEach( feature =&gt; {     face.annotations[ feature ].forEach( x =&gt; {         points.push( ( x[ 0 ] - x1 ) \/ bWidth );         points.push( ( x[ 1 ] - y1 ) \/ bHeight );     }); }); \/\/ Only grab the faces that are confident if( face.faceInViewConfidence &gt; 0.9 ) {     trainingData.push({         input: points,         output: ferData[ setIndex ].emotion,     }); }<\/code><\/pre>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 trainNet<strong>.<\/strong> \u0412 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>trackFace<\/code> \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0446\u0438\u043a\u043b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u0438 \u0432\u044b\u0439\u0434\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 200 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">async function trackFace() {     \/\/ Fast train on just 200 of the images     if( setIndex &gt;= 200 ) {         setText( \"Finished!\" );         trainNet();         return;     }     ... }<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u0430\u043a \u0434\u043e\u043b\u0433\u043e \u0436\u0434\u0430\u043b\u0438: \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>trainNet<\/code><strong> <\/strong>\u0438 \u043e\u0431\u0443\u0447\u0438\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0418\u0418!<\/p>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u043d\u0438\u0442\u0430\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u044d\u043c\u043e\u0446\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c TensorFlow \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u044f\u043c\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u0430 1000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c. \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0438\u0441\u043b\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c.<\/p>\n<pre><code class=\"javascript\">async function trainNet() {     let inputs = trainingData.map( x =&gt; x.input );     let outputs = trainingData.map( x =&gt; emotionToArray( x.output ) );      \/\/ Define our model with several hidden layers     const model = tf.sequential();     model.add(tf.layers.dense( { units: 100, activation: \"relu\", inputShape: [ inputs[ 0 ].length ] } ) );     model.add(tf.layers.dense( { units: 100, activation: \"relu\" } ) );     model.add(tf.layers.dense( { units: 100, activation: \"relu\" } ) );     model.add(tf.layers.dense( {         units: emotions.length,         kernelInitializer: 'varianceScaling',         useBias: false,         activation: \"softmax\"     } ) );      model.compile({         optimizer: \"adam\",         loss: \"categoricalCrossentropy\",         metrics: \"acc\"     });      const xs = tf.stack( inputs.map( x =&gt; tf.tensor1d( x ) ) );     const ys = tf.stack( outputs.map( x =&gt; tf.tensor1d( x ) ) );     await model.fit( xs, ys, {         epochs: 1000,         shuffle: true,         callbacks: {             onEpochEnd: ( epoch, logs ) =&gt; {                 setText( `Training... Epoch #${epoch} (${logs.acc.toFixed( 3 )})` );                 console.log( \"Epoch #\", epoch, logs );             }         }     } );      \/\/ Download the trained model     const saveResult = await model.save( \"downloads:\/\/facemo\" ); }<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/800\/779\/8f0\/8007798f02da13c649f4af16cb6b5d16.jpg\" width=\"500\" height=\"565\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451! \u041d\u0430 \u044d\u0442\u043e\u0439 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0418\u0418 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0430 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043b\u0438\u0446 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f\u0445, \u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u043c\u044b \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0430\u043b\u0435\u0435.<\/p>\n<h2>1. \u0424\u0438\u043d\u0438\u0448\u043d\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f<\/h2>\n<details class=\"spoiler\">\n<summary>\u0412\u043e\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 FER:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;html&gt;     &lt;head&gt;         &lt;title&gt;Training - Recognizing Facial Expressions in the Browser with Deep Learning using TensorFlow.js&lt;\/title&gt;         &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@tensorflow\/tfjs@2.4.0\/dist\/tf.min.js\"&gt;&lt;\/script&gt;         &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@tensorflow-models\/face-landmarks-detection@0.0.1\/dist\/face-landmarks-detection.js\"&gt;&lt;\/script&gt;         &lt;script src=\"web\/triangles.js\"&gt;&lt;\/script&gt;         &lt;script src=\"web\/fer2013.js\"&gt;&lt;\/script&gt;     &lt;\/head&gt;     &lt;body&gt;         &lt;canvas id=\"output\"&gt;&lt;\/canvas&gt;         &lt;img id=\"image\" style=\"             visibility: hidden;             width: auto;             height: auto;             \"\/&gt;         &lt;h1 id=\"status\"&gt;Loading...&lt;\/h1&gt;         &lt;script&gt;         function setText( text ) {             document.getElementById( \"status\" ).innerText = text;         }          async function setImage( url ) {             return new Promise( res =&gt; {                 let image = document.getElementById( \"image\" );                 image.src = url;                 image.onload = () =&gt; {                     res();                 };             });         }          function shuffleArray( array ) {             for( let i = array.length - 1; i &gt; 0; i-- ) {                 const j = Math.floor( Math.random() * ( i + 1 ) );                 [ array[ i ], array[ j ] ] = [ array[ j ], array[ i ] ];             }         }          function drawLine( ctx, x1, y1, x2, y2, scale = 1 ) {             ctx.beginPath();             ctx.moveTo( x1 * scale, y1 * scale );             ctx.lineTo( x2 * scale, y2 * scale );             ctx.stroke();         }          function drawTriangle( ctx, x1, y1, x2, y2, x3, y3, scale = 1 ) {             ctx.beginPath();             ctx.moveTo( x1 * scale, y1 * scale );             ctx.lineTo( x2 * scale, y2 * scale );             ctx.lineTo( x3 * scale, y3 * scale );             ctx.lineTo( x1 * scale, y1 * scale );             ctx.stroke();         }          const OUTPUT_SIZE = 500;         const emotions = [ \"angry\", \"disgust\", \"fear\", \"happy\", \"neutral\", \"sad\", \"surprise\" ];         let ferData = [];         let setIndex = 0;         let trainingData = [];          let output = null;         let model = null;          function emotionToArray( emotion ) {             let array = [];             for( let i = 0; i &lt; emotions.length; i++ ) {                 array.push( emotion === emotions[ i ] ? 1 : 0 );             }             return array;         }          async function trainNet() {             let inputs = trainingData.map( x =&gt; x.input );             let outputs = trainingData.map( x =&gt; emotionToArray( x.output ) );              \/\/ Define our model with several hidden layers             const model = tf.sequential();             model.add(tf.layers.dense( { units: 100, activation: \"relu\", inputShape: [ inputs[ 0 ].length ] } ) );             model.add(tf.layers.dense( { units: 100, activation: \"relu\" } ) );             model.add(tf.layers.dense( { units: 100, activation: \"relu\" } ) );             model.add(tf.layers.dense( {                 units: emotions.length,                 kernelInitializer: 'varianceScaling',                 useBias: false,                 activation: \"softmax\"             } ) );              model.compile({                 optimizer: \"adam\",                 loss: \"categoricalCrossentropy\",                 metrics: \"acc\"             });              const xs = tf.stack( inputs.map( x =&gt; tf.tensor1d( x ) ) );             const ys = tf.stack( outputs.map( x =&gt; tf.tensor1d( x ) ) );             await model.fit( xs, ys, {                 epochs: 1000,                 shuffle: true,                 callbacks: {                     onEpochEnd: ( epoch, logs ) =&gt; {                         setText( `Training... Epoch #${epoch} (${logs.acc.toFixed( 3 )})` );                         console.log( \"Epoch #\", epoch, logs );                     }                 }             } );              \/\/ Download the trained model             const saveResult = await model.save( \"downloads:\/\/facemo\" );         }          async function trackFace() {             \/\/ Fast train on just 200 of the images             if( setIndex &gt;= 200 ) {\/\/ferData.length ) {                 setText( \"Finished!\" );                 trainNet();                 return;             }             \/\/ Set to the next training image             await setImage( ferData[ setIndex ].file );             const image = document.getElementById( \"image\" );             const faces = await model.estimateFaces( {                 input: image,                 returnTensors: false,                 flipHorizontal: false,             });             output.drawImage(                 image,                 0, 0, image.width, image.height,                 0, 0, OUTPUT_SIZE, OUTPUT_SIZE             );              const scale = OUTPUT_SIZE \/ image.width;              faces.forEach( face =&gt; {                 \/\/ Draw the bounding box                 const x1 = face.boundingBox.topLeft[ 0 ];                 const y1 = face.boundingBox.topLeft[ 1 ];                 const x2 = face.boundingBox.bottomRight[ 0 ];                 const y2 = face.boundingBox.bottomRight[ 1 ];                 const bWidth = x2 - x1;                 const bHeight = y2 - y1;                 drawLine( output, x1, y1, x2, y1, scale );                 drawLine( output, x2, y1, x2, y2, scale );                 drawLine( output, x1, y2, x2, y2, scale );                 drawLine( output, x1, y1, x1, y2, scale );                  \/\/ Draw the face mesh                 const keypoints = face.scaledMesh;                 for( let i = 0; i &lt; FaceTriangles.length \/ 3; i++ ) {                     let pointA = keypoints[ FaceTriangles[ i * 3 ] ];                     let pointB = keypoints[ FaceTriangles[ i * 3 + 1 ] ];                     let pointC = keypoints[ FaceTriangles[ i * 3 + 2 ] ];                     drawTriangle( output, pointA[ 0 ], pointA[ 1 ], pointB[ 0 ], pointB[ 1 ], pointC[ 0 ], pointC[ 1 ], scale );                 }                  \/\/ Add just the nose, cheeks, eyes, eyebrows &amp; mouth                 const features = [                     \"noseTip\",                     \"leftCheek\",                     \"rightCheek\",                     \"leftEyeLower1\", \"leftEyeUpper1\",                     \"rightEyeLower1\", \"rightEyeUpper1\",                     \"leftEyebrowLower\", \/\/\"leftEyebrowUpper\",                     \"rightEyebrowLower\", \/\/\"rightEyebrowUpper\",                     \"lipsLowerInner\", \/\/\"lipsLowerOuter\",                     \"lipsUpperInner\", \/\/\"lipsUpperOuter\",                 ];                 let points = [];                 features.forEach( feature =&gt; {                     face.annotations[ feature ].forEach( x =&gt; {                         points.push( ( x[ 0 ] - x1 ) \/ bWidth );                         points.push( ( x[ 1 ] - y1 ) \/ bHeight );                     });                 });                 \/\/ Only grab the faces that are confident                 if( face.faceInViewConfidence &gt; 0.9 ) {                     trainingData.push({                         input: points,                         output: ferData[ setIndex ].emotion,                     });                 }             });              setText( `${setIndex + 1}. Face Tracking Confidence: ${face.faceInViewConfidence.toFixed( 3 )} - ${ferData[ setIndex ].emotion}` );             setIndex++;             requestAnimationFrame( trackFace );         }          (async () =&gt; {             \/\/ Get FER-2013 data from the local web server             \/\/ https:\/\/www.kaggle.com\/msambare\/fer2013             \/\/ The data can be downloaded from Kaggle and placed inside the \"web\/fer2013\" folder             \/\/ Get the lowest number of samples out of all emotion categories             const minSamples = Math.min( ...Object.keys( fer2013 ).map( em =&gt; fer2013[ em ].length ) );             Object.keys( fer2013 ).forEach( em =&gt; {                 shuffleArray( fer2013[ em ] );                 for( let i = 0; i &lt; minSamples; i++ ) {                     ferData.push({                         emotion: em,                         file: fer2013[ em ][ i ]                     });                 }             });             shuffleArray( ferData );              let canvas = document.getElementById( \"output\" );             canvas.width = OUTPUT_SIZE;              canvas.height = OUTPUT_SIZE;               output = canvas.getContext( \"2d\" );             output.translate( canvas.width, 0 );             output.scale( -1, 1 ); \/\/ Mirror cam             output.fillStyle = \"#fdffb6\";             output.strokeStyle = \"#fdffb6\";             output.lineWidth = 2;               \/\/ Load Face Landmarks Detection             model = await faceLandmarksDetection.load(                 faceLandmarksDetection.SupportedPackages.mediapipeFacemesh             );              setText( \"Loaded!\" );              trackFace();         })();         &lt;\/script&gt;     &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>2. \u041e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0446\u0438\u0439 \u043d\u0430 \u043b\u0438\u0446\u0435<\/h2>\n<p>\u041c\u044b \u043f\u043e\u0447\u0442\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u043b\u0438 \u0441\u0432\u043e\u0435\u0439 \u0446\u0435\u043b\u0438. \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u044d\u043c\u043e\u0446\u0438\u0439 \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u0435\u0451 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435. \u041d\u0430 \u044d\u0442\u043e\u0439 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c TensorFlow \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0445 \u043b\u0438\u0446\u0430\u0445 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 FER.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u044d\u043c\u043e\u0446\u0438\u0439 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u044f\u043c\u043e \u043f\u043e\u0434 \u043a\u043e\u0434\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432 \u043b\u0438\u0446\u0430. \u041e\u0431\u0443\u0447\u0438\u0432 \u0441\u0432\u043e\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0447\u0430\u0441\u0442\u0438&nbsp;1, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043c\u0435\u0441\u0442\u043e\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">let emotionModel = null;  (async () =&gt; {     ...     \/\/ Load Face Landmarks Detection     model = await faceLandmarksDetection.load(         faceLandmarksDetection.SupportedPackages.mediapipeFacemesh     );     \/\/ Load Emotion Detection     emotionModel = await tf.loadLayersModel( 'web\/model\/facemo.json' );     ... })();<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043c\u043e\u0434\u0435\u043b\u044c \u043a \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043b\u0438\u0446\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0439 \u044d\u043c\u043e\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">async function predictEmotion( points ) {     let result = tf.tidy( () =&gt; {         const xs = tf.stack( [ tf.tensor1d( points ) ] );         return emotionModel.predict( xs );     });     let prediction = await result.data();     result.dispose();     \/\/ Get the index of the maximum value     let id = prediction.indexOf( Math.max( ...prediction ) );     return emotions[ id ]; }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043c\u0435\u0436\u0434\u0443 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0430\u0443\u0437\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e wait:<\/p>\n<pre><code class=\"javascript\">function wait( ms ) {     return new Promise( res =&gt; setTimeout( res, ms ) ); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u0435\u0435 \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0437\u044f\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043b\u0438\u0446\u0430, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u044d\u043c\u043e\u0446\u0438\u0439 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u0439 \u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c 2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<pre><code class=\"javascript\">async function trackFace() {     ...      let points = null;     faces.forEach( face =&gt; {         ...          \/\/ Add just the nose, cheeks, eyes, eyebrows &amp; mouth         const features = [             \"noseTip\",             \"leftCheek\",             \"rightCheek\",             \"leftEyeLower1\", \"leftEyeUpper1\",             \"rightEyeLower1\", \"rightEyeUpper1\",             \"leftEyebrowLower\", \/\/\"leftEyebrowUpper\",             \"rightEyebrowLower\", \/\/\"rightEyebrowUpper\",             \"lipsLowerInner\", \/\/\"lipsLowerOuter\",             \"lipsUpperInner\", \/\/\"lipsUpperOuter\",         ];         points = [];         features.forEach( feature =&gt; {             face.annotations[ feature ].forEach( x =&gt; {                 points.push( ( x[ 0 ] - x1 ) \/ bWidth );                 points.push( ( x[ 1 ] - y1 ) \/ bHeight );             });         });     });      if( points ) {         let emotion = await predictEmotion( points );         setText( `${setIndex + 1}. Expected: ${ferData[ setIndex ].emotion} vs. ${emotion}` );     }     else {         setText( \"No Face\" );     }      setIndex++;     await wait( 2000 );     requestAnimationFrame( trackFace ); }<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/043\/467\/ced\/043467ced9fe1ca02d3336aa7b032763.jpg\" width=\"609\" height=\"221\"><figcaption><\/figcaption><\/figure>\n<p>\u0413\u043e\u0442\u043e\u0432\u043e! \u041d\u0430\u0448 \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u043c\u043e\u0446\u0438\u0438 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u0445 FER \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439 \u044d\u043c\u043e\u0446\u0438\u0435\u0439. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435, \u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h2>2. \u0424\u0438\u043d\u0438\u0448\u043d\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f<\/h2>\n<details class=\"spoiler\">\n<summary>\u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 FER:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;html&gt;     &lt;head&gt;         &lt;title&gt;Running - Recognizing Facial Expressions in the Browser with Deep Learning using TensorFlow.js&lt;\/title&gt;         &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@tensorflow\/tfjs@2.4.0\/dist\/tf.min.js\"&gt;&lt;\/script&gt;         &lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@tensorflow-models\/face-landmarks-detection@0.0.1\/dist\/face-landmarks-detection.js\"&gt;&lt;\/script&gt;         &lt;script src=\"web\/fer2013.js\"&gt;&lt;\/script&gt;     &lt;\/head&gt;     &lt;body&gt;         &lt;canvas id=\"output\"&gt;&lt;\/canvas&gt;         &lt;img id=\"image\" style=\"             visibility: hidden;             width: auto;             height: auto;             \"\/&gt;         &lt;h1 id=\"status\"&gt;Loading...&lt;\/h1&gt;         &lt;script&gt;         function setText( text ) {             document.getElementById( \"status\" ).innerText = text;         }          async function setImage( url ) {             return new Promise( res =&gt; {                 let image = document.getElementById( \"image\" );                 image.src = url;                 image.onload = () =&gt; {                     res();                 };             });         }          function shuffleArray( array ) {             for( let i = array.length - 1; i &gt; 0; i-- ) {                 const j = Math.floor( Math.random() * ( i + 1 ) );                 [ array[ i ], array[ j ] ] = [ array[ j ], array[ i ] ];             }         }          function drawLine( ctx, x1, y1, x2, y2, scale = 1 ) {             ctx.beginPath();             ctx.moveTo( x1 * scale, y1 * scale );             ctx.lineTo( x2 * scale, y2 * scale );             ctx.stroke();         }          function drawTriangle( ctx, x1, y1, x2, y2, x3, y3, scale = 1 ) {             ctx.beginPath();             ctx.moveTo( x1 * scale, y1 * scale );             ctx.lineTo( x2 * scale, y2 * scale );             ctx.lineTo( x3 * scale, y3 * scale );             ctx.lineTo( x1 * scale, y1 * scale );             ctx.stroke();         }          function wait( ms ) {             return new Promise( res =&gt; setTimeout( res, ms ) );         }          const OUTPUT_SIZE = 500;         const emotions = [ \"angry\", \"disgust\", \"fear\", \"happy\", \"neutral\", \"sad\", \"surprise\" ];         let ferData = [];         let setIndex = 0;         let emotionModel = null;          let output = null;         let model = null;          async function predictEmotion( points ) {             let result = tf.tidy( () =&gt; {                 const xs = tf.stack( [ tf.tensor1d( points ) ] );                 return emotionModel.predict( xs );             });             let prediction = await result.data();             result.dispose();             \/\/ Get the index of the maximum value             let id = prediction.indexOf( Math.max( ...prediction ) );             return emotions[ id ];         }          async function trackFace() {             \/\/ Set to the next training image             await setImage( ferData[ setIndex ].file );             const image = document.getElementById( \"image\" );             const faces = await model.estimateFaces( {                 input: image,                 returnTensors: false,                 flipHorizontal: false,             });             output.drawImage(                 image,                 0, 0, image.width, image.height,                 0, 0, OUTPUT_SIZE, OUTPUT_SIZE             );              const scale = OUTPUT_SIZE \/ image.width;              let points = null;             faces.forEach( face =&gt; {                 \/\/ Draw the bounding box                 const x1 = face.boundingBox.topLeft[ 0 ];                 const y1 = face.boundingBox.topLeft[ 1 ];                 const x2 = face.boundingBox.bottomRight[ 0 ];                 const y2 = face.boundingBox.bottomRight[ 1 ];                 const bWidth = x2 - x1;                 const bHeight = y2 - y1;                 drawLine( output, x1, y1, x2, y1, scale );                 drawLine( output, x2, y1, x2, y2, scale );                 drawLine( output, x1, y2, x2, y2, scale );                 drawLine( output, x1, y1, x1, y2, scale );                  \/\/ Add just the nose, cheeks, eyes, eyebrows &amp; mouth                 const features = [                     \"noseTip\",                     \"leftCheek\",                     \"rightCheek\",                     \"leftEyeLower1\", \"leftEyeUpper1\",                     \"rightEyeLower1\", \"rightEyeUpper1\",                     \"leftEyebrowLower\", \/\/\"leftEyebrowUpper\",                     \"rightEyebrowLower\", \/\/\"rightEyebrowUpper\",                     \"lipsLowerInner\", \/\/\"lipsLowerOuter\",                     \"lipsUpperInner\", \/\/\"lipsUpperOuter\",                 ];                 points = [];                 features.forEach( feature =&gt; {                     face.annotations[ feature ].forEach( x =&gt; {                         points.push( ( x[ 0 ] - x1 ) \/ bWidth );                         points.push( ( x[ 1 ] - y1 ) \/ bHeight );                     });                 });             });              if( points ) {                 let emotion = await predictEmotion( points );                 setText( `${setIndex + 1}. Expected: ${ferData[ setIndex ].emotion} vs. ${emotion}` );             }             else {                 setText( \"No Face\" );             }              setIndex++;             await wait( 2000 );             requestAnimationFrame( trackFace );         }          (async () =&gt; {             \/\/ Get FER-2013 data from the local web server             \/\/ https:\/\/www.kaggle.com\/msambare\/fer2013             \/\/ The data can be downloaded from Kaggle and placed inside the \"web\/fer2013\" folder             \/\/ Get the lowest number of samples out of all emotion categories             const minSamples = Math.min( ...Object.keys( fer2013 ).map( em =&gt; fer2013[ em ].length ) );             Object.keys( fer2013 ).forEach( em =&gt; {                 shuffleArray( fer2013[ em ] );                 for( let i = 0; i &lt; minSamples; i++ ) {                     ferData.push({                         emotion: em,                         file: fer2013[ em ][ i ]                     });                 }             });             shuffleArray( ferData );              let canvas = document.getElementById( \"output\" );             canvas.width = OUTPUT_SIZE;              canvas.height = OUTPUT_SIZE;               output = canvas.getContext( \"2d\" );             output.translate( canvas.width, 0 );             output.scale( -1, 1 ); \/\/ Mirror cam             output.fillStyle = \"#fdffb6\";             output.strokeStyle = \"#fdffb6\";             output.lineWidth = 2;               \/\/ Load Face Landmarks Detection             model = await faceLandmarksDetection.load(                 faceLandmarksDetection.SupportedPackages.mediapipeFacemesh             );             \/\/ Load Emotion Detection             emotionModel = await tf.loadLayersModel( 'web\/model\/facemo.json' );              setText( \"Loaded!\" );              trackFace();         })();         &lt;\/script&gt;     &lt;\/body&gt; &lt;\/html&gt;<\/code><\/pre>\n<\/div>\n<\/details>\n<h2>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u041f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430\u0448\u0438 \u044d\u043c\u043e\u0446\u0438\u0438 \u043d\u0430 \u043b\u0438\u0446\u0435?<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043b\u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432 \u043b\u0438\u0446\u0430 TensorFlow \u0441 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0447\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435. \u041d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0441\u0442\u0430\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u043c\u043e\u0446\u0438\u0439 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u043b\u0438\u0446\u0435.<\/p>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043c\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0441 \u0432\u0435\u0431-\u043a\u0430\u043c\u0435\u0440\u044b \u0432\u0438\u0434\u0435\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u043b\u0438\u0446\u0430, \u0443\u0437\u043d\u0430\u0435\u043c, \u0441\u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0435\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043b\u0438\u0446\u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. <strong>\u0414\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438 \u0437\u0430\u0432\u0442\u0440\u0430, \u0432 \u044d\u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f.<\/strong><\/p>\n<figure class=\"float\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ba\/890\/ab4\/5ba890ab43a4903dd93e7fb7aaacdab3.png\" width=\"212\" height=\"221\"><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/skillfactory.ru\/courses\/?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_ALLCOURSES&amp;utm_term=regular&amp;utm_content=230221\">\u0423\u0437\u043d\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438<\/a>, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c Level Up \u043f\u043e \u043d\u0430\u0432\u044b\u043a\u0430\u043c \u0438 \u0437\u0430\u0440\u043f\u043b\u0430\u0442\u0435 \u0438\u043b\u0438 \u0432\u043e\u0441\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044e \u0441 \u043d\u0443\u043b\u044f, \u043f\u0440\u043e\u0439\u0434\u044f \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u044b SkillFactory \u0441\u043e \u0441\u043a\u0438\u0434\u043a\u043e\u0439 40% \u0438 \u043f\u0440\u043e\u043c\u043e\u043a\u043e\u0434\u043e\u043c&nbsp;<strong>HABR<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0441\u0442 \u0435\u0449\u0435 +10% \u0441\u043a\u0438\u0434\u043a\u0438 \u043d\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/dstpro?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DSPR&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Scientist<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/dataanalystpro?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DAPR&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Data Analyst<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/dataengineer?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DEA&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 \u043f\u043e Data Engineering  <\/a>    <\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary><\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u0438 \u0438 \u043a\u0443\u0440\u0441\u044b<\/p>\n<p><strong>\u041f\u0420\u041e\u0424\u0415\u0421\u0421\u0418\u0418<\/strong>      <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/java?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_JAVA&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Java-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/java-qa-engineer?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_QAJA&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f QA-\u0438\u043d\u0436\u0435\u043d\u0435\u0440 \u043d\u0430 JAVA<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/frontend?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_FR&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Frontend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/cybersecurity?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_HACKER&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u042d\u0442\u0438\u0447\u043d\u044b\u0439 \u0445\u0430\u043a\u0435\u0440<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/cplus?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_CPLUS&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f C++ \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/game-dev?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_GAMEDEV&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0433\u0440 \u043d\u0430 Unity<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/webdev?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_WEBDEV&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f \u0412\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/iosdev?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_IOSDEV&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441 \u043d\u0443\u043b\u044f<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/android?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_ANDR&amp;utm_term=regular&amp;utm_content=020321\">\u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u044f Android-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441 \u043d\u0443\u043b\u044f<\/a><\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041a\u0423\u0420\u0421\u042b<\/strong>      <\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/ml-programma-machine-learning-online?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_ML&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 \u043f\u043e Machine Learning<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/math_and_ml?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_MATML&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 &#171;\u041c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430 \u0438 Machine Learning \u0434\u043b\u044f Data Science&#187;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/ml-and-dl?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_MLDL&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 &#171;Machine Learning \u0438 Deep Learning&#187;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/python-for-web-developers?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_PWS&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 &#171;Python \u0434\u043b\u044f \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438&#187;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/algo?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_algo&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 &#171;\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445&#187;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/analytics?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_SDA&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 \u043f\u043e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/skillfactory.ru\/devops?utm_source=infopartners&amp;utm_medium=habr&amp;utm_campaign=habr_DEVOPS&amp;utm_term=regular&amp;utm_content=020321\">\u041a\u0443\u0440\u0441 \u043f\u043e DevOps<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/details>\n<\/div>\n<p> \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\/company\/skillfactory\/blog\/544850\/\"> https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/544850\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/company\/skillfactory\/blog\/544846\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0418\u0418 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u044b \u043b\u0438\u0446. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u044b \u043b\u0438\u0446\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043b\u0438\u0446\u0435 \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u044b \u043b\u0438\u0446\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043b\u0438\u0446\u0435 \u0438\u0437 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u0446\u0430\u0445 \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 FER+ \u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u043c\u043e\u0446\u0438\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u043e \u0442\u043e\u0447\u043a\u0430\u043c \u043b\u0438\u0446\u0430 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TensorFlow.js.<\/p>\n<p>\u0421\u043e\u0435\u0434\u0438\u043d\u0438\u0432 \u043d\u0430\u0448 \u043a\u043e\u0434 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0441 <a href=\"https:\/\/github.com\/microsoft\/FERPlus\">\u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431 \u044d\u043c\u043e\u0446\u0438\u044f\u0445 \u043d\u0430 \u043b\u0438\u0446\u0435 FER<\/a>, \u043c\u044b \u043e\u0431\u0443\u0447\u0438\u043c \u0432\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u044d\u043c\u043e\u0446\u0438\u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c.<\/p>\n<hr>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0434\u0435\u043c\u043e\u0432\u0435\u0440\u0441\u0438\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0414\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u0432\u0435\u0431-\u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 WebGL. \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c <a href=\"https:\/\/www.codeproject.com\/KB\/AI\/5293492\/AIFaceFilters.zip\">\u043a\u043e\u0434 \u0438 \u0444\u0430\u0439\u043b\u044b<\/a> \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0431 \u044d\u043c\u043e\u0446\u0438\u044f\u0445 \u043d\u0430 \u043b\u0438\u0446\u0435 FER2013<\/h2>\n<p>\u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u041e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u0418\u0418 \u043d\u0430 \u0442\u043e\u0447\u043a\u0430\u0445 \u043e\u0442\u0441\u043b\u0435\u0436\u0435\u043d\u043d\u044b\u0445 \u043b\u0438\u0446 \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 FER, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0451 \u043a \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0451 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043e \u043b\u0438\u0446\u0430\u0445. \u041d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 FER2013 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0438\u0437 28 \u0442\u044b\u0441\u044f\u0447 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043b\u0438\u0446; \u043e\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043d\u0430 \u0432\u0435\u0431-\u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/www.kaggle.com\/c\/challenges-in-representation-learning-facial-expression-recognition-challenge\/data\">Kaggle<\/a>. \u041c\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0438 <a href=\"https:\/\/www.kaggle.com\/msambare\/fer2013\">\u044d\u0442\u0443 \u0432\u0435\u0440\u0441\u0438\u044e<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0436\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d \u0432 \u0444\u0430\u0439\u043b\u044b \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439, \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043b\u0438 \u0435\u0451 \u0432 \u043f\u0430\u043f\u043a\u0443 <em>web\/fer2013<\/em><strong>.<\/strong> \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u043b\u0438 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 NodeJS \u0432 <em>index.js<\/em>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:8080\/data\/\">http:\/\/localhost:8080\/data\/<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 JSON, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443, \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 JSON \u0432 \u0444\u0430\u0439\u043b\u0435 <em>web\/fer2013.js<\/em>, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u0432 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"javascript\">&lt;script src=\"web\/fer2013.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<p>\u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043d\u0435 \u0441 \u0432\u0438\u0434\u0435\u043e \u0441 \u0432\u0435\u0431-\u043a\u0430\u043c\u0435\u0440\u044b (\u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u0439\u0442\u0435\u0441\u044c, \u043c\u044b \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u0432\u0438\u0434\u0435\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442<code>&lt;video&gt;<\/code> \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c <code>&lt;img&gt;<\/code>\u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e ID \u0432 \u00abimage\u00bb. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u043c \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>setupWebcam<\/code>, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043e\u043d\u0430 \u043d\u0435 \u043d\u0443\u0436\u043d\u0430.<\/p>\n<pre><code class=\"javascript\">&lt;img id=\"image\" style=\"     visibility: hidden;     width: auto;     height: auto;     \"\/&gt;<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0434\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a \u043a\u0430\u043a \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0441\u0435\u0433\u043e 48&#215;48 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0437\u0430\u0434\u0430\u0434\u0438\u043c 500 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0446 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0435 canvas. \u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043b\u0438\u043d\u0438\u0439 \u0438 \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"javascript\">async function setImage( url ) {     return new Promise( res =&gt; {         let image = document.getElementById( \"image\" );         image.src = url;         image.onload = () =&gt; {             res();         };     }); }  function shuffleArray( array ) {     for( let i = array.length - 1; i &gt; 0; i-- ) {         const j = Math.floor( Math.random() * ( i + 1 ) );         [ array[ i ], array[ j ] ] = [ array[ j ], array[ i ] ];     } }  const OUTPUT_SIZE = 500;<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u044d\u043c\u043e\u0446\u0438\u0439, \u0441\u043f\u0438\u0441\u043a\u0430 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 FER \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430:<\/p>\n<pre><code class=\"javascript\">const emotions = [ \"angry\", \"disgust\", \"fear\", \"happy\", \"neutral\", \"sad\", \"surprise\" ]; let ferData = []; let setIndex = 0;<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0431\u043b\u043e\u043a\u0430 async \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 FER \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 canvas \u0434\u043e 500&#215;500 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439:<\/p>\n<pre><code class=\"javascript\">const minSamples = Math.min( ...Object.keys( fer2013 ).map( em =&gt; fer2013[ em ].length ) ); Object.keys( fer2013 ).forEach( em =&gt; {     shuffleArray( fer2013[ em ] );     for( let i = 0; i &lt; minSamples; i++ ) {         ferData.push({             emotion: em,             file: fer2013[ em ][ i ]         });     } }); shuffleArray( ferData );  let canvas = document.getElementById( \"output\" ); canvas.width = OUTPUT_SIZE; canvas.height = OUTPUT_SIZE;<\/code><\/pre>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d \u043a\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u0438 \u0418\u0418 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>trackFace<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c image, \u0430 \u043d\u0435 video. \u0422\u0430\u043a\u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0442\u043a\u0438 \u0434\u043b\u044f \u043b\u0438\u0446\u0430 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 canvas. \u041c\u044b \u0437\u0430\u0434\u0430\u0434\u0438\u043c \u043f\u0440\u0438\u0440\u0430\u0449\u0435\u043d\u0438\u0435 <code>setIndex<\/code> \u0432 \u043a\u043e\u043d\u0446\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044e.<\/p>\n<pre><code class=\"javascript\">async function trackFace() {     \/\/ Set to the next training image     await setImage( ferData[ setIndex ].file );     const image = document.getElementById( \"image\" );     const faces = await model.estimateFaces( {         input: image,         returnTensors: false,         flipHorizontal: false,     });     output.drawImage(         image,         0, 0, image.width, image.height,         0, 0, OUTPUT_SIZE, OUTPUT_SIZE     );      const scale = OUTPUT_SIZE \/ image.width;      faces.forEach( face =&gt; {         \/\/ Draw the bounding box         const x1 = face.boundingBox.topLeft[ 0 ];         const y1 = face.boundingBox.topLeft[ 1 ];         const x2 = face.boundingBox.bottomRight[ 0 ];         const y2 = face.boundingBox.bottomRight[ 1 ];         const bWidth = x2 - x1;         const bHeight = y2 - y1;         drawLine( output, x1, y1, x2, y1, scale );         drawLine( output, x2, y1, x2, y2, scale );         drawLine( output, x1, y2, x2, y2, scale );         drawLine( output, x1, y1, x1, y2, scale );          \/\/ Draw the face mesh         const keypoints = face.scaledMesh;         for( let i = 0; i &lt; FaceTriangles.length \/ 3; i++ ) {             let pointA = keypoints[ FaceTriangles[ i * 3 ] ];             let pointB = keypoints[ FaceTriangles[ i * 3 + 1 ] ];             let pointC = keypoints[ FaceTriangles[ i * 3 + 2 ] ];             drawTriangle( output, pointA[ 0 ], pointA[ 1 ], pointB[ 0 ], pointB[ 1 ], pointC[ 0 ], pointC[ 1 ], scale );         }     });      setText( `${setIndex + 1}. Face Tracking Confidence: ${face.faceInViewConfidence.toFixed( 3 )} - ${ferData[ setIndex ].emotion}` );     setIndex++;     requestAnimationFrame( trackFace ); }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0433\u043e\u0442\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0434\u0432\u0435 \u043a\u043e\u043f\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0437\u0430\u0434\u0430\u0442\u044c \u0434\u043b\u044f \u0433\u043b\u0443\u0431\u043e\u043a\u043e\u0433\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u0430 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443&nbsp;<a href=\"https:\/\/www.codeproject.com\/KB\/AI\/5293492\/AIFaceFilters.zip\"><strong>\u2013<\/strong><\/a> \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>1. \u0413\u043b\u0443\u0431\u043e\u043a\u043e\u0435 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u044d\u043c\u043e\u0446\u0438\u0439 \u043d\u0430 \u043b\u0438\u0446\u0435<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0432\u0435\u0431-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0437\u0430\u0434\u0430\u0442\u044c \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u0435\u0451 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0435\u0441\u0430 \u0432 \u0444\u0430\u0439\u043b. \u0412 \u043a\u043e\u0434 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c (\u0441\u043c. \u043f\u0430\u043f\u043a\u0443 <em>web\/model<\/em>), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u0447\u0430\u0441\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0447\u0430\u0441\u0442\u0438&nbsp;2.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u043a \u044d\u043c\u043e\u0446\u0438\u0439 \u0432 \u0443\u043d\u0438\u0442\u0430\u0440\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"javascript\">let trainingData = [];  function emotionToArray( emotion ) {     let array = [];     for( let i = 0; i &lt; emotions.length; i++ ) {         array.push( emotion === emotions[ i ] ? 1 : 0 );     }     return array; }<\/code><\/pre>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>trackFace<\/code> \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0447\u0435\u0440\u0442\u044b \u043b\u0438\u0446\u0430, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c \u0438\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0445 \u0432 \u043d\u0430\u0431\u043e\u0440 \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u043e. \u041c\u044b \u0437\u0430\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0435\u0440\u0442\u044b \u043b\u0438\u0446\u0430, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0435, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<pre><code class=\"javascript\">\/\/ Add just the nose, cheeks, eyes, eyebrows &amp; mouth const features = [     \"noseTip\",     \"leftCheek\",     \"rightCheek\",     \"leftEyeLower1\", \"leftEyeUpper1\",     \"rightEyeLower1\", \"rightEyeUpper1\",     \"leftEyebrowLower\", \/\/\"leftEyebrowUpper\",     \"rightEyebrowLower\", \/\/\"rightEyebrowUpper\",     \"lipsLowerInner\", \/\/\"lipsLowerOuter\",     \"lipsUpperInner\", \/\/\"lipsUpperOuter\", ]; let points = []; features.forEach( feature =&gt; {     face.annotations[ feature ].forEach( x =&gt; {         points.push( ( x[ 0 ] - x1 ) \/ bWidth );         points.push( ( x[ 1 ] - y1 ) \/ bHeight );     }); }); \/\/ Only grab the faces that are confident if( face.faceInViewConfidence &gt; 0.9 ) {     trainingData.push({         input: points,         output: ferData[ setIndex ].emotion,     }); }<\/code><\/pre>\n<p>\u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0432 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 trainNet<strong>.<\/strong> \u0412 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>trackFace<\/code> \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u0446\u0438\u043a\u043b \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u043b\u0438\u0446 \u0438 \u0432\u044b\u0439\u0434\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435 200 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">async function trackFace() {     \/\/ Fast train on just 200 of the images     if( setIndex &gt;= 200 ) {         setText( \"Finished!\" );         trainNet();         return;     }     ... }<\/code><\/pre>\n<p>\u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u044b \u043f\u0440\u0438\u0448\u043b\u0438 \u043a \u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0442\u0430\u043a \u0434\u043e\u043b\u0433\u043e \u0436\u0434\u0430\u043b\u0438: \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>trainNet<\/code><strong> <\/strong>\u0438 \u043e\u0431\u0443\u0447\u0438\u043c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0418\u0418!<\/p>\n<p>\u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0443\u043d\u0438\u0442\u0430\u0440\u043d\u044b\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u044d\u043c\u043e\u0446\u0438\u0439, \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c TensorFlow \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u044f\u043c\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0437\u0430 1000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c. \u0427\u0442\u043e\u0431\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u0447\u0438\u0441\u043b\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c.<\/p>\n<pre><code class=\"javascript\">async function trainNet() {     let inputs = trainingData.map( x =&gt; x.input );     let outputs = trainingData.map( x =&gt; emotionToArray( x.output ) );      \/\/ Define our model with several hidden layers     const model = tf.sequential();     model.add(tf.layers.dense( { units: 100, activation: \"relu\", inputShape: [ inputs[ 0 ].length ] } ) );     model.add(tf.layers.dense( { units: 100, activation: \"relu\" } ) );     model.add(tf.layers.dense( { units: 100, activation: \"relu\" } ) );     model.add(tf.layers.dense( {         units: emotions.length,         kernelInitializer: 'varianceScaling',         useBias: false,         activation: \"softmax\"     } ) );      model.compile({         optimizer:<\/code><\/pre>\n<\/hr>\n<p><\/br><\/p>\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-318919","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318919","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=318919"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/318919\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}