mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
hack(nodes): hack to get image urls in the invocation complete event
This commit is contained in:
parent
4d37ce31fc
commit
07c9b598bd
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654)
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any, Optional
|
||||||
from invokeai.app.api.models.images import ProgressImage
|
from invokeai.app.api.models.images import ProgressImage
|
||||||
from invokeai.app.util.misc import get_timestamp
|
from invokeai.app.util.misc import get_timestamp
|
||||||
|
|
||||||
@ -50,6 +50,8 @@ class EventServiceBase:
|
|||||||
result: dict,
|
result: dict,
|
||||||
node: dict,
|
node: dict,
|
||||||
source_node_id: str,
|
source_node_id: str,
|
||||||
|
image_url: Optional[str] = None,
|
||||||
|
thumbnail_url: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Emitted when an invocation has completed"""
|
"""Emitted when an invocation has completed"""
|
||||||
self.__emit_session_event(
|
self.__emit_session_event(
|
||||||
@ -59,6 +61,8 @@ class EventServiceBase:
|
|||||||
node=node,
|
node=node,
|
||||||
source_node_id=source_node_id,
|
source_node_id=source_node_id,
|
||||||
result=result,
|
result=result,
|
||||||
|
image_url=image_url,
|
||||||
|
thumbnail_url=thumbnail_url
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from threading import Event, Thread, BoundedSemaphore
|
from threading import Event, Thread, BoundedSemaphore
|
||||||
|
from typing import Any, TypeGuard
|
||||||
|
|
||||||
|
from invokeai.app.invocations.image import ImageOutput
|
||||||
|
from invokeai.app.models.image import ImageType
|
||||||
from ..invocations.baseinvocation import InvocationContext
|
from ..invocations.baseinvocation import InvocationContext
|
||||||
from .invocation_queue import InvocationQueueItem
|
from .invocation_queue import InvocationQueueItem
|
||||||
from .invoker import InvocationProcessorABC, Invoker
|
from .invoker import InvocationProcessorABC, Invoker
|
||||||
@ -88,12 +91,30 @@ class DefaultInvocationProcessor(InvocationProcessorABC):
|
|||||||
graph_execution_state
|
graph_execution_state
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def is_image_output(obj: Any) -> TypeGuard[ImageOutput]:
|
||||||
|
return obj.__class__ == ImageOutput
|
||||||
|
|
||||||
|
outputs_dict = outputs.dict()
|
||||||
|
|
||||||
|
if is_image_output(outputs):
|
||||||
|
image_url = self.__invoker.services.images_new.get_url(
|
||||||
|
ImageType.RESULT, outputs.image.image_name
|
||||||
|
)
|
||||||
|
thumbnail_url = self.__invoker.services.images_new.get_url(
|
||||||
|
ImageType.RESULT, outputs.image.image_name, True
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
image_url = None
|
||||||
|
thumbnail_url = None
|
||||||
|
|
||||||
# Send complete event
|
# Send complete event
|
||||||
self.__invoker.services.events.emit_invocation_complete(
|
self.__invoker.services.events.emit_invocation_complete(
|
||||||
graph_execution_state_id=graph_execution_state.id,
|
graph_execution_state_id=graph_execution_state.id,
|
||||||
node=invocation.dict(),
|
node=invocation.dict(),
|
||||||
source_node_id=source_node_id,
|
source_node_id=source_node_id,
|
||||||
result=outputs.dict(),
|
result=outputs_dict,
|
||||||
|
image_url=image_url,
|
||||||
|
thumbnail_url=thumbnail_url,
|
||||||
)
|
)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
Loading…
Reference in New Issue
Block a user