test_hogsvm.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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-center/"
  29. negative_dirs="/var/www/html/fire/sun-dataset/SUNOUT"
  30. IFS=$'\n'
  31. pfn="positive_anot.txt"
  32. nfn="negative_anot.txt"
  33. rm -f "$pfn" "$nfn"
  34. for i in $negative_dirs; do
  35. echo $i +
  36. find "$i" -type f -name '*.jpg' | sed 's/$/,non-fire/'|sort -R >> $nfn
  37. done
  38. for i in $positive_dirs; do
  39. echo $i +
  40. find "$i" -type f -name '*.jpg'| sed 's/$/,fire/' |sort -R >> "$pfn"
  41. done
  42. # print size of set
  43. wc -l "$pfn"
  44. wc -l "$nfn"
  45. # merge anot files together
  46. paste -d "\n" "$pfn" "$nfn" | sed '/^\s*$/d' > "anot.txt"
  47. # trim to DATASET_SIZE firts samples
  48. tmp=$(mktemp "/tmp/$0.XXXXXXX"); head "$fn" -n "$DATASET_SIZE" >"$tmp"; mv "$tmp" "anot.txt"
  49. rm -f "$pfn" "$nfn"
  50. cp "$fn" ./anot.$DATASET_SIZE.txt
  51. fi
  52. fi # if [ "$PREPARE_DATASET" = 1 ];
  53. wc -l "$fn"
  54. t1=$(date +%s)
  55. echo "Started at $(date --iso-8601=s)"
  56. ./hogsvm.py ./anot.txt
  57. t2=$(date +%s)
  58. echo "Ended at $(date --iso-8601=s)"
  59. echo "Elapsed $((t2 - t1)) seconds"