Skip to main content

DocSafe

Toward Practical Print-Proof Image Steganography via Frequency Decomposition and Covariance Alignment

DocSafe logo

🌐 Project Website · 📄 Paper (IEEE Xplore) · 📦 PyPI

Deep-learning-based watermark encoder/decoder for images and documents, with a full training pipeline (M1/M2/M3 model variants).

DocSafe encoded image samples Figure 7. Representative samples of encoded images without spatial masking, where the message is uniformly embedded across the entire image. Model M-1 produces high-quality encoded images, but its decoder performs well only on the face image dataset. Models M-2 and M-3 generate encoded images with lower visual quality than M-1, but demonstrate improved and acceptable decoder performance on the object image dataset.

Install

pip install DocSafe

Or from source:

git clone https://github.com/farhadsh1992/DocSafe.git
cd DocSafe
pip install .

Pretrained weights

Model weights are not bundled in the PyPI package (they're hundreds of MB, well past PyPI's practical size limits). Download pre_trained_models/ separately and point path_model= at it — see the release/host you're distributing weights from.

Quickstart: encode / decode a watermark

from DocSafe import encoder, decoder

encoder_router = encoder(model="M1", path_model="pre_trained_models/", secret_size=100)
encoder_router.load_network(device="cpu")

images = encoder_router.read_image(path=["test_images/original_images.jpg"])
image_batch = encoder_router.preprocess_images(images)
encoded = encoder_router(original_images=image_batch, messages="viste", mask=None)
encoder_router.save_encoded_image("encoded.png")

decoder_router = decoder(model="M1", path_model="pre_trained_models/", secret_size=100)
decoder_router.load_network(device="cpu")

encoded_images = decoder_router.read_image(path=["encoded.png"])
encoded_batch = decoder_router.preprocess_images(encoded_images)
messages = decoder_router(encoded_images=encoded_batch, mask=None)
print(messages)

See test_main.py for a complete runnable example.

Training

train_main.py shows the intended DocSafe.Trainer API. Two things to know before running it:

  • configs/paths_config.py hardcodes paths from the original training machine (pretrained_models/..., dataset directories) — edit it for your own environment.
  • Trainer.train() and Trainer.load_network() are still under active development (see the inline NOTE: comments in train_main.py).

Known limitations

  • DocSafe.loss_functions_lib.models.stylegan2 (and everything that depends on it — hyperstyle, psp, e4e, restyle_e4e_encoders, w_encoder, the hypernetworks) JIT-compiles CUDA/C++ extensions on import via torch.utils.cpp_extension.load(). It requires an actual CUDA GPU + nvcc + ninja (pip install DocSafe[stylegan2]) and will not import on CPU-only machines.
  • DocSafe.networks.net_StampOne is superseded/legacy — it isn't used by encoder/decoder/ Trainer (which all use DocSafe.networks.networks_M1/M2/M3) and has an unresolved Deformable_Conv2D dependency in one file.
  • DocSafe.networks.DETR_NET.segmentation's panoptic-segmentation helpers need pip install DocSafe[detr-extras].

License

MIT — see LICENSE.

Download files

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

Source Distribution

docsafe-0.1.1.tar.gz (2.5 MB view details)

Uploaded Source

Built Distribution

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

docsafe-0.1.1-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file docsafe-0.1.1.tar.gz.

File metadata

  • Download URL: docsafe-0.1.1.tar.gz
  • Upload date:
  • Size: 2.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for docsafe-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2949bb586ab0b63cdd84b54cde435d3b7e3c710047f71a1e7b883a72a1397b63
MD5 c19d830d55d633d2ef461acc58f2ccd4
BLAKE2b-256 3357ae80b2ba92809d0fe42da7ebfc4988dcb6947a24c260db9d9e186ad6ec8b

See more details on using hashes here.

File details

Details for the file docsafe-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: docsafe-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for docsafe-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f567ec1d176f677c31880973d64596f509a4a9688e267eb11bf88320dd8d6612
MD5 e2e0a13650e31a8455e5481d72765a17
BLAKE2b-256 6dda1d4d7abc6152788df1208ec368f20114e0b621791fc1bdaf803007c53edb

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page