forked from RockStarCoders/alienMarkovNetworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabelAllImagesGivenProbs.sh
executable file
·72 lines (57 loc) · 1.56 KB
/
labelAllImagesGivenProbs.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
#!/bin/bash
# Usage:
#
# labelAllImagesGivenProbs.sh K <outDir> file1 file2 .... fileN
#
# Like labelAllImages.sh, but assumes classifier has already been applied.
# So it works with the probs not the image, doesn't need classifier or
# superpixel parameters.
#
# Example:
# ./labelAllImagesGivenProbs \
# 0.1 \
# /vagrant/results/imagesLabelled/training \
# /vagrant/results/imagesClassified/training/*.pkl
#
function Usage() {
echo "Usage:"
echo " ./labelAllImagesGivenProbs.sh K <outDir> <nbCores> file1.pkl file2 .... fileN"
}
K="$1"; shift
outDir="$1"; shift
typeset -i nbCores="$1"; shift
echo "Using $nbCores cores"
if [ ! -d "$outDir" ]; then
echo "Error: output directory $outDir does not exist."
Usage
exit 1
fi
echo "MRF Smoothness K = $K"
# as we go, create a csv from labelled image to GT image
csvFn="$outDir"/evalpairs.csv
rm -f "$csvFn"
logFn="$outDir"/log.txt
rm -f "$logFn"
typeset -i ctr=0
for file in $*; do
echo "Processing input probability pickle file $file..."
echo "*" >> "$logFn"
echo "* Processing input probability pickle file $file..." >> "$logFn"
echo "*" >> "$logFn"
ifn=$(basename "$file")
extn="${ifn##*.}"
ifnBase="${ifn%.*}"
ofn="$outDir"/"$ifnBase".bmp
./sceneLabelSuperPixels.py "$file" \
--nbrPotentialMethod=degreeSensitive \
--K=$K \
--outfile="$ofn" >> "$logFn" 2>&1 &
# append to csv
echo "${ofn},${ifnBase}_GT.bmp" >> "$csvFn"
ctr=$(($ctr+1))
if [ $(($ctr % $nbCores)) = 0 ]; then
wait
fi
done
wait
echo "All done"