Files
chflame163-ComfyUI_LayerStyle/py/print_info.py
T
chflame163 9ec7d6c9c6 Add ImageBlendAdvance and PrintInfo nodes.
Add ImageBlendAdvance node. This node allows for the synthesis of background images and layers of different sizes, providing a more free synthesis experience. 
Add PrintInfo node as a workflow debugging aid.
2024-01-22 17:29:36 +08:00

49 lines
1.3 KiB
Python

import json
import torch
from .imagefunc import tensor2pil, log
class AnyType(str):
"""A special class that is always equal in not equal comparisons. Credit to pythongosssss"""
def __ne__(self, __value: object) -> bool:
return False
any = AnyType("*")
class PrintInfo:
@classmethod
def INPUT_TYPES(cls): # pylint: disable = invalid-name, missing-function-docstring
return {
"required": {
"anything": (any, {}),
},
}
CATEGORY = '😺dzNodes/LayerUtility'
RETURN_TYPES = ()
FUNCTION = "print_info"
OUTPUT_NODE = True
def print_info(self, anything=None):
value = 'PrintInfo:\nInput type is: ' + str(type(anything)) + '\n'
if isinstance(anything, torch.Tensor):
image = tensor2pil(anything)
value = value + 'Image.size=' + str(image.size) + ', Image.mode=' + str(image.mode) + '\n'
if anything is not None:
try:
value = value + json.dumps(anything) + "\n"
except Exception:
try:
value = value + str(anything) + "\n"
except Exception:
value = 'source exists, but could not be serialized.'
log(value)
return {"ui": {"text": (value,)}}
NODE_CLASS_MAPPINGS = {
"LayerUtility: PrintInfo": PrintInfo
}
NODE_DISPLAY_NAME_MAPPINGS = {
"LayerUtility: PrintInfo": "LayerUtility: PrintInfo"
}