mirror of
https://github.com/justUmen/Bjornulf_custom_nodes.git
synced 2026-03-21 20:52:11 -03:00
0.38
This commit is contained in:
32
README.md
32
README.md
@@ -1,4 +1,4 @@
|
||||
# 🔗 Comfyui : Bjornulf_custom_nodes v0.37 🔗
|
||||
# 🔗 Comfyui : Bjornulf_custom_nodes v0.38 🔗
|
||||
|
||||
# ❤️ Coffee : ☕☕☕☕☕ 5/5
|
||||
|
||||
@@ -85,6 +85,7 @@ wget --content-disposition -P /workspace/ComfyUI/models/checkpoints "https://civ
|
||||
- **v0.35**: Great improvements of the TTS node 31. It will also save the audio file in the "ComfyUI/Bjornulf_TTS/" folder. - Not tested on windows yet -
|
||||
- **v0.36**: Fix random model.
|
||||
- **v0.37**: New node : Random Load checkpoint (Model Selector). Alternative to the random checkpoint node. (Not preloading all checkpoints in memory, slower to switch between checkpoints, but more outputs to decide where to store your results.)
|
||||
- **v0.38**: New node : If-Else logic. (input == compare_with), examples with different latent space size. +fix some deserialization issues.
|
||||
|
||||
# 📝 Nodes descriptions
|
||||
|
||||
@@ -526,4 +527,31 @@ Select an image from a list of images.
|
||||
Useful in combination with my Load images from folder and preview image nodes.
|
||||
|
||||
You can also of course make a group node, like this one, which is the same as the screenshot above :
|
||||

|
||||

|
||||
|
||||
### 45 - 🔀 If-Else (input == compare_with)
|
||||
|
||||

|
||||
|
||||
**Description:**
|
||||
If the `input` given is equal to the `compare_with` given in the widget, it will forward `send_if_true`, otherwise it will forward `send_if_false`.
|
||||
You can forward anything, below is an example of forwarding a different size of latent space depending if it's SDXL or not.
|
||||
|
||||

|
||||
|
||||
If-Else are chainables, just connect `output` to `send_if_false`.
|
||||
⚠️ Always simply test `input` with `compare_with`, and connect the desired value to `send_if_true`. ⚠️
|
||||
Here a simple example with 2 If-Else nodes (choose between 3 different resolutions). ❗ Notice the same write text node is connected to both If-Else nodes input :
|
||||
|
||||

|
||||
|
||||
Let's take a similar example but let's use my Write loop text node to display all 3 types once :
|
||||
|
||||

|
||||
|
||||
If you understood the previous examples, here is a complete example that will create 3 images, landscape, portrait and normal :
|
||||
|
||||

