Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2fb51d

Browse files
Merge pull request tensorflow#5472 from JonathanJuhl/master
bug fix and python3 compatability
2 parents ad25420 + 08ad245 commit e2fb51d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

research/marco/Automated_Marco.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222

2323
"""
2424
usage:
25-
2625
Processes all .jpg, .png, .bmp and .gif files found in the specified directory and its subdirectories.
27-
2826
--PATH ( Path to directory of images or path to directory with subdirectory of images). e.g Path/To/Directory/
2927
--Model_PATH path to the tensorflow model
3028
"""
@@ -45,8 +43,8 @@
4543

4644
def load_images(file_list):
4745
for i in file_list:
48-
file = open(i)
49-
yield {"image_bytes":[file.read()]},i
46+
files = open(i,'rb')
47+
yield {"image_bytes":[files.read()]},i
5048

5149

5250

@@ -66,7 +64,9 @@ def load_images(file_list):
6664
results = predicter(data)
6765

6866
vals =results['scores'][0]
69-
vals = vals*100
70-
print('Image path: '+ name,'Crystal: '+str(vals[0]),'Other: '+ str(vals[1]),'Precipitate: '+ str(vals[2]),'Clear '+ str(vals[3]))
71-
Writer.writerow(['Image path: '+ name,'Crystal: '+str(vals[0]),'Other: '+ str(vals[1]),'Precipitate: '+ str(vals[2]),'Clear: '+ str(vals[3])])
67+
classes = results['classes'][0]
68+
dictionary = dict(zip(classes,vals))
69+
70+
print('Image path: '+ name+' Crystal: '+str(dictionary[b'Crystals'])+' Other: '+ str(dictionary[b'Other'])+' Precipitate: '+ str(dictionary[b'Precipitate'])+' Clear: '+ str(dictionary[b'Clear']))
71+
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'])])
7272

0 commit comments

Comments
 (0)