Spaces:
Running
Running
File size: 2,704 Bytes
681fa96 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
from server import PromptServer
import torch
def message(id,message):
if isinstance(message, torch.Tensor):
string = f"Tensor shape {message.shape}"
elif isinstance(message, dict) and "samples" in message and isinstance(message["samples"], torch.Tensor):
string = f"Latent shape {message['samples'].shape}"
else:
string = f"{message}"
PromptServer.instance.send_sync("ue-message-handler", {"id": id, "message":string})
class Base():
OUTPUT_NODE = True
FUNCTION = "func"
CATEGORY = "everywhere"
RETURN_TYPES = ()
class SimpleString(Base):
OUTPUT_NODE = False
@classmethod
def INPUT_TYPES(s):
return {"required":{ "string": ("STRING", {"default": ""}) }}
RETURN_TYPES = ("STRING",)
def func(self,string):
return (string,)
class SeedEverywhere(Base):
@classmethod
def INPUT_TYPES(s):
return {"required":{ "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}) },
"hidden": {"id":"UNIQUE_ID"} }
RETURN_TYPES = ("INT",)
def func(self, seed, id):
message(id, seed)
return (seed,)
class AnythingEverywhere(Base):
@classmethod
def INPUT_TYPES(s):
return {"required":{},
"optional": { "anything" : ("*", {}), },
"hidden": {"id":"UNIQUE_ID"} }
def func(self, id, **kwargs):
for key in kwargs:
message(id, kwargs[key],)
return ()
class AnythingEverywherePrompts(Base):
@classmethod
def INPUT_TYPES(s):
return {"required":{},
"optional": { "+ve" : ("*", {}), "-ve" : ("*", {}), } }
def func(self, **kwargs):
return ()
class AnythingEverywhereTriplet(Base):
@classmethod
def INPUT_TYPES(s):
return {"required":{},
"optional": { "anything" : ("*", {}), "anything2" : ("*", {}), "anything3" : ("*", {}),} }
def func(self, **kwargs):
return ()
class AnythingSomewhere(Base):
@classmethod
def INPUT_TYPES(s):
return {"required":{},
"optional": {
"anything" : ("*", {}),
"title_regex" : ("STRING", {"default":".*"}),
"input_regex" : ("STRING", {"default":".*"}),
"group_regex" : ("STRING", {"default":".*"}),
},
"hidden": {"id":"UNIQUE_ID"} }
def func(self, id, title_regex=None, input_regex=None, group_regex=None, **kwargs):
for key in kwargs:
message(id, kwargs[key],)
return ()
|