2023-06-27 03:57:31 +00:00
|
|
|
from ..invocations.latent import LatentsToImageInvocation, TextToLatentsInvocation
|
|
|
|
from ..invocations.noise import NoiseInvocation
|
2023-04-25 01:21:03 +00:00
|
|
|
from ..invocations.compel import CompelInvocation
|
2023-04-14 06:41:06 +00:00
|
|
|
from ..invocations.params import ParamIntInvocation
|
|
|
|
from .graph import Edge, EdgeConnection, ExposedNodeInput, ExposedNodeOutput, Graph, LibraryGraph
|
|
|
|
from .item_storage import ItemStorageABC
|
|
|
|
|
|
|
|
|
|
|
|
default_text_to_image_graph_id = '539b2af5-2b4d-4d8c-8071-e54a3255fc74'
|
|
|
|
|
|
|
|
|
|
|
|
def create_text_to_image() -> LibraryGraph:
|
|
|
|
return LibraryGraph(
|
|
|
|
id=default_text_to_image_graph_id,
|
|
|
|
name='t2i',
|
|
|
|
description='Converts text to an image',
|
|
|
|
graph=Graph(
|
|
|
|
nodes={
|
|
|
|
'width': ParamIntInvocation(id='width', a=512),
|
|
|
|
'height': ParamIntInvocation(id='height', a=512),
|
2023-04-25 10:11:50 +00:00
|
|
|
'seed': ParamIntInvocation(id='seed', a=-1),
|
2023-04-14 06:41:06 +00:00
|
|
|
'3': NoiseInvocation(id='3'),
|
2023-04-25 01:21:03 +00:00
|
|
|
'4': CompelInvocation(id='4'),
|
2023-05-05 18:09:29 +00:00
|
|
|
'5': CompelInvocation(id='5'),
|
|
|
|
'6': TextToLatentsInvocation(id='6'),
|
|
|
|
'7': LatentsToImageInvocation(id='7'),
|
2023-04-14 06:41:06 +00:00
|
|
|
},
|
|
|
|
edges=[
|
|
|
|
Edge(source=EdgeConnection(node_id='width', field='a'), destination=EdgeConnection(node_id='3', field='width')),
|
|
|
|
Edge(source=EdgeConnection(node_id='height', field='a'), destination=EdgeConnection(node_id='3', field='height')),
|
2023-04-25 10:11:50 +00:00
|
|
|
Edge(source=EdgeConnection(node_id='seed', field='a'), destination=EdgeConnection(node_id='3', field='seed')),
|
2023-05-05 18:09:29 +00:00
|
|
|
Edge(source=EdgeConnection(node_id='3', field='noise'), destination=EdgeConnection(node_id='6', field='noise')),
|
|
|
|
Edge(source=EdgeConnection(node_id='6', field='latents'), destination=EdgeConnection(node_id='7', field='latents')),
|
|
|
|
Edge(source=EdgeConnection(node_id='4', field='conditioning'), destination=EdgeConnection(node_id='6', field='positive_conditioning')),
|
|
|
|
Edge(source=EdgeConnection(node_id='5', field='conditioning'), destination=EdgeConnection(node_id='6', field='negative_conditioning')),
|
2023-04-14 06:41:06 +00:00
|
|
|
]
|
|
|
|
),
|
|
|
|
exposed_inputs=[
|
2023-05-05 18:09:29 +00:00
|
|
|
ExposedNodeInput(node_path='4', field='prompt', alias='positive_prompt'),
|
|
|
|
ExposedNodeInput(node_path='5', field='prompt', alias='negative_prompt'),
|
2023-04-14 06:41:06 +00:00
|
|
|
ExposedNodeInput(node_path='width', field='a', alias='width'),
|
2023-04-25 10:11:50 +00:00
|
|
|
ExposedNodeInput(node_path='height', field='a', alias='height'),
|
|
|
|
ExposedNodeInput(node_path='seed', field='a', alias='seed'),
|
2023-04-14 06:41:06 +00:00
|
|
|
],
|
|
|
|
exposed_outputs=[
|
2023-05-05 18:09:29 +00:00
|
|
|
ExposedNodeOutput(node_path='7', field='image', alias='image')
|
2023-04-14 06:41:06 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
def create_system_graphs(graph_library: ItemStorageABC[LibraryGraph]) -> list[LibraryGraph]:
|
|
|
|
"""Creates the default system graphs, or adds new versions if the old ones don't match"""
|
2023-05-09 13:39:29 +00:00
|
|
|
|
|
|
|
# TODO: Uncomment this when we are ready to fix this up to prevent breaking changes
|
2023-04-14 06:41:06 +00:00
|
|
|
graphs: list[LibraryGraph] = list()
|
|
|
|
|
2023-05-11 00:57:08 +00:00
|
|
|
# text_to_image = graph_library.get(default_text_to_image_graph_id)
|
2023-04-14 06:41:06 +00:00
|
|
|
|
2023-05-09 13:39:29 +00:00
|
|
|
# # TODO: Check if the graph is the same as the default one, and if not, update it
|
|
|
|
# #if text_to_image is None:
|
2023-04-14 06:41:06 +00:00
|
|
|
text_to_image = create_text_to_image()
|
|
|
|
graph_library.set(text_to_image)
|
|
|
|
|
|
|
|
graphs.append(text_to_image)
|
|
|
|
|
|
|
|
return graphs
|