one of the targets was in float dtype. But then I tried changing all to int64. Still, the error remains same.
# Convert everything into a torch.Tensor
        boxes = torch.as_tensor(boxes, dtype=torch.int64) 
        
        # Get the labels. We have only one class (wheat head)
        labels = torch.ones((n_objects, ), dtype=torch.int64)
        
        areas = torch.as_tensor(areas, dtype=torch.int64)
        
        # suppose all instances are not crowd
        iscrowd = torch.zeros((n_objects, ), dtype=torch.int64)
        
        if(n_objects == 0):
          boxes = torch.zeros((0,4), dtype=torch.int64)

        target = {
            'boxes': boxes,
            'labels': labels,
            'image_id': torch.tensor([index], dtype=torch.int64),
            'area': areas,
            'iscrowd': iscrowd
        }
        # if self.transform is not None:
        image = self.transform(image)

        return image, target