From 8263609470a1e16ffd1787904911ef743377c87b Mon Sep 17 00:00:00 2001 From: shadowcz007 Date: Tue, 23 Jan 2024 10:03:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96LoadImageURL=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0seed=EF=BC=8C=E4=BF=9D=E8=AF=81=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=8A=A0=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=90=8E=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=BB=A7=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 5 +++-- nodes/ImageNode.py | 11 ++++++++++- nodes/Utils.py | 25 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 0a739662..4ae1c465 100644 --- a/__init__.py +++ b/__init__.py @@ -557,7 +557,7 @@ def new_add_routes(self): from .nodes.Clipseg import CLIPSeg,CombineMasks from .nodes.ChatGPT import ChatGPTNode,ShowTextForGPT,CharacterInText from .nodes.Audio import GamePal,SpeechRecognition,SpeechSynthesis -from .nodes.Utils import TESTNODE_,AppInfo,IntNumber,FloatSlider,TextInput,ColorInput,FontInput,TextToNumber,DynamicDelayProcessor,LimitNumber,SwitchByIndex,MultiplicationNode +from .nodes.Utils import CreateSeedNode,TESTNODE_,AppInfo,IntNumber,FloatSlider,TextInput,ColorInput,FontInput,TextToNumber,DynamicDelayProcessor,LimitNumber,SwitchByIndex,MultiplicationNode from .nodes.Mask import OutlineMask,FeatheredMask @@ -617,7 +617,8 @@ def new_add_routes(self): "SwitchByIndex":SwitchByIndex, "LimitNumber":LimitNumber, "OutlineMask":OutlineMask, - "JoinWithDelimiter":JoinWithDelimiter + "JoinWithDelimiter":JoinWithDelimiter, + "Seed_":CreateSeedNode # "LaMaInpainting":LaMaInpainting # "GamePal":GamePal } diff --git a/nodes/ImageNode.py b/nodes/ImageNode.py index bc899fc3..7e0e8f78 100644 --- a/nodes/ImageNode.py +++ b/nodes/ImageNode.py @@ -13,7 +13,13 @@ import math from .Watcher import FolderWatcher +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_type = AnyType("*") FONT_PATH= os.path.abspath(os.path.join(os.path.dirname(__file__),'../assets/王汉宗颜楷体繁.ttf')) @@ -1250,6 +1256,9 @@ def INPUT_TYPES(s): return {"required": { "url": ("STRING",{"multiline": True,"default": "https://","dynamicPrompts": False}), }, + "optional":{ + "seed": (any_type, {"default": 0, "min": 0, "max": 0xffffffffffffffff}), + } } RETURN_TYPES = ("IMAGE","MASK",) @@ -1266,7 +1275,7 @@ def INPUT_TYPES(s): global urls_image urls_image={} - def run(self,url): + def run(self,url,seed=0): global urls_image print(urls_image) def filter_http_urls(urls): diff --git a/nodes/Utils.py b/nodes/Utils.py index 52bd6cca..a6ebf8d2 100644 --- a/nodes/Utils.py +++ b/nodes/Utils.py @@ -712,3 +712,28 @@ def run(self,ANY): result = list_stats.count_types(ANY) return {"ui": {"data": result,"type":[str(type(ANY[0]))]}, "result": (ANY,)} + + + +class CreateSeedNode: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}), + } + } + + RETURN_TYPES = ("INT",) + RETURN_NAMES = ("seed",) + + OUTPUT_NODE = True + FUNCTION = "run" + + CATEGORY = "♾️Mixlab/Utils" + + def run(self, seed): + return (seed,) \ No newline at end of file