Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not attempt to serialize Images from params for metadata #80

Merged
merged 1 commit into from
May 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)}
seruva19 marked this conversation as resolved.
Show resolved Hide resolved
params_as_json = json.dumps(params, skipkeys=True)

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