InkSight: Offline-to-Online Handwriting Conversion by Teaching Vision-Language Models to Read and Write
Organizations: Google DeepMind · EPFL
Abstract
Digital note-taking is gaining popularity, offering a durable, editable, and easily indexable way of storing notes in a vectorized form, known as digital ink. However, a substantial gap remains between this way of note-taking and traditional pen-and-paper note-taking, a practice that is still favored by a vast majority. Our work InkSight, aims to bridge the gap by empowering physical note-takers to effortlessly convert their work (offline handwriting) to digital ink (online handwriting), a process we refer to as derendering. Prior research on the topic has focused on the geometric properties of images, resulting in limited generalization beyond their training domains. Our approach combines reading and writing priors, allowing training a model in the absence of large amounts of paired samples, which are difficult to obtain. To our knowledge, this is the first work that effectively derenders handwritten text in arbitrary photos with diverse visual characteristics and backgrounds. Furthermore, it generalizes beyond its training domain into simple sketches. Our human evaluation reveals that 87% of the samples produced by our model on the challenging HierText dataset are considered as a valid tracing of the input image and 67% look like a pen trajectory traced by a human.
Figures & tables
| Task | Description |
|---|---|
| Vanilla Derender | The model receives a synthetic ink image with a conditioning task prompt and outputs ink tokens corresponding to the image content. |
| Derender with Text | The model receives a synthetic ink image and a task conditioning prompt including the target textual content, and outputs ink tokens corresponding to the provided text within the image. |
| Recognition (Syn/Real) | The model receives a handwriting image (either synthetic or real) and a task conditioning prompt and outputs the recognized textual content. This task uses both synthetic ink images and real images from OCR datasets. |
| Recognize and Derender | This task combines recognition and derendering. The model receives a synthetic ink image and a prompt and outputs both the recognized text and the corresponding ink tokens. |
| Model | IAM | IMGUR5K | HierText | |||
|---|---|---|---|---|---|---|
| F1 | Acc. | F1 | Acc. | F1 | Acc. | |
| Small-p | 0.65 | 0.60 | 0.47 | 0.33 | 0.53 | 0.37 |
| Small-i | 0.65 | 0.59 | 0.51 | 0.33 | 0.61 | 0.44 |
| Large-i | 0.66 | 0.58 | 0.51 | 0.32 | 0.61 | 0.46 |
| GVS | 0.69 | 0.02 | 0.51 | 0.01 | 0.55 | 0.01 |
| Human * | – | – | – | – | 0.64 | 0.74 |
| Setup | IAM | IMGUR5K | HierText | |||
| F1 | Acc. | F1 | Acc. | F1 | Acc. | |
| Small-i † | 0.66 | 0.59 | 0.51 | 0.33 | 0.61 | 0.45 |
| Vanilla | 0.61\,{\color[rgb]{0.8,0,0}\downarrow} | 0.53\,{\color[rgb]{0.8,0,0}\downarrow} | 0.44\,{\color[rgb]{0.8,0,0}\downarrow} | 0.28\,{\color[rgb]{0.8,0,0}\downarrow} | 0.53\,{\color[rgb]{0.8,0,0}\downarrow} | 0.35\,{\color[rgb]{0.8,0,0}\downarrow} |
| R+D | 0.62\,{\color[rgb]{0.8,0,0}\downarrow} | 0.57\,{\color[rgb]{0.8,0,0}\downarrow} | 0.46\,{\color[rgb]{0.8,0,0}\downarrow} | 0.32 | 0.57\,{\color[rgb]{0.8,0,0}\downarrow} | 0.42\,{\color[rgb]{0.8,0,0}\downarrow} |
| Remove | ||||||
| data aug * | 0.42\,{\color[rgb]{0.8,0,0}\downarrow} | 0.33\,{\color[rgb]{0.8,0,0}\downarrow} | 0.21\,{\color[rgb]{0.8,0,0}\downarrow} | 0.09\,{\color[rgb]{0.8,0,0}\downarrow} | 0.23\,{\color[rgb]{0.8,0,0}\downarrow} | 0.13\,{\color[rgb]{0.8,0,0}\downarrow} |
Appendix figures & tables54 assets
Supplementary material from the paper’s appendix.
Appendix
| Task Type | Dataset | Samples | License / Terms |
| Derendering | DeepWriting (words) | 89,565 | Custom 1 |
| DeepWriting (lines) | 33,933 | Custom 1 | |
| DeepWriting (characters) | 359,643 | Custom 1 | |
| VNOnDB | 66,991 | Custom 2 | |
| SCUT-COUCH (chars) | 1,998,784 | Custom 3 | |
| SCUT-COUCH (pinyin) | 15,653 | Custom 3 |
| Study | Code Availability | Data Availability | Model Weights Availability | Year |
|---|---|---|---|---|
| Mohamed Moussa et al. (2023) | ✗ | ✓ | ✗ | 2023 |
| Chen et al. (2022b) | ✗ Repo missing core elements: data preprocessing, incompatible configs | ✓ | ✗ | 2022 |
| Archibald et al. (2021) | ✗ | ✓ | ✗ | 2021 |
| Bhunia et al. (2021) | ✗ Repo missing core elements: training scripts, data preprocessing | ✓ | ✗ | 2021 |
| Nguyen et al. (2021) | ✗ | ✓ | ✗ | 2021 |
| Sumi et al. (2019) | ✗ | ✓ | ✗ | 2019 |
| Augmentation | Possible Values | Examples |
|---|---|---|
| Rotation | angle (rad): | |
| Stroke color | RGB: | |
| Background color | RGB: | |
| Stroke Width | width: | |
| Lines | line width: line dist: line color: RGB: | |
| Grids | line width: line dist: line color: RGB: |
| Model | Components | Parameters | Training Data |
|---|---|---|---|
| Large-i | ViT-L | 303M | In-house proprietary datasets |
| mT5-Large | 783M | as shown in Appendix C . | |
| Small-i | ViT-B | 85M | In-house proprietary datasets |
| mT5-Base | 247M | as shown in Appendix C . | |
| Small-p | ViT-B | 85M | Publicly available datasets |
| mT5-Base | 247M | as shown in Appendix C . |
| IAMOnDB | Small-i IAM derendered | Small-i IAMOnDB + IAM derendered | Small-p IAM derendered | Small-p IAMOnDB + IAM derendered | Large-i IAM derendered | Large-i IAMOnDB + IAM derendered | |
|---|---|---|---|---|---|---|---|
| CER | 6.1 | 7.8 | 4.6 | 8.2 | 4.5 | 8.4 | 4.6 |
| Description | Instruction |
|---|---|
| Task setup | You will be looking at input images of photos of handwriting in a variety of styles and the corresponding digital ink tracing performed either by a human or by one of our derendering models. Each stroke is rendered in a different color and with color gradient (darker whiter) to reflect the direction. You will see the derendered ink as well as the derendered ink overlaid on top of the image and can use either to make the judgment. For each sample answer the two questions on the right and click submit to proceed to the next sample. |
| Is Reasonable | Is the digital ink a reasonable tracing of the input image? • Yes, it’s a good tracing • It’s an okay tracing, but has some small errors • It’s a bad tracing, has some major artifacts One interpretation of the quality of the ink could be like this: If you were to use it in a note taking app, would you • keep it as is: good tracing • need to make some edits: okay tracing • not use it at all: bad tracing If you need some examples to get a better feeling, you can use the ones below, however there is some ambiguity within the task since we don’t want to impose any strict rules but allow for a natural variety of what people find a good derendering (it is designed to be subjective). |
| Is Real | Could this digital ink have been produced by a human? • Yes • No In this question go with your intuition, do you think the ink could have been traced by a [reasonable] human? |
| Model Summary | |
|---|---|
| Model Architecture | A multimodal sequence-to-sequence Transformer ( Vaswani et al., 2017 ) model with the mT5 ( Xue et al., 2021 ) encoder-decoder architecture. It takes text tokens and ViT ( Dosovitskiy et al., 2021 ) dense image embeddings as inputs to an encoder and autoregressively predicts discrete text and ink tokens with a decoder. |
| Input(s) | A pair of image and text. |
| Output(s) | Generated digital ink. |
| Usage | |
| Application | The model is for research prototype, and the public version Small-p is planned to be released and available for the public. |
| Known Caveats | None. |
Generative Modeling
Generative modeling learns data distributions to create new samples, from images and text to molecules, simulations, and structured records.
See all 493 papers