Update README.md
Browse files63 unmodified lines64656667686970717273747576777879808182838485868788899091929394959697989910010110210363 unmodified lines```
## Example
Here is example how to use```def pre_process(sample, processor, max_length=512, ignore_id=-100): # create tensor from image try: image = sample["image"].convert('RGB') pixel_values = processor( image, return_tensors="pt").pixel_values.squeeze() except Exception as e: print(sample) print(f"Error: {e}") return {}
# tokenize document input_ids = processor.tokenizer( sample["text"], add_special_tokens=False, max_length=max_length, padding="max_length", truncation=True, return_tensors="pt", )["input_ids"].squeeze(0)
labels = input_ids.clone() # model doesn't need to predict pad token labels[labels == processor.tokenizer.pad_token_id] = ignore_id return {"pixel_values": pixel_values, "labels": labels, "target_sequence": sample["text"]}
dataset = load_dataset("achang/plot_qa", streaming=True)processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base")processed_dataset = dataset.map(partial(pre_process, processor=processor, max_length=512, ignore_id=-100))```
## Misc
README.md+34