Wie kann ich die Option is_split_into_words an layoutlmv3Processor übergeben?Python

Python-Programme
Anonymous
 Wie kann ich die Option is_split_into_words an layoutlmv3Processor übergeben?

Post by Anonymous »

Ich bin ein Layoutlmv3 -Modell mit Huggingface-Transformatoren gut ab. Während der Vorverarbeitung möchte ich is_split_into_words = true verwenden, um eine ordnungsgemäße Etikettenausrichtung für die Token -Klassifizierung sicherzustellen.

Code: Select all

example["words"]
), Begrenzungsboxen und Bezeichnungen
Ich möchte während der Tokenisierung is_split_into_words = true bestehen

Code: Select all

LayoutLMv3Tokenizer.from_pretrained("microsoft/layoutlmv3-base")
processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")

...
def preprocess(example):

image = Image.open(example["image_path"]).convert("RGB")
image_width, image_height = image.size
normalized_bboxes = [normalize_bbox(bbox, image_width, image_height) for bbox in example["bboxes"]]

encoding = processor(
image,
example["words"],
is_split_into_words=True,
boxes=normalized_bboxes,
word_labels=[label2id[l] for l in example["labels"]],
truncation=True,
padding="max_length",
return_tensors="pt"
)

return {
"input_ids": encoding["input_ids"].squeeze(0),
"attention_mask": encoding["attention_mask"].squeeze(0),
"bbox": encoding["bbox"].squeeze(0),
"pixel_values": encoding["pixel_values"].squeeze(0),
"labels": encoding["labels"].squeeze(0)
}

tokenized_dataset = dataset.map(preprocess, remove_columns=dataset.column_names)
< /code>
, aber es löscht: < /p>
TypeError: LayoutLMv3TokenizerFast._batch_encode_plus() got an unexpected keyword argument 'is_split_into_words'

Es sieht so aus>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post