DALI icon indicating copy to clipboard operation
DALI copied to clipboard

can not find a op or function like width_shift_range in tf.ImageDataGenerator

Open zcuuu opened this issue 3 years ago • 1 comments

datagen_vgg = ImageDataGenerator( // this is tensorflow code rotation_range=0, horizontal_flip=True, width_shift_range=0.1, height_shift_range=0.1, #zoom_range=0.3 )

i can find function like rotation_range ,horizontal_flip when i use import nvidia.dali.fn but i can not find a function to instead replace width_shift_range and height_shift_range

zcuuu avatar May 10 '22 06:05 zcuuu

Hi @zcuuu,

If I understand correctly how these parameters work, you can achieve that with DALI using slice operator, setting out_of_bounds_policy='pad', and using random values to feed rel_start while keeping the shape unchanged. Something like this should work:

images = fn.slice(images, out_of_bounds_policy='pad',
                            rel_shape=(1,1),
                            rel_start=fn.random.uniform(shape=(2,), dtype=types.FLOAT, range=(-1,1)))

JanuszL avatar May 10 '22 07:05 JanuszL