KeyPoint Detection -- ImagePoints can't be label?

Hi there, I’m running fastai version 1.0.59.

I’m trying to use the data block API as found here in the “A Regression Example” section.

I have a get_y_func that returns an ImagePoints object as so:

def get_y_func( filename ):
    label = tensor(img2lab[filename]).reshape(-1,2)
    size = img2size[filename]

    return ImagePoints(FlowField(size, label))

When I use the data block API as so (following the :

data = (PointsItemList
        .label_from_func( get_y_func )
        .transform(transforms, tfm_y=True, size=(300,300), padding_mode='border')
        .databunch(bs=6, num_workers=0, no_check=True)

I get some errors on the .label_from_func(...) function, including a lack of reshape (it turns out ImagePoints has resize) and __len__. I extended this into an ImagePoints2 class, and added the functionality that was lacking.

Now I get to the next line and the .transform(...) throws TypeError: mul(): argument 'other' (position 1) must be Tensor, not ImagePoints2.

Am I doing something obviously wrong? Was this functionality broken in the upgrade for V1?

Check the headpose course notebook here:

That may not have been updated recently

Thanks that was helpful – now I’m using a get_y_func that returns a tensor instead of returning an ImagePoints object.

I have a slight issue in that with the ordinary get_transforms(), some of my key-points are pushed outside the image. This causes the tensor to be resized (e.g., from (4,2) to (2,2)) which stops my data from being collated into a batch. Is there any fix that you know of for this?