looooongChen / tfAugmentor

An image augmentation library for tensorflow. It can be used seamlessly with tf.data.Dataset
MIT License
6 stars 1 forks source link

MapDataset with unknown shapes #1

Closed tdincer closed 3 years ago

tdincer commented 4 years ago

Great library! Thank you so much for making it public.

I have a question regarding the main Augmenter class. I'm trying to feed a tensorflow model with augmented images from tfAugmentor. The main Augmenter class is producing mapdata with unknown shapes, e.g. <MapDataset shapes: (, ), types: (tf.float32, tf.float32)> (see the code snippet below). Is it possible to assign the input image's shape to the mapdataset?

train_im_list = tf.data.Dataset.from_tensor_slices(train_im_files) train_seg_list = tf.data.Dataset.from_tensor_slices(train_seg_files) train = tf.data.Dataset.zip((train_im_list, train_seg_list)) train = train.map(process_path, num_parallel_calls=AUTOTUNE) aug = tfaug.Augmentor(('image', 'semantic_mask'), image=['image'], label=['semantic_mask']) aug.flip_up_down(0.5) aug = aug(train, keep_size=True) # The unknown shapes occur here!

net.model.fit(aug.batch(5), epochs=1)

looooongChen commented 3 years ago

sorry not maintaining the project for a long time, the issue is fixed now. A point to mention, if .batch() of tf.data.Dataset is used before augmentation, please set drop_remainder=True. Oherwise, the batch_size will be set to None. The augmention of tfAgmentor requires the batch_size dimension. Btw, the keep_size argument is removed,