CHELSEA234 / HiFi_IFDL

Hierarchical Fine-Grained Image Forgery Detection and Localization (CVPR2023 and IJCV2024)
206 stars 15 forks source link

weights/NLCDetection weight-loading fails #19

Closed JulieChoo closed 1 year ago

JulieChoo commented 1 year ago

Hello, this problem occurred when using the latest weights you provided. Can you help me?

weights/HRNet weight-loading succeeds: weights/HRNet/225000.pth weights/HRNet_params: 6361208 weights/NLCDetection weight-loading fails weights/NLCDetection_params: 528923

pbernabeup commented 1 year ago

I have encountered the same problem, When removing the try/except block it returns the following error:

RuntimeError: Error(s) in loading state_dict for DataParallel: Missing key(s) in state_dict: "module.getmask.getmask.0.weight", "module.getmask.getmask.0.bias", "module.getmask.getmask.2.weight", "module.getmask.getmask.2.bias". Unexpected key(s) in state_dict: "module.FPN_LOC.smooth_s4.0.weight", "module.FPN_LOC.smooth_s4.0.bias", "module.FPN_LOC.smooth_s4.1.weight", "module.FPN_LOC.smooth_s4.1.bias", "module.FPN_LOC.smooth_s3.0.weight", "module.FPN_LOC.smooth_s3.0.bias", "module.FPN_LOC.smooth_s3.1.weight", "module.FPN_LOC.smooth_s3.1.bias", "module.FPN_LOC.smooth_s2.0.weight", "module.FPN_LOC.smooth_s2.0.bias", "module.FPN_LOC.smooth_s2.1.weight", "module.FPN_LOC.smooth_s2.1.bias", "module.FPN_LOC.smooth_s1.0.weight", "module.FPN_LOC.smooth_s1.0.bias", "module.FPN_LOC.smooth_s1.1.weight", "module.FPN_LOC.smooth_s1.1.bias", "module.FPN_LOC.fpn1.0.weight", "module.FPN_LOC.fpn1.1.weight", "module.FPN_LOC.fpn1.1.bias", "module.FPN_LOC.fpn1.1.running_mean", "module.FPN_LOC.fpn1.1.running_var", "module.FPN_LOC.fpn1.1.num_batches_tracked", "module.FPN_LOC.fpn2.0.weight", "module.FPN_LOC.fpn2.1.weight", "module.FPN_LOC.fpn2.1.bias", "module.FPN_LOC.fpn2.1.running_mean", "module.FPN_LOC.fpn2.1.running_var", "module.FPN_LOC.fpn2.1.num_batches_tracked", "module.FPN_LOC.fpn3.0.weight", "module.FPN_LOC.fpn3.1.weight", "module.FPN_LOC.fpn3.1.bias", "module.FPN_LOC.fpn3.1.running_mean", "module.FPN_LOC.fpn3.1.running_var", "module.FPN_LOC.fpn3.1.num_batches_tracked", "module.FPN_LOC.fpn4.0.weight", "module.FPN_LOC.fpn4.1.weight", "module.FPN_LOC.fpn4.1.bias", "module.FPN_LOC.fpn4.1.running_mean", "module.FPN_LOC.fpn4.1.running_var", "module.FPN_LOC.fpn4.1.num_batches_tracked", "module.getmask.conv_1.weight", "module.getmask.conv_1.bias", "module.getmask.conv_2.weight", "module.getmask.conv_2.bias". size mismatch for module.getmask.g.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 288, 1, 1]). size mismatch for module.getmask.g.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for module.getmask.theta.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 288, 1, 1]). size mismatch for module.getmask.theta.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for module.getmask.phi.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([288, 288, 1, 1]). size mismatch for module.getmask.phi.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([288]). size mismatch for module.getmask.W_s.weight: copying a param with shape torch.Size([64, 64, 1, 1]) from checkpoint, the shape in current model is torch.Size([18, 18, 1, 1]). size mismatch for module.getmask.W_s.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([18]). size mismatch for module.branch_cls_level_1.branch_cls.0.weight: copying a param with shape torch.Size([32, 317, 3, 3]) from checkpoint, the shape in current model is torch.Size([32, 271, 3, 3]).

CHELSEA234 commented 1 year ago

@JulieChoo @pabberpe the localization_only file is HiFi_Net_loc.py, which calls models/NLCDetection_loc.py, and the corresponding weights can be found here the localization and detection file is HiFi_Net.py, which calls models/NLCDetection_api.py. The corresponding weights are sitting here Let me know if this can solve your concerns.

JulieChoo commented 1 year ago

Hello author, thank you for your reply. I followed the steps here and used the corresponding weights to get the visualization. But when I use Casiav1's forged images for visualization, the effect I get is not good. May I ask where I went wrong? result

CHELSEA234 commented 1 year ago

@JulieChoo @pabberpe If you are only doing localization on dataset such as CASIA, please follow this loc. if you want to produce result on HiFi-IFDL dataset, please go to det_and_loc, which uses different data preprocessing steps.

pbernabeup commented 1 year ago

@JulieChoo @pabberpe the localization_only file is HiFi_Net_loc.py, which calls models/NLCDetection_loc.py, and the corresponding weights can be found here the localization and detection file is HiFi_Net.py, which calls models/NLCDetection_api.py. The corresponding weights are sitting here Let me know if this can solve your concerns.

This solved my issue. I hadn't seen there were two different download links. Thank you!

JulieChoo commented 1 year ago

@JulieChoo @pabberpe If you are only doing localization on dataset such as CASIA, please follow this loc. if you want to produce result on HiFi-IFDL dataset, please go to det_and_loc, which uses different data preprocessing steps.

Hello author, thank you for your efforts and reply. I solved the problem and can visualize the results on the CASIA dataset.

CHELSEA234 commented 1 year ago

@JulieChoo In fact, you can find both numerical results csv file and visualization in the same section.