test_hogsvm.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. #DATASET_SIZE=125
  3. #DATASET_SIZE=500
  4. #DATASET_SIZE=1000
  5. DATASET_SIZE=5000
  6. #DATASET_SIZE=25446
  7. #DATASET_SIZE=125240
  8. #DATASET_SIZE=150686
  9. dataset_size_cache="./$0.last_DATASET_SIZE"
  10. fn="anot.txt"
  11. if [ -f "$dataset_size_cache" ]; then
  12. DATASET_SIZE_PREV=$(cat "$dataset_size_cache")
  13. else
  14. DATASET_SIZE_PREV=0
  15. fi
  16. echo $DATASET_SIZE > "$dataset_size_cache"
  17. if [ "$DATASET_SIZE_PREV" -eq "$DATASET_SIZE" ]; then
  18. PREPARE_DATASET=0
  19. else
  20. PREPARE_DATASET=1
  21. fi
  22. if [ "$PREPARE_DATASET" = 1 ]; then
  23. if [ -f "./anot.$DATASET_SIZE.txt" ]; then
  24. echo "cp ./anot.$DATASET_SIZE.txt ./anot.txt"
  25. cp "./anot.$DATASET_SIZE.txt" "./anot.txt"
  26. else
  27. # positive_dirs="/var/www/html/fire/labelme_samples-80/"
  28. positive_dirs="/var/www/html/fire/labelme_samples-100/"
  29. # positive_dirs="/var/www/html/fire/labelme_samples-center/"
  30. negative_dirs="/var/www/html/fire/sun-dataset/SUNOUT"
  31. IFS=$'\n'
  32. pfn="positive_anot.txt"
  33. nfn="negative_anot.txt"
  34. rm -f "$pfn" "$nfn"
  35. for i in $negative_dirs; do
  36. echo $i +
  37. find "$i" -type f -name '*.jpg' | sed 's/$/,non-fire/'|sort -R >> $nfn
  38. done
  39. for i in $positive_dirs; do
  40. echo $i +
  41. find "$i" -type f -name '*.jpg'| sed 's/$/,fire/' |sort -R >> "$pfn"
  42. done
  43. # print size of set
  44. wc -l "$pfn"
  45. wc -l "$nfn"
  46. # merge anot files together
  47. paste -d "\n" "$pfn" "$nfn" | sed '/^\s*$/d' > "anot.txt"
  48. # trim to DATASET_SIZE firts samples
  49. tmp=$(mktemp "/tmp/$0.XXXXXXX"); head "$fn" -n "$DATASET_SIZE" >"$tmp"; mv "$tmp" "anot.txt"
  50. rm -f "$pfn" "$nfn"
  51. cp "$fn" ./anot.$DATASET_SIZE.txt
  52. fi
  53. fi # if [ "$PREPARE_DATASET" = 1 ];
  54. wc -l "$fn"
  55. t1=$(date +%s)
  56. echo "Started at $(date --iso-8601=s)"
  57. ./hogsvm.py ./anot.txt
  58. t2=$(date +%s)
  59. echo "Ended at $(date --iso-8601=s)"
  60. echo "Elapsed $((t2 - t1)) seconds"