-
Notifications
You must be signed in to change notification settings - Fork 10
/
preprocessworker.sh
executable file
·128 lines (99 loc) · 3.58 KB
/
preprocessworker.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
script_name=`basename $0`
script_dir=`dirname $0`
source "${script_dir}/commonfunctions.sh"
version="???"
maxpackages="5"
waitinterval="60"
if [ -f "$script_dir/VERSION" ] ; then
version=`cat $script_dir/VERSION`
fi
function usage()
{
echo "usage: $script_name [-h]
predictdir
Version: $version
Runs PreprocessPackage.m in a serial fashion
waiting if too many packages have yet to be
processed. This script uses predict.config
file to obtain location of trained model
and image data
positional arguments:
predictdir Predict directory generated by
runprediction.sh
optional arguments:
-h, --help show this help message and exit
--maxpackages Number of completed packages allowed before
script should wait to let prediction catch up.
(default $maxpackages)
--waitinterval Number of seconds to wait between checking
for number of completed packages
(default $waitinterval)
" 1>&2;
exit 1;
}
TEMP=`getopt -o h --long "help,maxpackages:,waitinterval:" -n '$0' -- "$@"`
eval set -- "$TEMP"
while true ; do
case "$1" in
-h ) usage ;;
--help ) usage ;;
--waitinterval ) waitinterval=$2 ; shift 2 ;;
--maxpackages ) maxpackages=$2 ; shift 2 ;;
--) shift ; break ;;
esac
done
if [ $# -ne 1 ] ; then
usage
fi
out_dir=$1
echo ""
predict_config="$out_dir/predict.config"
parse_predict_config "$predict_config"
if [ $? != 0 ] ; then
fatal_error "$out_dir" "ERROR parsing $predict_config" 2
fi
echo "Running PreprocessPackage"
echo ""
echo "Trained Model Dir: $trained_model_dir"
echo "Image Dir: $img_dir"
echo "Models: $model_list"
echo "Speed: $aug_speed"
echo ""
package_proc_info="$out_dir/augimages/package_processing_info.txt"
if [ ! -s "$package_proc_info" ] ; then
fatal_error "$out_dir" "ERROR $package_proc_info not found" 7
fi
parse_package_processing_info "$package_proc_info"
space_sep_models=$(get_models_as_space_separated_list "$model_list")
for model_name in `echo $space_sep_models` ; do
let cntr=1
for CUR_PKG in `seq -w 001 $num_pkgs` ; do
for CUR_Z in `seq -w 01 $num_zstacks` ; do
package_name=$(get_package_name "$CUR_PKG" "$CUR_Z")
Z="$out_dir/augimages/$model_name/$package_name"
out_pkg="$out_dir/$model_name/$package_name"
if [ -f "$out_pkg/DONE" ] ; then
echo " Found $out_pkg/DONE. Prediction completed. Skipping..."
continue
fi
echo "Preprocessing $package_name in model $model_name"
augoutfile="$out_dir/augimages/preproc.${model_name}.${package_name}.log"
/usr/bin/time -p PreprocessPackage.m "$img_dir" "$out_dir/augimages" $CUR_PKG $CUR_Z $model_name $aug_speed > "$augoutfile" 2>&1
ecode=$?
if [ $ecode != 0 ] ; then
fatal_error "$out_dir" "ERROR, a non-zero exit code ($ecode) received from PreprocessPackage.m $CUR_PKG $CUR_Z $model_name $aug_speed" 8
fi
echo "Waiting for prediction to catch up"
res=$(wait_for_prediction_to_catchup "$out_dir/augimages" $maxpackages $waitinterval)
if [ "$res" == "killed" ] ; then
echo "KILL.REQUEST file found. Exiting"
exit 1
fi
let cntr+=1
done
done
done
echo ""
echo "PreprocessPackaging has completed."
echo ""