Skip to content

Instantly share code, notes, and snippets.

@gurucharanmk
Last active March 11, 2020 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gurucharanmk/a114173573cdc08d112cb581355d7721 to your computer and use it in GitHub Desktop.
Save gurucharanmk/a114173573cdc08d112cb581355d7721 to your computer and use it in GitHub Desktop.
Code snippet for medium article
get_x = lambda x:CELEBA_PATH/f'{x[0]}'
get_y = lambda x:[headers[index+1] for index,val in enumerate(x[1:]) if val == 1]
batch_tfms = [*aug_transforms(size=224, max_warp=0), Normalize.from_stats(*imagenet_stats)]
item_tfms = RandomResizedCrop(460, min_scale=0.75, ratio=(1.,1.))
bs=64
celleba_data = DataBlock(blocks=(ImageBlock, MultiCategoryBlock),
get_x=get_x,
splitter=RandomSplitter(),
get_y=get_y,
item_tfms=item_tfms,
batch_tfms=batch_tfms)
dls = celleba_data.dataloaders(df, bs=bs)
dls.show_batch(max_n=9, figsize=(20,9))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment