Skip to main content

DocSafe (DocFace)

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

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.0.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.0-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docsafe-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1c3e49cb2a4c1dbc62d28fa5f2b986b338453e17e7eb6d8c76913dcdaf50e69e
MD5 67ed56d43bd8d726834d7b975da3c46d
BLAKE2b-256 4518a6a700e57cb786a60a516c6743fa1a6d696f8eb24ba7170dba0c8a6e3d0e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: docsafe-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c38842a710563a42e0943626307f4efbb7eadb36de040111bf672cf45b5c654
MD5 a9e11e06774dcd67865e7bb25d2d66c7
BLAKE2b-256 213995c0adf079d8a795eb4a0dabc2f3d905773b3e68716c5e51731d7129e502

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

2 files

This release

0.1.0 This release

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