Skip to content

Commit

Permalink
fix: image save
Browse files Browse the repository at this point in the history
  • Loading branch information
ispirtraian committed Apr 23, 2024
1 parent 31945c8 commit affb85b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/src/serving/serving_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,15 @@ def _predict_job (self, model_type: str, input, params:dict = None):
task_content_path = f"{self.cache_root}/tasks/{taskid}_{cndx}.bin"
os.makedirs(os.path.dirname(task_content_path), exist_ok=True)
#transform input to bytes if necessary
bytes_data = None
if isinstance(content, str):
bytes_data=content.encode('utf-8')
with open(task_content_path, 'wb') as file:
file.write(content.encode('utf-8'))
elif isinstance(content, Image.Image):
bytes_data=content.tobytes()
content.save(task_content_path, format=content.format)
else:
raise Exception("Unsupported content type")

with open(task_content_path, 'wb') as file:
file.write(bytes_data)
print(f"Data successfully written to {task_content_path}")

print(f"Data successfully written to {task_content_path}")
except Exception as exc:
self.P("Error saving job input: {}".format(exc))
result = "Exception saving job input"
Expand Down

0 comments on commit affb85b

Please sign in to comment.