fix(app): retain graph in metadata when uploading images

This commit is contained in:
psychedelicious
2024-05-17 19:14:59 +10:00
parent 386d552493
commit 93ebc175c6
5 changed files with 16 additions and 6 deletions

View File

@ -49,6 +49,7 @@ async def upload_image(
metadata = None
workflow = None
graph = None
contents = await file.read()
try:
@ -76,9 +77,17 @@ async def upload_image(
try:
workflow = WorkflowWithoutIDValidator.validate_json(workflow_raw)
except ValidationError:
ApiDependencies.invoker.services.logger.warn("Failed to parse metadata for uploaded image")
ApiDependencies.invoker.services.logger.warn("Failed to parse workflow for uploaded image")
pass
# attempt to extract graph from image
graph_raw = pil_image.info.get("invokeai_graph", None)
if isinstance(graph_raw, str):
graph = graph_raw
else:
ApiDependencies.invoker.services.logger.warn("Failed to parse graph for uploaded image")
pass
try:
image_dto = ApiDependencies.invoker.services.images.create(
image=pil_image,
@ -88,6 +97,7 @@ async def upload_image(
board_id=board_id,
metadata=metadata,
workflow=workflow,
graph=graph,
is_intermediate=is_intermediate,
)