What format should the input of custom collate have?

I am trying to make my custom collate file for the data.DataLoader, I have some difficulty in terms of understanding it.

  1. what format should the inputs of collate have?
    meaning if my collate is like:
def detection_collate(batch):
    """Custom collate fn for dealing with batches of images that have a different
    number of associated object annotations (bounding boxes).

        batch: (tuple) A tuple of tensor images and lists of annotations and their ids

        A tuple containing:
            1) (tensor) batch of images stacked on their 0 dim
            2) (list of tensors) annotations for a given image are stacked on 0 dim
            3) (list of str) id of images

    targets = []
    imgs = []
    ids = []
    for sample in batch:
    return torch.stack(imgs, 0), targets, ids

is there anything wrong with this collate?
Honestly i feel something might be wrong but im not sure, i remember from somewhere that i should not send str to collate? :expressionless::worried:

Any feedback from pytorch expert would be so helpful


This should work fine. Are you getting any error or unexpected output ?