cafierom commited on
Commit
68fe4a8
·
verified ·
1 Parent(s): 7863544

Upload modrag_molecule_functions.py

Browse files
Files changed (1) hide show
  1. modrag_molecule_functions.py +7 -3
modrag_molecule_functions.py CHANGED
@@ -174,8 +174,12 @@ def structure_node(smiles_list: list[str]) -> (list[str], str, list):
174
  img = Draw.MolsToGridImage(all_mols, molsPerRow=3, subImgSize=(250, 250))
175
 
176
  #save the image as current_image.png
177
- pic = img.data
178
- with open('current_image.png', 'wb') as f:
179
- f.write(pic)
 
 
 
180
  img = Image.open('current_image.png')
 
181
  return all_structures, output_string, img
 
174
  img = Draw.MolsToGridImage(all_mols, molsPerRow=3, subImgSize=(250, 250))
175
 
176
  #save the image as current_image.png
177
+ try:
178
+ img.save('current_image.png')
179
+ except:
180
+ pic = img.data
181
+ with open('current_image.png', 'wb') as f:
182
+ f.write(pic)
183
  img = Image.open('current_image.png')
184
+
185
  return all_structures, output_string, img