chandlerbing65nm / FakeImageDetection

Official implementation of "Frequency Masking for Universal DeepFake Detection" Accepted to ICASSP2024
https://arxiv.org/abs/2401.06506
Apache License 2.0
30 stars 4 forks source link

I have to give up this code. #7

Open tengshaofeng opened 2 weeks ago

tengshaofeng commented 2 weeks ago

It seems that spending a lot of time without getting the code to run properly, which can be quite frustrating. To ensure others can run the example successfully next time, give a correct test.py script along with the correct parameters. This will help in gaining stars and increasing influence.

chandlerbing65nm commented 2 weeks ago

did you use test.sh as explained in the readme?

chandlerbing65nm commented 2 weeks ago

as stated in the readme: to use the available checkpoint files I uploaded, you have to edit the test.sh, for example like this:

#!/bin/bash

# Define the arguments for your test script
GPUs="$1"
NUM_GPU=$(echo $GPUs | awk -F, '{print NF}')
DATA_TYPE="Wang_CVPR20"  # Wang_CVPR20 or Ojha_CVPR23
MODEL_NAME="RN50" # clip, RN50_mod or RN50
MASK_TYPE="spectral" # spectral, pixel, patch or nomask
BAND="all" # all, low, mid, high
RATIO=15
BATCH_SIZE=64

# Set the CUDA_VISIBLE_DEVICES environment variable to use GPUs
export CUDA_VISIBLE_DEVICES=$GPUs

echo "Using $NUM_GPU GPUs with IDs: $GPUs"

# Run the test command
python -m torch.distributed.launch --nproc_per_node=$NUM_GPU test.py \
  -- \
  --data_type $DATA_TYPE \
  --pretrained \
  --model_name $MODEL_NAME \
  --mask_type $MASK_TYPE \
  --band $BAND \
  --ratio $RATIO \
  --batch_size $BATCH_SIZE \

and then run it exactly like this:

bash test.sh "0"
tengshaofeng commented 2 weeks ago

File "/Users/tengbaoqiang/Library/Python/3.8/lib/python/site-packages/torch/serialization.py", line 426, in init super().init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'checkpoints/mask_15/rn50_spectralmask.pth'

The input parameters is not correct. You should manually set checkpoint_path = 'checkpoints/mask_15/rn50ft_spectralmask.pth' ?

chandlerbing65nm commented 2 weeks ago

You should manually set checkpoint_path = 'checkpoints/mask_15/rn50ft_spectralmask.pth' ?

yes, it's written in the readme.

tengshaofeng commented 2 weeks ago

@chandlerbing65nm Thanks for your reply. But I test 13 myown images, it seems failed for all the fake image. y_pred = [1.5196211e-02 4.5388688e-12 2.7732060e-08 1.9334713e-07 2.4430689e-08 3.9165342e-16 3.7373654e-10 1.2558779e-11 1.1911399e-24 1.9441848e-26 2.2974208e-07 3.8276365e-14 9.0400479e-29] y_ture = [1. 1. 1. 1. 1. 0. 0. 0. 0. 0. 0. 0. 0.] Following is a sample of fake image: 10