mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-21 12:42:11 -03:00
v0.11
This commit is contained in:
34
README.md
34
README.md
@@ -1,4 +1,4 @@
|
|||||||
# 🔗 Comfyui : Bjornulf_custom_nodes v0.10 🔗
|
# 🔗 Comfyui : Bjornulf_custom_nodes v0.11 🔗
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
- **v0.8**: Add basic node to transform greenscreen in to transparency.
|
- **v0.8**: Add basic node to transform greenscreen in to transparency.
|
||||||
- **v0.9**: Add a new node : Return one random line from input.
|
- **v0.9**: Add a new node : Return one random line from input.
|
||||||
- **v0.10**: Add a new node : Loop (All Lines from input) - Iterate over all lines from an input text.
|
- **v0.10**: Add a new node : Loop (All Lines from input) - Iterate over all lines from an input text.
|
||||||
|
- **v0.11**: Add a new node : Text with random Seed - Generate a random seed, along with text.
|
||||||
|
|
||||||
# 📝 Nodes descriptions
|
# 📝 Nodes descriptions
|
||||||
|
|
||||||
@@ -176,20 +177,45 @@ Update 0.8 : Also have a option to put image top, bottom or center.
|
|||||||
❗ Warning : For now, `background` is a static image. (I will allow video there later too.)
|
❗ Warning : For now, `background` is a static image. (I will allow video there later too.)
|
||||||
|
|
||||||
## 25 - 🟩➜▢ Green Screen to Transparency
|
## 25 - 🟩➜▢ Green Screen to Transparency
|
||||||

|

|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
Transform greenscreen into transparency.
|
Transform greenscreen into transparency.
|
||||||
Need clean greenscreen ofc. (Can adjust threshold but very basic node.)
|
Need clean greenscreen ofc. (Can adjust threshold but very basic node.)
|
||||||
|
|
||||||
## 26 - 🎲 Random line from input
|
## 26 - 🎲 Random line from input
|
||||||

|

|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
Take a random line from an input text. (When using multiple "Write Text" nodes is annoying for example, you can use that and just copy/paste a list from outside.)
|
Take a random line from an input text. (When using multiple "Write Text" nodes is annoying for example, you can use that and just copy/paste a list from outside.)
|
||||||
|
|
||||||
## 27 - ♻ Loop (All Lines from input)
|
## 27 - ♻ Loop (All Lines from input)
|
||||||

|

|
||||||
|
|
||||||
**Description:**
|
**Description:**
|
||||||
Iterate over all lines from an input text. (Good for testing multiple lines of text.)
|
Iterate over all lines from an input text. (Good for testing multiple lines of text.)
|
||||||
|
|
||||||
|
## 28 - 🔢 Text with random Seed
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
|
||||||
|
❗ This node is used to generate a random seed, along with text.
|
||||||
|
But what does that mean ???
|
||||||
|
When you use a loop, the loop will use the same seed for each iteration. (That is the point, it will keep the same seed to compare results.)
|
||||||
|
Simple example without using random seed node :
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
But, if you want to force using another seed for each iteration, you can use this node in the middle.
|
||||||
|
For example, if you want to generate a different image every time. (aka : You use loop nodes not to compare or test results but to generate multiple images.)
|
||||||
|
Use it like that for example :
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Here is an example of FLUX with different prompt (hood/helmet) but same seed :
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Here is an example of SDXL with different prompt (blue/red) but same seed :
|
||||||
|
|
||||||
|

