首页 > 其他分享 >2022CVPR_SNR-Aware Low-light Image Enhancement(SNR)

2022CVPR_SNR-Aware Low-light Image Enhancement(SNR)

时间:2023-05-04 15:33:17浏览次数:49  
标签:__ torch nn light Image vgg SNR self

一. motivation

二. contribution

三.Network

 1. 对于低光照的图片首先采用公式2获得SNR Map

 (1)

Ig:是低光图片

:是经过cv.blur进行均值滤波后的图像

 (2) 对Ig和Ig' 取得灰度图进行绝对值相减得到噪声N

 (3)SNR(mask):均值滤波后的图像与噪声相除得到S

2. 先进行浅层特征提取

 3.  对于fea进行深层特征提取,fea进行两个分支,一个分支(短分支)进行卷积块(更容易捕获局部信息)进行残差连接,另外一个分支(长分支)进行SNR引导的transformer结构(更容易捕获全局信息)

(1)短分支结构

 (2)长分支结构

 transformer包括Attention和FeedForward

对于Attention,对输入的特征进行归一化分别赋给q,k,v

q*k的转置是查看patch之间的相似度

对于mask的操作: 将mask分成s’个pacth,之后按照dim=2取得了mask的均值,采用公式,如果mask 的均值<0.5 则 取值为0,便于后面attention操作

      

 对于mask取值为0的地方,attn中填充为很大的负数,在计算softmax这部分像素值不会发生变化

 FeedForward: 首先归一化,之后全连接+relu,再归一化,一个跳连接。最后输出经过transformer结构的fea_unfold

 

再利用mask:进行特征融合

 

 

四. 损失

1.CharbonnierLoss2:

 大佬链接:https://blog.csdn.net/weixin_43135178/article/details/120865709

class CharbonnierLoss2(nn.Module):
    """Charbonnier Loss (L1)"""

    def __init__(self, eps=1e-6):
        super(CharbonnierLoss2, self).__init__()
        self.eps = eps

    def forward(self, x, y):
        diff = x - y
        loss = torch.mean(torch.sqrt(diff * diff + self.eps))
        return loss

2. perceptual loss

 对于nn.L1Loss中reduction的说明:https://blog.csdn.net/qq_39450134/article/details/121745209

import torchvision
class VGG19(torch.nn.Module):
    def __init__(self, requires_grad=False):
        super().__init__()
        vgg_pretrained_features = torchvision.models.vgg19(pretrained=True).features
        self.slice1 = torch.nn.Sequential()
        self.slice2 = torch.nn.Sequential()
        self.slice3 = torch.nn.Sequential()
        self.slice4 = torch.nn.Sequential()
        self.slice5 = torch.nn.Sequential()
        for x in range(2):
            self.slice1.add_module(str(x), vgg_pretrained_features[x])
        for x in range(2, 7):
            self.slice2.add_module(str(x), vgg_pretrained_features[x])
        for x in range(7, 12):
            self.slice3.add_module(str(x), vgg_pretrained_features[x])
        for x in range(12, 21):
            self.slice4.add_module(str(x), vgg_pretrained_features[x])
        for x in range(21, 30):
            self.slice5.add_module(str(x), vgg_pretrained_features[x])
        if not requires_grad:
            for param in self.parameters():
                param.requires_grad = False

    def forward(self, X):
        h_relu1 = self.slice1(X)
        h_relu2 = self.slice2(h_relu1)
        h_relu3 = self.slice3(h_relu2)
        h_relu4 = self.slice4(h_relu3)
        h_relu5 = self.slice5(h_relu4)
        out = [h_relu1, h_relu2, h_relu3, h_relu4, h_relu5]
        return out


class VGGLoss(nn.Module):
    def __init__(self):
        super(VGGLoss, self).__init__()
        self.vgg = VGG19().cuda()
        # self.criterion = nn.L1Loss()
        self.criterion = nn.L1Loss(reduction='sum')
        self.criterion2 = nn.L1Loss()
        self.weights = [1.0 / 32, 1.0 / 16, 1.0 / 8, 1.0 / 4, 1.0]

    def forward(self, x, y):
        x_vgg, y_vgg = self.vgg(x), self.vgg(y)
        loss = 0
        for i in range(len(x_vgg)):
            # print(x_vgg[i].shape, y_vgg[i].shape)
            loss += self.weights[i] * self.criterion(x_vgg[i], y_vgg[i].detach())
        return loss

 

标签:__,torch,nn,light,Image,vgg,SNR,self
From: https://www.cnblogs.com/yyhappy/p/17371090.html

相关文章

  • Vue使用:内联style动态绑定backgroundImage/background
    1.直接在vue中使用style内联样式设置background或backgroundImage是无效的;比如这样写无效:<divstyle="background:url('../../assets/import/aa1.png')">内容。。。</div>2.必须使用拼接;但是直接拼接也是无效的;比如这样写无效:<div:style="{backgroundImage:'url('......
  • 2022CVPR_Toward Fast, Flexible, and Robust Low-Light Image Enhancement(SCI_main)
    1.motivation(1)低光增强不能处理复杂的场景(2)需要耗费大量的计算2.contribution(1)节省计算(2)发明了自监督的SCI模块(SCI的核心是引入额外的网络模块(自校准照明)来辅助训练,而不是用于测试)大佬链接:(11条消息)低照度增强--论文阅读【《TowardFast,Flexible,andRobustLow-Light......
  • 高颜值在线绘图平台ImageGP系列教程 - 功能介绍
    在线平台BIC是ImageGP的重构升级版,重构于2020年初。该平台采用配置文件快速部署工具、生成结果或结果报告。其绘图和分析基于R语言(ImageGP包,在早期ImageGP脚本的基础上重新进行了封装,GitHub,Gitee)、Python语言。左侧导航目前包括:1.Professionalplotsinseconds;2.......
  • 一个比较强大的提供各种形状的ImageView
    github上比较老的项目了,但是还是比较好用的。各种形状总有一个满足你。在自己的项目中使用,最好不要将所有的类都导入进来,取自己需要的就可以了。<com.github.siyamed.shapeimageview.BubbleImageViewandroid:id="@+id/image"android:layou......
  • 设置ImageView的图片资源是直接来自SD卡
    在设置ImageView资源的时候,这时的图片是来自SD卡,查看API很容易就会看到view.setImageUri(Uriu)这个函数。所以一般会这样写:ImageViewview=(ImageView)findViewById(...);Filefile=newFile(path);Uriuri=Uri.from(file);view.setImageUr......
  • 旋转ImageView和TextView的效果实现
    如图ImageView和TextView组成布局同时旋转。,求实现效果。经过几天研究终于实现如图效果。代码如下,给需要的人吧。还涉及到部分背景图的效果。publicclassIconViewGroupextendsViewGroup{TextViewmTextView;ImageViewmImageView;//显示对应的icon......
  • 大幅超越DALL·E 2和Imagen,斯坦福发布RA-CM3模型,融合检索与生成
    最近,DALL-E和CM3等模型在多模态任务尤其是图文理解上表现出色。然而,这些模型似乎需要将所有学到的知识存储都存储在模型参数中,这就不得不需要越来越大的模型和训练数据来获取更多的知识,俨然将biggerandbetter绑定在了一起。那既然如此,哪还需要算法工程师?全体转行数据标注工程师和......
  • K8s报错:[preflight] WARNING: JoinControlPane.controlPlane settings will be ignore
    一、报错信息[preflight]WARNING:JoinControlPane.controlPlanesettingswillbeignoredwhencontrol-planeflagisnotset.[preflight]Runningpre-flightcheckserrorexecutionphasepreflight:[preflight]Somefatalerrorsoccurred:[ERRORFileAvailabl......
  • An Image Is Worth 16x16 Words: Transformers For Image Recognition At Scale
    模型如下图所示:将H×W×C的图像reshape成了N×(P2×C),其中(H,W)是图像的原始分辨率,C是通道数,(P,P)是每个图像块的分辨率,N=H×W/P2为图像块的数量,将一个图像块使用可学习的线性层映射到维度为D的隐藏向量,如式(1)所示,线性映射的输出称为patchembeddings.在patchembeddin......
  • wordpress插件:代码高亮显示并配置样式(SyntaxHighlighter Evolved 3.6.2 / wordpress
    一,安装插件:SyntaxHighlighterEvolved点击插件->安装插件->输入:SyntaxHighlighter进行搜索结果显示后,找到并进行安装,如图:安装第一个安装后的效果:二,安装插件后调整样式(行高):先找到样式文件路径,当前如下:/wp-content/plugins/syntaxhighlighter/syntaxhighlighter3/......