Skip to content

Commit 84dd13d

Browse files
committed
Make a dir for images with issues, move erroring images there
1 parent 488d079 commit 84dd13d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/py/label_dir.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def mkdir_p(path):
1717
src_dir = '/toScan'
1818
dest_dir = '/scanned'
1919
img_files = [f for f in listdir(src_dir) if isfile(join(src_dir, f))]
20+
issue_dir = join(dest_dir, '_issues')
21+
mkdir_p(issue_dir)
2022

2123
# Loads label file, strips off carriage return
2224
label_lines = [line.rstrip() for line
@@ -37,8 +39,14 @@ def mkdir_p(path):
3739
image_data = tf.gfile.FastGFile(src_image_path, 'rb').read()
3840

3941
print(src_image_path)
40-
predictions = sess.run(softmax_tensor, \
41-
{'DecodeJpeg/contents:0': image_data})
42+
43+
try:
44+
45+
predictions = sess.run(softmax_tensor, \
46+
{'DecodeJpeg/contents:0': image_data})
47+
except Exception as e:
48+
move(srcFilePath, join(issue_dir, imageFile))
49+
continue
4250

4351
# Sort to show labels of first prediction in order of confidence
4452
top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]

0 commit comments

Comments
 (0)