Skip to content

Commit 1886043

Browse files
authored
Merge pull request #4389 from sbrodehl/dev-catcherror
Catch errors during mkdirs, prevent duplicated download
2 parents d57fdb3 + bbf4669 commit 1886043

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

research/inception/inception/data/download_imagenet.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}" || BASE_URL_CHANGE=1
5959
if [ $BASE_URL_CHANGE ]; then
6060
BASE_URL="http://www.image-net.org/challenges/LSVRC/2012/nnoupb"
6161
BOUNDING_BOX_ANNOTATIONS="${BASE_URL}/ILSVRC2012_bbox_train_v2.tar.gz"
62-
BBOX_TAR_BALL="${BBOX_DIR}/annotations.tar.gz"
62+
wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}"
6363
fi
64-
wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}"
6564
echo "Uncompressing bounding box annotations ..."
6665
tar xzf "${BBOX_TAR_BALL}" -C "${BBOX_DIR}"
6766

research/inception/inception/data/preprocess_imagenet_validation_data.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from __future__ import print_function
5050

5151
import os
52+
import errno
5253
import os.path
5354
import sys
5455

@@ -69,7 +70,13 @@
6970
# Make all sub-directories in the validation data dir.
7071
for label in unique_labels:
7172
labeled_data_dir = os.path.join(data_dir, label)
72-
os.makedirs(labeled_data_dir)
73+
# Catch error if sub-directory exists
74+
try:
75+
os.makedirs(labeled_data_dir)
76+
except OSError as e:
77+
# Raise all errors but 'EEXIST'
78+
if e.errno != errno.EEXIST:
79+
raise
7380

7481
# Move all of the image to the appropriate sub-directory.
7582
for i in range(len(labels)):

0 commit comments

Comments
 (0)