-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeatures_libsvm_format.sh
More file actions
64 lines (59 loc) · 1014 Bytes
/
features_libsvm_format.sh
File metadata and controls
64 lines (59 loc) · 1014 Bytes
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
category_num=0
dir=$1
mode=$2
if [ ! -d "$dir" ]
then
echo "$dir is not directory" 1>&2
exit
fi
for d in "$dir"/*
do
if [ ! -d "$d" ]
then
echo "$d is not directory" 1>&2
continue
fi
count=$(( `ls -1 $d | wc -l` ))
# limit files less than or equal to 60
if [ $count -gt 60 ]
then
count=60
fi
# devide files by mode
# use first 30 files for testing
# use second 30 files for training
if [ "$mode" = test ]
then
max=$count
min=30
else
max=30
min=0
fi
#echo $count
#echo $max
#echo $min
for f in "$d"/*
do
if [ $count -eq $min ]
then
break
elif [ $count -gt $max ]
then
count=$(( count - 1 ))
continue
fi
# echo $count
count=$(( count - 1 ))
if [ ${f##*.} != jpg ]
then
echo "$f is not jpg" 1>&2
continue
fi
echo -n "$category_num"" "
# echo "$f"
python caffe_script/feature.py ${f} 2> /dev/null
#python caffe_script/feature.py ${f}
done
category_num=$(( category_num + 1 ))
done