Quick question: resize of target image?

(Thomas) #1

I am building an autoencoder with the ImageImageLIst class
I am able to create the data but I don’t get resizing of the output.

pct = 0.1
sample = 5000
src = (ImageImageList.from_df(df=df_.sample(sample), path=PATH, folder=TRAIN_AUG, suffix='.png')
       .random_split_by_pct(pct, seed=42)

def get_data(sz=64, bs=64):
    data = (src.label_from_func(lambda x: x)
            .transform(tfms, size=sz, tfms_y=True)
            .databunch(bs=bs).normalize(stats, do_y=True)
    data.c = 3
    return data

This only applies tfms and not the resize to output.

data = get_data(64, 2)
x,y = next(iter(data.train_dl))
>>(torch.Size([2, 3, 64, 64]), torch.Size([2, 3, 512, 512]))


Could you share how you defined your src? Just tested it and I got the right sizes.

(Thomas) #3

Thanks for looking, you can check the full nb here:

I noticed the problem when I saw the images with:


and then torch.shape shows the issue.

(Thomas) #4

Any ideas @sgugger ?? I am in 1.34 btw.


There is no s in tfm_y=True. You just made a typo :wink:

(Thomas) #6

LOL! why there is no warning or error? There is no aut complete or shift+atb magic with data block API. That’s something I miss. Actually, this line works:

    data = (src.label_from_func(lambda x: x)
#             .transform(tfms, size=sz, tfms_y=True)
            .transform(superluly, trump_donald=sz, sgugger=True)


Note that you get the tab completion if you do it bits by bits (instead of in one line of code). As for transform, it accepts any kwargs for now, which is something I’m not sure how to fix (since there are several things that can be passed along).

Edit: It’s actually easier than I thought, preparing a fix for this.