Skip to content

Commit

Permalink
Make a dir for images with issues, move erroring images there
Browse files Browse the repository at this point in the history
  • Loading branch information
BBB committed Jan 10, 2017
1 parent 488d079 commit 84dd13d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/py/label_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def mkdir_p(path):
src_dir = '/toScan'
dest_dir = '/scanned'
img_files = [f for f in listdir(src_dir) if isfile(join(src_dir, f))]
issue_dir = join(dest_dir, '_issues')
mkdir_p(issue_dir)

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

print(src_image_path)
predictions = sess.run(softmax_tensor, \
{'DecodeJpeg/contents:0': image_data})

try:

predictions = sess.run(softmax_tensor, \
{'DecodeJpeg/contents:0': image_data})
except Exception as e:
move(srcFilePath, join(issue_dir, imageFile))
continue

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

0 comments on commit 84dd13d

Please sign in to comment.