-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.sh
executable file
·60 lines (53 loc) · 1.14 KB
/
train.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
#!/bin/bash
# We're passed the path to a directory containing chopped images. This
# script runs train on each subdir, which analyzes the images contained
# inside and writes a file, hyperplane.txt, into that subdir.
basedir="$1"
numsv=$2
numimg=$3 #optional
numslices=144
traindist="/home/theapp/pca/dist/build/train/train"
function train {
$traindist "$basedir/$1/" $numsv $numimg
}
function format {
date -u -d @"$1" +"%T"
}
starttime=$(date +%s)
function progress {
current=$1
max=$2
elapsed=$(expr $(date +%s) - $starttime)
width=78
let numeq=current*width/max
let numspace=width-numeq
let estimated_remaining=max*elapsed/current-elapsed
#elapsed/total = current/max
#total = max * elapsed / current
echo -n '['
for j in $(seq 1 $numeq);
do
echo -n "="
done
for j in $(seq 1 $numspace);
do
echo -n " "
done
echo -n -e "]\r"
echo -n "[$(format $elapsed)/$(format $estimated_remaining)]"
}
function clearline {
echo -n -e "\r"
for z in $(seq 1 80)
do
echo -n ' '
done
echo -n -e "\r"
}
for i in $(seq 1 $numslices);
do
out=$(train $i)
clearline
echo $out
progress $i $numslices
done