-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_test_and_evaluation.sh
114 lines (88 loc) · 2.47 KB
/
run_test_and_evaluation.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
root='results'
out_root='results/metrics'
if [ ! -d $root ];then
mkdir -p $root
fi
if [ ! -d $out_root ];then
mkdir -p $out_root
fi
dataset_name_array=('self_celeba_v2' 'lfw_crop' 'wider')
dataset_location_array=('self_celeba_512_v2' 'lfw_cropped_faces' 'Wider-Test')
checkpoint='./experiments/DAEFR_model.ckpt'
config='./configs/DAEFR.yaml'
output_name='DAEFR'
GPU='4'
# echo ${0}
echo ${checkpoint}
echo ${config}
echo ${output_name}
echo $GPU
for i in $(seq 0 2)
do
outdir=$root'/'$output_name'_'${dataset_name_array[${i}]}
align_test_path='./datasets/'${dataset_location_array[${i}]}
if [ ! -d $outdir ];then
mkdir $outdir
fi
CUDA_VISIBLE_DEVICES=$GPU python -u scripts/test.py \
--outdir $outdir \
-r $checkpoint \
-c $config \
--test_path $align_test_path \
--aligned
done
# Calculate the FID for real-world datasets
for i in $(seq 1 2)
do
outdir=$output_name'_'${dataset_name_array[${i}]}
# echo $outdir
test_image=$outdir'/restored_faces'
# test_image=$outdir'/hq'
out_name=$outdir
# echo $out_name
# FID
CUDA_VISIBLE_DEVICES=$GPU python -u scripts/metrics/cal_fid.py \
$root'/'$test_image \
--fid_stats 'experiments/pretrained_models/inception_FFHQ_512-f7b384ab.pth' \
--save_name $out_root'/'$out_name'_fid.txt' \
done
# Calculate the FID for Celeba-Test datasets ----------------------------------
# For method results
outdir=$output_name'_'${dataset_name_array[0]}
test_image=$outdir'/restored_faces'
# test_image=$outdir'/hq'
# 0: the name of image does not include 00 and Codeformer
# 1: otherwise
need_post=1
# need_post=0
# For original dataset
# test_image=$test_name
# 0: the name of image does not include 00
# 1: otherwise
# need_post=0
out_name=$outdir
# echo $outdir $out_name
CelebAHQ_GT='./datasets/celeba_512_validation'
# FID
CUDA_VISIBLE_DEVICES=$GPU python -u scripts/metrics/cal_fid.py \
$root'/'$test_image \
--fid_stats 'experiments/pretrained_models/inception_FFHQ_512-f7b384ab.pth' \
--save_name $out_root'/'$out_name'_fid.txt' \
if [ -d $CelebAHQ_GT ]
then
# PSRN SSIM LPIPS
CUDA_VISIBLE_DEVICES=$GPU python -u scripts/metrics/cal_psnr_ssim.py \
$root'/'$test_image \
--gt_folder $CelebAHQ_GT \
--save_name $out_root'/'$out_name'_psnr_ssim_lpips.txt' \
--need_post $need_post \
# # # PSRN SSIM LPIPS
CUDA_VISIBLE_DEVICES=$GPU python -u scripts/metrics/cal_identity_distance.py \
$root'/'$test_image \
--gt_folder $CelebAHQ_GT \
--save_name $out_root'/'$out_name'_id.txt' \
--need_post $need_post
else
echo 'The path of GT does not exist'
fi