ZhendongWang6/DIRE

It seams that the DIRE tensor save format: jpg or png, determine the results of the resnet50 detector

Opened this issue · 1 comments

my computh_dir.sh is

## set MODEL_PATH, num_samples, has_subfolder, images_dir, recons_dir, dire_dir
export CUDA_VISIBLE_DEVICES=0
export NCCL_P2P_DISABLE=1
MODEL_PATH="../models/256x256_diffusion_uncond.pt" # "models/lsun_bedroom.pt, models/256x256_diffusion_uncond.pt"

SAMPLE_FLAGS="--batch_size 1 --num_samples 4  --timestep_respacing ddim20 --use_ddim True"
SAVE_FLAGS="--images_dir ../data/single_test --recons_dir ../recons_test/single_test --dire_dir ../dire_test/single_test"
MODEL_FLAGS="--attention_resolutions 32,16,8 --class_cond False --diffusion_steps 1000 --dropout 0.1 --image_size 256 --learn_sigma True --noise_schedule linear --num_channels 256 --num_head_channels 64 --num_res_blocks 2 --resblock_updown True --use_fp16 True --use_scale_shift_norm True"
mpiexec --allow-run-as-root -n 1 python compute_dire.py --model_path $MODEL_PATH $MODEL_FLAGS  $SAVE_FLAGS $SAMPLE_FLAGS --has_subfolder True

the diffusion model is 256x256_diffusion_uncond.pt, but i also tried other models like lsun_bedroom.pt.
then I run computh_dir.py to get the DIRE img.
then I run the demo.py to use resnet50 cnn model which weights is lsun_adm.pt:

python demo.py -f /data/github_issue/DIRE/dire_test/single_test/single_test -m /data/github_issue/DIRE/models/lsun_adm.pth

this scripts can get Prob of being synthetic.
In the test, the Fake image is png format, the real image is jpg format. these image is download from DiffusionForensics dataasets
My question is: when I using computh_dir.py to save the DIRE tensor to "PNG" format, the Prob of being synthetic always 1.0000; In the other hand, save to "JPG" format, the Prob of being synthetic always 0.0000, no matter whether fake or real image i use.

additionally, the only modify of the code is the compute_dire.py:

fn_save = fn_save.replace("png", "jpg")

add the line constrain to save the dire tensor to "png" format image file