Error trying to use nondefault padding_method

I have an image classification problem where I need to resize my images and I want to try padding with zeros. Based on my read of the forums and docs, I thought the following would work:

tfms = get_transforms()
tr_val_databunch = ImageDataBunch.from_df(path='.', 
                                df = train,
                                label_col = label_colname,
                                valid_pct = 0.20, 
                                size = 320,
                                resize_method = ResizeMethod.PAD,
                                padding_method = 'zeros',
                                bs = 20,
                                ds_tfms = tfms).normalize()

But I’m getting the error TypeError: create_from_ll() got an unexpected keyword argument 'padding_method'.

I also get an error if I pass padding_method = 'zeros' in get_transforms().

What is the correct way to set the padding mode to ‘zeros’ for all images which are resized to size = sz (meaning all images in the databunch)?

Thanks!
Max

based on this previous forum answer by @sgugger:

ds_tfms=get_transforms(max_zoom=0, max_warp=0, max_rotate=0), size=sz, padding_mode='zeros')
from Unable to change padding to zeros when using rotation / warp from get_transforms()

I also tried:

tfms = get_transforms()
tr_val_databunch = ImageDataBunch.from_df(path='.', 
                                df = train,
                                label_col = label_colname,
                                valid_pct = 0.20, 
                                resize_method = ResizeMethod.PAD,
                                bs = 20,
                                ds_tfms = tfms,
                                          size = 320,
                                          padding_method = 'zeros').normalize()

and

tfms = get_transforms()
tr_val_databunch = ImageDataBunch.from_df(path='.', 
                                df = train,
                                label_col = label_colname,
                                valid_pct = 0.20, 
#                                resize_method = ResizeMethod.PAD,
                                bs = 20,
                                ds_tfms = tfms,
                                          size = 320,
                                          resize_method = ResizeMethod.PAD,
                                          padding_method = 'zeros').normalize()

…but each gave me the same error as before: "TypeError: create_from_ll() got an unexpected keyword argument 'padding_method'"

The name of the argument is padding_mode, not padding_method.

1 Like

oh dang of course! Sorry for the bad question, but thanks a lot for the help!