Computer Vision News - August 2020

fast.ai 5 And now let’s use the PETS dataset to demonstrate. %reload_ext autoreload %autoreload 2 %matplotlib inline from fastai.vision import * def get_img(img_url): return open_image(img_url) def plots_of_one_image(img_url, tfms, rows=1, cols=3, width=15, height=5, **kwargs): img = get_img(img_url) [img.apply_tfms(tfms, **kwargs).show(ax=ax) for i,ax in enumerate(plt.subplots( rows,cols, figsize=(width,height)[1].flatten())] source = untar_data(URLs.PETS) testblock = DataBlock(blocks = (ImageBlock, CategoryBlock), get_items=get_image_files, splitter=RandomSplitter(seed=42), get_y=using_attr(RegexLabeller(r'(.+)_\d+.jpg$'), 'name'), item_tfms=[Resize(256)], batch_tfms=[*aug_transforms(xtra_tfms=None)]) test_dls = testblock.dataloaders(source/'images') test_dls.show_batch(max_n=6, nrows=1, ncols=6) test_dls.after_item This returns a Pipeline resize object. R esize has a default behavior that 'squishes' the image to the size specified. The image is resized so that the shorter dimension matches the size specified and the rest padded with what is specified in pad_mode. The method parameter can be be 1 of 3 values: Crop , Pad or Squish(default) eg: method=ResizeMethod.Squish The padding parameter also takes 1 of 3 values: Border , Zeros and Reflection(default) eg: *pad_mode=PadMode.Reflection* . The images are resized/resampled using bilinear and nearest neighbor interpolations. In the next image, the resize effect can be seen in the corners using different colors, which helps for the visualization.

RkJQdWJsaXNoZXIy NTc3NzU=