|
||||
|
||||
Workflow is hidden for simplicity, but is very basic, just connect latent to Ksampler, nothing special.)
|
||||
You can also connect the same advanced loop write text node with my save folder node to save the images (landscape/portrait/normal) in separate folders, but you do you...
|
||||
@@ -49,6 +49,7 @@ from .loop_write_text import LoopWriteText
|
||||
from .load_images_from_folder import LoadImagesFromSelectedFolder
|
||||
from .select_image_from_list import SelectImageFromList
|
||||
from .random_model_selector import RandomModelSelector
|
||||
from .if_else import IfElse
|
||||
|
||||
# from .pass_preview_image import PassPreviewImage
|
||||
# from .check_black_image import CheckBlackImage
|
||||
@@ -58,6 +59,7 @@ from .random_model_selector import RandomModelSelector
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
# "Bjornulf_CustomStringType": CustomStringType,
|
||||
"Bjornulf_ollamaLoader": ollamaLoader,
|
||||
"Bjornulf_IfElse": IfElse,
|
||||
"Bjornulf_RandomModelSelector": RandomModelSelector,
|
||||
"Bjornulf_SelectImageFromList": SelectImageFromList,
|
||||
"Bjornulf_WriteText": WriteText,
|
||||
@@ -167,6 +169,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"Bjornulf_PauseResume": "⏸️ Paused. Resume or Stop, Pick 👇",
|
||||
"Bjornulf_LoadImagesFromSelectedFolder": "📂🖼 Load Images from output folder",
|
||||
"Bjornulf_SelectImageFromList": "🖼🔍 Select an Image, Pick",
|
||||
"Bjornulf_IfElse": "🔀 If-Else (input == compare_with)",
|
||||
}
|
||||
|
||||
WEB_DIRECTORY = "./web"
|
||||
|
||||
26
if_else.py
Normal file
26
if_else.py
Normal file
@@ -0,0 +1,26 @@
|
||||
class Everything(str):
|
||||
def __ne__(self, __value: object) -> bool:
|
||||
return False
|
||||
|
||||
class IfElse:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"input": ("STRING", {"forceInput": True, "multiline": False}),
|
||||
"send_if_true": (Everything("*"),),
|
||||
"send_if_false": (Everything("*"),),
|
||||
"compare_with": ("STRING", {"multiline": False}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = (Everything("*"),"STRING")
|
||||
RETURN_NAMES = ("output","true_or_false")
|
||||
FUNCTION = "if_else"
|
||||
CATEGORY = "Bjornulf"
|
||||
|
||||
def if_else(self, input, send_if_true, send_if_false, compare_with):
|
||||
if input == compare_with:
|
||||
return (send_if_true,"True")
|
||||
else:
|
||||
return (send_if_false,"False")
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "bjornulf_custom_nodes"
|
||||
description = "Nodes: Ollama, Text to Speech, Combine Texts, Random Texts, Save image for Bjornulf LobeChat, Text with random Seed, Random line from input, Combine images, Image to grayscale (black & white), Remove image Transparency (alpha), Resize Image, ..."
|
||||
version = "0.37"
|
||||
version = "0.38"
|
||||
license = {file = "LICENSE"}
|
||||
|
||||
[project.urls]
|
||||
|
||||
BIN
screenshots/if1.png
Normal file
BIN
screenshots/if1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 108 KiB |
BIN
screenshots/if2.png
Normal file
BIN
screenshots/if2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 195 KiB |
BIN
screenshots/if3.png
Normal file
BIN
screenshots/if3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 KiB |
BIN
screenshots/if4.png
Normal file
BIN
screenshots/if4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 203 KiB |
BIN
screenshots/if5.png
Normal file
BIN
screenshots/if5.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 444 KiB |
@@ -49,12 +49,48 @@ app.registerExtension({
|
||||
};
|
||||
}
|
||||
|
||||
// Set seed widget to hidden input
|
||||
// Set seed widget to integer input
|
||||
const seedWidget = node.widgets.find((w) => w.name === "seed");
|
||||
if (seedWidget) {
|
||||
seedWidget.type = "HIDDEN";
|
||||
seedWidget.type = "HIDDEN"; // Hide seed widget after restoring saved state
|
||||
}
|
||||
|
||||
// Handle deserialization
|
||||
const originalOnConfigure = node.onConfigure;
|
||||
node.onConfigure = function(info) {
|
||||
if (originalOnConfigure) {
|
||||
originalOnConfigure.call(this, info);
|
||||
}
|
||||
|
||||
// Restore model widgets based on saved properties
|
||||
const savedProperties = info.properties;
|
||||
if (savedProperties) {
|
||||
Object.keys(savedProperties).forEach(key => {
|
||||
if (key.startsWith("model_")) {
|
||||
const widgetName = key;
|
||||
const widgetValue = savedProperties[key];
|
||||
const existingWidget = node.widgets.find(w => w.name === widgetName);
|
||||
if (existingWidget) {
|
||||
existingWidget.value = widgetValue;
|
||||
} else {
|
||||
node.addWidget("combo", widgetName, widgetValue, () => {}, {
|
||||
values: node.widgets.find(w => w.name === "model_1").options.values
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Ensure seed is a valid integer
|
||||
const seedWidget = node.widgets.find(w => w.name === "seed");
|
||||
if (seedWidget && isNaN(parseInt(seedWidget.value))) {
|
||||
seedWidget.value = 0; // Set a default value if invalid
|
||||
}
|
||||
|
||||
// Update model inputs after restoring saved state
|
||||
updateModelInputs();
|
||||
};
|
||||
|
||||
// Initial update
|
||||
updateModelInputs();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user