{"id":996,"date":"2016-10-17T08:21:48","date_gmt":"2016-10-16T23:21:48","guid":{"rendered":"http:\/\/now0930.iptime.org\/wordpress\/?p=996"},"modified":"2016-10-17T08:47:15","modified_gmt":"2016-10-16T23:47:15","slug":"matplotlib%eb%a5%bc-%ed%84%b0%eb%af%b8%eb%84%90-%ed%99%98%ea%b2%bd%ec%97%90%ec%84%9c-%ec%82%ac%ec%9a%a9%eb%b0%a9%eb%b2%95","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/matplotlib%eb%a5%bc-%ed%84%b0%eb%af%b8%eb%84%90-%ed%99%98%ea%b2%bd%ec%97%90%ec%84%9c-%ec%82%ac%ec%9a%a9%eb%b0%a9%eb%b2%95\/","title":{"rendered":"matplotlib\ub97c \ud130\ubbf8\ub110 \ud658\uacbd\uc5d0\uc11c \uc0ac\uc6a9\ud558\uae30"},"content":{"rendered":"<p>\uc9d1\uc5d0 \uc788\ub294 \uc11c\ubc84\uc5d0 tensorflow\uac00 \uc124\uce58\ub418\uc5b4 \uc788\ub294\ub370, ssh\ub85c \uc811\uc18d\ud558\uc5ec \uc2e4\ud589\ud55c\ub2e4. \uacb0\uacfc\ubb3c\uc774 \ud14d\uc2a4\ud2b8\uac19\uc774 \ud130\ubbf8\ub110\ub85c \ud45c\uc2dc\ub418\uba74 \ubcfc\uc218 \uc788\ub294\ub370 \uadf8\ub9bc\uc73c\ub85c \ud45c\uc2dc\ub418\uba74 \ud130\ubbf8\ub110\uc5d0 \ud45c\uc2dc\uac00 \uc548\ub41c\ub2e4.<\/p>\n<pre class=\"lang:sh decode:true \">Traceback (most recent call last):\r\n  File \"imagetran.py\", line 13, in &lt;module&gt;\r\n    plt.imshow(image)\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/pyplot.py\", line 3010, in imshow\r\n    ax = gca()\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/pyplot.py\", line 928, in gca\r\n    return gcf().gca(**kwargs)\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/pyplot.py\", line 578, in gcf\r\n    return figure()\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/pyplot.py\", line 527, in figure\r\n    **kwargs)\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/backends\/backend_qt4agg.py\", line 46, in new_figure_manager\r\n    return new_figure_manager_given_figure(num, thisFig)\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/backends\/backend_qt4agg.py\", line 53, in new_figure_manager_given_figure\r\n    canvas = FigureCanvasQTAgg(figure)\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/backends\/backend_qt4agg.py\", line 76, in __init__\r\n    FigureCanvasQT.__init__(self, figure)\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/backends\/backend_qt4.py\", line 68, in __init__\r\n    _create_qApp()\r\n  File \"\/home\/now0930\/anaconda2\/envs\/tensorflow\/lib\/python2.7\/site-packages\/matplotlib\/backends\/backend_qt5.py\", line 138, in _create_qApp\r\n    raise RuntimeError('Invalid DISPLAY variable')\r\nRuntimeError: Invalid DISPLAY variable\r\n<\/pre>\n<p>\ub9c8\uc9c0\ub9c9\uc5d0 Invalid DISPLAY variable\uc774\ub77c\uace0 \ub728\uace0 \uc8fd\ub294\ub370 \uc544\ub798\uc640 \uac19\uc774 \ubcc0\uacbd\ud558\uba74 \ub41c\ub2e4.<\/p>\n<pre class=\"lang:python decode:true\">import matplotlib\r\nmatplotlib.use('Agg')\r\n\r\nimport tensorflow as tf\r\nimport matplotlib.image as mpimg\r\nimport matplotlib.pyplot as plt\r\n\r\n# First, load the image\r\nfilename = \".\/MarshOrchid.jpg\"\r\nimage = mpimg.imread(filename)\r\n\r\n# Print out its shape\r\n#print(image.shape)\r\n\r\n\r\nplt.imshow(image)\r\nplt.savefig('test.jpg')\r\n\r\n\r\n# Create a TensorFlow Variable\r\nx = tf.Variable(image, name='x')\r\nmodel = tf.initialize_all_variables()\r\nwith tf.Session() as session:\r\n\tx = tf.transpose(x, perm=[1, 0, 2])\r\n\tsession.run(model)\r\n\tresult = session.run(x)\r\nprint(result.shape)\r\nmpimg.imsave('test.jpg',image)\r\nmpimg.imsave('test.jpg',result)\r\n<\/pre>\n<p>\ub514\uc2a4\ud50c\ub808\uc774\uac00 \uc788\ub294 PC\uc5d0\uc11c \ub2e4\uc6b4\ub85c\ub4dc\ud574 \ubcf4\uba74 \ub41c\ub2e4..\uc774\uac8c \uc6f9\uc73c\ub85c \ubcf4\ub0b4\uba74 \uc88b\uc740\ub370, \uc544\uc9c1 \uadf8\ub7f0\uac8c\ub294 \uc5c6\ub098\ubcf4\ub2e4. stack overflow\uc758 <a href=\"http:\/\/stackoverflow.com\/questions\/2801882\/generating-a-png-with-matplotlib-when-display-is-undefined\">\uc5ec\uae30<\/a>\uc5d0\uc11c \ub2f5\uc744 \uc5bb\uc5c8\ub2e4.<\/p>\n<p>\uc9c8\ubb38\uc740..<br \/>\n<strong> Generating a PNG with matplotlib when DISPLAY is undefined<\/strong><\/p>\n<p>\uc2dc\uc2a4\ud15c\uc5d0 \ub530\ub77c \uc124\uc815\ud30c\uc77c\uc744 \ubc14\uafb8\uba74 \uadc0\ucc2e\uac8c \uc548\uc368\ub3c4 \ub418\ub294\ub370, \ub098\uc758 \uacbd\uc6b0 \uc5b4\ub514\uc5d0 \uc124\uc815\ud30c\uc77c\uc774 \uc788\ub294\uc9c0 \ubab0\ub77c \uadf8\ub0e5 \uc368\uc57c\uaca0\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc9d1\uc5d0 \uc788\ub294 \uc11c\ubc84\uc5d0 tensorflow\uac00 \uc124\uce58\ub418\uc5b4 \uc788\ub294\ub370, ssh\ub85c \uc811\uc18d\ud558\uc5ec \uc2e4\ud589\ud55c\ub2e4. \uacb0\uacfc\ubb3c\uc774 \ud14d\uc2a4\ud2b8\uac19\uc774 \ud130\ubbf8\ub110\ub85c \ud45c\uc2dc\ub418\uba74 \ubcfc\uc218 \uc788\ub294\ub370 \uadf8\ub9bc\uc73c\ub85c \ud45c\uc2dc\ub418\uba74 \ud130\ubbf8\ub110\uc5d0 \ud45c\uc2dc\uac00 \uc548\ub41c\ub2e4. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[33],"tags":[110,109],"class_list":["post-996","post","type-post","status-publish","format-standard","hentry","category-tensorflow","tag-python","tag-tensorflow"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":4,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":1000,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/996\/revisions\/1000"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}