On Text Localization in End-to-End OCR-Free Document Understanding Transformer without Text Localization Supervision
Geewook Kim1 * †, Shuhei Yokoo2 *, Sukmin Seo1, Atsuki Osanai2, Yamato Okamoto2 and Youngmin Baek1�
* Equal Contribution † gwkim.rsrch@gmail.com
Agenda
Introduction: VDU & Donut 🍩
Introduction Part is from Donut ECCV-22 Slide
Visual Document Understanding (VDU)
VDU aims to extract useful information from the document image. For example,
VDU Model
Useful Information
Introduction Part is from Donut ECCV-22 Slide
Example 1: Document Classification
A document classifier aims to extract a category information from the image.
VDU Model
{ "class": "receipt" }
Introduction Part is from Donut ECCV-22 Slide
Example 2: Document Parsing
For another example, a document parser aims to get a data in a format,
such as, JSON or XML, that contains full information.
VDU Model
{ "menu": [
{
"nm": "3002-Kyoto Choco Mochi",
"unitprice": "14.000",
"cnt": "x2",
"price": "28.000"
}, … }
Introduction Part is from Donut ECCV-22 Slide
Conventional VDU Model
Here, we show a representative pipeline of visual document parsing.
Input
Output
{ "items": [
{
"name": "3002-Kyoto Choco Mochi",
"count": 2,
"priceInfo": {
"unitPrice": 14000,
"price": 28000
}
}, {
"name": "1001 - Choco Bun",
"count": 1,
"priceInfo": {
"unitPrice": 22000
"price": 22000
}
}, ...
],
"total": [ {
"menuqty_cnt": 4,
"total_price": 50000
}
]
}
≈
Conventional VDU Model
Most conventional VDU methods share a similar pipeline.
…
…
Input
Output
{ "items": [
{
"name": "3002-Kyoto Choco Mochi",
"count": 2,
"priceInfo": {
"unitPrice": 14000,
"price": 28000
}
}, {
"name": "1001 - Choco Bun",
"count": 1,
"priceInfo": {
"unitPrice": 22000
"price": 22000
}
}, ...
],
"total": [ {
"menuqty_cnt": 4,
"total_price": 50000
}
]
}
≈
Conventional VDU Model
First, a text detector finds all text boxes.
Detection!
Conventional VDU Model
And then, a text recognizer reads all texts in the extracted boxes.
Detection! Recognition!
{ "words": [ {
"id": 1,
"bbox":[[360,2048],...,[355,2127]],
"text": "3002-Kyoto"
}, {
"id": 2,
"bbox":[[801,2074],...,[801,2139]],
"text": "Choco"
}, {
"id": 3,
"bbox":[[1035,2074],...,[1035,2147]],
"text": "Mochi"
}, {
"id": 4,
"bbox":[[761,2172],...,[761,2253]],
"text": "14.000"
}, …, {
"id": 22,
"bbox":[[1573,3030],...,[1571,3126]],
"text": "50.000"
}
]
}
Conventional VDU Model
This two parts are also called as Optical Character Recognition (OCR).
Detection! Recognition!
{ "words": [ {
"id": 1,
"bbox":[[360,2048],...,[355,2127]],
"text": "3002-Kyoto"
}, {
"id": 2,
"bbox":[[801,2074],...,[801,2139]],
"text": "Choco"
}, {
"id": 3,
"bbox":[[1035,2074],...,[1035,2147]],
"text": "Mochi"
}, {
"id": 4,
"bbox":[[761,2172],...,[761,2253]],
"text": "14.000"
}, …, {
"id": 22,
"bbox":[[1573,3030],...,[1571,3126]],
"text": "50.000"
}
]
}
OCR
Conventional VDU Model
Finally, the OCR results are fed to a following module �to get full information of the document.
{ "items": [
{
"name": "3002-Kyoto Choco Mochi",
"count": 2,
"priceInfo": {
"unitPrice": 14000,
"price": 28000
}
}, {
"name": "1001 - Choco Bun",
"count": 1,
"priceInfo": {
"unitPrice": 22000
"price": 22000
}
}, ...
],
"total": [ {
"menuqty_cnt": 4,
"total_price": 50000
}
]
}
≈
{ "words": [ {
"id": 1,
"bbox":[[360,2048],...,[355,2127]],
"text": "3002-Kyoto"
}, {
"id": 2,
"bbox":[[801,2074],...,[801,2139]],
"text": "Choco"
}, {
"id": 3,
"bbox":[[1035,2074],...,[1035,2147]],
"text": "Mochi"
}, {
"id": 4,
"bbox":[[761,2172],...,[761,2253]],
"text": "14.000"
}, …, {
"id": 22,
"bbox":[[1573,3030],...,[1571,3126]],
"text": "50.000"
}
]
}
Detection! Recognition! Parsing!
OCR
Conventional VDU Model:
Details of the Parsing Stage
For example, in most methods, BIO-tags are predicted by a backbone.
… 3002-Kyoto Choco Mochi 14, 000 …
B-name I-name I-name B-price I-price
Transformer Backbone�(BERT, LayoutLM, …)
(Off-the-shelf)�OCR Engine
Conventional VDU Model:
Details of the Parsing Stage
Then, the tag sequence is converted into a final data format (e.g., JSON).
… 3002-Kyoto Choco Mochi 14, 000 …
B-name I-name I-name B-price I-price
Transformer Backbone�(BERT, LayoutLM, …)
(Off-the-shelf)�OCR Engine
{ "menu": [
{
"nm": "3002-Kyoto Choco Mochi",
"unitprice": "14.000",
"cnt": "x2",
"price": "28.000"
}, … }
Conventional VDU Model: Overview
OCR induces several negative ramifications to the subsequent processes.
Input Image
(Off-the-shelf)�OCR Engine
Backbone
(BERT-like)
BIO-Tags / Answer Token Span / etc
Output
New Approach: OCR-free Donut
Donut 🍩�(End-to-end Model)
Token Sequence
Output
Input Image
Pipeline Comparison
Donut 🍩�(End-to-end Model)
Token Sequence
Output
Input Image
Input Image
(Off-the-shelf)�OCR Engine
Backbone
(BERT-like)
BIO-Tags / Answer Token Span / etc
Output
Donut Model Details
This is the overview of Donut.
<vqa><question>what is the price
of choco mochi?</question><answer>
Converted JSON
transformer encoder
Input Image and Prompt
transformer decoder
Donut 🍩
<classification>
<parsing>
<class>receipt</class>
</classification>
14,000</answer></vqa>
<item><name>3002-Kyoto Choco Mochi</name>・・・ </parsing>
{ "items": [{"name": "3002-Kyoto Choco Mochi",
"count": 2,
"unitprice": 14000, …}], … }
Output Sequence
{ "class":"receipt" }
{ "question": "what is the price of choco mochi?",
"answer": "14,000" }
Donut Model Details
The visual encoder maps the input image into a set of embeddings.
<vqa><question>what is the price
of choco mochi?</question><answer>
Converted JSON
transformer encoder
Input Image and Prompt
transformer decoder
Donut 🍩
<classification>
<parsing>
<class>receipt</class>
</classification>
14,000</answer></vqa>
<item><name>3002-Kyoto Choco Mochi</name>・・・ </parsing>
{ "items": [{"name": "3002-Kyoto Choco Mochi",
"count": 2,
"unitprice": 14000, …}], … }
Output Sequence
{ "class":"receipt" }
{ "question": "what is the price of choco mochi?",
"answer": "14,000" }
Donut Model Details
The textual decoder processes the image embeddings and prompt tokens.
<vqa><question>what is the price
of choco mochi?</question><answer>
Converted JSON
transformer encoder
Input Image and Prompt
transformer decoder
Donut 🍩
<classification>
<parsing>
<class>receipt</class>
</classification>
14,000</answer></vqa>
<item><name>3002-Kyoto Choco Mochi</name>・・・ </parsing>
{ "items": [{"name": "3002-Kyoto Choco Mochi",
"count": 2,
"unitprice": 14000, …}], … }
Output Sequence
{ "class":"receipt" }
{ "question": "what is the price of choco mochi?",
"answer": "14,000" }
Donut Model Details
Then, the decoder outputs token sequences,
<vqa><question>what is the price
of choco mochi?</question><answer>
Converted JSON
transformer encoder
Input Image and Prompt
transformer decoder
Donut 🍩
<classification>
<parsing>
<class>receipt</class>
</classification>
14,000</answer></vqa>
<item><name>3002-Kyoto Choco Mochi</name>・・・ </parsing>
{ "items": [{"name": "3002-Kyoto Choco Mochi",
"count": 2,
"unitprice": 14000, …}], … }
Output Sequence
{ "class":"receipt" }
{ "question": "what is the price of choco mochi?",
"answer": "14,000" }
Donut Model Details
that can be converted into a desired data format, such as, a JSON format.
<vqa><question>what is the price
of choco mochi?</question><answer>
Converted JSON
transformer encoder
Input Image and Prompt
transformer decoder
Donut 🍩
<classification>
<parsing>
<class>receipt</class>
</classification>
14,000</answer></vqa>
<item><name>3002-Kyoto Choco Mochi</name>・・・ </parsing>
{ "items": [{"name": "3002-Kyoto Choco Mochi",
"count": 2,
"unitprice": 14000, …}], … }
Output Sequence
{ "class":"receipt" }
{ "question": "what is the price of choco mochi?",
"answer": "14,000" }
Donut Model Details
Swin Transformer and BART are used as an encoder and decoder, respectively.�More details can also be found in the manuscript.
<vqa><question>what is the price
of choco mochi?</question><answer>
Converted JSON
transformer encoder
Input Image and Prompt
transformer decoder
Donut 🍩
<classification>
<parsing>
<class>receipt</class>
</classification>
14,000</answer></vqa>
<item><name>3002-Kyoto Choco Mochi</name>・・・ </parsing>
{ "items": [{"name": "3002-Kyoto Choco Mochi",
"count": 2,
"unitprice": 14000, …}], … }
Output Sequence
{ "class":"receipt" }
{ "question": "what is the price of choco mochi?",
"answer": "14,000" }
Donut showed promising results, and…
Document parsing benchmark scores from the Donut paper (ECCV 22).
Table from https://www.ecva.net/papers/eccv_2022/papers_ECCV/papers/136880493.pdf
Donut has many application, but…
Screenshot from https://huggingface.co/spaces/naver-clova-ix/donut-base-finetuned-cord-v2
Research Motivation & Problems to Solve
How can we obtain the bounding boxes?
Screenshot from https://clova.ai/ocr/en
Our Question
Option 1: Should we revert to using OCR + Parser?
Option 2: Should we incorporate a Pix2Seq-like approach into Donut?
Images are from https://arxiv.org/abs/2109.10852
Research Question: Can we entirely eliminate the need for the localization annotation?
Intuition: Using the cross-attention map as a heat map!
We decided to explore this possibility.
Images are from OCR-Free Document Understanding Transformers (Donut), ECCV-22.
However, a straightforward visualization produces a blurred heatmap.
Proposal:� A bag of tricks for text localization in Donut (Free Donut)
Our idea is derived from three separate analyses:
Q: How to merge heatmaps? A: Use Variance.
Q: Do tokenization affects the maps? A: Yes.
Q: Can we be benefit from a (weak) blob detector? A: Yes.
Otsu’s binarization + Watershed labeling algorithm
In general, many non-text blobs are included.
However, a simple IoU-based blob matching is robust to non-text blobs.
As a result, here are some examples from the CORD test set.
Experiments and Analysis
We test two datasets: CORD and JP Business Card.
CORD.
JP Business Card.
Word-level Eval.
Field-level Eval.
CORD.
JP Business Card.
CORD.
JP Business Card.
Conclusion
If you have any questions please feel free to contact me :)�Thank you!
Thank you!
Contact: gwkim.rsrch@gmail.com