LayoutLMv3 processor error

For me the normalization was not the problem.
As mentioned in the above posts one of the recurrring problems was that the bounding boxes were too small.

That was not the problem for me:

code to check if each bbox is at least (1,1)

for bbox in bounding_boxes:
assert bbox[2] - bbox[0] > 1
assert bbox[3] - bbox[1] > 1

The problem was that the embedding layer in model wass not accepting the input ids in the data sample. This generally happens when the length of data sample is more than 512. one has to set the truncate parameter to True. So that the length never more than 512. Mine was 700.

encoding = processor(original_image, words, boxes=boxes, return_offsets_mapping=True, max_length=512, padding=“max_length”, truncation=True, return_tensors=“pt”)

But still have not figured out why resize to 224,224.

Thanks John6666

1 Like