{"id":6235,"date":"2021-01-21T17:31:14","date_gmt":"2021-01-21T09:31:14","guid":{"rendered":"https:\/\/vip.fxxkpython.com\/?p=6235"},"modified":"2021-02-07T21:32:42","modified_gmt":"2021-02-07T13:32:42","slug":"%e4%bd%bf%e7%94%a8-python-%e8%ae%a9%e6%97%a7%e7%85%a7%e7%89%87%e4%bf%ae%e5%a4%8d%e6%b8%85%e6%99%b0","status":"publish","type":"post","link":"https:\/\/vip.fxxkpython.com\/?p=6235","title":{"rendered":"\u4f7f\u7528 Python \u8ba9\u65e7\u7167\u7247\u4fee\u590d\u6e05\u6670"},"content":{"rendered":"\n<p>\u7ffb\u5f00\u5bb6\u91cc\u7684\u7684\u76f8\u7247\u518c\uff0c\u53ef\u4ee5\u770b\u5230\u6bcf\u5f20\u7167\u7247\u90fd\u662f\u90a3\u4e48\u7684\u5f25\u8db3\u73cd\u8d35\uff0c\u7279\u522b\u662f\u5f88\u4e45\u4ee5\u524d\u7684\u7167\u7247\uff0c\u90fd\u662f\u7f8e\u597d\u7684\u56de\u5fc6\uff0c\u8fd8\u6709\u90a3\u4e9b\u5e74\u9519\u8fc7\u7684\u573a\u666f\uff0c\u90fd\u88ab\u8bb0\u5f55\u4e0b\u6765\u4e86\uff0c\u4e0d\u8fc7\u53ef\u60dc\u7684\u662f\uff0c\u968f\u7740\u65f6\u95f4\u7684\u6d41\u901d\uff0c\u7167\u7247\u53ef\u80fd\u6cdb\u9ec4\uff0c\u51fa\u73b0\u5212\u75d5\uff0c\u753b\u8d28\u635f\u5931\u7b49\u7b49\uff0c\u90a3\u4e48\u8fd9\u65f6\u5019\uff0c\u5982\u679c\u53ef\u4ee5\u8ba9\u8fd9\u4e9b\u8001\u65e7\u7684\u7167\u7247\u4fee\u590d\u56de\u6765\uff0c\u90a3\u5c31\u5fd2\u68d2\u554a\uff01<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-81dbd85ea61ce98ac3a907693d91793c_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5982\u4f55\u4f7f\u7528\u5462\uff1f\u4eca\u5929\u5c0f\u5e05b\u548c\u4f60\u4e00\u8d77\u73a9\u4e00\u4e0b\uff0c\u628a\u65e7\u7167\u7247\u4fee\u590d\u6e05\u6670\u3002\u5728\u6b64\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u7684\u7535\u8111\u6709\uff1aPython3\u7684\u8fd0\u884c\u73af\u5883 GPU\u6216\u7740CPU<\/p>\n\n\n\n<h2>\u73af\u5883\u51c6\u5907<\/h2>\n\n\n\n<p>\u9996\u5148\u5c06\u5fae\u8f6f\u7684\u300cBringing-Old-Photos-Back-to-Life\u300d\u5e93 clone \u5230\u672c\u5730\uff1agit clone https:\/\/github.com\/microsoft\/Bringing-Old-Photos-Back-to-Life.git<\/p>\n\n\n\n<h2>\u4e0b\u8f7d Synchronized-BatchNorm-PyTorch<\/h2>\n\n\n\n<p>\u63a5\u7740\u8fdb\u5165\u9879\u76ee\u6587\u4ef6\uff0c\u8fdb\u5165 \u300cFace_Enhancement\/models\/networks\/\u300d\uff0c\u628a\u300cSynchronized-BatchNorm-PyTorch\u300dclone\u4e0b\u6765\uff1aclone https:\/\/github.com\/vacancy\/Synchronized-BatchNorm-PyTorch<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-209e5477fb78fd0c2574ac71085249f2_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u540c\u6837\u7684\uff0c\u5728\u300cGlobal\/detection_models\u300d\u4e0b\u540c\u6b65\u4e0b\u8f7d \u300cSynchronized-BatchNorm-PyTorch\u300d\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic4.zhimg.com\/80\/v2-b1c9f4d6258208c463b127ab9a49e19c_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2>\u4e0b\u8f7d landmark detection pretrained model<\/h2>\n\n\n\n<p>\u8fdb\u5165 \u300cFace_Enhancement\u300d\uff0c\u4f7f\u7528 wget \u547d\u4ee4\u4e0b\u8f7d\u5730\u6807\u68c0\u6d4b\u9884\u8bad\u7ec3\u6a21\u578b\uff1awget http:\/\/dlib.net\/files\/shape<em>predictor<\/em>68<em>face<\/em>landmarks.dat.bz2<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic1.zhimg.com\/80\/v2-25fb2d97d68174980b02c629c3521e09_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u63a5\u7740\u89e3\u538b\uff1abzip2 -d shape<em>predictor<\/em>68<em>face<\/em>landmarks.dat.bz2<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-d2d19e161dff8c03da72cb256a51a16a_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2>\u4e0b\u8f7d\u8bad\u7ec3\u6a21\u5757<\/h2>\n\n\n\n<p>\u8fdb\u5165\u300cFace_Enhancement\u300d\uff0c\u4f7f\u7528 wget \u4e0b\u8f7d\uff1awget https:\/\/facevc.blob.core.windows.net\/zhanbo\/old<em>photo\/pretrain\/Face<\/em>Enhancement\/checkpoints.zip\u63a5\u7740\u89e3\u538b\u4e00\u6ce2\uff1aunzip checkpoints.zip<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-cda8e11478a8b6aba203a1c0dd141dcc_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u8fdb\u5165 \u300cGlobal\u300d\uff0c\u4e0b\u8f7d\uff1awget https:\/\/facevc.blob.core.windows.net\/zhanbo\/old_photo\/pretrain\/Global\/checkpoints.zip\u540c\u6837\u89e3\u538b\u4e00\u6ce2\uff1aunzip checkpoints.zip<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-ead78a2c0b8ea3bed157923605c5d52f_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<h2>\u521b\u5efa python3 \u865a\u62df\u73af\u5883<\/h2>\n\n\n\n<p>python3 -m venv .venv source .venv\/bin\/activate<\/p>\n\n\n\n<h2>\u5b89\u88c5\u9879\u76ee\u4f9d\u8d56\u5e93<\/h2>\n\n\n\n<p>pip3 install -r requirements.txt<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-d4126cf9a455123a4d267d3322035212_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u81f3\u6b64\uff0c\u6211\u4eec\u8be5\u5b89\u88c5\u90fd\u7279\u4e48\u5b89\u88c5\u5b8c\u6210\u4e86\uff0c\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u4f7f\u7528\u4e86\u3002<\/p>\n\n\n\n<h2>\u4fee\u590d\u6ca1\u6709\u5212\u75d5\u7684\u8001\u7167\u7247<\/h2>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u521b\u5efa\u4e24\u6587\u4ef6\u5939\uff0c\u5206\u522b\u7528\u6765\u5b58\u653e\u65e7\u7167\u7247\u548c\u751f\u6210\u7684\u4fee\u590d\u7167\u7247\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic1.zhimg.com\/80\/v2-c8a22acbbaef67fbe19a41a63fa1009c_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6bd4\u5982\u4f60\u8981\u4fee\u590d\u8fd9\u6837\u7684\u65e7\u7167\u7247\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-2f9630e1324c25d4d7aa0c2511c26203_1440w.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u628a\u5b83\u653e\u8fdb \u300cold\u300d\u6587\u4ef6\u5939\u4e2d\uff0c\u7136\u540e\u4f7f\u7528\u8fd9\u6837\u7684\u547d\u4ee4\u8fdb\u884c\u4fee\u590d\uff1apython run.py &#8211;input<em>folder [\u65e7\u7167\u7247\u7684\u6587\u4ef6\u5939\u8def\u5f84] &#8211;output<\/em>folder [\u65b0\u7167\u7247\u7684\u6587\u4ef6\u5939\u8def\u5f84] &#8211;GPU 0\u50cf\u8fd9\u6837\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic2.zhimg.com\/80\/v2-6a80f3b38429fc255d84a13771f93261_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u8fd9\u65f6\u5019\u5728 \u300cout\u300d\u4e2d\u5c31\u53ef\u4ee5\u5f97\u5230\u4fee\u590d\u597d\u7684\u7167\u7247\u4e86\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic1.zhimg.com\/80\/v2-3802d514facb455073f05104b1238904_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u6253\u5f00\u53ef\u4ee5\u770b\u5230\u65b0\u7684\u7167\u7247\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic4.zhimg.com\/80\/v2-744adca1995ff751d3f60a014c556dc5_1440w.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u662f\u4e0d\u662f\u6e05\u6670\u4e86\u5f88\u591a\uff1f\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u6279\u91cf\u4fee\u590d\uff0c\u628a\u65e7\u7167\u7247\u90fd\u653e\u5165\u4f60\u521b\u5efa\u7684 old \u6587\u4ef6\u5939\u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n\n<h2>\u4fee\u590d\u6709\u5212\u75d5\u7684\u8001\u7167\u7247<\/h2>\n\n\n\n<p>\u4f7f\u7528\u65b9\u5f0f\u548c\u521a\u521a\u7684\u547d\u4ee4\u4e00\u6837\uff0c\u53ea\u4e0d\u8fc7\u6211\u4eec\u9700\u8981\u5728\u547d\u4ee4\u540e\u9762\u6dfb\u52a0 \u300c&#8211;with_scratch\u300d\u3002\u5220\u9664\u521a\u521a out \u4e0b\u751f\u6210\u7684\u6587\u4ef6\uff1a rm -rf test\/out\/* \u4fee\u590d\uff1a python run.py &#8211;input<em>folder [\u65e7\u7167\u7247\u7684\u6587\u4ef6\u5939\u8def\u5f84] &#8211;output<\/em>folder [\u65b0\u7167\u7247\u7684\u6587\u4ef6\u5939\u8def\u5f84] &#8211;GPU 0 &#8211;with_scratch\u5f97\u5230\u7684\u6548\u679c\u5c31\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic1.zhimg.com\/80\/v2-fe2bdda3c9fed15907f7bd2a3f6d74c1_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5199\u5230\u8fd9\u91cc\uff0c\u5c0f\u5e05b\u5728\u6dd8\u5b9d\u641c\u4e86\u4e00\u4e0b\u300c\u8001\u7167\u7247\u4fee\u590d\u300d\uff0c\u8fd9&#8230;\u5546\u673a\u554a\uff01<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic1.zhimg.com\/80\/v2-a3261ade7e82a3550fe00791506c1da5_1440w.png\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u54c8\u54c8\uff0cOK\uff0c\u4ee5\u4e0a\u5c31\u662f\u5c0f\u5e05b\u4eca\u5929\u7ed9\u4f60\u5e26\u6765\u7684\u5206\u4eab\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u5e2e\u52a9\u3002\u63a8\u8350\u9605\u8bfb\u5982\u4f55\u628a\u7f51\u9875\u79d2\u53d8 PDF\uff0c \u7136\u540e\u6162\u6162\u770b\uff1fPython \u9879\u76ee\u4ee3\u7801\u5199\u5b8c\u4e86\uff0c\u7136\u540e\u600e\u4e48\u6253\u5305\u548c\u53d1\u5e03\uff1f<br>\u4e0b\u56de\u89c1\uff0c<strong>peace\uff01<\/strong> \u6e23\u7537\u4eec\uff0c\u70b9\u4e2a\u8d5e\u54af<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ffb\u5f00\u5bb6\u91cc\u7684\u7684\u76f8\u7247\u518c\uff0c\u53ef\u4ee5\u770b\u5230\u6bcf\u5f20\u7167\u7247\u90fd\u662f\u90a3\u4e48\u7684\u5f25\u8db3\u73cd\u8d35\uff0c\u7279\u522b\u662f\u5f88\u4e45\u4ee5\u524d\u7684\u7167\u7247\uff0c\u90fd\u662f\u7f8e\u597d\u7684\u56de\u5fc6\uff0c\u8fd8\u6709\u90a3\u4e9b\u5e74\u9519\u8fc7\u7684\u573a\u666f\uff0c\u90fd\u88ab\u8bb0\u5f55\u4e0b\u6765\u4e86\uff0c\u4e0d\u8fc7\u53ef\u60dc\u7684\u662f\uff0c\u968f\u7740\u65f6\u95f4\u7684\u6d41\u901d\uff0c\u7167\u7247\u53ef\u80fd\u6cdb\u9ec4\uff0c\u51fa\u73b0\u5212\u75d5\uff0c\u753b\u8d28\u635f\u5931\u7b49\u7b49\uff0c\u90a3\u4e48\u8fd9\u65f6\u5019\uff0c\u5982\u679c\u53ef\u4ee5\u8ba9\u8fd9\u4e9b\u8001\u65e7\u7684\u7167\u7247\u4fee\u590d\u56de\u6765\uff0c\u90a3\u5c31&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[303],"tags":[19,519],"_links":{"self":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6235"}],"collection":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6235"}],"version-history":[{"count":2,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6235\/revisions"}],"predecessor-version":[{"id":6237,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=\/wp\/v2\/posts\/6235\/revisions\/6237"}],"wp:attachment":[{"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vip.fxxkpython.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}