-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathimagenet_data_setup.sh
executable file
·44 lines (36 loc) · 1.81 KB
/
imagenet_data_setup.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
export IMAGENET_HOME=/media/Data/imagenet_data
# Setup folders
mkdir -p $IMAGENET_HOME/validation
mkdir -p $IMAGENET_HOME/train
# ###### Modification 1: set .tar files path to $IMAGENET_HOME #############
# Extract validation and training
tar xf $IMAGENET_HOME/ILSVRC2012_img_val.tar -C $IMAGENET_HOME/validation
tar xf $IMAGENET_HOME/ILSVRC2012_img_train.tar -C $IMAGENET_HOME/train
# ##########################################################################
# Extract and then delete individual training tar files This can be pasted
# directly into a bash command-line or create a file and execute.
cd $IMAGENET_HOME/train
for f in *.tar; do
d=`basename $f .tar`
mkdir $d
tar xf $f -C $d
done
cd $IMAGENET_HOME # Move back to the base folder
# [Optional] Delete tar files if desired as they are not needed
rm $IMAGENET_HOME/train/*.tar
# ###### Modification 2: Updated deprecated link #############
# Download labels file.
wget -O $IMAGENET_HOME/synset_labels.txt \
https://raw.githubusercontent.com/tensorflow/models/master/research/slim/datasets/imagenet_2012_validation_synset_labels.txt
# ############################################################
# Process the files. Remember to get the script from github first. The TFRecords
# will end up in the --local_scratch_dir. To upload to gcs with this method
# leave off `nogcs_upload` and provide gcs flags for project and output_path.
python imagenet_to_gcs.py \
--raw_data_dir=$IMAGENET_HOME \
--local_scratch_dir=$IMAGENET_HOME/tf_records \
--nogcs_upload
# ######## Modification 3: move train and validation files to root dir #######################
mv $IMAGENET_HOME/tf_records/train* $IMAGENET_HOME/tf_records
mv $IMAGENET_HOME/tf_records/validation* $IMAGENET_HOME/tf_records
# ############################################################################################