-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathmodel_test.py
More file actions
34 lines (27 loc) · 962 Bytes
/
model_test.py
File metadata and controls
34 lines (27 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import torch
import torch.nn as nn
class EnhanceNetwork(nn.Module):
def __init__(self):
super(EnhanceNetwork, self).__init__()
self.out_conv = nn.Sequential(
nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, stride=1, padding=1),
nn.ReLU(),
nn.Conv2d(in_channels=3, out_channels=3, kernel_size=3, stride=1, padding=1),
nn.Sigmoid()
)
def forward(self, input):
fea = self.out_conv(input)
illu = fea + input
illu = torch.clamp(illu, 0.0001, 1)
return illu
class Network(nn.Module):
def __init__(self):
super(Network, self).__init__()
self.enhance = EnhanceNetwork()
def forward(self, input):
i1 = self.enhance(input)
r1 = input / i1
r1 = torch.clamp(r1, 0, 1)
return r1