I have a folder containing images of various sizes. I need to resize them all to (160,120) and create a tf.data.Dataset. For this I used the tf.data.Dataset.from_generator. But I can't seem to figure out how to send the other arguments to the generator like target_size, class_mode etc other than the directory itself. [NOTE: I am using Tensorflow 2.0 Beta1]
The args parameter takes tf.Tensor objects and uses them as arguments for the generator. I tried passing all the arguments as a list.
# gen is the ImageDataGenerator
real_imgs_dataset = tf.data.Dataset.from_generator(gen.flow_from_directory,
args =
(data_path, # DIRECTORY
(160, 128), # TARGET SIZE
'rgb', # COLOR MODE
None, # CLASSES
None, # CLASS MODE
32, # BATCH SIZE
True), # SHUFFLE
output_types = tf.float32,
output_shapes = ([None,160,128,3])
)
What I wanted to do was to pass the images through the generator, and the generator would spit out images batch by batch and create a tf.data.Dataset. However, when I try to run the above snippet, I get an error saying:-
"ValueError: Attempt to convert a value (None) with an unsupported type () to a Tensor"