Skip to content

Commit

Permalink
优化LoadImageURL,增加seed,保证图片加载失败后可以继续
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowcz007 committed Jan 23, 2024
1 parent fc2367d commit 8263609
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
5 changes: 3 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
}
Expand Down
11 changes: 10 additions & 1 deletion nodes/ImageNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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",)
Expand All @@ -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):
Expand Down
25 changes: 25 additions & 0 deletions nodes/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)

0 comments on commit 8263609

Please sign in to comment.