huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
135.11k stars 27.04k forks source link

err_handle(layoutlmv3): Error message doesn't give much clarity when boxes not containing enough information #29127

Open Sushaanth-Suresh-Kumar opened 9 months ago

Sushaanth-Suresh-Kumar commented 9 months ago

System Info

Who can help?

@younesbelkada @ArthurZucker

Information

Tasks

Reproduction


Model I am using LayoutLMv3:

when boxes = [[123, 53], [36, 87], ...] (basically any list which is not according to the proper format) by proper format I mean [[123, 346, 234, 634], [356, 568, 234, 25], ...]

encoding = processor(
        image_1,
        text,
        boxes=boxes,
        max_length=512,
        padding="max_length",
        truncation=True,
        return_tensors="pt"
    )

It produces a this error message

ValueError: Unable to create tensor, you should probably activate truncation and/or padding with 'padding=True' 'truncation=True' to have batched tensors with the same length. Perhaps your features (labels in this case) have excessive nesting (inputs type list where type int is expected).

To Reproduce Steps to reproduce the behavior:

  1. add any list of boxes with not enough values like boxes = [[123, 53], [36, 87], ...]
  2. when run it throws the ValueError mentioned above

Expected behavior

Can throw an error saying

ValueError: boxes doesn't have enough values inside each box. Each box should contain 4 values 
ArthurZucker commented 9 months ago

Would you like to open a PR to improve the error? 🤗

Sushaanth-Suresh-Kumar commented 9 months ago

Sure

Sushaanth-Suresh-Kumar commented 8 months ago

I was busy for a while. I will try it and let you know. @ArthurZucker

I am forked and cloned the huggingface/transformers library. Now when I was following through the instructions. I came into the problem where I am getting this error message below when I was executing this command pip install -e ".[dev]"

This is the Error:

ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11
ERROR: Could not find a version that satisfies the requirement tensorflow-text<2.16; extra == "dev" (from transformers[dev]) (from versions: none)
ERROR: No matching distribution found for tensorflow-text<2.16; extra == "dev"
amyeroberts commented 8 months ago

@Sushaanth-Suresh-Kumar Could you open a new issue for this? This will help us make sure this problem isn't lost, properly tracked and clear if it's been resolved

ArthurZucker commented 7 months ago

Are you running this on macos?