Files
Derfuu-Derfuu_ComfyUI_Modde…/pyscripts/components/fields.py
T
Derfuu 665c3f10b1 Debug node get additional output to be able for use in-line with other nodes;
Removed(commented) "Tuples" nodes;
Removed "TUPLES" type from "Get size" nodes; (DON'T FORGET TO REPLACE THEM IF THEY'RE PERSISTS IN YOUR WORKFLOW)
Types moved into their own class with class methods and default parameters instead of just tuples with strings and dicts;
Added "Logic node" (>, <, =, AND, OR, XOR); (idk why i did this one, but got an idea that with object recognition models to count objects and correct them in next iterations would be not so bad idea as i think. Or something like this)
changed README.md to current state of this repo
2024-04-03 03:07:33 +03:00

85 lines
2.6 KiB
Python

import sys
from typing import Tuple
class AnyType(str):
def __ne__(self, __value: object) -> bool:
return False
ANY = AnyType("*")
class Field:
@staticmethod
def field(field: str | list, data: dict = None) -> tuple[str | list, dict] | tuple[str | list]:
if data:
return (field, data,)
return (field, )
@staticmethod
def bool(
default: float = False, force: bool = False
) -> tuple[str, dict]:
field_data = {"default": default, "force": force}
return Field.field("BOOL", field_data)
@staticmethod
def float(
default: float = 1, min: float = -sys.float_info.max, max: float = sys.float_info.max, step: float = 0.01, force: bool = False
) -> tuple[str, dict]:
field_data = {"default": default, "min": min, "max": max, "step": step, "forceInput": force}
return Field.field("FLOAT", field_data)
@staticmethod
def int(
default: int = 1, min: int = -sys.maxsize, max: int = sys.maxsize, step: int = 1, force: bool = False
) -> tuple[str, dict]:
field_data = {"default": default, "min": min, "max": max, "step": step, "forceInput": force}
return Field.field("INT", field_data)
@staticmethod
def string(
default: str = '', multiline: bool = False, force: bool = False
) -> tuple[str, dict]:
field_data = {"default": default, 'multiline': multiline, "forceInput": force}
return Field.field("STRING", field_data)
@staticmethod
def any():
return Field.field(ANY, {"forceInput": False})
@staticmethod
def latent(force: bool = False):
field_data = {"forceInput": force}
return Field.field("LATENT", field_data)
@staticmethod
def image(force: bool = False):
field_data = {"forceInput": force}
return Field.field("IMAGE", field_data)
@staticmethod
def model(force: bool = False):
field_data = {"forceInput": force}
return Field.field("MODEL", field_data)
@staticmethod
def lora(force: bool = False):
field_data = {"forceInput": force}
return Field.field("LORA", field_data)
@staticmethod
def vae(force: bool = False):
field_data = {"forceInput": force}
return Field.field("VAE", field_data)
@staticmethod
def conditioning(force: bool = False):
field_data = {"forceInput": force}
return Field.field("COND", field_data)
@staticmethod
def combo(data: list, force: bool = False):
field_data = {"forceInput": force}
return Field.field(data, field_data)