It seems you are dealing with input images and masks, which could be a segmentation use case?
If that’s the case, the mask should be your target. I’m not sure, how your use case is related to the get_target_from_path method.