Unverified Commit e2fb51d1 authored by Vincent Vanhoucke's avatar Vincent Vanhoucke Committed by GitHub
Browse files

Merge pull request #5472 from JonathanJuhl/master

bug fix and python3 compatability
parents ad254209 08ad2455
...@@ -22,9 +22,7 @@ import argparse ...@@ -22,9 +22,7 @@ import argparse
""" """
usage: usage:
Processes all .jpg, .png, .bmp and .gif files found in the specified directory and its subdirectories. Processes all .jpg, .png, .bmp and .gif files found in the specified directory and its subdirectories.
--PATH ( Path to directory of images or path to directory with subdirectory of images). e.g Path/To/Directory/ --PATH ( Path to directory of images or path to directory with subdirectory of images). e.g Path/To/Directory/
--Model_PATH path to the tensorflow model --Model_PATH path to the tensorflow model
""" """
...@@ -45,8 +43,8 @@ size = len(crystal_images) ...@@ -45,8 +43,8 @@ size = len(crystal_images)
def load_images(file_list): def load_images(file_list):
for i in file_list: for i in file_list:
file = open(i) files = open(i,'rb')
yield {"image_bytes":[file.read()]},i yield {"image_bytes":[files.read()]},i
...@@ -66,7 +64,9 @@ with open(PATH +'results.csv', 'w') as csvfile: ...@@ -66,7 +64,9 @@ with open(PATH +'results.csv', 'w') as csvfile:
results = predicter(data) results = predicter(data)
vals =results['scores'][0] vals =results['scores'][0]
vals = vals*100 classes = results['classes'][0]
print('Image path: '+ name,'Crystal: '+str(vals[0]),'Other: '+ str(vals[1]),'Precipitate: '+ str(vals[2]),'Clear '+ str(vals[3])) dictionary = dict(zip(classes,vals))
Writer.writerow(['Image path: '+ name,'Crystal: '+str(vals[0]),'Other: '+ str(vals[1]),'Precipitate: '+ str(vals[2]),'Clear: '+ str(vals[3])])
print('Image path: '+ name+' Crystal: '+str(dictionary[b'Crystals'])+' Other: '+ str(dictionary[b'Other'])+' Precipitate: '+ str(dictionary[b'Precipitate'])+' Clear: '+ str(dictionary[b'Clear']))
Writer.writerow(['Image path: '+ name,'Crystal: '+str(dictionary[b'Crystals']),'Other: '+ str(dictionary[b'Other']),'Precipitate: '+ str(dictionary[b'Precipitate']),'Clear: '+ str(dictionary[b'Clear'])])
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