-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtrain-val-split.sh
executable file
·63 lines (49 loc) · 2.14 KB
/
train-val-split.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
# Script to partition the 'raw' cdnet dataset in 3 dirs: background, train, val.
# The ratio variable defines the size of the train set relative to the whole
# dataset. Ratio should be in the interval [0,100]
dataset=$1
destination=$2
ratio=$3
for videoType in $dataset/*; do
videoTypeName=${videoType##*/}
for video in $videoType/*; do
videoName=${video##*/}
mkdir -p $destination/train/$videoTypeName/$videoName/input/
mkdir -p $destination/val/$videoTypeName/$videoName/input/
mkdir -p $destination/train/$videoTypeName/$videoName/groundtruth/
mkdir -p $destination/val/$videoTypeName/$videoName/groundtruth/
mkdir -p $destination/background/$videoTypeName/$videoName/ROI/
mkdir -p $destination/background/$videoTypeName/$videoName/reference/
ROI=$(<$video/temporalROI.txt)
eval x=($ROI)
begin=${x[0]}
end=${x[1]}
if [[ ("$videoTypeName" = "badWeather") || ("$videoTypeName" = "PTZ") || ("$videoTypeName" = "turbulence") || ("$videoTypeName" = "nightVideos") || ("$videoTypeName" = "lowFramerate") ]]; then
(( end = ($end + $begin)/2 - 1 ))
echo "fixed roi for "$videoName
fi
(( endTrain = $begin + ( $ratio*( $end - $begin ) + 50 )/100 ))
(( beginTest = $endTrain + 1))
echo $videoTypeName"/"$videoName
echo "begin - "$begin
echo "endTrain - "$endTrain
echo "beginTest - "$beginTest
echo "end - "$end
echo -e "\n"
cp $video/ROI.jpg $destination/background/$videoTypeName/$videoName/ROI/
for (( frame=1; frame<=150; frame++)); do
printf -v name "%06d" $frame
cp $video/input/in${name}.jpg $destination/background/$videoTypeName/$videoName/reference/
done
for (( frame=$begin; frame<=$endTrain; frame++)); do
printf -v name "%06d" $frame
cp $video/input/in${name}.jpg $destination/train/$videoTypeName/$videoName/input/
cp $video/groundtruth/gt${name}.png $destination/train/$videoTypeName/$videoName/groundtruth/
done
for (( frame=$beginTest; frame<=$end; frame++)); do
printf -v name "%06d" $frame
cp $video/input/in${name}.jpg $destination/val/$videoTypeName/$videoName/input/
cp $video/groundtruth/gt${name}.png $destination/val/$videoTypeName/$videoName/groundtruth/
done
done
done