"Can't pickle local object" on learner.export() for unet_learner

When trying to export a learner which has been trained to identify regions in an image I get the following error:

While not exactly the same as the lesson 2 notebooks, there is a lot of similarities:

def get_y_fn(x): return x.parent.parent / ('labels/' + x.name)

codes = ['background', 'foreground']

src = (SegmentationItemList.from_folder(path)
.label_from_func(get_y_fn, classes=codes))

data = (src.transform(get_transforms(), tfm_y=True)

learn = unet_learner(data, models.resnet34, wd=1e-2, bottle=True)


learn.fit_one_cycle(10, slice(lr), pct_start=0.9)


lrs = slice(lr/400,lr/4)

learn.fit_one_cycle(12, lrs, pct_start=0.8)


I have used a fast.ai installation on my local machine and run the same code via Salamander and both return the same error. Any advice would be fantastic.