This repository has been archived by the owner on Apr 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convolution_denoise.py
64 lines (61 loc) · 1.71 KB
/
convolution_denoise.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from keras.models import Model
from keras.optimizers import Adam
from keras.layers import Average, Conv2D, Convolution2DTranspose, Input, UpSampling2D
from .base import Base
from .loss_func import psnr_loss
class ConvolutionDenoise(Base):
def _model(self):
inp = Input(shape=(160, 90, 3))
layer = Conv2D(
64,
3,
padding='same',
activation='relu',
input_shape=(160, 90, 3),
)(inp)
layer = UpSampling2D()(layer)
layer_conv = Conv2D(
64,
3,
padding='same',
activation='relu',
input_shape=(320, 180, 64),
)(layer)
layer_deconv = Convolution2DTranspose(
64,
3,
padding='same',
activation='relu',
input_shape=(320, 180, 64),
)(layer_conv)
layer = Average()([layer_conv, layer_deconv])
layer = UpSampling2D()(layer)
layer_conv = Conv2D(
64,
3,
padding='same',
activation='relu',
input_shape=(640, 360, 64),
)(layer)
layer_deconv = Convolution2DTranspose(
64,
3,
padding='same',
activation='relu',
input_shape=(640, 360, 64),
)(layer)
layer = Average()([layer_conv, layer_deconv])
out = Conv2D(
3,
5,
padding='same',
activation='relu',
input_shape=(640, 360, 64),
)(layer)
model = Model(inp, out)
model.compile(
optimizer=Adam(lr=1e-3),
loss='mse',
metrics=[psnr_loss],
)
return model