DocSafe
Toward Practical Print-Proof Image Steganography via Frequency Decomposition and Covariance Alignment
🌐 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).
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.pyhardcodes paths from the original training machine (pretrained_models/..., dataset directories) — edit it for your own environment.Trainer.train()andTrainer.load_network()are still under active development (see the inlineNOTE:comments intrain_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 viatorch.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_StampOneis superseded/legacy — it isn't used byencoder/decoder/Trainer(which all useDocSafe.networks.networks_M1/M2/M3) and has an unresolvedDeformable_Conv2Ddependency in one file.DocSafe.networks.DETR_NET.segmentation's panoptic-segmentation helpers needpip 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2949bb586ab0b63cdd84b54cde435d3b7e3c710047f71a1e7b883a72a1397b63
|
|
| MD5 |
c19d830d55d633d2ef461acc58f2ccd4
|
|
| BLAKE2b-256 |
3357ae80b2ba92809d0fe42da7ebfc4988dcb6947a24c260db9d9e186ad6ec8b
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f567ec1d176f677c31880973d64596f509a4a9688e267eb11bf88320dd8d6612
|
|
| MD5 |
e2e0a13650e31a8455e5481d72765a17
|
|
| BLAKE2b-256 |
6dda1d4d7abc6152788df1208ec368f20114e0b621791fc1bdaf803007c53edb
|