Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
78153f1f
Commit
78153f1f
authored
Apr 03, 2017
by
Neal Wu
Browse files
Additional fixes to get download_and_preprocess_flowers working
parent
4da1c86f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
inception/inception/data/download_and_preprocess_flowers.sh
inception/inception/data/download_and_preprocess_flowers.sh
+9
-9
No files found.
inception/inception/data/download_and_preprocess_flowers.sh
View file @
78153f1f
...
...
@@ -41,7 +41,7 @@ fi
# Create the output and temporary directories.
DATA_DIR
=
"
${
1
%/
}
"
SCRATCH_DIR
=
"
${
DATA_DIR
}
/raw-data
/
"
SCRATCH_DIR
=
"
${
DATA_DIR
}
/raw-data"
mkdir
-p
"
${
DATA_DIR
}
"
mkdir
-p
"
${
SCRATCH_DIR
}
"
# http://stackoverflow.com/questions/59895/getting-the-source-directory-of-a-bash-script-from-within
...
...
@@ -50,23 +50,23 @@ WORK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Download the flowers data.
DATA_URL
=
"http://download.tensorflow.org/example_images/flower_photos.tgz"
CURRENT_DIR
=
$(
pwd
)
cd
"
${
DATA_DIR
}
"
TARBALL
=
"flower_photos.tgz"
if
[
!
-f
${
TARBALL
}
]
;
then
echo
"Downloading flower data set."
curl
-o
${
TARBALL
}
"
${
DATA_URL
}
"
curl
-o
${
DATA_DIR
}
/
${
TARBALL
}
"
${
DATA_URL
}
"
else
echo
"Skipping download of flower data."
fi
# Note the locations of the train and validation data.
TRAIN_DIRECTORY
=
"
${
SCRATCH_DIR
}
train
/
"
VALIDATION_DIRECTORY
=
"
${
SCRATCH_DIR
}
validation
/
"
TRAIN_DIRECTORY
=
"
${
SCRATCH_DIR
}
/
train"
VALIDATION_DIRECTORY
=
"
${
SCRATCH_DIR
}
/
validation"
# Expands the data into the flower_photos/ directory and rename it as the
# train directory.
tar
xf flower_photos.tgz
tar
xf
${
DATA_DIR
}
/
flower_photos.tgz
rm
-rf
"
${
TRAIN_DIRECTORY
}
"
"
${
VALIDATION_DIRECTORY
}
"
mkdir
-p
"
${
TRAIN_DIRECTORY
}
"
mv
flower_photos
"
${
TRAIN_DIRECTORY
}
"
# Generate a list of 5 labels: daisy, dandelion, roses, sunflowers, tulips
...
...
@@ -75,14 +75,14 @@ ls -1 "${TRAIN_DIRECTORY}" | grep -v 'LICENSE' | sed 's/\///' | sort > "${LABELS
# Generate the validation data set.
while
read
LABEL
;
do
VALIDATION_DIR_FOR_LABEL
=
"
${
VALIDATION_DIRECTORY
}${
LABEL
}
"
TRAIN_DIR_FOR_LABEL
=
"
${
TRAIN_DIRECTORY
}${
LABEL
}
"
VALIDATION_DIR_FOR_LABEL
=
"
${
VALIDATION_DIRECTORY
}
/
${
LABEL
}
"
TRAIN_DIR_FOR_LABEL
=
"
${
TRAIN_DIRECTORY
}
/
${
LABEL
}
"
# Move the first randomly selected 100 images to the validation set.
mkdir
-p
"
${
VALIDATION_DIR_FOR_LABEL
}
"
VALIDATION_IMAGES
=
$(
ls
-1
"
${
TRAIN_DIR_FOR_LABEL
}
"
|
shuf
|
head
-100
)
for
IMAGE
in
${
VALIDATION_IMAGES
}
;
do
mv
-f
"
${
TRAIN_DIRECTORY
}${
LABEL
}
/
${
IMAGE
}
"
"
${
VALIDATION_DIR_FOR_LABEL
}
"
mv
-f
"
${
TRAIN_DIRECTORY
}
/
${
LABEL
}
/
${
IMAGE
}
"
"
${
VALIDATION_DIR_FOR_LABEL
}
"
done
done
<
"
${
LABELS_FILE
}
"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment