zero-dce➕➕代码实现
时间: 2023-09-24 19:09:37 浏览: 171
Zero-DCE:零参考深曲线估计的Pytorch实施,用于弱光图像增强
你可以使用以下代码来实现 Zero-DCE 算法:
```python
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.models import vgg16
from torchvision.transforms import Normalize
class ZeroDCE(nn.Module):
def __init__(self):
super(ZeroDCE, self).__init__()
self.vgg = vgg16(pretrained=True).features[:23]
self.renorm = Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
self.conv1 = nn.Conv2d(512, 256, kernel_size=1)
self.conv2 = nn.Conv2d(512, 256, kernel_size=1)
self.conv3 = nn.Conv2d(512, 256, kernel_size=1)
self.conv4 = nn.Conv2d(512, 256, kernel_size=1)
self.conv5 = nn.Conv2d(512, 256, kernel_size=1)
self.conv6 = nn.Conv2d(512, 256, kernel_size=1)
self.conv7 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
self.conv8 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
self.conv9 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
self.conv10 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
self.conv11 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
self.conv12 = nn.Conv2d(256, 256, kernel_size=3, padding=1)
self.conv13 = nn.Conv2d(256, 3, kernel_size=1)
def forward(self, x):
x = self.renorm(x)
x = self.vgg(x)
x1 = self.conv1(x)
x1 = self.conv7(F.relu(x1))
x2 = self.conv2(x)
x2 = self.conv8(F.relu(x2))
x3 = self.conv3(x)
x3 = self.conv9(F.relu(x3))
x4 = self.conv4(x)
阅读全文