Skip to content

Commit

Permalink
Merge pull request #61 from erosDiffusion/49-make-the-transform-outpu…
Browse files Browse the repository at this point in the history
…t-usable-for-other-nodes

49 make the transform output usable for other nodes
  • Loading branch information
erosDiffusion authored Sep 20, 2024
2 parents 4c4f17f + 7e0a7b4 commit 0b7060c
Show file tree
Hide file tree
Showing 17 changed files with 3,467 additions and 513 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__pycache__/*
__pycache__/*
*.iml
.idea/**
/.idea/
22 changes: 19 additions & 3 deletions Compositor3.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ async def receivedDone(request):
class Compositor3:
file = "new.png"
result = None
configCache = None

@classmethod
def IS_CHANGED(cls, **kwargs):
fabricData = kwargs.get("fabricData")
print(fabricData)
# print(fabricData)
return fabricData

@classmethod
Expand All @@ -35,6 +36,9 @@ def INPUT_TYPES(cls):
"fabricData": ("STRING", {"default": "{}"}),
"imageName": ("STRING", {"default": "new.png"}),
},
"optional": {
"tools": ("BOOLEAN", {"forceInput": True, "default": True}),
},
"hidden": {
"extra_pnginfo": "EXTRA_PNGINFO",
"node_id": "UNIQUE_ID",
Expand All @@ -50,6 +54,7 @@ def composite(self, **kwargs):
# https://blog.miguelgrinberg.com/post/how-to-make-python-wait
node_id = kwargs.pop('node_id', None)


imageName = kwargs.get('imageName', "new.png")

config = kwargs.get('config', "default")
Expand All @@ -58,9 +63,17 @@ def composite(self, **kwargs):
width = config["width"]
height = config["height"]
config_node_id = config["node_id"]
onConfigChanged = config["onConfigChanged"]
names = config["names"]
fabricData = kwargs.get("fabricData")

configChanged = self.configCache != config
# print(configChanged)
# print(config)
# print(self.configCache)


self.configCache = config
ui = {
"test": ("value",),
"padding": [padding],
Expand All @@ -71,14 +84,17 @@ def composite(self, **kwargs):
"names": names,
"fabricData": [fabricData],
"awaited": [self.result],
"configChanged": [configChanged],
"onConfigChanged": [onConfigChanged],
}

# break and send a message to the gui as if it was "executed" below
detail = {"output": ui, "node": node_id}
PromptServer.instance.send_sync("compositor_init", detail)

imageExists = folder_paths.exists_annotated_filepath(imageName)
if imageName == "new.png" or not imageExists:
# block when config changed
if imageName == "new.png" or not imageExists or configChanged:
return {
"ui": ui,
"result": (ExecutionBlocker(None), ExecutionBlocker(None))
Expand All @@ -91,7 +107,7 @@ def composite(self, **kwargs):
i = i.point(lambda i: i * (1 / 255))
image = i.convert("RGB")
image = np.array(image).astype(np.float32) / 255.0
image = torch.from_numpy(image)[None,]
image = torch.from_numpy(image)[None, ]

return {
"ui": ui,
Expand Down
200 changes: 0 additions & 200 deletions CompositorConfig.py

This file was deleted.

Loading

0 comments on commit 0b7060c

Please sign in to comment.