ZhendongWang6 / DIRE

[ICCV 2023] Official implementation of the paper: "DIRE for Diffusion-Generated Image Detection"
307 stars 24 forks source link

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

Open JYccode opened 6 months ago

JYccode commented 6 months ago

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.

JYccode commented 6 months ago

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

ww3636 commented 2 months ago

我的computh_dir.sh是

## 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

扩散模型是 256x256_diffusion_uncond.pt,但我也尝试了其他模型,如 lsun_bedroom.pt。然后我computh_dir.py跑去获取夜魇 img。然后我运行 demo.py 以使用 resnet50 cnn 模型,其权重为 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

此脚本可能会获得 Prob 的合成性。在测试中,假图为 png 格式,实图为 jpg 格式。这些图像是从 DiffusionForensics 数据集下载的 我的问题是:当我使用 computh_dir.py 将 DIRE 张量保存为“PNG”格式时,合成的概率始终为 1.0000;另一方面,保存为“JPG”格式,无论我使用的是假图像还是真图像,合成的可能性始终为 0.0000。

hello,i have trouble to use one gpu to run the compute-dire.py.only chnage CUDA_VISIBLE_DEVICES to 0 ,can it run on one gpu device? if you could answer me i couldn't be more apprecuated thanks

lcayvinliu commented 2 months ago

我的computh_dir.sh是

## 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

扩散模型是 256x256_diffusion_uncond.pt,但我也尝试了其他模型,如 lsun_bedroom.pt。然后我computh_dir.py跑去获取夜魇 img。然后我运行 demo.py 以使用 resnet50 cnn 模型,其权重为 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

此脚本可能会获得 Prob 的合成性。在测试中,假图为 png 格式,实图为 jpg 格式。这些图像是从 DiffusionForensics 数据集下载的 我的问题是:当我使用 computh_dir.py 将 DIRE 张量保存为“PNG”格式时,合成的概率始终为 1.0000;另一方面,保存为“JPG”格式,无论我使用的是假图像还是真图像,合成的可能性始终为 0.0000。

hello,i have trouble to use one gpu to run the compute-dire.py.only chnage CUDA_VISIBLE_DEVICES to 0 ,can it run on one gpu device? if you could answer me i couldn't be more apprecuated thanks

I can run the script on one gpu device, could you provide the runtime error info in detail?

ww3636 commented 2 months ago

我的computh_dir.sh是

## 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

扩散模型是 256x256_diffusion_uncond.pt,但我也尝试了其他模型,如 lsun_bedroom.pt。然后我computh_dir.py跑去获取夜魇 img。然后我运行 demo.py 以使用 resnet50 cnn 模型,其权重为 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

此脚本可能会获得 Prob 的合成性。在测试中,假图为 png 格式,实图为 jpg 格式。这些图像是从 DiffusionForensics 数据集下载的 我的问题是:当我使用 computh_dir.py 将 DIRE 张量保存为“PNG”格式时,合成的概率始终为 1.0000;另一方面,保存为“JPG”格式,无论我使用的是假图像还是真图像,合成的可能性始终为 0.0000。

hello,i have trouble to use one gpu to run the compute-dire.py.only chnage CUDA_VISIBLE_DEVICES to 0 ,can it run on one gpu device? if you could answer me i couldn't be more apprecuated thanks

I can run the script on one gpu device, could you provide the runtime error info in detail?

i am in class. But i do experiment on windows ,did you do experiment on linux?

lcayvinliu commented 2 months ago

我的computh_dir.sh是

## 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

扩散模型是 256x256_diffusion_uncond.pt,但我也尝试了其他模型,如 lsun_bedroom.pt。然后我computh_dir.py跑去获取夜魇 img。然后我运行 demo.py 以使用 resnet50 cnn 模型,其权重为 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

此脚本可能会获得 Prob 的合成性。在测试中,假图为 png 格式,实图为 jpg 格式。这些图像是从 DiffusionForensics 数据集下载的 我的问题是:当我使用 computh_dir.py 将 DIRE 张量保存为“PNG”格式时,合成的概率始终为 1.0000;另一方面,保存为“JPG”格式,无论我使用的是假图像还是真图像,合成的可能性始终为 0.0000。

hello,i have trouble to use one gpu to run the compute-dire.py.only chnage CUDA_VISIBLE_DEVICES to 0 ,can it run on one gpu device? if you could answer me i couldn't be more apprecuated thanks

I can run the script on one gpu device, could you provide the runtime error info in detail?

i am in class. But i do experiment on windows ,did you do experiment on linux?

yes, mine is linux