@@ -14,7 +14,7 @@ def conv_out_size_same(size, stride):
14
14
return int (math .ceil (float (size ) / float (stride )))
15
15
16
16
class DCGAN (object ):
17
- def __init__ (self , sess , input_height = 108 , input_width = 108 , is_crop = True ,
17
+ def __init__ (self , sess , input_height = 108 , input_width = 108 , crop = True ,
18
18
batch_size = 64 , sample_num = 64 , output_height = 64 , output_width = 64 ,
19
19
y_dim = None , z_dim = 100 , gf_dim = 64 , df_dim = 64 ,
20
20
gfc_dim = 1024 , dfc_dim = 1024 , c_dim = 3 , dataset_name = 'default' ,
@@ -33,7 +33,7 @@ def __init__(self, sess, input_height=108, input_width=108, is_crop=True,
33
33
c_dim: (optional) Dimension of image color. For grayscale input, set to 1. [3]
34
34
"""
35
35
self .sess = sess
36
- self .is_crop = is_crop
36
+ self .crop = crop
37
37
38
38
self .batch_size = batch_size
39
39
self .sample_num = sample_num
@@ -52,7 +52,6 @@ def __init__(self, sess, input_height=108, input_width=108, is_crop=True,
52
52
self .gfc_dim = gfc_dim
53
53
self .dfc_dim = dfc_dim
54
54
55
-
56
55
# batch normalization : deals with poor initialization helps gradient flow
57
56
self .d_bn1 = batch_norm (name = 'd_bn1' )
58
57
self .d_bn2 = batch_norm (name = 'd_bn2' )
@@ -76,17 +75,17 @@ def __init__(self, sess, input_height=108, input_width=108, is_crop=True,
76
75
self .c_dim = self .data_X [0 ].shape [- 1 ]
77
76
else :
78
77
self .data = glob (os .path .join ("./data" , self .dataset_name , self .input_fname_pattern ))
79
- self .c_dim = self .data [0 ].shape [- 1 ]
78
+ self .c_dim = imread ( self .data [0 ]) .shape [- 1 ]
80
79
81
- self .is_grayscale = (self .c_dim == 1 )
80
+ self .grayscale = (self .c_dim == 1 )
82
81
83
82
self .build_model ()
84
83
85
84
def build_model (self ):
86
85
if self .y_dim :
87
86
self .y = tf .placeholder (tf .float32 , [self .batch_size , self .y_dim ], name = 'y' )
88
87
89
- if self .is_crop :
88
+ if self .crop :
90
89
image_dims = [self .output_height , self .output_width , self .c_dim ]
91
90
else :
92
91
image_dims = [self .input_height , self .input_width , self .c_dim ]
@@ -179,9 +178,9 @@ def train(self, config):
179
178
input_width = self .input_width ,
180
179
resize_height = self .output_height ,
181
180
resize_width = self .output_width ,
182
- is_crop = self .is_crop ,
183
- is_grayscale = self .is_grayscale ) for sample_file in sample_files ]
184
- if (self .is_grayscale ):
181
+ crop = self .crop ,
182
+ grayscale = self .grayscale ) for sample_file in sample_files ]
183
+ if (self .grayscale ):
185
184
sample_inputs = np .array (sample ).astype (np .float32 )[:, :, :, None ]
186
185
else :
187
186
sample_inputs = np .array (sample ).astype (np .float32 )
@@ -215,9 +214,9 @@ def train(self, config):
215
214
input_width = self .input_width ,
216
215
resize_height = self .output_height ,
217
216
resize_width = self .output_width ,
218
- is_crop = self .is_crop ,
219
- is_grayscale = self .is_grayscale ) for batch_file in batch_files ]
220
- if ( self .is_grayscale ) :
217
+ crop = self .crop ,
218
+ grayscale = self .grayscale ) for batch_file in batch_files ]
219
+ if self .grayscale :
221
220
batch_images = np .array (batch ).astype (np .float32 )[:, :, :, None ]
222
221
else :
223
222
batch_images = np .array (batch ).astype (np .float32 )
0 commit comments