{"id":332,"date":"2022-03-25T11:38:17","date_gmt":"2022-03-25T11:38:17","guid":{"rendered":"https:\/\/blog.liguanxin.cn\/?p=332"},"modified":"2022-03-25T11:38:17","modified_gmt":"2022-03-25T11:38:17","slug":"%e8%ae%ba%e6%96%87%e7%ac%94%e8%ae%b0-image-super-resolution-using-very-deep-residual-channel-attention-networks","status":"publish","type":"post","link":"https:\/\/blog.liguanxin.cn\/index.php\/2022\/03\/25\/%e8%ae%ba%e6%96%87%e7%ac%94%e8%ae%b0-image-super-resolution-using-very-deep-residual-channel-attention-networks\/","title":{"rendered":"\u8bba\u6587\u7b14\u8bb0\u2014\u2014Image Super-Resolution Using Very Deep Residual Channel Attention Networks"},"content":{"rendered":"<p><strong>\u521b\u65b0\u70b9\uff1a<br \/>\n\uff081\uff09\u975e\u5e38\u6df1\u7684\u6b8b\u5dee\u901a\u9053\u6ce8\u610f\u7f51\u7edc(RCAN)\uff0c\u7528\u4e8e\u9ad8\u7cbe\u5ea6\u7684\u56fe\u50cfSR\u3002\u6211\u4eec\u7684RCAN\u53ef\u4ee5\u6bd4\u4ee5\u524d\u7684\u57fa\u4e8ecnn\u7684\u65b9\u6cd5\u66f4\u6df1\u5165\uff0c\u5e76\u83b7\u5f97\u66f4\u597d\u7684SR\u6027\u80fd\u3002<br \/>\n\uff082\uff09\u6b8b\u5dee\u5230\u6b8b\u5dee(residual in residual)(RIR)\u7ed3\u6784\u6765\u6784\u5efa\u975e\u5e38\u6df1\u7684\u53ef\u8bad\u7ec3\u7f51\u7edc\u3002RIR\u4e2d\u7684\u957f\u3001\u77ed\u8df3\u8fde\u63a5\u6709\u52a9\u4e8e\u7ed5\u8fc7\u4e30\u5bcc\u7684\u4f4e\u9891\u4fe1\u606f\uff0c\u4f7f\u4e3b\u7f51\u7edc\u5b66\u4e60\u5230\u66f4\u6709\u6548\u7684\u4fe1\u606f\u3002<br \/>\n\uff083\uff09\u901a\u9053\u6ce8\u610f(CA)\u673a\u5236\uff0c\u901a\u8fc7\u8003\u8651\u7279\u5f81\u901a\u9053\u4e4b\u95f4\u7684\u76f8\u4e92\u4f9d\u8d56\u5173\u7cfb\u6765\u81ea\u9002\u5e94\u5730\u7f29\u653e\u7279\u5f81\u3002\u8fd9\u79cdCA\u673a\u5236\u8fdb\u4e00\u6b65\u63d0\u9ad8\u4e86\u7f51\u7edc\u7684\u8868\u5f81\u80fd\u529b\u3002<\/strong><\/p>\n<p>\u5173\u952e\u70b9\uff1a\u6b8b\u5dee\u7fa4RG\u3001\u957f\u8df3\u8fde\u63a5LSC\u3001\u77ed\u8df3\u8fde\u63a5SSC\u3001\u901a\u9053\u6ce8\u610f\u529b\u673a\u5236CA<\/p>\n<p>\u7531\u4e8e\u7528\u4e86\u975e\u5e38\u591a\u6b8b\u5dee\u8fde\u63a5\uff0c\u7f51\u7edc\u6df1\u5ea6\u751a\u81f3\u53ef\u4ee5\u8fbe\u5230400\u5c42\u3002<\/p>\n<h1>\u6574\u4f53\u7ed3\u6784<\/h1>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324224909.png\" alt=\"\" \/><\/p>\n<p>\u4e3b\u8981\u5305\u62ec\u56db\u4e2a\u90e8\u5206\uff1a\u6d45\u5c42\u7279\u5f81\u63d0\u53d6\u3001\u6b8b\u5dee(RIR)\u6df1\u5ea6\u7279\u5f81\u63d0\u53d6\u3001\u4e0a\u91c7\u7528\u6a21\u5757\u548c\u91cd\u5efa\u90e8\u5206\u3002<\/p>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324232854.png\" alt=\"\" \/><br \/>\nWLSC\u8868\u793aRIR\u6700\u540e\u4e00\u4e2a\u5377\u79ef\u5c42\u540e\u91c7\u7528\u7684\u6743\u91cd\u3002<\/p>\n<h1>\u901a\u9053\u6ce8\u610f\u529b\u673a\u5236CA<\/h1>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324231333.png\" alt=\"\" \/><br \/>\n\u901a\u9053\u6ce8\u610f(CA)\u673a\u5236\uff0c\u901a\u8fc7\u5efa\u6a21\u7279\u5f81\u901a\u9053\u4e4b\u95f4\u7684\u76f8\u4e92\u4f9d\u8d56\u5173\u7cfb\uff0c\u81ea\u9002\u5e94\u5730\u91cd\u65b0\u8c03\u6574\u6bcf\u4e2a\u901a\u9053\u7ea7\u7279\u5f81\u3002\u8fd9\u6837\u7684CA\u673a\u5236\u5141\u8bb8\u6211\u4eec\u63d0\u51fa\u7684\u7f51\u7edc\u96c6\u4e2d\u4e8e\u66f4\u6709\u7528\u7684\u7f51\u7edc\u3002<br \/>\n\u4e3b\u8981\u6b65\u9aa4\uff1a\u5229\u7528\u5168\u5c40\u5e73\u5747\u6c60\u5316\u65b9\u6cd5\u5c06\u901a\u9053\u7ea7\u7684\u5168\u5c40\u7a7a\u95f4\u4fe1\u606f\u5f15\u5165\u901a\u9053token\u3002<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324233955.png\" alt=\"\" \/><\/p>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324234322.png\" alt=\"\" \/><br \/>\nWD\u662f\u5377\u79ef\u5c42\u7684\u6743\u91cd\u3002<\/p>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324234312.png\" alt=\"\" \/><br \/>\nsc\u662f\u7f29\u653e\u6bd4\u4f8b\uff0cxc\u662f\u7279\u5f81map\u3002<\/p>\n<h1>RCAB\uff1a B\u4e2aresidual channel attention blocks<\/h1>\n<p><img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324234755.png\" alt=\"\" \/><\/p>\n<h4>\u635f\u5931\u51fd\u6570<\/h4>\n<p>L1\u8303\u6570<\/p>\n<h1>CODE<\/h1>\n<p>CA\u5c42\uff0c\u5bf9\u5e94<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324231333.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-python\">## Channel Attention (CA) Layer\nclass CALayer(nn.Module):\n    def __init__(self, channel, reduction=16):\n        super(CALayer, self).__init__()\n        # global average pooling: feature --&gt; point\n        self.avg_pool = nn.AdaptiveAvgPool2d(1)\n        # feature channel downscale and upscale --&gt; channel weight\n        self.conv_du = nn.Sequential(\n                nn.Conv2d(channel, channel \/\/ reduction, 1, padding=0, bias=True),\n                nn.ReLU(inplace=True),\n                nn.Conv2d(channel \/\/ reduction, channel, 1, padding=0, bias=True),\n                nn.Sigmoid()\n        )\n\n    def forward(self, x):\n        y = self.avg_pool(x)\n        y = self.conv_du(y)\n        return x * y<\/code><\/pre>\n<p>RCAB\u5c42\uff0c\u5bf9\u5e94<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220324234755.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-python\">## Residual Channel Attention Block (RCAB)\nclass RCAB(nn.Module):\n    def __init__(\n        self, conv, n_feat, kernel_size, reduction,\n        bias=True, bn=False, act=nn.ReLU(True), res_scale=1):\n\n        super(RCAB, self).__init__()\n        modules_body = []\n        for i in range(2):\n            modules_body.append(conv(n_feat, n_feat, kernel_size, bias=bias))  # \u5377\u79ef\n            if bn: modules_body.append(nn.BatchNorm2d(n_feat))\n            if i == 0: modules_body.append(act)          # \u56fe4\u4e2d\u7684ReLU\u5c42\n        modules_body.append(CALayer(n_feat, reduction))  # \u52a0\u5165CA\u5c42\n        self.body = nn.Sequential(*modules_body)\n        self.res_scale = res_scale\n\n    def forward(self, x):\n        res = self.body(x)\n        #res = self.body(x).mul(self.res_scale)\n        res += x\n        return res<\/code><\/pre>\n<p>RG\u5c42\uff0c\u5bf9\u5e94<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220325192924.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-python\">## Residual Group (RG)\nclass ResidualGroup(nn.Module):\n    def __init__(self, conv, n_feat, kernel_size, reduction, act, res_scale, n_resblocks):\n        super(ResidualGroup, self).__init__()\n        modules_body = []\n        modules_body = [\n            RCAB(\n                conv, n_feat, kernel_size, reduction, bias=True, bn=False, act=nn.ReLU(True), res_scale=1) \\\n            for _ in range(n_resblocks)]\n        modules_body.append(conv(n_feat, n_feat, kernel_size))\n        self.body = nn.Sequential(*modules_body)\n\n    def forward(self, x):\n        res = self.body(x)\n        res += x\n        return res<\/code><\/pre>\n<p>\u6574\u4f53RCAN\u5c42<br \/>\n<img src=\"https:\/\/blog.liguanxin.cn\/wp-content\/uploads\/2022\/03\/\u5fae\u4fe1\u622a\u56fe_20220325193223.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-python\">## Residual Channel Attention Network (RCAN)\nclass RCAN(nn.Module):\n    def __init__(self, args, conv=common.default_conv):\n        super(RCAN, self).__init__()\n\n        n_resgroups = args.n_resgroups\n        n_resblocks = args.n_resblocks\n        n_feats = args.n_feats\n        kernel_size = 3\n        reduction = args.reduction \n        scale = args.scale[0]\n        act = nn.ReLU(True)\n\n        # RGB mean for DIV2K\n        rgb_mean = (0.4488, 0.4371, 0.4040)\n        rgb_std = (1.0, 1.0, 1.0)\n        self.sub_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std)\n\n        # define head module\n        modules_head = [conv(args.n_colors, n_feats, kernel_size)]\n\n        # define body module\n        # RG\u5c42\u53e0\u52a0\n        modules_body = [\n            ResidualGroup(\n                conv, n_feats, kernel_size, reduction, act=act, res_scale=args.res_scale, n_resblocks=n_resblocks) \\\n            for _ in range(n_resgroups)]\n\n        modules_body.append(conv(n_feats, n_feats, kernel_size))\n\n        # define tail module\n        modules_tail = [\n            common.Upsampler(conv, scale, n_feats, act=False),\n            conv(n_feats, args.n_colors, kernel_size)]\n\n        self.add_mean = common.MeanShift(args.rgb_range, rgb_mean, rgb_std, 1)\n\n        self.head = nn.Sequential(*modules_head)\n        self.body = nn.Sequential(*modules_body)\n        self.tail = nn.Sequential(*modules_tail)\n\n    def forward(self, x):\n        x = self.sub_mean(x)  # \u5f52\u4e00\u5316\u5904\u7406\n        x = self.head(x)  # \u6d45\u5c42\u7279\u5f81\u63d0\u53d6\n\n        res = self.body(x) # RG\u7fa4\n        res += x\n\n        x = self.tail(res) # \u4e0a\u91c7\u6837\u6a21\u5757\uff0c\u4e3b\u8981\u7528\u4e86\u4e00\u4e2a\u5377\u79ef\u548c\u4e00\u4e2aPixelShuffle\n        x = self.add_mean(x)  # \u53cd\u5f52\u4e00\u5316\n\n        return x <\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u521b\u65b0\u70b9\uff1a \uff081\uff09\u975e\u5e38\u6df1\u7684\u6b8b\u5dee\u901a\u9053\u6ce8\u610f\u7f51\u7edc(RCAN)\uff0c\u7528\u4e8e\u9ad8\u7cbe\u5ea6\u7684\u56fe\u50cfSR\u3002\u6211\u4eec\u7684RCAN\u53ef\u4ee5\u6bd4\u4ee5\u524d\u7684\u57fa\u4e8ecn [&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":[11,12,21],"_links":{"self":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/332"}],"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=332"}],"version-history":[{"count":6,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":348,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/posts\/332\/revisions\/348"}],"wp:attachment":[{"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/media?parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/categories?post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.liguanxin.cn\/index.php\/wp-json\/wp\/v2\/tags?post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}