{"id":298638,"date":"2020-02-13T15:00:25","date_gmt":"2020-02-13T15:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=298638"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-02-13T15:00:25","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=298638","title":{"rendered":"\u0420\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 android \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e TensorFlow: \u043e\u0442 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/redmadrobot\/blog\/488210\/\">\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044e \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u2014 \u0434\u043e\u043b\u0433\u0438\u0439 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0435\u043c\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e\u0439 \u043d\u043e\u0443\u0442, \u0430 \u043d\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441 \u043c\u043e\u0449\u043d\u043e\u0439 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u043e\u0439. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0434\u0451\u0442 <a href=\"https:\/\/colab.research.google.com\/\">Google Colaboratory<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f GPU \u0443\u0440\u043e\u0432\u043d\u044f Tesla K80 (<a href=\"https:\/\/colab.research.google.com\/drive\/151805XTDg--dgHb3-AXJCpnWaqRhop_2\">\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/a>).<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 tensorflow \u0432 Google Colaboratory \u0438 \u0435\u0451 \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430 android \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"podgotovka-dannyh\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0431\u0435\u043b\u044b\u0435 \u0438\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u0441\u0442\u0438 \u043d\u0430 \u0447\u0435\u0440\u043d\u043e\u043c \u0444\u043e\u043d\u0435. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0439 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (\u043f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 ~100 \u0444\u043e\u0442\u043e).<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/q1\/a9\/7z\/q1a97zueu96rei1w4tx2bxmlpzg.png\"><\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u0414\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f <a href=\"https:\/\/github.com\/tensorflow\/models\/tree\/master\/research\/object_detection\">Tensorflow Object Detection API<\/a>. \u0412\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u043d\u0430 \u043d\u043e\u0443\u0442\u0431\u0443\u043a\u0435. \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 <strong>conda<\/strong>. \u0418\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 <a href=\"https:\/\/docs.conda.io\/projects\/conda\/en\/latest\/user-guide\/install\/index.html\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">conda create -n object_detection_prepare pip python=3.6<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">conda activate object_detection_prepare<\/code><\/pre>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">pip install --ignore-installed --upgrade tensorflow==1.14 pip install --ignore-installed pandas pip install --ignore-installed Pillow pip install lxml conda install pyqt=5<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <strong>object_detection<\/strong>, \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0432\u0441\u0435 \u043d\u0430\u0448\u0438 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>object_detection\/images<\/strong>.<\/p>\n<p>  <\/p>\n<blockquote><p>\u0412 Google Colab \u0435\u0441\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439, \u0447\u0442\u043e\u0431\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 <strong>&quot;tcmalloc: large alloc&#8230;.&quot;<\/strong>.<\/p><\/blockquote>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <strong>object_detection\/preprocessing<\/strong> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0435\u0451 <a href=\"https:\/\/github.com\/AleksandrTabolin\/tensorflow_object_detector_with_colab\/tree\/master\/object_detection\/preprocessing\">\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435<\/a> \u0441\u043a\u0440\u0438\u043f\u0442\u044b.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0444\u043e\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">python .\/object_detection\/preprocessing\/image_resize.py -i .\/object_detection\/images --imageWidth=800 --imageHeight=600<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u0442\u0441\u044f \u043f\u043e \u043f\u0430\u043f\u043a\u0435 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0444\u043e\u0442\u043e, \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043e 800&#215;600 \u0438 \u0441\u043b\u043e\u0436\u0438\u0442 \u0438\u0445 \u0432 <strong>object_detection\/images\/resized<\/strong>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u043c\u0438 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0432 <strong>object_detection\/images<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0443\u043b\u0437\u043e\u0439 <a href=\"https:\/\/github.com\/tzutalin\/labelImg\">labelImg<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 <strong>labelImg<\/strong> \u0432 <strong>object_detection<\/strong><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 <strong>labelImg<\/strong> <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd [FULL_PATH]\/object_detection\/labelImg <\/code><\/pre>\n<p>  <\/p>\n<p>\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443: <\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">pyrcc5 -o libs\/resources.py resources.qrc<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 (\u044d\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u0434\u043e\u043b\u0433\u0438\u0439 \u0438 \u0441\u043a\u0443\u0447\u043d\u044b\u0439 \u044d\u0442\u0430\u043f):<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">python labelImg.py<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dg\/-4\/ho\/dg-4hojgkwt6irfuphncnnnulhq.png\"><\/p>\n<p>  <\/p>\n<p>\u0412 \u201cOpen dir\u201d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 <strong>object_detection\/images<\/strong> \u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0432\u0441\u0435\u043c \u0444\u043e\u0442\u043e, \u0432\u044b\u0434\u0435\u043b\u044f\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043b\u044f \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u0438\u0445 \u043a\u043b\u0430\u0441\u0441. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043d\u043e\u043c\u0438\u043d\u0430\u043b\u044b \u0438\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u0441\u0442\u0435\u0439 (1, 2, 3, 4, 5, 6). \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 (\u0444\u0430\u0439\u043b\u044b *.xml) \u0432 \u0442\u043e\u0439 \u0436\u0435 \u043f\u0430\u043f\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <strong>object_detection\/training_demo<\/strong>, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u0437\u0430\u043b\u044c\u0435\u043c \u0432 Google Colab \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430\u0448\u0438 \u0444\u043e\u0442\u043e (\u0441 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438) \u043d\u0430 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0432 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 <strong>80\/20<\/strong> \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0438\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 <strong>object_detection\/training_demo\/images\/train<\/strong> \u0438 <strong>object_detection\/training_demo\/images\/test<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u043f\u043a\u0443 <strong>object_detection\/training_demo\/annotations<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0441 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f. \u041f\u0435\u0440\u0432\u044b\u043c \u0438\u0437 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 <strong>label_map.pbtxt<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u043a\u0430\u0436\u0435\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">label_map.pbtxt<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"json\">item {     id: 1     name: '1' }  item {     id: 2     name: '2' }  item {     id: 3     name: '3' }  item {     id: 4     name: '4' }  item {     id: 5     name: '5' }  item {     id: 6     name: '6' }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445? \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 <a href=\"https:\/\/www.tensorflow.org\/tutorials\/load_data\/tf_records\">TFRecord<\/a>. \u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438 \u0438\u0437 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 [1].<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430: <strong>xml<\/strong> -&gt; <strong>csv<\/strong> \u0438 <strong>csv<\/strong> -&gt; <strong>record<\/strong><\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 preprocessing :<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cd [FULL_PATH]\\object_detection\\preprocessing<\/code><\/pre>\n<p>  <\/p>\n<p><strong>1.<\/strong>\u0418\u0437 xml \u0432 csv<\/p>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">python xml_to_csv.py -i [FULL_PATH]\/object_detection\/training_demo\/images\/train -o [FULL_PATH]\/object_detection\/training_demo\/annotations\/train_labels.csv<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">python xml_to_csv.py -i [FULL_PATH]\/object_detection\/training_demo\/images\/test -o [FULL_PATH]\/object_detection\/training_demo\/annotations\/test_labels.csv<\/code><\/pre>\n<p>  <\/p>\n<p><strong>2.<\/strong> \u0418\u0437 csv \u0432 record<\/p>\n<p>  <\/p>\n<p>\u0422\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">python generate_tfrecord.py --label_map_path=[FULL_PATH]\\object_detection\\training_demo\\annotations\\label_map.pbtxt --csv_input=[FULL_PATH]\\object_detection\\training_demo\\annotations\\train_labels.csv --output_path=[FULL_PATH]\\object_detection\\training_demo\\annotations\\train.record --img_path=[FULL_PATH]\\object_detection\\training_demo\\images\\train<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">python generate_tfrecord.py --label_map_path=[FULL_PATH]\\object_detection\\training_demo\\annotations\\label_map.pbtxt --csv_input=[FULL_PATH]\\object_detection\\training_demo\\annotations\\test_labels.csv --output_path=[FULL_PATH]\\object_detection\\training_demo\\annotations\\test.record --img_path=[FULL_PATH]\\object_detection\\training_demo\\images\\test<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0443\u0447\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/tensorflow\/models\/blob\/master\/research\/object_detection\/g3doc\/detection_model_zoo.md\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c <strong>ssdlite_mobilenet_v2_coco<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 <strong>android<\/strong> \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435.<\/p>\n<p>  <\/p>\n<p>\u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0430\u0440\u0445\u0438\u0432 \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0438 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 <strong>object_detection\/training_demo\/pre-trained-model<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435<br \/>  <strong>object_detection\/training_demo\/pre-trained-model\/ssdlite_mobilenet_v2_coco_2018_05_09<\/strong><\/p>\n<p>  <\/p>\n<p>\u0418\u0437 \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 \u043a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <strong>pipeline.config<\/strong> \u0432 <strong>object_detection\/training_demo\/training<\/strong> \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 <strong>ssdlite_mobilenet_v2_coco.config<\/strong>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0434 \u0441\u0432\u043e\u044e \u0437\u0430\u0434\u0430\u0447\u0443, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e:<\/p>\n<p>  <\/p>\n<p><strong>1.<\/strong> \u0423\u043a\u0430\u0436\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">model.ssd.num_classes: 6<\/code><\/pre>\n<p>  <\/p>\n<p><strong>2.<\/strong> \u0423\u043a\u0430\u0436\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u0430 (\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430 \u043e\u0434\u043d\u0443 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e), \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u0438 \u043f\u0443\u0442\u044c \u043a \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438\u0437 \u0430\u0440\u0445\u0438\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">train_config.batch_size: 18 train_config.num_steps: 20000 train_config.fine_tune_checkpoint:&quot;.\/training_demo\/pre-trained-model\/ssdlite_mobilenet_v2_coco_2018_05_09\/model.ckpt&quot;<\/code><\/pre>\n<p>  <\/p>\n<p><strong>3.<\/strong> \u0423\u043a\u0430\u0436\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u043e\u0442\u043e \u0432 \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 (<strong>object_detection\/training_demo\/images\/train<\/strong>)<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">eval_config.num_examples: 64<\/code><\/pre>\n<p>  <\/p>\n<p><strong>4.<\/strong> \u0423\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u043d\u0430\u0431\u043e\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u043a\u0438<\/p>\n<p>  <\/p>\n<pre><code class=\"cpp\">train_input_reader.label_map_path: &quot;.\/training_demo\/annotations\/label_map.pbtxt&quot; train_input_reader.tf_record_input_reader.input_path:&quot;.\/training_demo\/annotations\/train.record&quot;<\/code><\/pre>\n<p>  <\/p>\n<p><strong>5.<\/strong> \u0423\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \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>  <\/p>\n<pre><code class=\"cpp\">eval_input_reader.label_map_path: &quot;.\/training_demo\/annotations\/label_map.pbtxt&quot; eval_input_reader.tf_record_input_reader.input_path:&quot;.\/training_demo\/annotations\/test.record&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0443 \u0432\u0430\u0441 \u0434\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0447\u0442\u043e \u0442\u043e \u0432\u0440\u043e\u0434\u0435 <a href=\"https:\/\/github.com\/AleksandrTabolin\/tensorflow_object_detector_with_colab\/tree\/master\/object_detection\/training_demo\">\u044d\u0442\u043e\u0433\u043e<\/a>.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u043f\u043a\u0443 <strong>training_demo<\/strong> \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f <strong>training_demo.zip<\/strong> \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u0432 Google Drive.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0440\u0445\u0438\u0432\u043e\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<blockquote><p>\u0412 <a href=\"https:\/\/dev.to\/kriyeng\/8-tips-for-google-colab-notebooks-to-take-advantage-of-their-free-of-charge-12gb-ram-gpu-be4\">\u044d\u0442\u043e\u0439<\/a> \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0440\u0438\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c google drive \u043a \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 Google Colab, \u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043d\u0435 \u0437\u0430\u0431\u044b\u0442\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u043f\u0443\u0442\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0430\u0445 \u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u0445<\/p><\/blockquote>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044e.<\/p>\n<p>  <\/p>\n<h2 id=\"obuchenie-modeli\">\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 Google Drive \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c <strong>training_demo.zip<\/strong>, \u043a\u043b\u0438\u043a\u0430\u0435\u043c \u043d\u0430 <strong>Get shareable link<\/strong> \u0438 \u0438\u0437 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u0441\u0435\u0431\u0435 <strong>id<\/strong> \u044d\u0442\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430:<\/p>\n<p>  <\/p>\n<p>drive.google.com\/open?id=<strong>[YOUR_FILE_ID_HERE]<\/strong><\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f Google Colab \u2014 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u0432 Google Drive.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fl\/o3\/ee\/flo3eeezvo-q42lngwpxamixtsg.png\"><\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0430 CPU. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c GPU, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u0438\u043f runtime.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/37\/ko\/ap\/37koapmnqw-l9cuvxw7gbjomxds.png\"><\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ng\/b0\/mm\/ngb0mmui99onkgqergw8uo88ba8.png\"><\/p>\n<p>  <\/p>\n<p>\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c <a href=\"https:\/\/github.com\/AleksandrTabolin\/tensorflow_object_detector_with_colab\/blob\/master\/object_detection.ipynb\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<p><strong>1.<\/strong> \u041a\u043b\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 TensorFlow Models:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!git clone https:\/\/github.com\/tensorflow\/models.git                                                <\/code><\/pre>\n<p>  <\/p>\n<p><strong>2.<\/strong> \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c protobuf \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 object_detection:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!apt-get -qq install libprotobuf-java protobuf-compiler                                                %cd .\/models\/research\/ !protoc object_detection\/protos\/*.proto --python_out=. %cd ..\/..<\/code><\/pre>\n<p>  <\/p>\n<p><strong>3.<\/strong> \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0443\u0442\u0438 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f PYTHONPATH: <\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import os os.environ['PYTHONPATH'] += &quot;:\/content\/models\/research\/&quot; os.environ['PYTHONPATH'] += &quot;:\/content\/models\/research\/slim&quot; os.environ['PYTHONPATH'] += &quot;:\/content\/models\/research\/object_detection&quot; os.environ['PYTHONPATH'] += &quot;:\/content\/models\/research\/object_detection\/utils&quot;<\/code><\/pre>\n<p>  <\/p>\n<p><strong>4.<\/strong> \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 Google Drive \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c PyDrive \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">!pip install -U -q PyDrive  from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive from google.colab import auth from oauth2client.client import GoogleCredentials  auth.authenticate_user() gauth = GoogleAuth() gauth.credentials = GoogleCredentials.get_application_default() drive = GoogleDrive(gauth)<\/code><\/pre>\n<p>  <\/p>\n<p><strong>5.<\/strong> \u0421\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0430\u0440\u0445\u0438\u0432 (\u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c id \u0432\u0430\u0448\u0435\u0433\u043e \u0444\u0430\u0439\u043b\u0430) \u0438 \u0440\u0430\u0437\u0430\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">drive_file_id=&quot;[YOUR_FILE_ID_HERE]&quot;  training_demo_zip = drive.CreateFile({'id': drive_file_id}) training_demo_zip.GetContentFile('training_demo.zip')  !unzip training_demo.zip !rm training_demo.zip<\/code><\/pre>\n<p>  <\/p>\n<p><strong>6.<\/strong> \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!python .\/models\/research\/object_detection\/legacy\/train.py --logtostderr --train_dir=.\/training_demo\/training --pipeline_config_path=.\/training_demo\/training\/ssdlite_mobilenet_v2_coco.config<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><strong>&#8212;train_dir<\/strong>=.\/training_demo\/training \u2014 \u043f\u0443\u0442\u044c \u043a \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043b\u0435\u0436\u0430\u0442\u044c<br \/>  \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435<\/p>\n<p>  <\/p>\n<p><strong>&#8212;pipeline_config_path<\/strong>=.\/training_demo\/training\/ssdlite_mobilenet_v2_coco.config \u2014 \u043f\u0443\u0442\u044c \u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><strong>7.<\/strong> \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432 frozen graph, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!python \/content\/models\/research\/object_detection\/export_inference_graph.py --input_type image_tensor --pipeline_config_path \/content\/training_demo\/training\/ssdlite_mobilenet_v2_coco.config --trained_checkpoint_prefix \/content\/training_demo\/training\/model.ckpt-[CHECKPOINT_NUMBER]  --output_directory \/content\/training_demo\/training\/output_inference_graph_v1.pb<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><strong>&#8212;pipeline_config_path<\/strong> \/content\/training_demo\/training\/ssdlite_mobilenet_v2_coco.config \u2014 \u043f\u0443\u0442\u044c \u043a \u043a\u043e\u043d\u0444\u0438\u0433\u0443<\/p>\n<p>  <\/p>\n<p><strong>&#8212;trained_checkpoint_prefix<\/strong> \/content\/training_demo\/training\/model.ckpt-[CHECKPOINT_NUMBER] \u2014 \u043f\u0443\u0442\u044c \u043a \u0447\u0435\u043a\u043f\u043e\u0438\u043d\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  <\/p>\n<p><strong>&#8212;output_directory<\/strong> \/content\/training_demo\/training\/output_inference_graph_v1.pb \u2014 \u0438\u043c\u044f \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438<\/p>\n<p>  <\/p>\n<p>\u041d\u043e\u043c\u0435\u0440 \u0447\u0435\u043a\u043f\u043e\u0438\u043d\u0442\u0430 <strong>[CHECKPOINT_NUMBER]<\/strong>, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u043f\u0430\u043f\u043a\u0435 <strong>content\/training_demo\/training\/<\/strong>. <strong>\u041f\u041e\u0421\u041b\u0415<\/strong> \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0430\u043c \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0444\u0430\u0439\u043b\u044b \u0442\u0438\u043f\u0430 model.ckpt-1440.index, model.ckpt-1440.meta. 1440 \u2014 \u044d\u0442\u043e \u0438 <strong>[CHECKPOINT_NUMBER]<\/strong> \u0438 \u043d\u043e\u043c\u0435\u0440 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/g-\/m8\/kf\/g-m8kf5wi515656u-kha_bebbe8.png\"><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432 \u0431\u043b\u043e\u043a\u043d\u043e\u0442\u0435 \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442. \u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u043b\u0435 ~20000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rm\/et\/nq\/rmetnqjmwcurf-gg5kfgc0w-hqu.png\"><\/p>\n<p>  <\/p>\n<p><strong>8.<\/strong> \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 tflite.<br \/>  \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <a href=\"https:\/\/www.tensorflow.org\/lite\">tensorflow lite<\/a> \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 <strong>tflite<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0432 <strong>frozen graph<\/strong> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u0432 <strong>tflite<\/strong> (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043a\u0430\u043a \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 <strong>export_inference_graph.py<\/strong>):<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!python \/content\/models\/research\/object_detection\/export_tflite_ssd_graph.py --pipeline_config_path \/content\/training_demo\/training\/ssdlite_mobilenet_v2_coco.config --trained_checkpoint_prefix \/content\/training_demo\/training\/model.ckpt-[CHECKPOINT_NUMBER] --output_directory \/content\/training_demo\/training\/output_inference_graph_tf_lite.pb<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432 <strong>tflite<\/strong> \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043c\u043e\u0434\u0435\u043b\u0438, \u0434\u043b\u044f \u0435\u0451 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u0438\u0437 <strong>output_inference_graph_tf_lite.pb<\/strong>:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bi\/bl\/nr\/biblnrzykjebdm7fcbri14qhipq.png\"><\/p>\n<p>  <\/p>\n<p>\u0418 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0451 \u0432 \u0442\u0443\u043b\u0437\u0435 <a href=\"https:\/\/lutzroeder.github.io\/netron\/\">Netron<\/a>. \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u043e\u0432 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yq\/wb\/og\/yqwbogkc-dr3hk6pem3cpfx5gly.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/dm\/2i\/b5\/dm2ib5a058pwphfh9vcpiad-h_0.png\"><\/p>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u044f \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c pb \u043c\u043e\u0434\u0435\u043b\u044c \u0432 tflite \u0444\u043e\u0440\u043c\u0430\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!tflite_convert --output_file=\/content\/training_demo\/training\/model_q.tflite  --graph_def_file=\/content\/training_demo\/training\/output_inference_graph_tf_lite_v1.pb\/tflite_graph.pb --input_arrays=normalized_input_image_tensor  --output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' --input_shapes=1,300,300,3 --enable_select_tf_ops --allow_custom_ops  --inference_input_type=QUANTIZED_UINT8 --inference_type=FLOAT --mean_values=128 --std_dev_values=128<\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<p><strong>&#8212;output_file<\/strong>=\/content\/training_demo\/training\/model_q.tflite \u2014 \u043f\u0443\u0442\u044c \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438<\/p>\n<p>  <\/p>\n<p><strong>&#8212;graph_def_file<\/strong>=\/content\/training_demo\/training\/output_inference_graph_tf_lite_v1.pb\/tflite_graph.pb \u2014 \u043f\u0443\u0442\u044c \u043a frozen graph, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n<p>  <\/p>\n<p><strong>&#8212;input_arrays<\/strong>=normalized_input_image_tensor \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0443\u0437\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0432\u044b\u0448\u0435<\/p>\n<p>  <\/p>\n<p><strong>&#8212;output_arrays<\/strong>=&#8217;TFLite_Detection_PostProcess&#8217;,&#8217;TFLite_Detection_PostProcess:1&#8242;,&#8217;TFLite_Detection_PostProcess:2&#8242;,&#8217;TFLite_Detection_PostProcess:3&#8242; \u2014 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0432\u044b\u0448\u0435<\/p>\n<p>  <\/p>\n<p><strong>&#8212;input_shapes<\/strong>=1,300,300,3 \u2014 \u0440\u0430\u0437\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0432\u044b\u0448\u0435<\/p>\n<p>  <\/p>\n<p><strong>&#8212;enable_select_tf_ops<\/strong> \u2014 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0433\u043e runtime TensorFlow Lite<\/p>\n<p>  <\/p>\n<p><strong>&#8212;allow_custom_ops<\/strong> \u2014 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f TensorFlow Lite Optimizing Converter <\/p>\n<p>  <\/p>\n<p><strong>&#8212;inference_type<\/strong>=FLOAT \u2014 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 \u043a\u0440\u043e\u043c\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445<\/p>\n<p>  <\/p>\n<p><strong>&#8212;inference_input_type<\/strong>=QUANTIZED_UINT8 \u2014 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 <\/p>\n<p>  <\/p>\n<p><strong>&#8212;mean_values<\/strong>=128 <strong>&#8212;std_dev_values<\/strong>=128 \u2014 \u0441\u0440\u0435\u0434\u043d\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f QUANTIZED_UINT8<\/p>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0410\u0440\u0445\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u043f\u043a\u0443 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0451 \u0432 Google Drive:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">!zip -r .\/training_demo\/training.zip .\/training_demo\/training\/  training_result = drive.CreateFile({'title': 'training_result.zip'}) training_result.SetContentFile('training_demo\/training.zip') training_result.Upload()<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0415\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 Invalid client secrets file, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0432 google drive.<\/p><\/blockquote>\n<p>  <\/p>\n<h2 id=\"zapusk-modeli-na-android-ustroystve\">\u0417\u0430\u043f\u0443\u0441\u043a \u043c\u043e\u0434\u0435\u043b\u0438 \u043d\u0430 android \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043e\u0441\u043d\u043e\u0432\u0435 android \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d <a href=\"https:\/\/www.tensorflow.org\/lite\/models\/object_detection\/overview\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0433\u0430\u0439\u0434<\/a> \u043f\u043e object detection, \u043d\u043e \u043e\u043d \u0431\u044b\u043b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043d \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c kotlin \u0438 <a href=\"https:\/\/developer.android.com\/training\/camerax\">CameraX<\/a>. \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/github.com\/AleksandrTabolin\/tf_object_detection_android\">\u0442\u0443\u0442<\/a>. <\/p>\n<p>  <\/p>\n<p>CameraX \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u043e\u0432 \u0441 \u043a\u0430\u043c\u0435\u0440\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/developer.android.com\/reference\/androidx\/camera\/core\/ImageAnalysis.html\">ImageAnalysis<\/a>. \u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <a href=\"https:\/\/github.com\/AleksandrTabolin\/tf_object_detection_android\/blob\/master\/app\/src\/main\/java\/ru\/object\/detection\/camera\/ObjectDetectorAnalyzer.kt\">ObjectDetectorAnalyzer<\/a>. <\/p>\n<p>  <\/p>\n<p>\u0412\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432:<\/p>\n<p>  <\/p>\n<p><strong>1.<\/strong> \u041d\u0430 \u0432\u0445\u043e\u0434 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u043c\u0435\u0435\u0442 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/YUV\">YUV<\/a> \u0444\u043e\u0440\u043c\u0430\u0442. \u0414\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 RGB \u0444\u043e\u0440\u043c\u0430\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"kotlin\">val rgbArray = convertYuvToRgb(image)<\/code><\/pre>\n<p>  <\/p>\n<p><strong>2.<\/strong> \u0414\u0430\u043b\u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (\u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c, \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0434\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043c\u043e\u0434\u0435\u043b\u0438, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e 300&#215;300), \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u0442\u0440\u0438\u0441\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 Bitmap \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043d\u0430 \u043d\u0451\u043c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"kotlin\">val rgbBitmap = getRgbBitmap(rgbArray, image.width, image.height) val transformation =  getTransformation(rotationDegrees, image.width, image.height) Canvas(resizedBitmap).drawBitmap(rgbBitmap, transformation, null)<\/code><\/pre>\n<p>  <\/p>\n<p><strong>3.<\/strong> \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c bitmap \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439, \u0438 \u043e\u0442\u0434\u0430\u0434\u0438\u043c \u0435\u0433\u043e \u043d\u0430 \u0432\u0445\u043e\u0434 \u0434\u0435\u0442\u0435\u043a\u0442\u043e\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"kotlin\">ImageUtil.storePixels(resizedBitmap, inputArray) val objects = detect(inputArray)<\/code><\/pre>\n<p>  <\/p>\n<p><strong>4.<\/strong> \u0414\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044f \u0432 RecognitionResultOverlayView \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0441 \u0441\u043e\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441\u0442\u043e\u0440\u043e\u043d:<\/p>\n<p>  <\/p>\n<pre><code class=\"kotlin\">val scaleFactorX = measuredWidth \/ result.imageWidth.toFloat() val scaleFactorY = measuredHeight \/ result.imageHeight.toFloat()  result.objects.forEach { obj -&gt;     val left = obj.location.left * scaleFactorX     val top = obj.location.top * scaleFactorY     val right = obj.location.right * scaleFactorX     val bottom = obj.location.bottom * scaleFactorY      canvas.drawRect(left, top, right, bottom, boxPaint)     canvas.drawText(obj.text, left, top - 25f, textPaint) }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432 assets \u0444\u0430\u0439\u043b \u0441 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043d\u0430 <strong>training_demo\/training\/model_q.tflite<\/strong> (\u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0432 \u0435\u0451 \u0432 <strong>detect.tflite<\/strong>) \u0438 \u0444\u0430\u0439\u043b \u0441 \u043c\u0435\u0442\u043a\u0430\u043c\u0438 <strong>labelmap.txt<\/strong>, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">detect.tflite<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">1 2 3 4 5 6<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0433\u0430\u0439\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <strong>SSD Mobilenet V1<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441 1, \u0430 \u043d\u0435 \u0441 0, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c labelOffset \u0441 1 \u043d\u0430 0 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 collectDetectionResult \u043a\u043b\u0430\u0441\u0441\u0430 ObjectDetector.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0451.<br \/>  \u041d\u0430 \u0432\u0438\u0434\u0435\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u0441\u0442\u0430\u0440\u0435\u043d\u044c\u043a\u043e\u043c Xiaomi Redmi 4X :<\/p>\n<p>  <\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.2493%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/GXtiLAjPlHg?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<blockquote><p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b:  <\/p>\n<ul>\n<li><a href=\"https:\/\/tensorflow-object-detection-api-tutorial.readthedocs.io\">https:\/\/tensorflow-object-detection-api-tutorial.readthedocs.io<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/EdjeElectronics\/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10\">https:\/\/github.com\/EdjeElectronics\/TensorFlow-Object-Detection-API-Tutorial-Train-Multiple-Objects-Windows-10<\/a><\/li>\n<li><a href=\"https:\/\/lutzroeder.github.io\/netron\/\">https:\/\/lutzroeder.github.io\/netron\/<\/a><\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\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\/redmadrobot\/blog\/488210\/\"> https:\/\/habr.com\/ru\/company\/redmadrobot\/blog\/488210\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/redmadrobot\/blog\/488210\/\">\n<p>\u041e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u0438 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u044e \u043e\u0431\u0440\u0430\u0437\u043e\u0432 \u2014 \u0434\u043e\u043b\u0433\u0438\u0439 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0435\u043c\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0434 \u0440\u0443\u043a\u043e\u0439 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u043e\u0439 \u043d\u043e\u0443\u0442, \u0430 \u043d\u0435 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u0441 \u043c\u043e\u0449\u043d\u043e\u0439 \u0432\u0438\u0434\u0435\u043e\u043a\u0430\u0440\u0442\u043e\u0439. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0434\u0451\u0442 <a href=\"https:\/\/colab.research.google.com\/\">Google Colaboratory<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f GPU \u0443\u0440\u043e\u0432\u043d\u044f Tesla K80 (<a href=\"https:\/\/colab.research.google.com\/drive\/151805XTDg--dgHb3-AXJCpnWaqRhop_2\">\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/a>).<\/p>\n<p>  <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 tensorflow \u0432 Google Colaboratory \u0438 \u0435\u0451 \u0437\u0430\u043f\u0443\u0441\u043a \u043d\u0430 android \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435.<\/p>\n<p>  <\/p>\n<h2 id=\"podgotovka-dannyh\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u0439\u0440\u043e\u0441\u0435\u0442\u044c \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0431\u0435\u043b\u044b\u0435 \u0438\u0433\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u0441\u0442\u0438 \u043d\u0430 \u0447\u0435\u0440\u043d\u043e\u043c \u0444\u043e\u043d\u0435. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043d\u0430\u0434\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0439 \u0434\u043b\u044f \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f (\u043f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 ~100 \u0444\u043e\u0442\u043e).<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/q1\/a9\/7z\/q1a97zueu96rei1w4tx2bxmlpzg.png\"><\/p>\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-298638","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298638","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=298638"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/298638\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=298638"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=298638"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=298638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}