@@ -101,11 +101,10 @@ def upscale(self, img_path, scale_factor=2, save_intermediate=False, return_imag
101
101
# Read image
102
102
scale_factor = int (scale_factor )
103
103
true_img = imread (img_path , mode = 'RGB' )
104
- init_height , init_width = true_img .shape [0 ], true_img .shape [1 ]
104
+ init_width , init_height = true_img .shape [0 ], true_img .shape [1 ]
105
105
if verbose : print ("Old Size : " , true_img .shape )
106
106
if verbose : print ("New Size : (%d, %d, 3)" % (init_height * scale_factor , init_width * scale_factor ))
107
107
108
- images = None
109
108
img_height , img_width = 0 , 0
110
109
111
110
denoise_models = ['Deep Denoise SR' ]
@@ -120,14 +119,14 @@ def upscale(self, img_path, scale_factor=2, save_intermediate=False, return_imag
120
119
images = img_utils .make_patches (true_img , scale_factor , patch_size , verbose )
121
120
122
121
nb_images = images .shape [0 ]
123
- img_height , img_width = images .shape [1 ], images .shape [2 ]
122
+ img_width , img_height = images .shape [1 ], images .shape [2 ]
124
123
print ("Number of patches = %d, Patch Shape = (%d, %d)" % (nb_images , img_height , img_width ))
125
124
else :
126
125
# Use full image for super resolution
127
- img_height , img_width = self .__match_denoise_size (denoise_models , img_height , img_width , init_height ,
126
+ img_width , img_height = self .__match_denoise_size (denoise_models , img_height , img_width , init_height ,
128
127
init_width , scale_factor )
129
128
130
- images = imresize (true_img , (img_height , img_width ))
129
+ images = imresize (true_img , (img_width , img_height ))
131
130
images = np .expand_dims (images , axis = 0 )
132
131
print ("Image is reshaped to : (%d, %d, %d)" % (images .shape [1 ], images .shape [2 ], images .shape [3 ]))
133
132
@@ -136,7 +135,7 @@ def upscale(self, img_path, scale_factor=2, save_intermediate=False, return_imag
136
135
if save_intermediate :
137
136
if verbose : print ("Saving intermediate image." )
138
137
fn = path [0 ] + "_intermediate_" + path [1 ]
139
- intermediate_img = imresize (true_img , (init_height * scale_factor , init_width * scale_factor ))
138
+ intermediate_img = imresize (true_img , (init_width * scale_factor , init_height * scale_factor ))
140
139
imsave (fn , intermediate_img )
141
140
142
141
# Transpose and Process images
@@ -159,9 +158,9 @@ def upscale(self, img_path, scale_factor=2, save_intermediate=False, return_imag
159
158
else :
160
159
result = result .astype (np .float32 ) * 255.
161
160
162
- # Output shape is (original_height * scale, original_width * scale, nb_channels)
161
+ # Output shape is (original_width * scale, original_height * scale, nb_channels)
163
162
if mode == 'patch' :
164
- out_shape = (init_height * scale_factor , init_width * scale_factor , 3 )
163
+ out_shape = (init_width * scale_factor , init_height * scale_factor , 3 )
165
164
result = img_utils .combine_patches (result , out_shape , scale_factor )
166
165
else :
167
166
result = result [0 , :, :, :] # Access the 3 Dimensional image vector
@@ -181,15 +180,15 @@ def upscale(self, img_path, scale_factor=2, save_intermediate=False, return_imag
181
180
if verbose : print ("Evaluating results." )
182
181
# Convert initial image into correct format
183
182
if intermediate_img is None :
184
- intermediate_img = imresize (true_img , (init_height * scale_factor , init_width * scale_factor ))
183
+ intermediate_img = imresize (true_img , (init_width * scale_factor , init_height * scale_factor ))
185
184
186
185
if mode == 'patch' :
187
186
intermediate_img = img_utils .make_patches (intermediate_img , scale_factor , patch_size , upscale = False )
188
187
else :
189
- img_height , img_width = self .__match_denoise_size (denoise_models , img_height , img_width , init_height ,
188
+ img_width , img_height = self .__match_denoise_size (denoise_models , img_height , img_width , init_height ,
190
189
init_width , scale_factor )
191
190
192
- intermediate_img = imresize (true_img , (img_height , img_width ))
191
+ intermediate_img = imresize (true_img , (img_width , img_height ))
193
192
intermediate_img = np .expand_dims (intermediate_img , axis = 0 )
194
193
195
194
if K .image_dim_ordering () == "th" :
@@ -230,9 +229,9 @@ def create_model(self, height=33, width=33, channels=3, load_weights=False, batc
230
229
Creates a model to be used to scale images of specific height and width.
231
230
"""
232
231
if K .image_dim_ordering () == "th" :
233
- shape = (channels , height , width )
232
+ shape = (channels , width , height )
234
233
else :
235
- shape = (height , width , channels )
234
+ shape = (width , height , channels )
236
235
237
236
init = Input (shape = shape )
238
237
@@ -268,9 +267,9 @@ def create_model(self, height=33, width=33, channels=3, load_weights=False, batc
268
267
Creates a model to be used to scale images of specific height and width.
269
268
"""
270
269
if K .image_dim_ordering () == "th" :
271
- shape = (channels , height , width )
270
+ shape = (channels , width , height )
272
271
else :
273
- shape = (height , width , channels )
272
+ shape = (width , height , channels )
274
273
275
274
init = Input (shape = shape )
276
275
@@ -308,9 +307,9 @@ def create_model(self, height=33, width=33, channels=3, load_weights=False, batc
308
307
from keras .layers import merge
309
308
310
309
if K .image_dim_ordering () == "th" :
311
- shape = (channels , height , width )
310
+ shape = (channels , width , height )
312
311
else :
313
- shape = (height , width , channels )
312
+ shape = (width , height , channels )
314
313
315
314
init = Input (shape = shape )
316
315
@@ -357,9 +356,9 @@ def create_model(self, height=32, width=32, channels=3, load_weights=False, batc
357
356
from keras .layers import merge
358
357
359
358
if K .image_dim_ordering () == "th" :
360
- shape = (channels , height , width )
359
+ shape = (channels , width , height )
361
360
else :
362
- shape = (height , width , channels )
361
+ shape = (width , height , channels )
363
362
364
363
init = Input (shape = shape )
365
364
0 commit comments