Example of apply_tfms in docs doesn't work for me


#1

In the docs there is an example to apply transforms.

When I try it with an image that I loaded, I get the error:
TypeError: crop_pad() missing 1 required positional argument: 'size'

I had to change the code snippet from:

tfms = get_transforms()
_, axs = plt.subplots(2,4,figsize=(12,6))
for ax in axs.flatten():
    img = apply_tfms(tfms[0], get_class_ex(), size=224)
    img.show(ax=ax)

To:

tfms = get_transforms()
_, axs = plt.subplots(2,4,figsize=(12,6))
for ax in axs.flatten():
    img = apply_tfms(tfms[0], sample_img, xtra={tfms[1][0].tfm: {"size": 224}}, size=224)
    img.show(ax=ax)

Is this a problem on my part? Or is the example in the docs wrong?

I had a look at the source code, and it seems like the first transform of the tfms array is a random_crop that calls crop_pad which needs the size parameter.


#2

Which version of fastai are you running? I just ran the notebook without any error.
Maybe try to update your fastai (or use a developer install to have master)?


#3

I use the master branch from the repo, so I don’t think updating is the problem. Any other thoughts?


#4

Like I said, i just run the notebook on master without any problem. Can you give us more details about your install and hardware?


(Jeremy Howard (Admin)) #5

Here’s a list of things that might help us help you:


#6

Hi, I was wondering where you ran the notebook. I’m trying to find it but I can’t, after I run the notebook I will provide the details about the installation and hardware, I’ll see if it’s a problem from my side first.


#7

All the documentation notebooks are here.