mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-26 14:48:51 -03:00
0.22
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# 🔗 Comfyui : Bjornulf_custom_nodes v0.21 🔗
|
# 🔗 Comfyui : Bjornulf_custom_nodes v0.22 🔗
|
||||||
|
|
||||||
# ☁ Usage in cloud :
|
# ☁ Usage in cloud :
|
||||||
|
|
||||||
@@ -63,7 +63,8 @@ wget --content-disposition -P /workspace/ComfyUI/models/checkpoints "https://civ
|
|||||||
- **v0.18**: New loop node, Free VRAM hack
|
- **v0.18**: New loop node, Free VRAM hack
|
||||||
- **v0.19**: Changes for save to folder node : ignore missing images filenames, will use the highest number found + 1.
|
- **v0.19**: Changes for save to folder node : ignore missing images filenames, will use the highest number found + 1.
|
||||||
- **v0.20**: Changes for lobechat save image : include the code of free VRAM hack + ignore missing images filenames
|
- **v0.20**: Changes for lobechat save image : include the code of free VRAM hack + ignore missing images filenames
|
||||||
- **v0.21**: Add a write text node that also display the text in the comfyui console (good for debugging)
|
- **v0.21**: Add a new write text node that also display the text in the comfyui console (good for debugging)
|
||||||
|
- **v0.22**: Allow write text node to use random selection like this {hood|helmet} will randomly choose between hood or helmet.
|
||||||
|
|
||||||
# 📝 Nodes descriptions
|
# 📝 Nodes descriptions
|
||||||
|
|
||||||
@@ -75,6 +76,7 @@ wget --content-disposition -P /workspace/ComfyUI/models/checkpoints "https://civ
|
|||||||
Three simple nodes to write and show text.
|
Three simple nodes to write and show text.
|
||||||
Write node is a textarea where you can write your text.
|
Write node is a textarea where you can write your text.
|
||||||
The show text node will only display the text. (That's why I made it a different color : green, uneditable, display only.)
|
The show text node will only display the text. (That's why I made it a different color : green, uneditable, display only.)
|
||||||
|
Write text node now allow for special syntax to accept random variants, like `{hood|helmet}` will randomly choose between hood or helmet.
|
||||||
|
|
||||||
## 3 - 🔗 Combine Texts
|
## 3 - 🔗 Combine Texts
|
||||||

|

|
||||||
|
|||||||
@@ -1,19 +1,44 @@
|
|||||||
|
import re
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
class WriteText:
|
class WriteText:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"text": ("STRING", {"multiline": True}),
|
"text": ("STRING", {"multiline": True}),
|
||||||
}
|
},
|
||||||
|
"hidden": {
|
||||||
|
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff}),
|
||||||
|
"control_after_update": ("INT", {"default": 0})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# INPUT_IS_LIST = True
|
|
||||||
RETURN_TYPES = ("STRING",)
|
RETURN_TYPES = ("STRING",)
|
||||||
RETURN_NAMES = ("text",)
|
RETURN_NAMES = ("text",)
|
||||||
FUNCTION = "write_text"
|
FUNCTION = "write_text"
|
||||||
OUTPUT_NODE = True
|
OUTPUT_NODE = True
|
||||||
OUTPUT_IS_LIST = (False,)
|
|
||||||
CATEGORY = "Bjornulf"
|
CATEGORY = "Bjornulf"
|
||||||
|
|
||||||
def write_text(self, text):
|
def write_text(self, text, seed=None, control_after_update=None):
|
||||||
return {"ui": {"text": text}, "result": (text,)}
|
# If seed is not provided, generate a new one
|
||||||
|
if seed is None:
|
||||||
|
seed = int(time.time() * 1000)
|
||||||
|
|
||||||
|
# Use the seed to initialize the random number generator
|
||||||
|
random.seed(seed)
|
||||||
|
|
||||||
|
def replace_random(match):
|
||||||
|
options = match.group(1).split('|')
|
||||||
|
return random.choice(options)
|
||||||
|
|
||||||
|
pattern = r'\{([^}]+)\}'
|
||||||
|
result = re.sub(pattern, replace_random, text)
|
||||||
|
|
||||||
|
return (result,)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def IS_CHANGED(s, text, seed=None, control_after_update=None):
|
||||||
|
# This method is called to determine if the node needs to be re-executed
|
||||||
|
return float("nan") # Always re-execute to ensure consistency
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
import re
|
||||||
|
import random
|
||||||
|
import time
|
||||||
import logging
|
import logging
|
||||||
class WriteTextInConsole:
|
class WriteTextInConsole:
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -16,6 +19,25 @@ class WriteTextInConsole:
|
|||||||
OUTPUT_IS_LIST = (False,)
|
OUTPUT_IS_LIST = (False,)
|
||||||
CATEGORY = "Bjornulf"
|
CATEGORY = "Bjornulf"
|
||||||
|
|
||||||
def write_text_in_console(self, text):
|
def write_text_in_console(self, text, seed=None, control_after_update=None):
|
||||||
logging.info(f"Text: {text}")
|
logging.info(f"Text: {text}")
|
||||||
return {"ui": {"text": text}, "result": (text,)}
|
# If seed is not provided, generate a new one
|
||||||
|
if seed is None:
|
||||||
|
seed = int(time.time() * 1000)
|
||||||
|
|
||||||
|
# Use the seed to initialize the random number generator
|
||||||
|
random.seed(seed)
|
||||||
|
|
||||||
|
def replace_random(match):
|
||||||
|
options = match.group(1).split('|')
|
||||||
|
return random.choice(options)
|
||||||
|
|
||||||
|
pattern = r'\{([^}]+)\}'
|
||||||
|
result = re.sub(pattern, replace_random, text)
|
||||||
|
|
||||||
|
return (result,)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def IS_CHANGED(s, text, seed=None, control_after_update=None):
|
||||||
|
# This method is called to determine if the node needs to be re-executed
|
||||||
|
return float("nan") # Always re-execute to ensure consistency
|
||||||
Reference in New Issue
Block a user