forked from RockStarCoders/alienMarkovNetworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaluateMSRCLabelling.sh
executable file
·65 lines (54 loc) · 1.64 KB
/
evaluateMSRCLabelling.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
#!/bin/bash
#Kvals="0.01 0.05 0.1 0.5 1.0 1.5 2.0"
Kvals="0.1 0.2 0.3 0.4 0.5"
# assume you have called classifyAllImages on validation set to make image
# probabilities as pkl files.
#
# Give this directory as an input to this script. Will process all pkl files as
# input.
function Usage() {
echo "Usage:"
echo " ./evaluateMSRCLabelling.sh <indir> <outdir> <MSRCPath> <adjFile>"
echo "indir is where the input probability pkl files are."
echo "MSRCPath is where the ground truth data is."
echo "WARNING: USE ABSOLUTE PATHS!"
}
inDir="$1"; shift
outDirBase="$1"; shift
msrcPath="$1"; shift
adjFile="$1"; shift
if [ ! -d "$inDir" ]; then
echo "Error: input directory $inDir DNE."
Usage
exit 1
fi
if [ ! -d "$outDirBase" ]; then
echo "Error: output directory $outDirBase DNE."
Usage
exit 1
fi
if [ ! -d "$msrcPath" ]; then
echo "Error: msrc path $msrcPath DNE."
Usage
exit 1
fi
if [ ! -f "$adjFile" ]; then
echo "Error: class adjacency file $adjFile DNE."
Usage
exit 1
fi
set -e
for K in $Kvals; do
echo "Evaluting MRF for K = $K"
outDir="$outDirBase/Kis${K}"
mkdir "$outDir"
#for each MSRC class probabilities image in validation set:
./labelAllImagesGivenProbs.sh "$adjFile" "$K" "$outDir" "$inDir"/*.pkl \
>/dev/null 2>/dev/null
# evaluate output labellings against GT
#echo ./evalPredictions.py "$outDir"/evalpairs.csv "$msrcPath" ''
acc=$( ( ./evalPredictions.py "$outDir"/evalpairs.csv "$msrcPath" '' 2>/dev/null ) | grep 'Avg prediction' | cut -d '=' -f 2 )
echo $acc
# report accuracy for this K
echo " K = $K, average accuracy = $acc"
done