{"id":181,"date":"2022-03-15T06:47:30","date_gmt":"2022-03-15T06:47:30","guid":{"rendered":"https:\/\/blog.liguanxin.cn\/?p=181"},"modified":"2022-03-16T05:26:34","modified_gmt":"2022-03-16T05:26:34","slug":"%e8%ae%ba%e6%96%87%e7%ac%94%e8%ae%b0-deep-face-super-resolution-with-iterative-collaboration-between-attentive-recovery-and-landmark-estimation","status":"publish","type":"post","link":"https:\/\/blog.liguanxin.cn\/index.php\/2022\/03\/15\/%e8%ae%ba%e6%96%87%e7%ac%94%e8%ae%b0-deep-face-super-resolution-with-iterative-collaboration-between-attentive-recovery-and-landmark-estimation\/","title":{"rendered":"\u8bba\u6587\u7b14\u8bb0\u2014\u2014Deep Face Super-Resolution with Iterative Collaboration between Attentive Recovery and Landmark Estimation"},"content":{"rendered":"<p><strong>\u521b\u65b0\u70b9\uff1a<br \/>\n\u2460\u4e24\u4e2a\u5faa\u73af\u534f\u4f5c\u7684\u7f51\u7edc\uff0c\u4e00\u4e2a\u6062\u590d\u56fe\u50cf\uff0c\u4e00\u4e2a\u8bc4\u4f30landmark<br \/>\n\u2461\u6ce8\u610f\u529b\u878d\u5408\u6a21\u5757<\/strong><\/p>\n<p><strong>\u89e3\u51b3\u7684\u75db\u70b9\uff1a\u901a\u8fc7\u4f4e\u5206\u8fa8\u7387\u56fe\u7247 LR \u6216\u8005\u7c97\u8d85\u5206\u8fa8\u7387\u56fe\u7247 SR \u5f97\u5230\u7684\u4eba\u8138\u5148\u9a8c\u4fe1\u606f\u4e0d\u4e00\u5b9a\u51c6\u786e<br \/>\n\u5927\u90e8\u5206\u65b9\u6cd5\u4f7f\u7528\u4eba\u8138\u5148\u9a8c\u7684\u65b9\u5f0f\u4e3a\u7b80\u5355\u7684 concatenate \u64cd\u4f5c\uff0c\u4e0d\u80fd\u5145\u5206\u5229\u7528\u5148\u9a8c\u4fe1\u606f<\/strong><br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220311140145.png\" alt=\"\" \/><br \/>\n\u5728\u6b64\u6846\u67b6\u4e2d\uff0c\u4eba\u8138\u6062\u590d\u548c\u5173\u952e\u70b9\u5b9a\u4f4d\u540c\u65f6\u5e76\u9012\u5f52\u6267\u884c\u3002 \u5982\u679c\u8f93\u5165\u4eba\u8138\u7684\u8d28\u91cf\u66f4\u9ad8\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u51c6\u786e\u7684\u5173\u952e\u70b9\u83b7\u5f97\u66f4\u597d\u7684SR\u56fe\u50cf\uff0c\u56e0\u4e3a\u53ef\u4ee5\u66f4\u6b63\u786e\u5730\u4f30\u8ba1\u5173\u952e\u70b9\u3002 \u8fd9\u4e24\u4e2a\u8fc7\u7a0b\u53ef\u4ee5\u4e92\u76f8\u4fc3\u8fdb\uff0c\u5e76\u9010\u6b65\u8fbe\u5230\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n<p>\u5176\u4e2d\u5faa\u73afSR\u5206\u652fG\u5305\u62ec\u4f4e\u5206\u8fa8\u7387\u7279\u5f81\u63d0\u53d6\u5668G1\uff0c\u9012\u5f52\u5757GR\u548c\u9ad8\u5206\u8fa8\u7387\u751f\u6210\u5c42G2\u3002  GR\u5305\u62ec\u4e00\u4e2a\u6ce8\u610f\u878d\u5408\u6a21\u5757\u548c\u4e00\u4e2a\u5faa\u73afSR\u6a21\u5757\u3002 \u7c7b\u4f3c\u4e8eSR\u5206\u652f\uff0c\u9012\u5f52\u5bf9\u9f50\u5206\u652f\u5305\u62ec\u4e00\u4e2a\u9884\u5904\u7406\u6a21\u5757A1\uff0c\u4e00\u4e2a\u9012\u5f52\u6c99\u6f0f\u6a21\u5757AR\u548c\u4e00\u4e2a\u540e\u5904\u7406\u6a21\u5757A2\u3002 \u5bf9\u4e8e\u7b2cn\u6b65\uff0c\u5176\u4e2dn = 1\uff0c&#8230;\uff0cN\uff0cSR\u5206\u652f\u901a\u8fc7\u4f7f\u7528\u5bf9\u9f50\u7ed3\u679c\u548c\u524d\u4e00\u6b65n-1\u7684\u53cd\u9988\u4fe1\u606f\u6765\u6062\u590dSR\u56fe\u50cfInSR\u3002 \u6b64\u5916\uff0cLR\u8f93\u5165\u5728\u6bcf\u4e2a\u6b65\u9aa4\u4e2d\u4e5f\u5f88\u91cd\u8981\u3002 \u56e0\u6b64\uff0c\u7531G1\u63d0\u53d6\u7684LR\u7279\u5f81\u4e5f\u88ab\u9001\u5230\u9012\u5f52\u5757\u4e2d\u3002 \u56e0\u6b64\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u6765\u8ba1\u7b97\u4eba\u8138SR\u8fc7\u7a0b\uff1a<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220311140236.png\" alt=\"\" \/><br \/>\n\u5176\u4e2dU\u8868\u793a\u4e0a\u91c7\u6837\u64cd\u4f5c\u3002 \u540c\u6837\uff0c\u4eba\u8138\u5bf9\u9f50\u5206\u652f\u5c06\u524d\u4e00\u6b65\u4e2d\u7684\u5faa\u73af\u7279\u5f81\u548cA1\u4eceSR\u56fe\u50cfInSR\u4e2d\u63d0\u53d6\u7684SR\u7279\u5f81\u7528\u4f5c\u66f4\u51c6\u786e\u5730\u4f30\u8ba1\u5173\u952e\u70b9\u7684\u6307\u5bfc\uff0c\u5982\u4e0b\u6240\u793a\uff1a<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220311140250.png\" alt=\"\" \/><br \/>\n\u635f\u5931\u8ba1\u7b97\uff08L2\u8303\u6570\uff09\uff1a<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220311140300.png\" alt=\"\" \/><\/p>\n<h3>\u6ce8\u610f\u529b\u878d\u5408\u6a21\u5757<\/h3>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220311141030.png\" alt=\"\" \/><\/p>\n<h4>PixelShuffle(\u50cf\u7d20\u91cd\u7ec4)\u7684\u4e3b\u8981\u529f\u80fd\u662f\u5c06\u4f4e\u5206\u8fa8\u7684\u7279\u5f81\u56fe\uff0c\u901a\u8fc7\u5377\u79ef\u548c\u591a\u901a\u9053\u95f4\u7684\u91cd\u7ec4\u5f97\u5230\u9ad8\u5206\u8fa8\u7387\u7684\u7279\u5f81\u56fe\u3002\u8fd9\u4e00\u65b9\u6cd5\u6700\u521d\u662f\u4e3a\u4e86\u89e3\u51b3\u56fe\u50cf\u8d85\u5206\u8fa8\u7387\u95ee\u9898\u800c\u63d0\u51fa\u7684\uff0c\u8fd9\u79cd\u79f0\u4e3aSub-Pixel Convolutional Neural Network\u7684\u65b9\u6cd5\u6210\u4e3a\u4e86\u4e0a\u91c7\u6837\u7684\u6709\u6548\u624b\u6bb5\u3002<\/h4>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/2019080116323060.png\" alt=\"\" \/><\/p>\n<h3>\u4ee3\u7801<\/h3>\n<p>\u6ce8\u610f\u529b\u878d\u5408\u6a21\u5757\uff08\u901a\u8fc7\u6307\u5b9amark\u7684\u7f16\u53f7\u6765\u786e\u5b9a\u4e94\u5b98\uff09<\/p>\n<pre><code class=\"language-python\">def merge_heatmap_5(heatmap_in, detach):\n    &#039;&#039;&#039;\n    merge 68 heatmap to 5\n    heatmap: B*N*32*32\n    &#039;&#039;&#039;\n    # landmark[36:42], landmark[42:48], landmark[27:36], landmark[48:68]\n    heatmap = heatmap_in.clone()\n    max_heat = heatmap.max(dim=2, keepdim=True)[0].max(dim=3, keepdim=True)[0]\n    max_heat = torch.max(max_heat, torch.ones_like(max_heat) * 0.05)\n    heatmap \/= max_heat\n    if heatmap.size(1) == 5:\n        return heatmap.detach() if detach else heatmap\n    elif heatmap.size(1) == 68:\n        new_heatmap = torch.zeros_like(heatmap[:, :5])\n        new_heatmap[:, 0] = heatmap[:, 36:42].sum(1) # left eye\n        new_heatmap[:, 1] = heatmap[:, 42:48].sum(1) # right eye\n        new_heatmap[:, 2] = heatmap[:, 27:36].sum(1) # nose\n        new_heatmap[:, 3] = heatmap[:, 48:68].sum(1) # mouse\n        new_heatmap[:, 4] = heatmap[:, :27].sum(1) # face silhouette\n        return new_heatmap.detach() if detach else new_heatmap\n    elif heatmap.size(1) == 194: # Helen\n        new_heatmap = torch.zeros_like(heatmap[:, :5])\n        tmp_id = torch.cat((torch.arange(134, 153), torch.arange(174, 193)))\n        new_heatmap[:, 0] = heatmap[:, tmp_id].sum(1) # left eye\n        tmp_id = torch.cat((torch.arange(114, 133), torch.arange(154, 173)))\n        new_heatmap[:, 1] = heatmap[:, tmp_id].sum(1) # right eye\n        tmp_id = torch.arange(41, 57)\n        new_heatmap[:, 2] = heatmap[:, tmp_id].sum(1) # nose\n        tmp_id = torch.arange(58, 113)\n        new_heatmap[:, 3] = heatmap[:, tmp_id].sum(1) # mouse\n        tmp_id = torch.arange(0, 40)\n        new_heatmap[:, 4] = heatmap[:, tmp_id].sum(1) # face silhouette\n        return new_heatmap.detach() if detach else new_heatmap\n    else:\n        raise NotImplementedError(&#039;Fusion for face landmark number %d not implemented!&#039; % heatmap.size(1))<\/code><\/pre>\n<p>\u7ed3\u6784\u4e3b\u4f53<\/p>\n<pre><code class=\"language-python\">class DIC(nn.Module):\n    def __init__(self, opt, device):\n        ...\n        # LR feature extraction block\n        self.conv_in = ConvBlock(\n            in_channels,\n            4 * num_features,\n            kernel_size=3,\n            act_type=act_type,\n            norm_type=norm_type)\n        self.feat_in = nn.PixelShuffle(2)\n        ...\n        self.out = DeconvBlock(  # \u53cd\u5377\u79ef\u5c42\n            num_features,\n            num_features,\n            kernel_size=kernel_size,\n            stride=stride,\n            padding=padding,\n            act_type=&#039;prelu&#039;,\n            norm_type=norm_type)\n        self.conv_out = ConvBlock(  # \u5377\u79ef\n            num_features,\n            out_channels,\n            kernel_size=3,\n            act_type=None,\n            norm_type=norm_type)\n        self.HG = FeedbackHourGlass(hg_num_feature, hg_num_keypoints)\n\n    def forward(self, x):\n        inter_res = nn.functional.interpolate(\n            x,\n            scale_factor=self.upscale_factor,\n            mode=&#039;bilinear&#039;,\n            align_corners=False)\n\n        batch_size = x.size(0)\n\n        x = self.conv_in(x)  # 3*3\u5377\u79ef\n        x = self.feat_in(x)  # pixelshuffle\u64cd\u4f5c\n        sr_outs = []\n        heatmap_outs = []\n        hg_last_hidden = None\n\n        # initalize heatmap and FB feature with first coarse block\n\n        for step in range(self.num_steps):\n            if step == 0:\n                FB_out_first = self.first_block(x)  # \u7b2c\u4e00\u4e2a\u5faa\u73af\u7684block\u7528LR\u7684\u7279\u5f81\u4f5c\u4e3a\u8f93\u5165\n                h = torch.add(inter_res, self.conv_out(self.out(FB_out_first)))\n                heatmap, hg_last_hidden = self.HG(h, hg_last_hidden) \n                self.block.last_hidden = FB_out_first\n                assert self.block.should_reset == False\n            else:\n                FB_out = self.block(x, merge_heatmap_5(heatmap, self.detach_attention))\n                h = torch.add(inter_res, self.conv_out(self.out(FB_out)))\n                heatmap, hg_last_hidden = self.HG(h, hg_last_hidden) \n\n            sr_outs.append(h)\n            heatmap_outs.append(heatmap)\n\n        return sr_outs, heatmap_outs  # return output of every timesteps<\/code><\/pre>\n<h3>\u7591\u95ee<\/h3>\n<p>\u4e3a\u4ec0\u4e48\u4eba\u8138\u8d85\u5206\u7684\u6587\u7ae0\u4f1a\u8865\u5145\u4e00\u4e2aGAN\u7f51\u7edc\uff1f<br \/>\n\u7b54\uff1a\u56e0\u4e3a\u76f4\u63a5\u7528\u7f51\u7edc\u751f\u6210\u7684\u4eba\u8138\u56fe\u50cf\u6307\u6807\u597d\u3002\u800c\u7528gan\u751f\u6210\u7684\u56fe\u50cf\u89c2\u611f\u597d\uff0c\u4f46\u662f\u6307\u6807\u7565\u4f4e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u65b0\u70b9\uff1a \u2460\u4e24\u4e2a\u5faa\u73af\u534f\u4f5c\u7684\u7f51\u7edc\uff0c\u4e00\u4e2a\u6062\u590d\u56fe\u50cf\uff0c\u4e00\u4e2a\u8bc4\u4f30landmark \u2461\u6ce8\u610f\u529b\u878d\u5408\u6a21\u5757 \u89e3\u51b3\u7684\u75db\u70b9\uff1a\u901a\u8fc7\u4f4e\u5206 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[20,11],"_links":{"self":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/181"}],"collection":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":2,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":189,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/181\/revisions\/189"}],"wp:attachment":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/media?parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/categories?post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/tags?post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}