Package: lucidtech-synthetic
Image/PDF synthesizer for CradlDisclaimerThis code does not guarantee that images/PDFs will be successfully synthesized. Use at your own risk.InstallationLink to PyPiLink to Dockerhub$pipinstalllucidtech-syntheticMake sure to have the following software installed on your system before using the CLI:ghostscriptBasic UsageDockerWe recommend disabling networking and setting/path/to/src_dirto read-only as shown below:dockerrun--networknone-v/path/to/src_dir:/root/src_dir:ro-v/path/to/dst_dir:/root/dst_dir-itlucidtechai/syntheticpdf/root/src_dir/root/dst_dir
dockerrun--networknone-v/path/to/src_dir:/root/src_dir:ro-v/path/to/dst_dir:/root/dst_dir-itlucidtechai/syntheticimage/root/src_dir/root/dst_dir/usr/share/fonts/truetype/dejavu/DejaVuSansMono-Bold.ttf6-36CLIsyntheticpdf/path/to/src_dir/path/to/dst_dir
syntheticimage/path/to/src_dir/path/to/dst_dir/usr/share/fonts/ubuntu/Ubuntu-B.ttf6-36/path/to/src_diris the input directory and should contain your image/PDFs and JSON ground truths/path/to/dst_diris the output directory where synthesized image/PDFs and JSON ground truths will be written toHere 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.jsonThe 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.jsonUsing a custom SynthesizerThe following examples shown are for custom PDF synthesizers, but it works similarly for image synthesizersCLIsyntheticpdf/path/to/src_dir/path/to/dst_dir--synthesizer-classpath.to.python.ClassMake sure that parent directory ofpath.to.python.Classis in yourPYTHONPATHExample using one of the example Synthesizers inexamplesdirectorysyntheticpdf/path/to/src_dir/path/to/dst_dir--synthesizer-classexamples.exclude-words.synthesizer.ExcludeWordsSynthesizerDockerdockerrun--networknone-v/path/to/synthesizer:/root/synthesizer-v/path/to/src_dir:/root/src_dir:ro-v/path/to/dst_dir:/root/dst_dir-itlucidtechai/syntheticpdf/root/src_dir/root/dst_dir--synthesizer-classmypythonfile.ExcludeWordsSynthesizerNote that the python module must be mounted into the docker container to/root/synthesizerfor it to work. In the above example we assume a directory structure of your custom synthesizer to be like below./path/to/synthesizer
└── mypythonfile.pyExample using one of the example Synthesizers inexamplesdirectory. Theexamplesdirectory should already exist in the image so that we don't need to mount anything additional.dockerrun--networknone-v/path/to/src_dir:/root/src_dir:ro-v/path/to/dst_dir:/root/dst_dir-itlucidtechai/syntheticpdf/root/src_dir/root/dst_dir--synthesizer-classexamples.exclude-words.synthesizer.ExcludeWordsSynthesizerHelpAll methods support the--helpflag which will provide information on the purpose of the method,
and what arguments could be added.$synthetic--helpKnown IssuesImage SynthesizerSynthesized text does not follow the rotation of the document in the image if document is rotatedBounding boxes needed in ground truthPDF SynthesizerDoes not synthesize images inside PDFReplaced strings are sometimes not hexadecimal encoded even when expected to beText appearing as single characters with custom spacing in PDF will often yield poor results