SteganoGAN
SteganoGAN is a tool for creating steganographic images using adversarial training. In our implementation, we fixed the original code's memory leak during training and also refactored the model saving strategy so that pretrained models doesn't have to rely on the model's name. We provide pretrained weights on datasets DIV2K and MS-COCO, available to download at GitHub release - Pretrained weights.
- Source code at DAI-Lab/SteganoGAN.
- Preprint at arXiv:1901.03892.
stegobox.codec.SteganoGAN
Bases: BaseCodec
Source code in stegobox/codec/stegano_gan/steganogan.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
__init__(arch='basic', data_depth=1, hidden_size=32, weights_path=None, cuda=False, verbose=False)
SteganoGAN: high capacity image steganography with GANs.
Extensive work has been done to refactor the original implementation, so the weights provided in the original repo are not compatible with our version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arch |
str
|
Architecture, either |
'basic'
|
data_depth |
int
|
Depth of payload data. Defaults to 1. |
1
|
hidden_size |
int
|
Size of hidden layer. Defaults to 32. |
32
|
weights_path |
Optional[str]
|
Pretrained weights |
None
|
cuda |
bool
|
Whether use cuda or not. Defaults to False. |
False
|
verbose |
bool
|
Whether enable verbose logging or not. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If architecture |
Source code in stegobox/codec/stegano_gan/steganogan.py
encode(carrier, payload)
Encode payload string into carrier image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
carrier |
Image
|
PIL image, choose carefully according to the pretrained model used |
required |
payload |
str
|
Payload secret message |
required |
Returns:
Type | Description |
---|---|
Image
|
Encoded steganographic image. |
Source code in stegobox/codec/stegano_gan/steganogan.py
decode(carrier)
Decode secret message from encoded steganographic image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
carrier |
Image
|
Encoded carrier image. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If failed to decode message from the input image. |
Returns:
Type | Description |
---|---|
str
|
The decoded message if decode is successful. |
Source code in stegobox/codec/stegano_gan/steganogan.py
Training
Tip
You can train your own model following the process in stegobox.codec.stegano_gan.fit.
stegobox.codec.stegano_gan.fit
Call this module if you are training a SteganoGAN model from scratch. From the root directory of the project, call:
python stegobox/codec/stegano_gan/fit.py --arch=basic --epoch=12 --batch-size=32 \
--dataset-root=data/mscoco/ --save-path=basic_mscoco.pt --cuda
Two datasets are available for training the model:
- DIV2K:
- train: http://data.vision.ee.ethz.ch/cvl/DIV2K/DIV2K_train_HR.zip
- validate: http://data.vision.ee.ethz.ch/cvl/DIV2K/DIV2K_valid_HR.zip
- MS-COCO:
- train: http://images.cocodataset.org/zips/train2017.zip
- validate: http://images.cocodataset.org/zips/test2017.zip