{"id":3019,"date":"2021-05-18T01:38:08","date_gmt":"2021-05-17T16:38:08","guid":{"rendered":"http:\/\/43.203.250.216\/?p=3019"},"modified":"2023-02-15T04:36:24","modified_gmt":"2023-02-14T19:36:24","slug":"openvino-python%ec%9d%84-%ec%9d%b4%ec%9a%a9%ed%95%9c-%ea%b0%84%eb%8b%a8%ed%95%9c-inferencing-%ec%98%88%ec%a0%9c","status":"publish","type":"post","link":"https:\/\/litcoder.com\/?p=3019","title":{"rendered":"OpenVINO python\uc744 \uc774\uc6a9\ud55c inference \uc608\uc81c"},"content":{"rendered":"\n<p>OpenVINO\ub97c \uc774\uc6a9\ud574\uc11c TensorFlow(Keras)\ub85c training\ud55c \ubaa8\ub378\ub85c \ucd94\ub860(inference)\uc744 \uc218\ud589\ud558\ub294 \uac04\ub2e8\ud55c \uc608\uc81c\ub97c \uc791\uc131\ud574 \ubcf4\uc558\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">TensorFlow model\uc744 freeze\ud558\uae30<\/h3>\n\n\n\n<p>Training\ub41c \ubaa8\ub378\uc744 model optimizer\uc5d0 \ub123\uae30 \uc804\uc5d0 freeze\uc2dc\ucf1c\uc57c \ud558\ub294\ub370, output_node_names\ub97c \uc785\ub825\ud558\ub77c\ub294 \uc624\ub958 \uba54\uc138\uc9c0\uac00 \uacc4\uc18d \ub72c\ub2e4\uba74 \uc81c\ub300\ub85c freezing\uc744 \uc218\ud589\ud588\ub294\uc9c0 \ud655\uc778\ud574 \ubcf4\ub294\uac8c \uc88b\ub2e4. \uc54c\uc544\ubcf4\uae30 \uc27d\uac8c \ud558\uae30 \uc704\ud574 \uc785\ucd9c\ub825 layer\uc5d0 &#8216;name=&#8217; parameter\ub85c \ub2e4\uc74c\uacfc \uac19\uc774 \uc774\ub984\uc744 \uc9c0\uc815\ud574 \uc8fc\uc5c8\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"eclipse\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">model = tf.keras.models.Sequential([\n    tf.keras.layers.Flatten(input_shape=(28, 28), name='input'),\n    tf.keras.layers.Dense(128, activation='relu'),\n    tf.keras.layers.Dropout(0.2),\n    tf.keras.layers.Dense(10, activation='softmax', name='output')\n])<\/pre>\n\n\n\n<p>\uadf8\ub7ec\uba74 layer\uc758 \uc774\ub984\ub4e4\uc744 \ucd9c\ub825\ud560 \ub54c \ub2e4\uc74c\uacfc \uac19\uc774 \ub098\uc628\ub2e4. \uc804\uccb4 MINST model training\uacfc freezing \uacfc\uc815\uc740 \uc774 <a href=\"https:\/\/colab.research.google.com\/drive\/14TNis9JeRRv7lT6en_SS7rlvn-PxdD_G?authuser=1\" data-type=\"URL\">CoLab<\/a>\uc5d0 \uc801\uc5b4 \ub450\uc5c8\uc73c\ub2c8 \ucc38\uc870.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">------------------------------------------------------------\nFrozen model layers:\nx\nsequential\/input\/Const\nsequential\/input\/Reshape\nsequential\/dense\/MatMul\/ReadVariableOp\/resource\nsequential\/dense\/MatMul\/ReadVariableOp\nsequential\/dense\/MatMul\nsequential\/dense\/BiasAdd\/ReadVariableOp\/resource\nsequential\/dense\/BiasAdd\/ReadVariableOp\nsequential\/dense\/BiasAdd\nsequential\/dense\/Relu\nsequential\/dropout\/Identity\nsequential\/output\/MatMul\/ReadVariableOp\/resource\nsequential\/output\/MatMul\/ReadVariableOp\nsequential\/output\/MatMul\nsequential\/output\/BiasAdd\/ReadVariableOp\/resource\nsequential\/output\/BiasAdd\/ReadVariableOp\nsequential\/output\/BiasAdd\nsequential\/output\/Softmax\nIdentity\n------------------------------------------------------------<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\ubaa8\ub378 \uc635\ud2f0\ub9c8\uc774\uc800(mo-tf.py)<\/h2>\n\n\n\n<p>Freeze\ub41c \ubaa8\ub378\uc744 \ub2e4\uc6b4\ub85c\ub4dc \ubc1b\uc740 \ud6c4\uc5d0 TensorFlow\uc6a9 model optimizer\uc778 mo-tf.py\ub97c \uc2e4\ud589 \uc2dc\ud0a4\uba74 model\uc744 \ub098\ud0c0\ub0b4\ub294 xml file\uacfc weight\uac12\uc744 \uc800\uc7a5\ud558\ub294 bin file\uc774 \uc0dd\uc131\ub41c\ub2e4. \uc774 \ub54c training\ub41c \ubaa8\ub378\uc740 \uc785\ub825 shape\uc744 [-1, 28, 28]\ub85c \uc54c\uace0 \uc788\uae30 \ub54c\ubb38\uc5d0 \uc74c\uc218\uac00 \uc544\ub2cc \uac12\uc744 \ub123\uc5b4 \ub2ec\ub77c\ub294 \uc5d0\ub7ec\uac00 \uc0dd\uae34\ub2e4. &#8211;input_shape parameter\ub97c \ub2e4\uc74c\uacfc \uac19\uc774 \uc801\uc5b4\uc900\ub2e4.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/intel\/openvino_2021\/deployment_tools\/model_optimizer\/mo_tf.py --input_model .\/model\/mnist_model\/frozen_graph.pb  --input_shape [28,28]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">OpenVINO\ub97c \uc774\uc6a9\ud55c inference<\/h2>\n\n\n\n<p>Model optimizer\uac00 \uc218\ud589\ub418\uc5c8\ub2e4\uba74 \uc774\uc81c xml file\uc744 \uc774\uc6a9\ud574 model\uc744 load\ud558\uace0 inference\ub97c \uc218\ud589\ud558\uba74 \ub41c\ub2e4. \ub2e4\uc74c\uc740 Training \ud6c4 freezing\uacfc model optimization\uc774 \uc218\ud589\ub41c XML file\uc744 \uc774\uc6a9\ud574\uc11c inference\ub97c \uc218\ud589\ud558\ub294 \uac04\ub2e8\ud55c \ucf54\ub4dc\uc774\ub2e4.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/0d9dd08a84e665644ef18e1bd2009abd.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\"> \ucd9c\ub825\uacb0\uacfc<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"dracula\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ python3 .\/infer_mnist.py .\/model\/mnist_model\/frozen\/frozen_graph.xml\n\n        Model path= .\/model\/mnist_model\/frozen\/frozen_graph.xml \n        Device= CPU\nAccuracy: 0.9789 (hit: 9789\/ miss: 211)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>OpenVINO\ub97c \uc774\uc6a9\ud574\uc11c TensorFlow(Keras)\ub85c training\ud55c \ubaa8\ub378\ub85c \ucd94\ub860(inference)\uc744 \uc218\ud589\ud558\ub294 \uac04\ub2e8\ud55c \uc608\uc81c\ub97c \uc791\uc131\ud574 \ubcf4\uc558\ub2e4. TensorFlow model\uc744 freeze\ud558\uae30 Training\ub41c \ubaa8\ub378\uc744 model optimizer\uc5d0 \ub123\uae30 \uc804\uc5d0 freeze\uc2dc\ucf1c\uc57c \ud558\ub294\ub370, output_node_names\ub97c \uc785\ub825\ud558\ub77c\ub294 \uc624\ub958 \uba54\uc138\uc9c0\uac00 \uacc4\uc18d \ub72c\ub2e4\uba74 \uc81c\ub300\ub85c freezing\uc744 \uc218\ud589\ud588\ub294\uc9c0 \ud655\uc778\ud574 \ubcf4\ub294\uac8c \uc88b\ub2e4. \uc54c\uc544\ubcf4\uae30 \uc27d\uac8c \ud558\uae30 \uc704\ud574 \uc785\ucd9c\ub825 layer\uc5d0 &#8216;name=&#8217; parameter\ub85c \ub2e4\uc74c\uacfc \uac19\uc774 \uc774\ub984\uc744 \uc9c0\uc815\ud574 \uc8fc\uc5c8\ub2e4. \uadf8\ub7ec\uba74 layer\uc758 \uc774\ub984\ub4e4\uc744 \ucd9c\ub825\ud560 \ub54c \ub2e4\uc74c\uacfc \uac19\uc774 \ub098\uc628\ub2e4. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[277,278,276,275,105,228],"class_list":["post-3019","post","type-post","status-publish","format-standard","hentry","category-programming","tag-colab","tag-model-freezing","tag-model-optimizer","tag-openvino","tag-python","tag-tensorflow"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/3019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3019"}],"version-history":[{"count":9,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/3019\/revisions"}],"predecessor-version":[{"id":3206,"href":"https:\/\/litcoder.com\/index.php?rest_route=\/wp\/v2\/posts\/3019\/revisions\/3206"}],"wp:attachment":[{"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/litcoder.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}