compare_folder.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. if [ -z "$1" ]
  2. then
  3. echo "No argument supplied"
  4. echo "Folder with images to compare"
  5. exit 1
  6. fi
  7. if [ -z "$2" ]
  8. then
  9. echo "No argument supplied"
  10. echo "Expected metric choice"
  11. exit 1
  12. fi
  13. if [ -z "$3" ]
  14. then
  15. echo "No argument supplied"
  16. echo "Output markdown filename"
  17. exit 1
  18. fi
  19. folder_path=$1
  20. metric=$2
  21. markdown_file=$3
  22. header_line="# | "
  23. for image in $(ls ${folder_path}/)
  24. do
  25. IFS='.' read -ra ADDR <<< "${image}"
  26. image_name=${ADDR[0]}
  27. IFS='_' read -ra ADDR <<< "${image_name}"
  28. image_index=${ADDR[-1]}
  29. header_line="${header_line} ${image_index} |"
  30. done
  31. echo $folder_path > $markdown_file
  32. echo ""
  33. echo ${header_line} >> $markdown_file
  34. for image_i in $(ls ${folder_path}/)
  35. do
  36. IFS='.' read -ra ADDR <<< "${image_i}"
  37. image_i_name=${ADDR[0]}
  38. IFS='_' read -ra ADDR <<< "${image_i_name}"
  39. image_i_index=${ADDR[-1]}
  40. line="${image_i_index} | "
  41. for image_j in $(ls ${folder_path}/)
  42. do
  43. echo "Comparisons between ${image_i} and ${image_j}"
  44. estimated_error=$(python utils/compare_images.py --img1 ${folder_path}/${image_i} --img2 ${folder_path}/${image_j} --metric ${metric})
  45. line="${line} ${estimated_error} | "
  46. done
  47. echo ${line} >> $markdown_file
  48. done