Skip to main content

Augmentation pipeline for rendering synthetic paper printing and scanning processes

Project description

Augraphy is a Python library that creates multiple copies of original documents though an augmentation pipeline that randomly distorts each copy -- degrading the clean version into dirty and realistic copies rendered through synthetic paper printing, faxing, scanning and copy machine processes.

Highly-configurable pipelines apply adjustments to the originals to create realistic old or noisy documents by acting as a factory, producing almost an infinite number of variations from their source. This simulation of realistic paper-oriented process distortions can create large amounts of training data for AI/ML processes to learn how to remove those distortions.

Treatments applied by Augraphy fabricate realistic documents that appear to have been printed on dirty laser or inkjet printers, scanned by dirty office scanners, faxed by low-resolution fax machines and otherwise mistreated by real-world paper handling office equipment.

What makes Augraphy Magical?

Virtually no readily available datasets exist with both a clean and noisy version of target documents. Augraphy addresses that problem by manufacturing large volumes of high-quality noisy documents to train alongside their clean source originals.

Training neural networks typically requires augmenting limited sources of data in a variety of ways so that networks can learn to generalize their solutions. Networks designed to work with scanned document images must be trained with images that have the type of distortions and noise typical of real-world scanned office documents.

However, if we only have real-world dirty documents, then we don’t have a good way to know for sure what the right answer is when training a neural network. By going in the reverse direction, starting with the clean document we hope a trained network will produce, we can simulate training data with dirty documents for which we already have a perfect original.

With flawless rendering of distorted "originals", we can train a model to undo all that distortion and restore the document to its original form. It’s pretty much magic!

How It Works

Augraphy's augmentation pipeline starts with an image of a clean document. The pipeline begins by extracting the text and graphics from the source into an "ink" layer. (Ink is synonymous with toner within Augraphy.) The augmentation pipeline then distorts and degrades the ink layer.

A paper factory provides either a white page or a randomly-selected paper texture base. Like the ink layer, the paper can also be processed through a pipeline to further provide random realistic paper textures.

After both the ink and paper phases are completed, processing continues by applying the ink, with its desired effects, to the paper. This merged document image is then augmented further with distortions such as adding folds or other physical deformations or distortions that rely on simultaneous interactions of paper and ink layers.

The end result is an image that mimics real documents.

Example Before / After Images

examples

Example Usage

To use the default pipeline which contains all available augmentations and sensible defaults:

from augraphy import *

pipeline = default_augraphy_pipeline()

img = cv2.imread("image.png")

data = pipeline.augment(img)

augmented = data["output"]

Documentation

For full documentation, including installation and tutorials, check the doc directory.

Alternative Augmentation Libraries

There are plenty of choices when it comes to augmentation libraries. However, only Augraphy is designed to address everyday office automation needs associated with paper-oriented process distortions that come from printing, faxing, scanning and copy machines. Most other libraries focus on video and images pertinent to camera-oriented data sources and problem domains. Augraphy is focused on supporting problems related to automation of document images such as OCR, form recognition, form data extraction, document classification, barcode decoding, denoising, document restoration, identity document data extraction, document cropping, etc. Eventually, Augraphy will be able to support photo OCR problems with augmentations designed to emulate camera phone distortions.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Citations

If you used Augraphy in your research, please cite the project.

BibTeX:

@software{The_Augraphy_Project,
author = {{The Augraphy Project}},
title = {{Augraphy: an augmentation pipeline for rendering synthetic paper printing, faxing, scanning and copy machine processes}},
url = {https://github.com/sparkfish/augraphy},
version = {7.0.0}
}

APA:

The Augraphy Project. Augraphy: an augmentation pipeline for rendering synthetic paper printing, faxing, scanning and copy machine processes (Version 7.0.0) [Computer software]. https://github.com/sparkfish/augraphy

License

Copyright 2022 Sparkfish LLC

Augraphy is free and open-source software distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

augraphy-8.0.0.tar.gz (62.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

augraphy-8.0.0-py3-none-any.whl (82.9 kB view details)

Uploaded Python 3

File details

Details for the file augraphy-8.0.0.tar.gz.

File metadata

  • Download URL: augraphy-8.0.0.tar.gz
  • Upload date:
  • Size: 62.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for augraphy-8.0.0.tar.gz
Algorithm Hash digest
SHA256 1f2c33a4adfacdc487f8d234762a43d4fc2324a915a73dff8e531281484a2090
MD5 640ddd6b8eb4cc7da0ae4b69dde4d931
BLAKE2b-256 fdb87e9bc1ba9ed23b0f2c2f64dc0b2e9f80cbf260e607bb3567d8d19a1e30af

See more details on using hashes here.

File details

Details for the file augraphy-8.0.0-py3-none-any.whl.

File metadata

  • Download URL: augraphy-8.0.0-py3-none-any.whl
  • Upload date:
  • Size: 82.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for augraphy-8.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee61f1ad92a18a617e514d642fec0d88257f462b664031fd7f493a5812e4a80b
MD5 3a009c7b4b2db3dc75d484c039ac7b06
BLAKE2b-256 ce239d55e39e1b3935101e66ec4bc4bff9cb3aeb8e5ca6cdb747b95f239638e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page