-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsrcnn.py
29 lines (25 loc) · 1.05 KB
/
srcnn.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
# import packages
from keras.models import Sequential
from keras.layers.convolutional import Conv2D
from keras.layers.core import Activation
from keras import backend as K
class SRCNN:
@staticmethod
def build(width, height, depth):
# initialize the model
model = Sequential()
inputShape = (height, width, depth)
# if we are using "channels_first" update the input shape
if K.image_data_format() == "channels_first":
inputShape = (depth, height, width)
# the entire SRCNN architecture consists of three CONV => RELU
# layers without any zero-padding
model.add(Conv2D(64, (9, 9), kernel_initializer = "he_normal",
input_shape = inputShape))
model.add(Activation("relu"))
model.add(Conv2D(32, (1, 1), kernel_initializer = "he_normal"))
model.add(Activation("relu"))
model.add(Conv2D(depth, (5, 5), kernel_initializer = "he_normal"))
model.add(Activation("relu"))
# return the constructed network architecture
return model