Image/PDF synthesizer for Cradl
Disclaimer
This code does not guarantee that images/PDFs will be successfully synthesized. Use at your own risk.
Installation
$ pip install lucidtech-synthetic
Make sure to have the following software installed on your system before using the CLI:
- ghostscript
Basic Usage
Docker
We recommend disabling networking and setting /path/to/src_dir to read-only as shown below:
docker run --network none -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic pdf /root/src_dir /root/dst_dir
docker run --network none -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic image /root/src_dir /root/dst_dir /usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf 6-36
CLI
synthetic pdf /path/to/src_dir /path/to/dst_dir
synthetic image /path/to/src_dir /path/to/dst_dir /usr/share/fonts/ubuntu/Ubuntu-B.ttf 6-36
/path/to/src_dir is the input directory and should contain your image/PDFs and JSON ground truths
/path/to/dst_dir is the output directory where synthesized image/PDFs and JSON ground truths will be written to
Here is an example of the directory layout for /path/to/src_dir:
/path/to/src_dir
├── a.pdf|jpeg
├── a.json
├── b.pdf|jpeg
└── b.json
The output directory will follow the same layout but with modified images/PDFs and JSON ground truths:
/path/to/dst_dir
├── a.pdf|jpeg
├── a.json
├── b.pdf|jpeg
└── b.json
Using a custom Synthesizer
The following examples shown are for custom PDF synthesizers, but it works similarly for image synthesizers
CLI
synthetic pdf /path/to/src_dir /path/to/dst_dir --synthesizer-class path.to.python.Class
Make sure that parent directory of path.to.python.Class is in your PYTHONPATH
Example using one of the example Synthesizers in examples directory
synthetic pdf /path/to/src_dir /path/to/dst_dir --synthesizer-class examples.exclude-words.synthesizer.ExcludeWordsSynthesizer
Docker
docker run --network none -v /path/to/synthesizer:/root/synthesizer -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic pdf /root/src_dir /root/dst_dir --synthesizer-class mypythonfile.ExcludeWordsSynthesizer
Note that the python module must be mounted into the docker container to /root/synthesizer for it to work. In the above example we assume a directory structure of your custom synthesizer to be like below.
/path/to/synthesizer
└── mypythonfile.py
Example using one of the example Synthesizers in examples directory. The examples directory should already exist in the image so that we don't need to mount anything additional.
docker run --network none -v /path/to/src_dir:/root/src_dir:ro -v /path/to/dst_dir:/root/dst_dir -it lucidtechai/synthetic pdf /root/src_dir /root/dst_dir --synthesizer-class examples.exclude-words.synthesizer.ExcludeWordsSynthesizer
Help
All methods support the --help flag which will provide information on the purpose of the method,
and what arguments could be added.
$ synthetic --help
Known Issues
Image Synthesizer
- Synthesized text does not follow the rotation of the document in the image if document is rotated
- Bounding boxes needed in ground truth
PDF Synthesizer
- Does not synthesize images inside PDF
- Replaced strings are sometimes not hexadecimal encoded even when expected to be
- Text appearing as single characters with custom spacing in PDF will often yield poor results
Metadata
Release files for lucidtech-synthetic 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lucidtech-synthetic-0.6.1.tar.gz | 20.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lucidtech_synthetic-0.6.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 44.5 kB
Release files / lucidtech-synthetic-0.6.1.tar.gz
| Download URL | lucidtech-synthetic-0.6.1.tar.gz |
|---|---|
| Size | 20.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
965dd48715b49ecf3cda1ad6e7c242167024c5eef34ffe79360d6eaee7c1d542
|
|
BLAKE2b-256 checksum How to use checksums |
68d35af82eb666cd6ebb57d00e7e477115d83f7be749979b2f71f42876d5e0eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / lucidtech_synthetic-0.6.1-py2.py3-none-any.whl
| Download URL | lucidtech_synthetic-0.6.1-py2.py3-none-any.whl |
|---|---|
| Size | 24.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
416de5702fbf611312eced4d6db413b025cab43b16493a7565e64ae0841c9215
|
|
BLAKE2b-256 checksum How to use checksums |
695c074776ed241536540c4281930ea43a2e02918136086598bc93c27c27f1fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for lucidtech-synthetic 0.6.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.