I am getting the following error when I run the ‘get_data’ method. I have found in other threads that the code needs to be updated. But, I do not know where from.
I didn’t find it in platform.ai and it also doesn’t appear that the code has been updated on github.
TypeError: coercing to Unicode: need string or buffer, DirectoryIterator found
Following is the traceback.
TypeError Traceback (most recent call last)
in ()
----> 1 val_data = get_data(val_batches)
2
/home/ubuntu/nbs/utils.pyc in get_data(path, target_size)
134
135 def get_data(path, target_size=(224,224)):
–> 136 batches = get_batches(path, shuffle=False, batch_size=1, class_mode=None, target_size=target_size)
137 return np.concatenate([batches.next() for i in range(batches.nb_sample)])
138
/home/ubuntu/nbs/utils.pyc in get_batches(dirname, gen, shuffle, batch_size, class_mode, target_size)
90 target_size=(224,224)):
91 return gen.flow_from_directory(dirname, target_size=target_size,
—> 92 class_mode=class_mode, shuffle=shuffle, batch_size=batch_size)
93
94
/home/ubuntu/anaconda2/lib/python2.7/site-packages/keras/preprocessing/image.pyc in flow_from_directory(self, directory, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format, follow_links)
444 save_prefix=save_prefix,
445 save_format=save_format,
–> 446 follow_links=follow_links)
447
448 def standardize(self, x):
/home/ubuntu/anaconda2/lib/python2.7/site-packages/keras/preprocessing/image.pyc in init(self, directory, image_data_generator, target_size, color_mode, dim_ordering, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format, follow_links)
775 if not classes:
776 classes = []
–> 777 for subdir in sorted(os.listdir(directory)):
778 if os.path.isdir(os.path.join(directory, subdir)):
779 classes.append(subdir)
TypeError: coercing to Unicode: need string or buffer, DirectoryIterator found