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.
Metadata
Release files for DocSafe 0.1.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 | |
|---|---|---|---|
| docsafe-0.1.1.tar.gz | 2.5 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docsafe-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.1 MB
Release files / docsafe-0.1.1.tar.gz
| Download URL | docsafe-0.1.1.tar.gz |
|---|---|
| Size | 2.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2949bb586ab0b63cdd84b54cde435d3b7e3c710047f71a1e7b883a72a1397b63
|
|
BLAKE2b-256 checksum How to use checksums |
3357ae80b2ba92809d0fe42da7ebfc4988dcb6947a24c260db9d9e186ad6ec8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / docsafe-0.1.1-py3-none-any.whl
| Download URL | docsafe-0.1.1-py3-none-any.whl |
|---|---|
| Size | 2.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f567ec1d176f677c31880973d64596f509a4a9688e267eb11bf88320dd8d6612
|
|
BLAKE2b-256 checksum How to use checksums |
6dda1d4d7abc6152788df1208ec368f20114e0b621791fc1bdaf803007c53edb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|