|
||||||
@@ -32,6 +32,7 @@ from .save_bjornulf_lobechat import SaveBjornulfLobeChat
|
|||||||
from .green_to_transparency import GreenScreenToTransparency
|
from .green_to_transparency import GreenScreenToTransparency
|
||||||
from .random_line_from_input import RandomLineFromInput
|
from .random_line_from_input import RandomLineFromInput
|
||||||
from .loop_lines import LoopAllLines
|
from .loop_lines import LoopAllLines
|
||||||
|
from .random_seed_with_text import TextToStringAndSeed
|
||||||
# from .check_black_image import CheckBlackImage
|
# from .check_black_image import CheckBlackImage
|
||||||
# from .clear_vram import ClearVRAM
|
# from .clear_vram import ClearVRAM
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
# "Bjornulf_CustomStringType": CustomStringType,
|
# "Bjornulf_CustomStringType": CustomStringType,
|
||||||
"Bjornulf_ollamaLoader": ollamaLoader,
|
"Bjornulf_ollamaLoader": ollamaLoader,
|
||||||
"Bjornulf_LoopAllLines": LoopAllLines,
|
"Bjornulf_LoopAllLines": LoopAllLines,
|
||||||
|
"Bjornulf_TextToStringAndSeed": TextToStringAndSeed,
|
||||||
"Bjornulf_GreenScreenToTransparency": GreenScreenToTransparency,
|
"Bjornulf_GreenScreenToTransparency": GreenScreenToTransparency,
|
||||||
"Bjornulf_RandomLineFromInput": RandomLineFromInput,
|
"Bjornulf_RandomLineFromInput": RandomLineFromInput,
|
||||||
# "Bjornulf_CheckBlackImage": CheckBlackImage,
|
# "Bjornulf_CheckBlackImage": CheckBlackImage,
|
||||||
@@ -83,6 +85,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|||||||
"Bjornulf_GreenScreenToTransparency": "🟩➜▢ Green Screen to Transparency",
|
"Bjornulf_GreenScreenToTransparency": "🟩➜▢ Green Screen to Transparency",
|
||||||
# "Bjornulf_CheckBlackImage": "🔲 Check Black Image (Empty mask)",
|
# "Bjornulf_CheckBlackImage": "🔲 Check Black Image (Empty mask)",
|
||||||
"Bjornulf_SaveBjornulfLobeChat": "🖼💬 Save image for Bjornulf LobeChat",
|
"Bjornulf_SaveBjornulfLobeChat": "🖼💬 Save image for Bjornulf LobeChat",
|
||||||
|
"Bjornulf_TextToStringAndSeed": "🔢 Text with random Seed",
|
||||||
# "Bjornulf_ClearVRAM": "🧹 Clear VRAM",
|
# "Bjornulf_ClearVRAM": "🧹 Clear VRAM",
|
||||||
"Bjornulf_RandomLineFromInput": "🎲 Random line from input",
|
"Bjornulf_RandomLineFromInput": "🎲 Random line from input",
|
||||||
"Bjornulf_ShowText": "👁 Show (Text)",
|
"Bjornulf_ShowText": "👁 Show (Text)",
|
||||||
|
|||||||
31
create_seed_from_text.txt
Normal file
31
create_seed_from_text.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import random
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
class TextToStringAndSeed:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"text": ("STRING", {"forceInput": True}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_NAMES = ("text","random_seed")
|
||||||
|
RETURN_TYPES = ("STRING", "INT")
|
||||||
|
FUNCTION = "process"
|
||||||
|
CATEGORY = "utils"
|
||||||
|
|
||||||
|
def process(self, text):
|
||||||
|
# Generate a hash from the input text
|
||||||
|
text_hash = hashlib.md5(text.encode()).hexdigest()
|
||||||
|
|
||||||
|
# Use the hash to seed the random number generator
|
||||||
|
random.seed(text_hash)
|
||||||
|
|
||||||
|
# Generate a random seed (integer)
|
||||||
|
random_seed = random.randint(0, 2**32 - 1)
|
||||||
|
|
||||||
|
# Reset the random seed to ensure randomness in subsequent calls
|
||||||
|
random.seed()
|
||||||
|
|
||||||
|
return (text, random_seed)
|
||||||
22
random_seed_with_text.py
Normal file
22
random_seed_with_text.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
class TextToStringAndSeed:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {
|
||||||
|
"required": {
|
||||||
|
"text": ("STRING", {"forceInput": True}),
|
||||||
|
"seed": ("INT", {"default": 1}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_NAMES = ("text", "random_seed")
|
||||||
|
RETURN_TYPES = ("STRING", "INT")
|
||||||
|
FUNCTION = "text_with_random_seed"
|
||||||
|
CATEGORY = "Bjornulf"
|
||||||
|
|
||||||
|
def text_with_random_seed(self, text, seed):
|
||||||
|
# Generate a random seed (integer)
|
||||||
|
random_seed = random.randint(0, 2**32 - 1)
|
||||||
|
|
||||||
|
return (text, random_seed)
|
||||||
BIN
screenshots/random_seed_1.png
Normal file
BIN
screenshots/random_seed_1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 455 KiB |
BIN
screenshots/random_seed_2.png
Normal file
BIN
screenshots/random_seed_2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 520 KiB |
BIN
screenshots/random_seed_3_flux.png
Normal file
BIN
screenshots/random_seed_3_flux.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 772 KiB |
BIN
screenshots/random_seed_4_sdxl.png
Normal file
BIN
screenshots/random_seed_4_sdxl.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 846 KiB |
19
web/js/random_seed_with_text.js
Normal file
19
web/js/random_seed_with_text.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { app } from "../../../scripts/app.js";
|
||||||
|
|
||||||
|
app.registerExtension({
|
||||||
|
name: "Bjornulf.TextToStringAndSeed",
|
||||||
|
async nodeCreated(node) {
|
||||||
|
if (node.comfyClass === "Bjornulf_TextToStringAndSeed") {
|
||||||
|
// Set seed widget to hidden input
|
||||||
|
const seedWidget = node.widgets.find(w => w.name === "seed");
|
||||||
|
if (seedWidget) {
|
||||||
|
seedWidget.type = "HIDDEN";
|
||||||
|
}
|
||||||
|
// Set seed widget to hidden input
|
||||||
|
const controlWidget = node.widgets.find(w => w.name === "control_after_generate");
|
||||||
|
if (controlWidget) {
|
||||||
|
controlWidget.type = "HIDDEN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user