Theivaprakasham / layoutlmv3

This Repository consists of all my experiments performed on LayoutLMv3 model.
Apache License 2.0
28 stars 9 forks source link

Invalid image type. Expected either PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or jax.ndarray, but got <class 'list'>. #3

Open promaprogga opened 7 months ago

promaprogga commented 7 months ago

I am getting this error in this cell

from datasets import Features, Sequence, ClassLabel, Value, Array2D, Array3D

# we need to define custom features for `set_format` (used later on) to work properly
features = Features({
    'pixel_values': Array3D(dtype="float32", shape=(3, 224, 224)),
    'input_ids': Sequence(feature=Value(dtype='int64')),
    'attention_mask': Sequence(Value(dtype='int64')),
    'bbox': Array2D(dtype="int64", shape=(512, 4)),
    'labels': Sequence(feature=Value(dtype='int64')),
})

train_dataset = dataset["train"].map(
    prepare_examples,
    batched=True,
    remove_columns=column_names,
    features=features,
)
eval_dataset = dataset["test"].map(
    prepare_examples,
    batched=True,
    remove_columns=column_names,
    features=features,
)

Map:   0%  0/100 [00:00<?, ? examples/s]

ValueError Traceback (most recent call last) in <cell line: 12>() 10 }) 11 ---> 12 train_dataset = dataset["train"].map( 13 prepare_examples, 14 batched=True,

9 frames /usr/local/lib/python3.10/dist-packages/transformers/image_utils.py in make_list_of_images(images, expected_ndims) 160 ) 161 return images --> 162 raise ValueError( 163 "Invalid image type. Expected either PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or " 164 f"jax.ndarray, but got {type(images)}."

ValueError: Invalid image type. Expected either PIL.Image.Image, numpy.ndarray, torch.Tensor, tf.Tensor or jax.ndarray, but got <class 'list'>.

tianchiguaixia commented 2 months ago

1 (1)