Unverified Commit 1886043f authored by Jon Shlens's avatar Jon Shlens Committed by GitHub
Browse files

Merge pull request #4389 from sbrodehl/dev-catcherror

Catch errors during mkdirs, prevent duplicated download
parents d57fdb38 bbf46694
...@@ -59,9 +59,8 @@ wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}" || BASE_URL_CHANGE=1 ...@@ -59,9 +59,8 @@ wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}" || BASE_URL_CHANGE=1
if [ $BASE_URL_CHANGE ]; then if [ $BASE_URL_CHANGE ]; then
BASE_URL="http://www.image-net.org/challenges/LSVRC/2012/nnoupb" BASE_URL="http://www.image-net.org/challenges/LSVRC/2012/nnoupb"
BOUNDING_BOX_ANNOTATIONS="${BASE_URL}/ILSVRC2012_bbox_train_v2.tar.gz" BOUNDING_BOX_ANNOTATIONS="${BASE_URL}/ILSVRC2012_bbox_train_v2.tar.gz"
BBOX_TAR_BALL="${BBOX_DIR}/annotations.tar.gz" wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}"
fi fi
wget "${BOUNDING_BOX_ANNOTATIONS}" -O "${BBOX_TAR_BALL}"
echo "Uncompressing bounding box annotations ..." echo "Uncompressing bounding box annotations ..."
tar xzf "${BBOX_TAR_BALL}" -C "${BBOX_DIR}" tar xzf "${BBOX_TAR_BALL}" -C "${BBOX_DIR}"
......
...@@ -49,6 +49,7 @@ from __future__ import division ...@@ -49,6 +49,7 @@ from __future__ import division
from __future__ import print_function from __future__ import print_function
import os import os
import errno
import os.path import os.path
import sys import sys
...@@ -69,7 +70,13 @@ if __name__ == '__main__': ...@@ -69,7 +70,13 @@ if __name__ == '__main__':
# Make all sub-directories in the validation data dir. # Make all sub-directories in the validation data dir.
for label in unique_labels: for label in unique_labels:
labeled_data_dir = os.path.join(data_dir, label) labeled_data_dir = os.path.join(data_dir, label)
os.makedirs(labeled_data_dir) # Catch error if sub-directory exists
try:
os.makedirs(labeled_data_dir)
except OSError as e:
# Raise all errors but 'EEXIST'
if e.errno != errno.EEXIST:
raise
# Move all of the image to the appropriate sub-directory. # Move all of the image to the appropriate sub-directory.
for i in range(len(labels)): for i in range(len(labels)):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment