In Document Understanding, the challenge of reconstructing damaged, occluded, or incomplete text remains a critical yet unexplored problem. Subsequent document understanding tasks can benefit from a document reconstruction process. In response, this paper presents a novel unified pipeline combining state-of-the-art Optical Character Recognition (OCR), advanced image analysis, masked language modeling, and diffusion-based models to restore and reconstruct text while preserving visual integrity. We create a synthetic dataset of 30{,}078 degraded document images that simulates diverse document degradation scenarios, setting a benchmark for restoration tasks. Our pipeline detects and recognizes text, identifies degradation with an occlusion detector, and uses an inpainting model for semantically coherent reconstruction. A diffusion-based module seamlessly reintegrates text, matching font, size, and alignment. To evaluate restoration quality, we propose a Unified Context Similarity Metric (UCSM), incorporating edit, semantic, and length similarities with a contextual predictability measure that penalizes deviations when the correct text is contextually obvious. Our work advances document restoration, benefiting archival research and digital preservation while setting a new standard for text reconstruction. The OPRB dataset and code are available at Hugging Face and Github respectively.
Figures & tables
Figure 1: Feature completeness across document datasets: OPRB is the only benchmark that jointly provides degradation-aware labels, paired clean/degraded pages, word-level supervision, and restoration-oriented structure, making it more suitable for document restoration than standard layout-only benchmarks.
Figure 2: Sample visualization of occluding patches over a document page. Magnified views highlight representative degradations such as stamps, scribbles, black ink, and other occlusions that partially or fully obscure the text.
Figure 3: t-SNE comparison across document datasets: OPRB occupies both distinct and shared regions in the shared feature space, indicating that it captures degradation patterns and restoration-relevant document conditions not represented by standard clean-layout benchmarks.
Figure 4: PCA variance across datasets: OPRB exhibits broad variation in its document appearance and degradation patterns, which is important for evaluating restoration methods under diverse conditions.
Figure 5: DocRevive: a unified model architecture for the proposed document restoration pipeline. Given a degraded document image, the framework first performs OCR, followed by occlusion-aware blank region extraction to localize missing text areas. The surrounding word context is then grouped and converted into formatted prompt tokens, which are processed by the RoBERTa masked language model to predict the missing content. In parallel, style patches from nearby regions guide the text-editing branch, while text inpainting helps recover occluded neighboring text regions. Finally, postprocessing integrates the edited patches, cleans the gaps between lines, and generates a restored document image.
Figure 6: Visualization of the proposed framework on a real scanned document degraded using whiteboard marker ink. The document image in Left: was destroyed using concentrated ink, whereas the document in Right: was destroyed using diluted ink.
Method
Opaque Classes
Transparent Classes
Special
Average
B.Ink
Burnt
Whitener
Dust
Stamp
Scribble
Avg.
YOLO26n [ 30 ]
93.701
92.254
90.880
71.175
86.802
86.103
86.819
YOLOv8n [ 46 ]
99.452
99.498
99.483
90.498
99.500
99.270
97.950
YOLOv8s [ 46 ]
99.493
99.500
99.496
91.895
99.487
99.442
98.219
YOLOv9c [ 41 ]
99.500
99.500
99.497
90.675
99.500
99.431
98.017
YOLOv10b [ 40 ]
99.490
99.487
99.454
92.153
99.079
99.288
98.159
Table 1: Class-wise occlusion detector ablation after removing the Mixed class. Values report mAP50 (%). Bold texts represent best results whereas underlined texts represent second best results.
Model
UCSM ↑
ED ↓
CER ↓
Exact Match (%) ↑
RoBERTa-large (fill-mask) [ 22 ]
0.6102
8.2662
1.3762
21.60
Qwen3-0.6B (causal LM) [ 38 ]
0.1240
7.0928
1.0807
0.15
Table 2: RoBERTa [ 22 ] vs. Qwen3 [ 38 ] text prediction ablation on a 6000-sample validation subset. Bold represent best results whereas underlined represent second best results. Higher UCSM and exact-match are better, while lower ED and CER are better.
Sample Set
UCSM ↑
Exact Match (%) ↑
ED ↓
RoBERTa
Qwen3
RoBERTa
Qwen3
RoBERTa
Qwen3
0-1000
0.6131
0.1221
22.30
0.10
8.4530
7.3240
1001-2000
0.6201
0.1243
22.40
0.10
8.2380
7.0400
2001-3000
0.6093
0.1154
21.50
0.40
8.2000
7.0470
3001-4000
0.6175
0.1335
23.00
0.20
8.2210
7.0370
4001-5000
0.6046
0.1317
19.90
0.10
8.3670
7.0380
Table 3: Bucket-wise comparison between fine-tuned RoBERTa [ 22 ] and Qwen3 [ 38 ] on a validation fold. Each bucket contains 1000 consecutive expanded validation samples. Bold represent best results whereas underlined represent second best results.
Method and Variant
Precision
Recall
F1-Score
mIoU
LinkNet-ResNet18 [ 8 ]
89.46
92.52
90.97
74.00
LinkNet-ResNet34 [ 8 ]
87.38
91.07
89.18
74.00
LinkNet-ResNet50 [ 8 ]
88.58
93.56
91.00
74.00
DB-ResNet50 [ 21 ]
89.33
95.27
92.20
76.00
DB-MobileNetV3L [ 21 ]
88.60
93.80
91.13
74.00
FAST-tiny [ 11 ]
90.68
94.63
92.61
78.00
Table 4: Text detection performance on OPRB dataset. Bold texts represent best results whereas underlined texts represent second best results. Here DB means Differentiable Binarization
Method
Accuracy
1-NED
Confidence
CLIPOCR [ 42 ]
94.55
97.71
96.34
DATR [ 29 ]
89.97
96.19
90.94
PARSEQ [ 5 ] (Our Baseline)
95.42
98.03
95.85
Table 5: Text recognition performance on OPRB dataset. Bold represent best whereas underlined represent second best results.
Type
SSIM ↑
FID ↓
UCSM ↑
Black Ink
0.6844
19.10
0.6667
Burnt
0.6859
20.50
0.9631
Dust
0.7230
20.08
0.5138
Scribble
0.6748
19.41
0.6352
Stamp
0.6329
38.11
0.3717
Whitener
0.7560
14.36
0.5104
Table 6: Performance comparison across different occlusion types on DocRevive. Higher SSIM and UCSM indicate better perceptual quality, while lower FID indicates better distribution similarity.
Tokenα=
[K=Mα] PreTextα<mask>PostTextα
Algorithm 2 Prompt Token Generation for Emitted Blanks
Figure 7: Visualization of the proposed framework on a few OPRB document images for different types of occlusions. [Zoom in for better visualization]
Figure 8: Visualization of the state of the art industry models on a few OPRB document images for different types of occlusions. [Zoom in for better visualization]
Prediction
ED
Sedit
Ssem
Slen
Ectx
UCSM
Example 1: Semantic Blindness Context: “We evaluate the on three benchmark datasets.” GT: “proposed method”
proposed method (exact match)
0
1.000
1.000
1.000
0.000
1.000
proposed methoc (OCR typo)
1
0.933
0.665
1.000
0.000
0.853
suggested approach (synonym)
13
0.278
0.859
0.833
0.000
0.584
random variables (hallucination)
15
0.062
0.523
0.938
0.000
0.313
Example 2: Length Blindness Both predictions have ED = 5, but severity is opposite
Table 7: Three blind spots of Edit Distance that UCSM addresses. Sedit , Ssem , and Slen are defined in Eqs. ( 5 )–( 7 ), Econtext in Eq. ( 9 ), UCSM in Eq. ( 10 ). Semantic embeddings are computed with all-MiniLM-L6-v2, context predictability with GPT-2.
Figure 9: Graphical visualization of effectiveness of UCSM over Edit Distance [Zoom in for better visualization]
Method
SSIM ↑
PSNR ↑
FID ↓
DocDiff
0.6620
16.46
43.25
GSDM
0.6634
16.58
53.78
NAFNet
0.6663
17.42
67.57
DocRevive (Ours)
0.6814
17.23
9.00
Table 8: Overall comparison on the OPRB subset. Best results in bold . Second best in underline .
SSIM ↑
PSNR ↑
Method
Blk. Ink
Scrib.
Dust
Stamp
Burnt
Whit.
Blk. Ink
Scrib.
Dust
Stamp
Burnt
Whit.
DocDiff
0.6792
0.6726
0.6416
0.6538
0.6748
0.6500
15.90
16.90
16.45
16.12
16.91
16.51
GSDM
0.6814
0. 6751
0.6458
0.6556
0.6742
0.6486
16.93
17.37
15.61
15.75
17.11
16.72
NAFNet
0.6790
0.6699
0.6490
0.6609
0.6805
0.6587
16.73
17.77
17.44
17.10
17.88
17.59
DocRevive
0.6816
0.6745
0.6833
0.6768
0.6866
0.6855
17.24
17.09
17.26
16.83
17.48
17.50
Table 9: Per-occlusion-type SSIM ↑ and PSNR ↑ on the OPRB. Best in bold . Second best in underline
Figure 10: Qualitative comparison of document restoration methods across occlusion types.
Institute of National Security, Minzu University of China, Beijing, China · School of Information Engineering, Minzu University of China, Beijing, China · School of Artificial Intelligence and Computer Science, North China University of Technology, Beijing, China