Skip to content

Commit 9efc14f

Browse files
committed
Pythonic var names
1 parent 6d75ad6 commit 9efc14f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/py/label_dir.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
from os import mkdir
1313
from shutil import copyfile
1414
from os.path import isfile, join
15-
varPath = '/toScan'
16-
destDir = "/scanned"
17-
imgFiles = [f for f in listdir(varPath) if isfile(join(varPath, f))]
15+
var_path = '/toScan'
16+
dest_dir = "/scanned"
17+
img_files = [f for f in listdir(var_path) if isfile(join(var_path, f))]
1818

1919

2020
# Loads label file, strips off carriage return
@@ -31,25 +31,25 @@
3131
# Feed the image_data as input to the graph and get first prediction
3232
softmax_tensor = sess.graph.get_tensor_by_name('final_result:0')
3333
#try:
34-
# shutil.rmtree(destDir)
34+
# shutil.rmtree(dest_dir)
3535
#except:
3636
# None
3737
#mkdir ('scanned')
3838

39-
for imageFile in imgFiles:
40-
image_data = tf.gfile.FastGFile(varPath+"/"+imageFile, 'rb').read()
39+
for image_file in img_files:
40+
image_data = tf.gfile.FastGFile(var_path+"/"+image_file, 'rb').read()
4141

42-
print (varPath+"/"+imageFile)
42+
print (var_path+"/"+image_file)
4343
predictions = sess.run(softmax_tensor, \
4444
{'DecodeJpeg/contents:0': image_data})
4545

4646
# Sort to show labels of first prediction in order of confidence
4747
top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]
4848
firstElt = top_k[0];
4949

50-
newFileName = label_lines[firstElt] +"--"+ str(predictions[0][firstElt])[2:7]+".jpg"
51-
print(newFileName)
52-
copyfile(varPath+"/"+imageFile, destDir+"/"+newFileName)
50+
new_file_name = label_lines[firstElt] +"--"+ str(predictions[0][firstElt])[2:7]+".jpg"
51+
print(new_file_name)
52+
copyfile(var_path+"/"+image_file, dest_dir+"/"+new_file_name)
5353

5454
for node_id in top_k:
5555
human_string = label_lines[node_id]

0 commit comments

Comments
 (0)