/
test.sh
executable file
·34 lines (27 loc) · 1.09 KB
/
test.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
#!/bin/sh
# Remove the old testing directory
rm -rf processed_test
# Testing the model with the testing data set
python model/model.py --mode test --input_dir processed/val --output_dir processed_test --checkpoint processed_train
# Comparing the Structural Similarity Image Metric (SSIM) between each guess and each corresponding ground truth
cd ./processed_test/images
# Sorting the output and target files
outputs=( $(find . -name "*-outputs.png") )
IFS=$'\n'
sorted_outputs=($(sort <<<"${outputs[*]}"))
unset IFS
targets=( $(find . -name "*-targets.png") )
IFS=$'\n'
sorted_targets=($(sort <<<"${targets[*]}"))
unset IFS
# Finding pairs of images and calculating SSIM between each image, then updating index.html
for((i=0;i<${#outputs[@]};i++)); do
output_file=${sorted_outputs[$i]}
target_file=${sorted_targets[$i]}
image_id=${output_file:2:5}
suffix="-accuracy"
accuracy="$(pyssim ${sorted_outputs[$i]} ${sorted_targets[$i]})"
sed -i.bak s/$image_id$suffix/$accuracy/g ../index.html
echo "$image_id accuracy: $accuracy"
done
echo "Success: open processed_test/index.html to view the results"