Skip to content

Commit ce6fccb

Browse files
committed
Catch error if directory already exists, and continue script.
1 parent 28b9142 commit ce6fccb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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)