TextDoctor: Unified Document Image Inpainting via Patch Pyramid Diffusion Models
Wanglong Lu, Lingming Su, Jingjing Zheng, Vinícius Veloso de Melo, Farzaneh Shoeleh, John Hawkin, Terrence Tricco, Hanli Zhao, Xianta Jiang
TL;DR
TextDoctor addresses the challenge of high-resolution, unseen-document inpainting by learning text-element priors from patches and applying diffusion-driven restoration at the whole-document level. It introduces a structure pyramid prediction to capture multiscale text structures and a patch pyramid diffusion model to denoise documents via pyramid patches, enabling memory-efficient, high-quality inpainting across diverse document styles. Across seven public datasets, TextDoctor demonstrates competitive or superior performance to state-of-the-art methods without dataset-specific fine-tuning, with ablations validating the effectiveness of patch-based inference, multiscale structures, and pyramid patches. The work offers a practical, scalable solution for robust document restoration with clear implications for OCR accuracy and downstream document analysis, while noting limitations with very large masks and suggesting directions for faster ultra-high-resolution inference.
Abstract
Digital versions of real-world text documents often suffer from issues like environmental corrosion of the original document, low-quality scanning, or human interference. Existing document restoration and inpainting methods typically struggle with generalizing to unseen document styles and handling high-resolution images. To address these challenges, we introduce TextDoctor, a novel unified document image inpainting method. Inspired by human reading behavior, TextDoctor restores fundamental text elements from patches and then applies diffusion models to entire document images instead of training models on specific document types. To handle varying text sizes and avoid out-of-memory issues, common in high-resolution documents, we propose using structure pyramid prediction and patch pyramid diffusion models. These techniques leverage multiscale inputs and pyramid patches to enhance the quality of inpainting both globally and locally. Extensive qualitative and quantitative experiments on seven public datasets validated that TextDoctor outperforms state-of-the-art methods in restoring various types of high-resolution document images.
