microsoft / unilm

Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities
https://aka.ms/GeneralAI
MIT License
20.21k stars 2.55k forks source link

How to get LayoutLMv2 output as key-value pairs? #465

Closed avinashok closed 3 years ago

avinashok commented 3 years ago

Describe Model I am using is LayoutLMv2:

(Link of the demo for reference: https://huggingface.co/spaces/nielsr/LayoutLMv2-FUNSD )

I do get 'questions' & 'answers' as separate colored boxes in output image. But is there a way to get it as a python dictionary (key-value pairs), as in questions become keys & answers become its corresponding values?

wolfshow commented 3 years ago

@avinashok You may refer to the relation extracton example in LayoutXLM at https://github.com/microsoft/unilm/tree/master/layoutxlm#fine-tuning-for-relation-extraction