Skip to content

Commit

Permalink
Do not attampt to serialize Images from params for metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojtek Kowaluk authored and Wojtek Kowaluk committed May 20, 2023
1 parent b4a1548 commit c881644
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

def create_png_info(metadata):
png_info = PngImagePlugin.PngInfo()
png_info.add_text("kubin_image_metadata", metadata)
if metadata:
png_info.add_text("kubin_image_metadata", metadata)
return png_info

def create_filename(path, params):
Expand All @@ -34,8 +35,11 @@ def create_filename(path, params):

def save_output(output_dir, task_type, images, params=None):
output = []
params_as_json = None

params_as_json = None if params is None else json.dumps(params, skipkeys=True)
if params:
params = {v: k for k, v in params.items() if not isinstance(v, Image.Image)}
params_as_json = json.dumps(params, skipkeys=True)

for img in images:
path = f'{output_dir}/{task_type}'
Expand Down

0 comments on commit c881644

Please sign in to comment.