compare_folder.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. table_line="---|"
  24. for image in $(ls ${folder_path}/)
  25. do
  26. IFS='.' read -ra ADDR <<< "${image}"
  27. image_name=${ADDR[0]}
  28. IFS='_' read -ra ADDR <<< "${image_name}"
  29. image_index=${ADDR[-1]}
  30. header_line="${header_line} ${image_index} |"
  31. table_line="${table_line}---|"
  32. done
  33. echo $folder_path > $markdown_file
  34. echo ""
  35. echo ${header_line} >> $markdown_file
  36. echo ${table_line} >> $markdown_file
  37. for image_i in $(ls ${folder_path}/)
  38. do
  39. IFS='.' read -ra ADDR <<< "${image_i}"
  40. image_i_name=${ADDR[0]}
  41. IFS='_' read -ra ADDR <<< "${image_i_name}"
  42. image_i_index=${ADDR[-1]}
  43. line="${image_i_index} | "
  44. for image_j in $(ls ${folder_path}/)
  45. do
  46. echo "Comparisons between ${image_i} and ${image_j}"
  47. estimated_error=$(python utils/compare_images.py --img1 ${folder_path}/${image_i} --img2 ${folder_path}/${image_j} --metric ${metric})
  48. line="${line} ${estimated_error} | "
  49. done
  50. echo ${line} >> $markdown_file
  51. done