Pandas DataFrame causes Problems in CustomDataset

Within my self.transforms-Function in my CustomDataset I want to replace two columns of the original pandas DataFrame dataframe with the new pd.DF which are transformed (BoundingBoxes, Keypoints)

Unfortunately it doesn’t work within in my CustomDS (outside the CustomDS it does).

What I basically do is:
dataframe.bbox = resized_dataframe.bbox
This works, but only if the shapes are the same (which they are and have to be, since my resize function accesses the dataframe.

That’s inside the resize function

def data_transform(img_arr, dataframe, resize, image_height_resize, image_width_resize, flip_probability):

    if resize:

        ### resize image and if needed: flipped
        transform_resize_img_bb_kyp = albumentations.Compose(
        [albumentations.Resize(height=image_height_resize, width=image_width_resize, always_apply=True),
         albumentations.HorizontalFlip(p=flip_probability)],
        bbox_params=albumentations.BboxParams(format='pascal_voc', label_fields=[]),
        keypoint_params=albumentations.KeypointParams(format="xy"))

        transformed_img_bb_kyp = transform_resize_img_bb_kyp(image=img_arr, bboxes=dataframe.bbox, keypoints=dataframe.forward_keypoint)
        bb = pd.DataFrame(transformed_img_bb_kyp["bboxes"])
        kp = pd.DataFrame(transformed_img_bb_kyp["keypoints"])
        print(f"While Transform: Shape resized Dataframe {dataframe.bbox.shape}")
        print(f"While Transform: Shape resized BoundingBox {bb.shape}")
        dataframe.bbox = bb
        dataframe.forward_keypoint = kp

        print("resized")

        return transformed_img_bb_kyp["image"], dataframe

The result:
grafik

The ValueError can’t be right, since the Shape resized BoundingBox is a result / outcome of the dataframe (9,4)
It also says that the shape of the Dataframe itself is (9, NOTHING) which can’t be (and is not) true, because of the same reason as above.

So what could be wrong here?

I am even thinking about a workaround to just return the untouched dataframe and resizedBoundingBoxes and replace the values after the return of the CustomDataset, within my train_function

Could you post a minimal and executable code snippet by adding (random) dataframes, which would reproduce the issue, please?