-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_database.sh
executable file
·73 lines (58 loc) · 1.88 KB
/
create_database.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
73
#!/usr/bin/env sh
# Create the database lmdb inputs and mean images
# N.B. set the path to the training images + val data dirs
set -e
FOLDER_CAFFE=../caffe/build/tools
DATA=data/neuro_iCub
TRAIN_DATA_ROOT=$DATA/train
TRAIN_FILE=$DATA/train/train_list.txt
TRAINDB_NAME=$DATA/train/train_database
TEST_DATA_ROOT=$DATA/test
TEST_FILE=$DATA/test/test_list.txt
TESTDB_NAME=$DATA/test/test_database
BACKEND="lmdb"
ENCODE_TYPE='jpg'
RESIZE_WIDTH=100
RESIZE_HEIGHT=100
if [ ! -d "$TRAIN_DATA_ROOT" ]; then
echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $TRAIN_DATA_ROOT"
echo "Set the TRAIN_DATA_ROOT variable in create_imagenet.sh to the path" \
"where the training data is stored."
exit 1
fi
if [ ! -d "$TEST_DATA_ROOT" ]; then
echo "Error: TEST_DATA_ROOT is not a path to a directory: $TEST_DATA_ROOT"
echo "Set the TEST_DATA_ROOT variable in create_imagenet.sh to the path" \
"where the validation data is stored."
exit 1
fi
echo "Creating train lmdb..."
rm -rf $TRAINDB_NAME
echo "RESIZING IMAGES TO $RESIZE_WIDTH x $RESIZE_HEIGHT"
GLOG_logtostderr=1 $FOLDER_CAFFE/convert_imageset \
--backend=$BACKEND \
--resize_width=$RESIZE_WIDTH \
--resize_height=$RESIZE_HEIGHT \
--encode_type=$ENCODE_TYPE \
--shuffle \
$TRAIN_DATA_ROOT \
$TRAIN_FILE \
$TRAINDB_NAME
echo "Creating mean images for train lmdb..."
$FOLDER_CAFFE/compute_image_mean $TRAINDB_NAME \
$TRAIN_DATA_ROOT/train_mean.binaryproto
echo "Creating test lmdb..."
rm -rf $TESTDB_NAME
GLOG_logtostderr=1 $FOLDER_CAFFE/convert_imageset \
--backend=$BACKEND \
--resize_width=$RESIZE_WIDTH \
--resize_height=$RESIZE_HEIGHT \
--encode_type=$ENCODE_TYPE \
--shuffle \
$TEST_DATA_ROOT \
$TEST_FILE \
$TESTDB_NAME
echo "Creating mean images for test lmdb..."
$FOLDER_CAFFE/compute_image_mean $TESTDB_NAME \
$TEST_DATA_ROOT/test_mean.binaryproto
echo "Done."