Assert boxes.size(1) == 5, 'The boxes tensor shape is not correct as Tensor[K, 5]' AssertionError: The boxes tensor shape is not correct as Tensor[K, 5]

Hello All,

I am getting the following error while using the from torchvision.ops import roi_align function in Pytorch, while using the function roi_align()

assert boxes.size(1) == 5, 'The boxes tensor shape is not correct as 
Tensor[K, 5]' 
AssertionError: The boxes tensor shape is not correct as Tensor[K, 5]

I went through the Pytorch doc and see that it required for it to be of dimension 5, where the 1st column represents the batch index.

boxes (Tensor[K, 5] or List[Tensor[L, 4]]): the box coordinates in (x1, y1, 
x2, y2) format where the regions will be taken from. If a single Tensor is 
passed,then the first column should contain the batch index. If a list of 
Tensors is passed, then each Tensor will correspond to the boxes for 
an element in a batch

I am not quite sure what does the batch index mean here . In my training case, I have set the Batch Size to be 1 and size of boxes which is currently being passed is torch.Size([66, 4]) (where 66 is something which would vary on each batch.)

Thank you!

Hi, did you find solution to your problem.