The library for creating and decoding invisible image watermarks
Project description
invisible-watermark
invisible-watermark is a python library and command line tool for creating invisible watermark over image.(aka. blink image watermark, digital image watermark). The algorithm doesn't reply on the original image.
Note that this library is still experimental and it doesn't support GPU acceleration, carefully deploy it on the production environment.
supported algorithms:
- Discrete wavelet transform + Discrete cosine transform frequency embedding algorithm variants.
- RivaGAN, a deep-learning model trained from Hollywood2 movie clips dataset.
But only the default method (dwtDCT, ~300ms 1080P image) is suitable for on-the-fly embedding. The other methods are too slow on a CPU only environment.
Supported Algorithms
- frequency methods: algorithm process and test result
- rivaGan: encoder/decoder model with Attention mechanism + embed watermark bits into vector.
How to install
pip install invisible-watermark
Library API
Embed watermark
- example embed 4 characters (32 bits) watermark
import cv2
from imwatermark import WatermarkEncoder
bgr = cv2.imread('test.png')
wm = 'test'
encoder = WatermarkEncoder()
encoder.set_watermark('bytes', wm.encode('utf-8'))
bgr_encoded = encoder.encode(bgr, 'dwtDct')
cv2.imwrite('test_wm.png', bgr_encoded)
Decode watermark
- example decode 4 characters (32 bits) watermark
import cv2
from imwatermark import WatermarkDecoder
bgr = cv2.imread('test_wm.png')
decoder = WatermarkDecoder('bytes', 32)
watermark = decoder.decode(bgr, 'dwtDct')
print(watermark.decode('utf-8'))
CLI Usage
embed watermark: ./invisible-watermark -v -a encode -t bytes -m dwtDct -w 'hello' -o ./test_vectors/wm.png ./test_vectors/original.jpg
decode watermark: ./invisible-watermark -v -a decode -t bytes -m dwtDct -l 40 ./test_vectors/wm.png
positional arguments:
input The path of input
optional arguments:
-h, --help show this help message and exit
-a ACTION, --action ACTION
encode|decode (default: None)
-t TYPE, --type TYPE bytes|b16|bits|uuid|ipv4 (default: bits)
-m METHOD, --method METHOD
dwtDct|dwtDctSvd|rivaGan (default: maxDct)
-w WATERMARK, --watermark WATERMARK
embedded string (default: )
-l LENGTH, --length LENGTH
watermark bits length, required for bytes|b16|bits
watermark (default: 0)
-o OUTPUT, --output OUTPUT
The path of output (default: None)
-v, --verbose print info (default: False)
Test Result
For better doc reading, we compress all images in this page, but the test is taken on 1920x1080 original image.
Methods are not robust to resize or aspect ratio changed crop but robust to noise, color filter, brightness and jpg compress.
rivaGan overcomes default method on crop attack.
only default method is ready for on-the-fly embedding.
Input
- Input Image: 1960x1080 Image
- Watermark:
- For freq method, we use 64bits, string expression "qingquan"
- For RivaGan method, we use 32bits, string expression "qing"
- Parameters: only take U frame to keep image quality,
scale=36
Attack Performance
Watermarked Image
Attacks | Image | Freq Method | RivaGan |
---|---|---|---|
JPG Compress | Pass | Pass | |
Noise | Pass | Pass | |
Brightness | Pass | Pass | |
Overlay | Pass | Pass | |
Mask | Pass | Pass | |
crop 7x5 | Fail | Pass | |
Resize 50% | Fail | Fail | |
Rotate 30 degress | Fail | Fail |
Running Speed (CPU Only)
Method | Encoding | Decoding |
---|---|---|
dwtDct | 300-350ms | 150ms-200ms |
dwtDctSvd | 1500ms-2s | ~1s |
rivaGan | ~5s | 4-5s |
RivaGAN Experimental
Further, We will deliver the 64bit rivaGan model and test the performance on GPU environment.
Detail: https://github.com/DAI-Lab/RivaGAN
Zhang, Kevin Alex and Xu, Lei and Cuesta-Infante, Alfredo and Veeramachaneni, Kalyan. Robust Invisible Video Watermarking with Attention. MIT EECS, September 2019.[PDF]
Project details
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
File details
Details for the file invisible-watermark-0.1.3.tar.gz
.
File metadata
- Download URL: invisible-watermark-0.1.3.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6df1611e0ddd72c4ca80b67376daaeacf31bbd1a01f2359d9bd1adf5650cdc |
|
MD5 | 6b9320c73942ece536b4dc3dbde26139 |
|
BLAKE2b-256 | 9e554203a43075ba0434709b214d96c06a15380d9f95fa622b6b176d915b8741 |
Provenance
File details
Details for the file invisible_watermark-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: invisible_watermark-0.1.3-py3-none-any.whl
- Upload date:
- Size: 1.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d37dcf493eac4b7d838c4dd71a33ad60f653ec2aec5b31307204a7420243fd36 |
|
MD5 | 97545c9b8a0f6e24fc95f9fd2e1c673f |
|
BLAKE2b-256 | 1ab26e431084d3556be0e4348004fe52a501cfb1063a5064373984f77c16381b |