Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e32010bd6 | ||
|
|
b1c76243cf | ||
|
|
a871257f6f | ||
|
|
682f8fd078 | ||
|
|
7f1b8df89d | ||
|
|
ecbeaf3c26 | ||
|
|
a33221a244 | ||
|
|
fa587bd2c5 | ||
|
|
7e880158c9 | ||
|
|
182595a88d | ||
|
|
73db772c1c | ||
|
|
70e8847125 |
@@ -4,6 +4,12 @@ A custom node collection for ComfyUI that generates abstract images with compreh
|
||||
|
||||
This node collection is designed to create unique abstract base images on the fly within your ComfyUI workflows, which can then be used as input for VAE encoding, image-to-image generation, or other creative processes.
|
||||
|
||||
## Workflow
|
||||
|
||||
This image can be loaded into ComfyUI as a workflow
|
||||
|
||||
<img src="examples/workflow.png" alt="Workflow" width="1000">
|
||||
|
||||
# V2
|
||||
|
||||
A custom node pack for ComfyUI, providing modular components to generate abstract images with enhanced user control. This pack was created by splitting functionalities from the original abstract image generator into dedicated nodes for greater flexibility and customization.
|
||||
@@ -12,12 +18,12 @@ A custom node pack for ComfyUI, providing modular components to generate abstrac
|
||||
|
||||
This pack includes the following nodes:
|
||||
|
||||
* **Abstract Image Background:** Generate a base solid color or gradient background.
|
||||
* **Abstract Image Filled Shapes Layer:** Add a layer of filled shapes (rectangles, ellipses, triangles, polygons).
|
||||
* **Abstract Image Lines/Zigzags Layer:** Add a layer of lines and zigzag patterns.
|
||||
* **Abstract Image Pattern Layer:** Add a layer of repeating tiled patterns.
|
||||
* **Abstract Image Noise Layer:** Add a layer of noise patterns.
|
||||
* **Abstract Image Postprocessing:** Apply various post-processing effects to an image.
|
||||
* **[Abstract Image Background](#abstract-image-background):** Generate a base solid color or gradient background.
|
||||
* **[Abstract Image Filled Shapes Layer](#abstract-image-filled-shapes-layer):** Add a layer of filled shapes (rectangles, ellipses, triangles, polygons).
|
||||
* **[Abstract Image Lines/Zigzags Layer](#abstract-image-lineszigzags-layer):** Add a layer of lines and zigzag patterns.
|
||||
* **[Abstract Image Pattern Layer](#abstract-image-pattern-layer):** Add a layer of repeating tiled patterns.
|
||||
* **[Abstract Image Noise Layer](#abstract-image-noise-layer):** Add a layer of noise patterns.
|
||||
* **[Abstract Image Postprocessing](#abstract-image-postprocessing):** Apply various post-processing effects to an image.
|
||||
|
||||
|
||||
## Usage
|
||||
@@ -31,6 +37,8 @@ These nodes are designed to be chained together in a ComfyUI workflow. A typical
|
||||
|
||||
Each node offers various parameters to control the appearance of the generated elements, including randomization toggles for quick variations based on the seed.
|
||||
|
||||
<img src="examples/sample_example.png" alt="Sample Example" width="1000">
|
||||
|
||||
## Installation
|
||||
|
||||
### ComfyUI-Manager (Recommended)
|
||||
@@ -76,6 +84,8 @@ You should now find the node under the "AbstractImage" category in the add node
|
||||
|
||||
Generates a base image that can be a solid color or a gradient.
|
||||
|
||||
<img src="examples/background_example.png" alt="BG Example" width="1000">
|
||||
|
||||
* **Inputs:**
|
||||
* `width`, `height`: Image dimensions.
|
||||
* `seed`: Seed for random background generation (especially for gradient direction and randomized colors).
|
||||
@@ -92,6 +102,8 @@ Generates a base image that can be a solid color or a gradient.
|
||||
|
||||
Adds a layer of randomized filled shapes to an existing image.
|
||||
|
||||
<img src="examples/shape_example.png" alt="Shape Example" width="1000">
|
||||
|
||||
* **Inputs:**
|
||||
* `image`: Input image tensor.
|
||||
* `seed`: Seed for randomness within this layer.
|
||||
@@ -112,6 +124,8 @@ Adds a layer of randomized filled shapes to an existing image.
|
||||
|
||||
Adds a layer of randomized lines and zigzag patterns to an existing image.
|
||||
|
||||
<img src="examples/lines_example.png" alt="Lines Example" width="1000">
|
||||
|
||||
* **Inputs:**
|
||||
* `image`: Input image tensor.
|
||||
* `seed`: Seed for randomness within this layer.
|
||||
@@ -132,6 +146,8 @@ Adds a layer of randomized lines and zigzag patterns to an existing image.
|
||||
|
||||
Adds a layer of repeating tiled patterns to an existing image.
|
||||
|
||||
<img src="examples/pattern_example.png" alt="Pattern Example" width="1000">
|
||||
|
||||
* **Inputs:**
|
||||
* `image`: Input image tensor.
|
||||
* `seed`: Seed for randomness within this layer.
|
||||
@@ -151,6 +167,8 @@ Adds a layer of repeating tiled patterns to an existing image.
|
||||
|
||||
Adds a layer of noise patterns to an existing image.
|
||||
|
||||
<img src="examples/noise_example.png" alt="Noise Example" width="1000">
|
||||
|
||||
* **Inputs:**
|
||||
* `image`: Input image tensor.
|
||||
* `seed`: Seed for randomness within this layer.
|
||||
@@ -169,6 +187,8 @@ Adds a layer of noise patterns to an existing image.
|
||||
|
||||
Applies various final effects to an image.
|
||||
|
||||
<img src="examples/postprocessing_example.png" alt="Postprocessing Example" width="1000">
|
||||
|
||||
* **Inputs:**
|
||||
* `image`: Input image tensor.
|
||||
* `seed`: Seed for randomness within postprocessing (if randomize is true).
|
||||
|
||||
@@ -716,7 +716,7 @@ class AbstractImageGenerator:
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "generate"
|
||||
CATEGORY = "AbstractImage"
|
||||
CATEGORY = "AbstractImage/Old-V1"
|
||||
|
||||
def generate(self, width, height, seed, color_mode,
|
||||
toned_rgb_r, toned_rgb_g, toned_rgb_b,
|
||||
|
||||
@@ -15,22 +15,22 @@ class AbstractImageBackground:
|
||||
color_modes = ["random"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]]
|
||||
return {
|
||||
"required": {
|
||||
"width": ("INT", {"default": 512, "min": 64, "max": 2048, "step": 8, "display": "number", "description": "Width of the generated image."}),
|
||||
"height": ("INT", {"default": 512, "min": 64, "max": 2048, "step": 8, "display": "number", "description": "Height of the generated image."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for background randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize background type, colors, and gradient direction using the seed. Hex inputs override random colors if valid."}),
|
||||
"background_type": (["solid", "gradient"], {"default": "solid", "description": "Choose between a solid color or gradient background."}),
|
||||
"width": ("INT", {"default": 512, "min": 64, "max": 2048, "step": 8, "display": "number", "tooltip": "Width of the generated image."}),
|
||||
"height": ("INT", {"default": 512, "min": 64, "max": 2048, "step": 8, "display": "number", "tooltip": "Height of the generated image."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "tooltip": "Seed for background randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "tooltip": "If true, randomize background type, colors, and gradient direction using the seed. Hex inputs override random colors if valid."}),
|
||||
"background_type": (["solid", "gradient"], {"default": "solid", "tooltip": "Choose between a solid color or gradient background."}),
|
||||
|
||||
# Solid Color Options
|
||||
"solid_color_mode": (color_modes, {"default": "random", "description": "Color selection mode for solid background."}),
|
||||
"solid_color_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for solid color background (overrides Solid Color Mode if valid). Example: #FF0000 for red."}),
|
||||
"solid_color_mode": (color_modes, {"default": "random", "tooltip": "Color selection mode for solid background."}),
|
||||
"solid_color_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for solid color background (overrides Solid Color Mode if valid). Example: #FF0000 for red."}),
|
||||
|
||||
# Gradient Color Options
|
||||
"gradient_color_mode_start": (color_modes, {"default": "random", "description": "Color selection mode for the gradient start color."}), # New input
|
||||
"gradient_color_mode_end": (color_modes, {"default": "random", "description": "Color selection mode for the gradient end color."}), # New input
|
||||
"gradient_start_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for gradient start color (overrides Start Color Mode if valid). Example: #00FF00 for green."}),
|
||||
"gradient_end_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for gradient end color (overrides End Color Mode if valid). Example: #0000FF for blue."}),
|
||||
"gradient_direction": (["vertical", "horizontal", "radial", "diagonal"], {"default": "vertical", "description": "Direction of the gradient."}),
|
||||
"gradient_color_mode_start": (color_modes, {"default": "random", "tooltip": "Color selection mode for the gradient start color."}), # New input
|
||||
"gradient_color_mode_end": (color_modes, {"default": "random", "tooltip": "Color selection mode for the gradient end color."}), # New input
|
||||
"gradient_start_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for gradient start color (overrides Start Color Mode if valid). Example: #00FF00 for green."}),
|
||||
"gradient_end_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for gradient end color (overrides End Color Mode if valid). Example: #0000FF for blue."}),
|
||||
"gradient_direction": (["vertical", "horizontal", "radial", "diagonal"], {"default": "vertical", "tooltip": "Direction of the gradient."}),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -37,19 +37,19 @@ class AbstractImageFilledShapes:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for shapes randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize shapes per layer, colors, size, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "description": "Number of shape layers to add."}),
|
||||
"shapes_per_layer": ("INT", {"default": 10, "min": 1, "max": 100, "step": 1, "display": "number", "description": "Number of shapes to draw per layer."}),
|
||||
"max_shape_size": ("INT", {"default": 256, "min": 10, "max": 1024, "step": 1, "display": "number", "description": "Maximum size (width or height) of a single shape."}),
|
||||
"filled_shape_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "description": "Color selection mode for filled shapes. 'random' uses implicit RGB."}),
|
||||
"filled_shape_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for filled shapes color (used if Filled Shape Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "description": "Alpha (transparency) for shapes (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "description": "Restrict shapes to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "description": "Blending mode to composite the shapes layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "description": "Apply Gaussian blur to the alpha channel of the shapes layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Maximum sigma for feathering (if applied)."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "tooltip": "Seed for shapes randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "tooltip": "If true, randomize shapes per layer, colors, size, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "tooltip": "Number of shape layers to add."}),
|
||||
"shapes_per_layer": ("INT", {"default": 10, "min": 1, "max": 100, "step": 1, "display": "number", "tooltip": "Number of shapes to draw per layer."}),
|
||||
"max_shape_size": ("INT", {"default": 256, "min": 10, "max": 1024, "step": 1, "display": "number", "tooltip": "Maximum size (width or height) of a single shape."}),
|
||||
"filled_shape_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "tooltip": "Color selection mode for filled shapes. 'random' uses implicit RGB."}),
|
||||
"filled_shape_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for filled shapes color (used if Filled Shape Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "tooltip": "Alpha (transparency) for shapes (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "tooltip": "Restrict shapes to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "tooltip": "Blending mode to composite the shapes layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "tooltip": "Apply Gaussian blur to the alpha channel of the shapes layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Maximum sigma for feathering (if applied)."}),
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
# abstract_image_postprocessing.py
|
||||
|
||||
import random
|
||||
import torch
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from .abstract_image_utils import (
|
||||
pil_to_np, np_to_pil,
|
||||
add_grain_np, adjust_contrast_np, adjust_brightness_np,
|
||||
apply_grayscale_np, apply_final_blur_np
|
||||
)
|
||||
|
||||
class AbstractImagePostprocessing:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",), # Input image
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for post-processing randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize which effects are applied and their parameters using the seed."}),
|
||||
|
||||
"apply_grain": ("BOOLEAN", {"default": False, "label": "Apply Grain", "description": "Apply photographic grain (noise) to the image."}),
|
||||
"grain_amount": ("FLOAT", {"default": 0.05, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "description": "Amount of grain to apply."}),
|
||||
"grain_amount_random_min": ("FLOAT", {"default": 0.01, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "description": "Minimum grain amount if randomized."}),
|
||||
"grain_amount_random_max": ("FLOAT", {"default": 0.08, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "description": "Maximum grain amount if randomized."}),
|
||||
|
||||
|
||||
"apply_contrast": ("BOOLEAN", {"default": False, "label": "Adjust Contrast", "description": "Adjust the image contrast."}),
|
||||
"contrast_factor": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "description": "Contrast adjustment factor (1.0 is no change)."}),
|
||||
"contrast_random_min": ("FLOAT", {"default": 0.8, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "description": "Minimum contrast factor if randomized."}),
|
||||
"contrast_random_max": ("FLOAT", {"default": 1.3, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "description": "Maximum contrast factor if randomized."}),
|
||||
|
||||
|
||||
"apply_brightness": ("BOOLEAN", {"default": False, "label": "Adjust Brightness", "description": "Adjust the image brightness."}),
|
||||
"brightness_amount": ("INT", {"default": 0, "min": -255, "max": 255, "step": 1, "display": "number", "description": "Brightness adjustment amount (-255 is black, 255 is white)."}),
|
||||
"brightness_random_min": ("INT", {"default": -20, "min": -255, "max": 255, "step": 1, "display": "number", "description": "Minimum brightness amount if randomized."}),
|
||||
"brightness_random_max": ("INT", {"default": 20, "min": -255, "max": 255, "step": 1, "display": "number", "description": "Maximum brightness amount if randomized."}),
|
||||
|
||||
|
||||
"apply_grayscale": ("BOOLEAN", {"default": False, "label": "Apply Grayscale", "description": "Convert the image to grayscale."}),
|
||||
|
||||
"apply_blur": ("BOOLEAN", {"default": False, "label": "Apply Blur", "description": "Apply Gaussian blur to the image."}),
|
||||
"blur_sigma": ("FLOAT", {"default": 0.8, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "description": "Sigma for Gaussian blur."}),
|
||||
"blur_sigma_random_min": ("FLOAT", {"default": 0.4, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "description": "Minimum blur sigma if randomized."}),
|
||||
"blur_sigma_random_max": ("FLOAT", {"default": 1.2, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "description": "Maximum blur sigma if randomized."}),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "process"
|
||||
CATEGORY = "AbstractImage/Postprocessing"
|
||||
|
||||
def process(self, image, seed, randomize,
|
||||
apply_grain, grain_amount, grain_amount_random_min, grain_amount_random_max,
|
||||
apply_contrast, contrast_factor, contrast_random_min, contrast_random_max,
|
||||
apply_brightness, brightness_amount, brightness_random_min, brightness_random_max,
|
||||
apply_grayscale, apply_blur, blur_sigma, blur_sigma_random_min, blur_sigma_random_max):
|
||||
|
||||
# Convert input tensor to PIL Image (RGBA for consistent processing)
|
||||
image = image.permute(0, 3, 1, 2) if image.shape[1] == 3 or image.shape[1] == 4 else image
|
||||
image = image.squeeze(0)
|
||||
image_np = image.cpu().numpy() * 255.0
|
||||
image_pil = Image.fromarray(np.clip(image_np, 0, 255).astype(np.uint8), 'RGB').convert('RGBA')
|
||||
current_np = pil_to_np(image_pil)
|
||||
|
||||
main_rng = random.Random(seed)
|
||||
|
||||
# --- Determine which effects to apply and their parameters based on randomization ---
|
||||
final_apply_grain = apply_grain
|
||||
final_grain_amount = grain_amount
|
||||
final_apply_contrast = apply_contrast
|
||||
final_contrast_factor = contrast_factor
|
||||
final_apply_brightness = apply_brightness
|
||||
final_brightness_amount = brightness_amount
|
||||
final_apply_grayscale = apply_grayscale
|
||||
final_apply_blur = apply_blur
|
||||
final_blur_sigma = blur_sigma
|
||||
|
||||
if randomize:
|
||||
rand_rng = random.Random(seed + 100)
|
||||
|
||||
final_apply_grain = apply_grain and rand_rng.random() < 0.5
|
||||
if final_apply_grain:
|
||||
final_grain_amount = rand_rng.uniform(grain_amount_random_min, grain_amount_random_max)
|
||||
|
||||
final_apply_contrast = apply_contrast and rand_rng.random() < 0.5
|
||||
if final_apply_contrast:
|
||||
final_contrast_factor = rand_rng.uniform(contrast_random_min, contrast_random_max)
|
||||
|
||||
final_apply_brightness = apply_brightness and rand_rng.random() < 0.5
|
||||
if final_apply_brightness:
|
||||
final_brightness_amount = rand_rng.randint(brightness_random_min, brightness_random_max)
|
||||
|
||||
final_apply_grayscale = apply_grayscale and rand_rng.random() < 0.5
|
||||
final_apply_blur = apply_blur and rand_rng.random() < 0.5
|
||||
if final_apply_blur:
|
||||
final_blur_sigma = rand_rng.uniform(blur_sigma_random_min, blur_sigma_random_max)
|
||||
|
||||
|
||||
# --- Apply Post-processing Effects ---
|
||||
if final_apply_grain:
|
||||
grain_rng = random.Random(main_rng.randint(0, 2**32-1))
|
||||
current_np = add_grain_np(current_np, grain_rng, amount_range=(final_grain_amount, final_grain_amount))
|
||||
|
||||
if final_apply_contrast:
|
||||
contrast_rng = random.Random(main_rng.randint(0, 2**32-1))
|
||||
current_np = adjust_contrast_np(current_np, contrast_rng, contrast_range=(final_contrast_factor, final_contrast_factor))
|
||||
|
||||
if final_apply_brightness:
|
||||
brightness_rng = random.Random(main_rng.randint(0, 2**32-1))
|
||||
current_np = adjust_brightness_np(current_np, brightness_rng, brightness_range=(final_brightness_amount, final_brightness_amount))
|
||||
|
||||
if final_apply_grayscale:
|
||||
current_np = apply_grayscale_np(current_np)
|
||||
|
||||
if final_apply_blur:
|
||||
blur_rng = random.Random(main_rng.randint(0, 2**32-1))
|
||||
current_np = apply_final_blur_np(current_np, blur_rng, sigma_range=(final_blur_sigma, final_blur_sigma))
|
||||
|
||||
|
||||
# Convert final numpy array back to tensor
|
||||
final_pil = np_to_pil(current_np)
|
||||
final_rgb_pil = Image.new("RGB", final_pil.size, (0, 0, 0))
|
||||
final_rgb_pil.paste(final_pil, mask=final_pil.split()[3])
|
||||
|
||||
|
||||
img_np = np.array(final_rgb_pil).astype(np.float32) / 255.0
|
||||
img_tensor = torch.from_numpy(img_np)[None,]
|
||||
|
||||
return (img_tensor,)
|
||||
|
||||
|
||||
# Node mapping for ComfyUI
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"AbstractImagePostprocessing": AbstractImagePostprocessing
|
||||
}
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"AbstractImagePostprocessing": "Abstract Image Postprocessing"
|
||||
}
|
||||
@@ -37,20 +37,20 @@ class AbstractImageLines:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",), # Input image
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for lines/zigzags randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize lines per layer, colors, width, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "description": "Number of line/zigzag layers to add."}),
|
||||
"lines_per_layer": ("INT", {"default": 10, "min": 1, "max": 100, "step": 1, "display": "number", "description": "Number of lines/zigzags to draw per layer."}),
|
||||
"line_width_min": ("INT", {"default": 5, "min": 1, "max": 100, "step": 1, "display": "number", "description": "Minimum width for lines and zig-zags."}),
|
||||
"line_width_max": ("INT", {"default": 30, "min": 1, "max": 100, "step": 1, "display": "number", "description": "Maximum width for lines and zig-zags."}),
|
||||
"line_zigzag_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "description": "Color selection mode for lines and zig-zags. 'random' uses implicit RGB."}),
|
||||
"line_zigzag_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for line/zigzag color (used if Line/Zigzag Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "description": "Alpha (transparency) for lines/zigzags (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "description": "Restrict lines/zigzags to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "description": "Blending mode to composite the lines/zigzags layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "description": "Apply Gaussian blur to the alpha channel of the lines/zigzags layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Maximum sigma for feathering (if applied)."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "tooltip": "Seed for lines/zigzags randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "tooltip": "If true, randomize lines per layer, colors, width, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "tooltip": "Number of line/zigzag layers to add."}),
|
||||
"lines_per_layer": ("INT", {"default": 10, "min": 1, "max": 100, "step": 1, "display": "number", "tooltip": "Number of lines/zigzags to draw per layer."}),
|
||||
"line_width_min": ("INT", {"default": 5, "min": 1, "max": 100, "step": 1, "display": "number", "tooltip": "Minimum width for lines and zig-zags."}),
|
||||
"line_width_max": ("INT", {"default": 30, "min": 1, "max": 100, "step": 1, "display": "number", "tooltip": "Maximum width for lines and zig-zags."}),
|
||||
"line_zigzag_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "tooltip": "Color selection mode for lines and zig-zags. 'random' uses implicit RGB."}),
|
||||
"line_zigzag_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for line/zigzag color (used if Line/Zigzag Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "tooltip": "Alpha (transparency) for lines/zigzags (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "tooltip": "Restrict lines/zigzags to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "tooltip": "Blending mode to composite the lines/zigzags layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "tooltip": "Apply Gaussian blur to the alpha channel of the lines/zigzags layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Maximum sigma for feathering (if applied)."}),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -36,17 +36,17 @@ class AbstractImageNoise:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",), # Input image
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for noise pattern randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize noise scale, colors, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "description": "Number of noise layers to add."}),
|
||||
"noise_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "description": "Color selection mode for noise. 'random' uses implicit RGB."}),
|
||||
"noise_color_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for noise color (used if Noise Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "description": "Alpha (transparency) for noise (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "description": "Restrict noise pattern to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "description": "Blending mode to composite the noise layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "description": "Apply Gaussian blur to the alpha channel of the noise layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Maximum sigma for feathering (if applied)."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "tooltip": "Seed for noise pattern randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "tooltip": "If true, randomize noise scale, colors, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "tooltip": "Number of noise layers to add."}),
|
||||
"noise_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "tooltip": "Color selection mode for noise. 'random' uses implicit RGB."}),
|
||||
"noise_color_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for noise color (used if Noise Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "tooltip": "Alpha (transparency) for noise (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "tooltip": "Restrict noise pattern to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "tooltip": "Blending mode to composite the noise layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "tooltip": "Apply Gaussian blur to the alpha channel of the noise layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Maximum sigma for feathering (if applied)."}),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -36,18 +36,18 @@ class AbstractImagePattern:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",), # Input image
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for pattern randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize pattern size, colors, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "description": "Number of pattern layers to add."}),
|
||||
"tile_size": ("INT", {"default": 64, "min": 16, "max": 512, "step": 16, "display": "number", "description": "Size of the repeating pattern tile."}),
|
||||
"pattern_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "description": "Color selection mode for pattern. 'random' uses implicit RGB."}),
|
||||
"pattern_color_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "description": "Hex code for pattern color (used if Pattern Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "description": "Alpha (transparency) for pattern (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "description": "Restrict pattern to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "description": "Blending mode to composite the pattern layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "description": "Apply Gaussian blur to the alpha channel of the pattern layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "description": "Maximum sigma for feathering (if applied)."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "tooltip": "Seed for pattern randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "tooltip": "If true, randomize pattern size, colors, position, and blend mode using the seed."}),
|
||||
"num_layers": ("INT", {"default": 1, "min": 1, "max": 10, "step": 1, "display": "number", "tooltip": "Number of pattern layers to add."}),
|
||||
"tile_size": ("INT", {"default": 64, "min": 16, "max": 512, "step": 16, "display": "number", "tooltip": "Size of the repeating pattern tile."}),
|
||||
"pattern_color_mode": (["random", "hex"] + [c.lower() for c in ["Red", "Green", "Blue", "Cyan", "Magenta", "Yellow", "Black", "White"]], {"default": "random", "tooltip": "Color selection mode for pattern. 'random' uses implicit RGB."}),
|
||||
"pattern_color_hex": ("STRING", {"default": "", "placeholder": "#RRGGBB", "tooltip": "Hex code for pattern color (used if Pattern Color Mode is 'hex')."}),
|
||||
"alpha": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1, "display": "number", "tooltip": "Alpha (transparency) for pattern (0 is fully transparent, 255 is fully opaque)."}),
|
||||
"shape_position": (["full", "upper_right", "upper_left", "lower_right", "lower_left", "center"], {"default": "full", "tooltip": "Restrict pattern to a specific position/quadrant."},),
|
||||
"blend_mode": (BLEND_MODES, {"default": "normal", "tooltip": "Blending mode to composite the pattern layer onto the base image."}),
|
||||
"feather_layer": ("BOOLEAN", {"default": False, "label": "Feather Layer", "tooltip": "Apply Gaussian blur to the alpha channel of the pattern layer."}),
|
||||
"feather_sigma_min": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Minimum sigma for feathering (if applied)."}),
|
||||
"feather_sigma_max": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 20.0, "step": 0.1, "display": "number", "tooltip": "Maximum sigma for feathering (if applied)."}),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -19,33 +19,33 @@ class AbstractImagePostprocessing:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",), # Input image
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "description": "Seed for post-processing randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "description": "If true, randomize which effects are applied and their parameters using the seed."}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "display": "number", "tooltip": "Seed for post-processing randomness."}),
|
||||
"randomize": ("BOOLEAN", {"default": False, "label": "Enable Randomization", "tooltip": "If true, randomize which effects are applied and their parameters using the seed."}),
|
||||
|
||||
"apply_grain": ("BOOLEAN", {"default": False, "label": "Apply Grain", "description": "Apply photographic grain (noise) to the image."}),
|
||||
"grain_amount": ("FLOAT", {"default": 0.05, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "description": "Amount of grain to apply."}),
|
||||
"grain_amount_random_min": ("FLOAT", {"default": 0.01, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "description": "Minimum grain amount if randomized."}),
|
||||
"grain_amount_random_max": ("FLOAT", {"default": 0.08, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "description": "Maximum grain amount if randomized."}),
|
||||
"apply_grain": ("BOOLEAN", {"default": False, "label": "Apply Grain", "tooltip": "Apply photographic grain (noise) to the image."}),
|
||||
"grain_amount": ("FLOAT", {"default": 0.05, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "tooltip": "Amount of grain to apply."}),
|
||||
"grain_amount_random_min": ("FLOAT", {"default": 0.01, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "tooltip": "Minimum grain amount if randomized."}),
|
||||
"grain_amount_random_max": ("FLOAT", {"default": 0.08, "min": 0.0, "max": 1.0, "step": 0.001, "display": "number", "tooltip": "Maximum grain amount if randomized."}),
|
||||
|
||||
|
||||
"apply_contrast": ("BOOLEAN", {"default": False, "label": "Adjust Contrast", "description": "Adjust the image contrast."}),
|
||||
"contrast_factor": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "description": "Contrast adjustment factor (1.0 is no change)."}),
|
||||
"contrast_random_min": ("FLOAT", {"default": 0.8, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "description": "Minimum contrast factor if randomized."}),
|
||||
"contrast_random_max": ("FLOAT", {"default": 1.3, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "description": "Maximum contrast factor if randomized."}),
|
||||
"apply_contrast": ("BOOLEAN", {"default": False, "label": "Adjust Contrast", "tooltip": "Adjust the image contrast."}),
|
||||
"contrast_factor": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "tooltip": "Contrast adjustment factor (1.0 is no change)."}),
|
||||
"contrast_random_min": ("FLOAT", {"default": 0.8, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "tooltip": "Minimum contrast factor if randomized."}),
|
||||
"contrast_random_max": ("FLOAT", {"default": 1.3, "min": 0.0, "max": 5.0, "step": 0.01, "display": "number", "tooltip": "Maximum contrast factor if randomized."}),
|
||||
|
||||
|
||||
"apply_brightness": ("BOOLEAN", {"default": False, "label": "Adjust Brightness", "description": "Adjust the image brightness."}),
|
||||
"brightness_amount": ("INT", {"default": 0, "min": -255, "max": 255, "step": 1, "display": "number", "description": "Brightness adjustment amount (-255 is black, 255 is white)."}),
|
||||
"brightness_random_min": ("INT", {"default": -20, "min": -255, "max": 255, "step": 1, "display": "number", "description": "Minimum brightness amount if randomized."}),
|
||||
"brightness_random_max": ("INT", {"default": 20, "min": -255, "max": 255, "step": 1, "display": "number", "description": "Maximum brightness amount if randomized."}),
|
||||
"apply_brightness": ("BOOLEAN", {"default": False, "label": "Adjust Brightness", "tooltip": "Adjust the image brightness."}),
|
||||
"brightness_amount": ("INT", {"default": 0, "min": -255, "max": 255, "step": 1, "display": "number", "tooltip": "Brightness adjustment amount (-255 is black, 255 is white)."}),
|
||||
"brightness_random_min": ("INT", {"default": -20, "min": -255, "max": 255, "step": 1, "display": "number", "tooltip": "Minimum brightness amount if randomized."}),
|
||||
"brightness_random_max": ("INT", {"default": 20, "min": -255, "max": 255, "step": 1, "display": "number", "tooltip": "Maximum brightness amount if randomized."}),
|
||||
|
||||
|
||||
"apply_grayscale": ("BOOLEAN", {"default": False, "label": "Apply Grayscale", "description": "Convert the image to grayscale."}),
|
||||
"apply_grayscale": ("BOOLEAN", {"default": False, "label": "Apply Grayscale", "tooltip": "Convert the image to grayscale."}),
|
||||
|
||||
"apply_blur": ("BOOLEAN", {"default": False, "label": "Apply Blur", "description": "Apply Gaussian blur to the image."}),
|
||||
"blur_sigma": ("FLOAT", {"default": 0.8, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "description": "Sigma for Gaussian blur."}),
|
||||
"blur_sigma_random_min": ("FLOAT", {"default": 0.4, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "description": "Minimum blur sigma if randomized."}),
|
||||
"blur_sigma_random_max": ("FLOAT", {"default": 1.2, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "description": "Maximum blur sigma if randomized."}),
|
||||
"apply_blur": ("BOOLEAN", {"default": False, "label": "Apply Blur", "tooltip": "Apply Gaussian blur to the image."}),
|
||||
"blur_sigma": ("FLOAT", {"default": 0.8, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "tooltip": "Sigma for Gaussian blur."}),
|
||||
"blur_sigma_random_min": ("FLOAT", {"default": 0.4, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "tooltip": "Minimum blur sigma if randomized."}),
|
||||
"blur_sigma_random_max": ("FLOAT", {"default": 1.2, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number", "tooltip": "Maximum blur sigma if randomized."}),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user