Frequency-Guided Multi-Scale Composite Network for document image tampering localization.
This repository is prepared for paper submission and focuses on reproducibility.
- Dual-stream input stem: RGB + SRM residual features.
- Wavelet-based encoder-decoder with DWT downsampling and IDWT upsampling.
- Frequency-guided spatial reduction attention (FG-SRA).
- Dual-domain gate bridge (spatial MHSA + learnable spectral filter).
- Multi-scale deep supervision with composite loss (BCE + Dice + Edge).
- Paper link: coming soon
- Pretrained weights: Google Drive
- Inference demo script: coming soon
- Clone the repo:
git clone https://github.com/<your-username>/FG-MSCNet.git
cd FG-MSCNet- Activate conda environment:
conda activate <your_env>- Install PyTorch first (matching your CUDA):
- Install remaining dependencies:
pip install -r requirements.txtUse the DocTamper dataset with this directory layout:
<data_dir>/
DocTamperV1-TrainingSet/
DocTamperV1-TestingSet/
DocTamperV1-FCD/
DocTamperV1-SCD/
LMDB keys expected by dataset.py:
num-samplesimage-%09dlabel-%09d
Important: train.py uses distributed APIs internally. Run it with torchrun even on 1 GPU.
Single GPU:
torchrun --standalone --nproc_per_node=1 train.py \
--data_dir <path/to/data_dir> \
--exp_name fg_mscnet_exp1 \
--runs_dir ./runs \
--img_size 512 \
--batch_size 2 \
--epochs 200 \
--lr 1e-4Multi-GPU (example: 4 GPUs):
torchrun --standalone --nnodes=1 --nproc_per_node=4 train.py \
--data_dir <path/to/data_dir> \
--exp_name fg_mscnet_4gpu \
--runs_dir ./runsResume full training state:
torchrun --standalone --nproc_per_node=1 train.py \
--data_dir <path/to/data_dir> \
--resume runs/<timestamp>_<exp_name>/checkpoints/last_model.pthLoad weights for finetuning:
torchrun --standalone --nproc_per_node=1 train.py \
--data_dir <path/to/data_dir> \
--finetune <path/to/checkpoint.pth>Outputs are saved to:
runs/<timestamp>_<exp_name>/
logs/train.log
tensorboard/
checkpoints/best_model.pth
checkpoints/last_model.pth
Important: eval.py also uses distributed collectives. Use torchrun.
torchrun --standalone --nproc_per_node=1 eval.py \
--data_dir <path/to/data_dir> \
--checkpoint runs/<timestamp>_<exp_name>/checkpoints/best_model.pth \
--img_size 512 \
--save_dir ./eval_results \
--save_n 50Optional flag:
--pred_as_heatmapEvaluation behavior:
- Tests on
fcd,scd, andtest. - Searches threshold from
0.1to0.9(step0.1) and reports the best F1 threshold. - Prints a markdown-style metrics table:
- F1, Precision, Recall, mIoU, Accuracy, AUC-ROC, AP.
- Saves visualization panels under
eval_results/<dataset_name>/.
python look.pyInput RGB
-> InputStem (RGB + SRM fusion)
-> Encoder x4 (DWT + FG-SRA)
-> DDG Bridge
-> Decoder x4 (IDWT + skip + mask guidance)
-> Final head
Outputs: [H, H/2, H/4, H/8]
FG-MSCNet/
layer/
fg_mscnet.py
modules.py
dct.py
srm.py
wavelet.py
dataset.py
loss.py
train.py
eval.py
look.py
requirements.txt
LICENSE
README.md
| Dataset | F1 | Precision | Recall | mIoU | Pixel Acc | AUC-ROC | AP |
|---|---|---|---|---|---|---|---|
| FCD | 0.8483 | 0.9009 | 0.8016 | 0.7366 | 0.9898 | 0.9867 | 0.8803 |
| SCD | 0.9184 | 0.8703 | 0.9721 | 0.8491 | 0.9985 | 0.9995 | 0.9332 |
| TEST | 0.9714 | 0.9697 | 0.9730 | 0.9443 | 0.9993 | 0.9998 | 0.9926 |
This project is released under the MIT License. See LICENSE.
