Skip to content

sejal-prog/Watermarking

Repository files navigation

Deep Learning based Video Watermarking via Group Equivariant Convolutional Networks

Rotation-Invariant Video Watermarking using Group-Equivariant Convolutional Neural Networks

This repository contains the implementation of my Master's thesis work on improving rotation robustness in video watermarking using Group-Equivariant CNNs (G-CNNs). Built upon Meta's VideoSeal framework.

🎯 Key Contribution

Traditional CNN-based watermarking systems struggle with rotation attacks because standard convolutions are not rotation-equivariant. This work introduces a hybrid architecture that combines:

  • Standard VideoSeal Embedder β€” Full expressiveness for watermark embedding
  • G-ConvNeXt Extractor β€” Group-equivariant ConvNeXt for rotation-invariant extraction

Why Hybrid?

Original Image β†’ [Embedder] β†’ Watermarked β†’ [ROTATION ATTACK] β†’ [Extractor] β†’ Message
                     ↑                                              ↑
              Sees ORIGINAL                                  Sees ROTATED
              (no equivariance needed)                       (needs G-CNN!)

Key insight: Rotation happens after embedding, before extraction. Only the extractor needs rotation invariance.

πŸ“Š Results

Image Evaluation (COCO - 100 images)

Model PSNR Identity Rotate 30Β° Rotate 45Β° Rotate 90Β°
VideoSeal Baseline (22K SA-1B) 44.6 dB 66.1% 51.5% 50.3% 62.9%
G-ConvNeXt C4 44.4 dB 69.6% 61.2% 54.6% 69.4%
G-ConvNeXt C8 44.2 dB 68.4% 59.7% 54.3% 68.1%

Video Evaluation (SA-V - 155 videos)

Model PSNR Identity H264 H265
G-ConvNeXt C4 45.1 dB 67.5% 57.1% 57.7%
G-ConvNeXt C8 43.6 dB 61.7% 54.4% 55.1%

πŸ—οΈ Architecture

G-ConvNeXt Extractor

The extractor uses group-equivariant convolutions from the escnn library:

  1. Lifting Convolution β€” Maps input from ZΒ² to group space G Γ— ZΒ²
  2. Group Convolutions β€” Preserves equivariance through the network
  3. Group Pooling β€” Converts equivariant β†’ invariant features for bit prediction

Supported groups:

  • C4: 4-fold rotation symmetry (0Β°, 90Β°, 180Β°, 270Β°)
  • C8: 8-fold rotation symmetry (0Β°, 45Β°, 90Β°, ..., 315Β°)

Parameter Count

Model Parameters
ConvNeXt-tiny (baseline) ~3.98M
G-ConvNeXt C4 ~4.7M
G-ConvNeXt C8 ~9.5M

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/sejal-prog/Watermarking.git
cd Watermarking

# Create conda environment
conda create -n gcnn_env python=3.10
conda activate gcnn_env

# Install PyTorch
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.1 -c pytorch -c nvidia

# Install dependencies
pip install -r requirements.txt
pip install escnn  # For group-equivariant convolutions

Training

Image Training (G-ConvNeXt C4)

python train.py \
    --image_dataset sa-1b \
    --video_dataset none \
    --batch_size 8 \
    --gradient_accumulation_steps 2 \
    --img_size 256 \
    --extractor_model g_convnext \
    --embedder_model unet_small2_yuv_quant \
    --nbits 128 \
    --epochs 601 \
    --optimizer AdamW,lr=5e-4 \
    --lambda_dec 1.0 \
    --lambda_d 0.1 \
    --lambda_i 0.1 \
    --perceptual_loss yuv \
    --augmentation_config configs/all_augs.yaml

Note: Set group_type: C4 or group_type: C8 in configs/extractor.yaml

Video Fine-tuning

python train.py \
    --image_dataset sa-1b \
    --video_dataset sav \
    --prop_img_vid 0.0 \
    --video_start 601 \
    --frames_per_clip 16 \
    --batch_size_video 1 \
    --extractor_model g_convnext \
    --embedder_model unet_small2_yuv_quant \
    --nbits 128 \
    --epochs 801 \
    --optimizer AdamW,lr=5e-6 \
    --scaling_w 0.2

Evaluation

python -m videoseal.evals.full \
    --checkpoint /path/to/checkpoint.pth \
    --dataset coco \
    --is_video false \
    --num_samples 100 \
    --output_dir outputs/

πŸ“ Project Structure

β”œβ”€β”€ videoseal/
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ extractor.py          # Base extractor classes
β”‚   β”‚   └── g_extractor.py        # G-ConvNeXt extractor
β”‚   β”œβ”€β”€ modules/
β”‚   β”‚   β”œβ”€β”€ g_convnext.py         # G-ConvNeXt blocks and stages
β”‚   β”‚   └── g_common.py           # Common G-CNN utilities
β”‚   └── evals/
β”‚       └── full.py               # Evaluation script
β”œβ”€β”€ configs/
β”‚   β”œβ”€β”€ extractor.yaml            # Extractor config (set group_type here)
β”‚   └── all_augs.yaml             # Augmentation config
β”œβ”€β”€ train.py                      # Training script
└── count_params.py               # Parameter counting utility

πŸ”§ Configuration

Setting Group Type

Edit configs/extractor.yaml:

g_convnext:
  group_type: C4  # Options: C4, C8
  encoder:
    depths: [2, 2, 2]
    dims: [32, 64, 128]

πŸ“š References

πŸ“ Citation

If you use this work, please cite:

@mastersthesis{gcnn_watermarking_2026,
  title={Rotation-Invariant Video Watermarking using Group-Equivariant CNNs},
  author={Sejal},
  year={2026},
  school={Your University}
}

@article{fernandez2024video,
  title={Video Seal: Open and Efficient Video Watermarking},
  author={Fernandez, Pierre and Elsahar, Hady and Yalniz, I. Zeki and Mourachko, Alexandre},
  journal={arXiv preprint arXiv:2412.09492},
  year={2024}
}

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

Rotation-invariant video watermarking using Group Equivariant CNNs (C4/C8/D4). Built on Meta's VideoSeal. Master's thesis project.

Topics

Resources

License

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors