-
Notifications
You must be signed in to change notification settings - Fork 267
/
tests.py
195 lines (140 loc) · 5.16 KB
/
tests.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
from __future__ import print_function, division
from keras.utils.vis_utils import plot_model
import models
import img_utils
if __name__ == "__main__":
path = r"headline_carspeed.jpg"
val_path = "val_images/"
scale = 2
"""
Plot the models
"""
# model = models.ImageSuperResolutionModel(scale).create_model()
# plot_model(model, to_file="architectures/SRCNN.png", show_shapes=True, show_layer_names=True)
# model = models.ExpantionSuperResolution(scale).create_model()
# plot_model(model, to_file="architectures/ESRCNN.png", show_layer_names=True, show_shapes=True)
# model = models.DenoisingAutoEncoderSR(scale).create_model()
# plot_model(model, to_file="architectures/Denoise.png", show_layer_names=True, show_shapes=True)
# model = models.DeepDenoiseSR(scale).create_model()
# plot_model(model, to_file="architectures/Deep Denoise.png", show_layer_names=True, show_shapes=True)
# model = models.ResNetSR(scale).create_model()
# plot_model(model, to_file="architectures/ResNet.png", show_layer_names=True, show_shapes=True)
# model = models.GANImageSuperResolutionModel(scale).create_model(mode='train')
# plot_model(model, to_file='architectures/GAN Image SR.png', show_shapes=True, show_layer_names=True)
# model = models.DistilledResNetSR(scale).create_model()
# plot_model(model, to_file='architectures/distilled_resnet_sr.png', show_layer_names=True, show_shapes=True)
# model = models.NonLocalResNetSR(scale).create_model()
# plot_model(model, to_file='architectures/non_local_resnet_sr.png', show_layer_names=True, show_shapes=True)
"""
Train Super Resolution
"""
# sr = models.ImageSuperResolutionModel(scale)
# sr.create_model()
# sr.fit(nb_epochs=250)
"""
Train ExpantionSuperResolution
"""
# esr = models.ExpantionSuperResolution(scale)
# esr.create_model()
# esr.fit(nb_epochs=250)
"""
Train DenoisingAutoEncoderSR
"""
# dsr = models.DenoisingAutoEncoderSR(scale)
# dsr.create_model()
# dsr.fit(nb_epochs=250)
"""
Train Deep Denoise SR
"""
# ddsr = models.DeepDenoiseSR(scale)
# ddsr.create_model()
# ddsr.fit(nb_epochs=180)
"""
Train Res Net SR
"""
# rnsr = models.ResNetSR(scale)
# rnsr.create_model(load_weights=True)
# rnsr.fit(nb_epochs=50)
"""
Train ESPCNN SR
"""
# espcnn = models.EfficientSubPixelConvolutionalSR(scale)
# espcnn.create_model()
# espcnn.fit(nb_epochs=50)
"""
Train GAN Super Resolution
"""
# gsr = models.GANImageSuperResolutionModel(scale)
# gsr.create_model(mode='train')
# gsr.fit(nb_pretrain_samples=10000, nb_epochs=10)
"""
Train Non Local ResNets
"""
# non_local_rnsr = models.NonLocalResNetSR(scale)
# non_local_rnsr.create_model()
# non_local_rnsr.fit(nb_epochs=50)
"""
Evaluate Super Resolution on Set5/14
"""
# sr = models.ImageSuperResolutionModel(scale)
# sr.evaluate(val_path)
"""
Evaluate ESRCNN on Set5/14
"""
#esr = models.ExpantionSuperResolution(scale)
#esr.evaluate(val_path)
"""
Evaluate DSRCNN on Set5/14 cannot be performed at the moment.
This is because this model uses Deconvolution networks, whose output shape must be pre determined.
This causes the model to fail to predict different images of different image sizes.
"""
#dsr = models.DenoisingAutoEncoderSR(scale)
#dsr.evaluate(val_path)
"""
Evaluate DDSRCNN on Set5/14
"""
#ddsr = models.DeepDenoiseSR(scale)
#ddsr.evaluate(val_path)
"""
Evaluate ResNetSR on Set5/14
"""
# rnsr = models.ResNetSR(scale)
# rnsr.create_model(None, None, 3, load_weights=True)
# rnsr.evaluate(val_path)
"""
Distilled ResNetSR
"""
# distilled_rnsr = models.DistilledResNetSR(scale)
# distilled_rnsr.create_model(None, None, 3, load_weights=True)
# distilled_rnsr.evaluate(val_path)
"""
Evaluate ESPCNN SR on Set 5/14
"""
# espcnn = models.EfficientSubPixelConvolutionalSR(scale)
# espcnn.evaluate(val_path)
"""
Evaluate GAN Super Resolution on Set 5/14
"""
# gsr = models.GANImageSuperResolutionModel(scale)
# gsr.evaluate(val_path)
"""
Evaluate Non Local ResNetSR on Set 5/14
"""
# non_local_rnsr = models.NonLocalResNetSR(scale)
# non_local_rnsr.evaluate(val_path)
"""
Compare output images of sr, esr, dsr and ddsr models
"""
#sr = models.ImageSuperResolutionModel(scale)
#sr.upscale(path, save_intermediate=False, suffix="sr")
#esr = models.ExpantionSuperResolution(scale)
#esr.upscale(path, save_intermediate=False, suffix="esr")
#dsr = models.DenoisingAutoEncoderSR(scale)
#dsr.upscale(path, save_intermediate=False, suffix="dsr")
# ddsr = models.DeepDenoiseSR(scale)
# ddsr.upscale(path, save_intermediate=False, suffix="ddsr")
# rnsr = models.ResNetSR(scale)
# rnsr.create_model(None, None, 3, load_weights=True)
# rnsr.upscale(path, save_intermediate=False, suffix="rnsr")
#gansr = models.GANImageSuperResolutionModel(scale)
#gansr.upscale(path, save_intermediate=False, suffix='gansr')