1616import skimage .transform as transf
1717import skimage .io as io
1818import numpy as np
19+ import cv2
1920
2021sky = [128 , 128 , 128 ]
2122building = [128 , 0 , 0 ]
@@ -98,7 +99,7 @@ def train_generator(batch_size,
9899 target_size = (256 , 256 ),
99100 seed = 1 ):
100101 """Train generator function.
101-
102+
102103 Parameters
103104 ----------
104105 batch_size : int
@@ -129,7 +130,7 @@ def train_generator(batch_size,
129130 Target size for the images. The default is (256, 256).
130131 seed : int, optional
131132 Seed for the random number generator. The default is 1.
132-
133+
133134 Yields
134135 ------
135136 img : array
@@ -188,7 +189,7 @@ def test_generator(test_path,
188189 Flag for multi-class segmentation. The default is False.
189190 as_gray : bool, optional
190191 Flag for grayscale images. The default is True.
191-
192+
192193 Yields
193194 ------
194195 img : array
@@ -203,7 +204,8 @@ def test_generator(test_path,
203204 img = np .reshape (img , img .shape + (1 ,)) \
204205 if not flag_multi_class else img
205206 img = np .reshape (img , (1 , ) + img .shape )
206- yield img
207+ # yield img # Newer versions ask for tuple
208+ yield (img , )
207209
208210
209211def visualize_label (num_class , color_dict , img ):
@@ -217,7 +219,7 @@ def visualize_label(num_class, color_dict, img):
217219 Dictionary of colors.
218220 img : array
219221 Image array.
220-
222+
221223 Returns
222224 -------
223225 img_out : array
@@ -259,4 +261,5 @@ def save_results(save_path, npyfile, flag_multi_class=False, num_class=2):
259261 img = img .astype (np .uint8 )
260262
261263 img_path = os .path .join (save_path , f'{ i } .png' )
262- io .imsave (img_path , img )
264+ # io.imsave(img_path, img) # Newer versions mark error saving in Colab
265+ cv2 .imwrite (img_path , img )
0 commit comments