Skip to content

Commit

Permalink
better list handling
Browse files Browse the repository at this point in the history
wave defaults for offset/phase adjusted
  • Loading branch information
Amorano committed Nov 16, 2024
1 parent 517e968 commit 6f36d7f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 53 deletions.
37 changes: 4 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ If those nodes have descriptions written in HTML or Markdown, they will be conve

## UPDATES

**2024/11/16** @1.2.47:
* Better list handling for `VALUE` node et. al.
* Wave defaults for offset/phase adjusted to be zero (0)

**2024/10/29** @1.2.46:
* `DELAY` node updated maintain ComfyUI zoom (fixes issue #61)
* Added Enable/Disable for Screensaver mode in `DELAY` node (added option from issue #61)
Expand Down Expand Up @@ -136,39 +140,6 @@ If those nodes have descriptions written in HTML or Markdown, they will be conve
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/09/09** @1.2.38:
* `QUEUE`s will signal true (TRIGGER) on complete unless halted
* doubled speed of midi reader when idle
* reduced GLSL footprint for color conversions
* * sorry if that blew someone's network!
* new `GLSL COLOR PALETTE` node based on cosines
* new `GLSL HSV ADJUST`
* Officially Supported Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/09/08** @1.2.36:
* MIDI `MIDI FILTER` and `MIDI FILTER EZ` Nodes cleaned up
* `COMPARISON` Node value conversion fixed
* new `GLSL TRANSFORM` Node -- offset, rotate and tile
* new `GLSL POSTERIZE` Node
* new `GLSL WARP` Node -- warps image based on distortion and strength mask
* new `GLSL CONICAL GRADIENT` Node
* new `EDGE` mode for `GLSL shaders`: Clamp, Wrap, Mirror
* `QUEUE TOO` Node updated to support batch
* Officially Supported Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/09/05** @1.2.35:
* `VALUE` Node defaults fixed on save
* `Colorizer` Panel is a undergoing major re-constructive surgery
* Allow slice reversal in `ARRAY` Node
* `GLSL` Nodes allow for `IMAGE or MASK` input for RGB(A)
* NOTE ADJUSTED VERSION NUMBERS TO SHOW OLDEST COMFYUI and FRONTEND VERSIONS SUPPORTED:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

# INSTALLATION

[Please see the wiki for advanced use of the environment variables used during startup](https://github.com/Amorano/Jovimetrix/wiki/B.-ASICS)
Expand Down
13 changes: 7 additions & 6 deletions core/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ def run(self, ident, **kw) -> Tuple[int, float, float, Any]:
class ValueNode(JOVBaseNode):
NAME = "VALUE (JOV) 🧬"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
INPUT_IS_LIST = True
RETURN_TYPES = (JOV_TYPE_NUMBER, JOV_TYPE_NUMBER, JOV_TYPE_NUMBER, JOV_TYPE_NUMBER, JOV_TYPE_NUMBER,)
RETURN_NAMES = (Lexicon.ANY_OUT, Lexicon.X, Lexicon.Y, Lexicon.Z, Lexicon.W)
SORT = 5
Expand Down Expand Up @@ -999,7 +1000,7 @@ def INPUT_TYPES(cls) -> dict:
return Lexicon._parse(d, cls)

def run(self, **kw) -> Tuple[bool]:
raw = parse_param(kw, Lexicon.IN_A, EnumConvertType.ANY, [0])
raw = parse_param(kw, Lexicon.IN_A, EnumConvertType.ANY, [0], skip_list=True)
r_x = parse_param(kw, Lexicon.X, EnumConvertType.FLOAT, None, -sys.maxsize, sys.maxsize)
r_y = parse_param(kw, Lexicon.Y, EnumConvertType.FLOAT, None, -sys.maxsize, sys.maxsize)
r_z = parse_param(kw, Lexicon.Z, EnumConvertType.FLOAT, None, -sys.maxsize, sys.maxsize)
Expand Down Expand Up @@ -1054,8 +1055,8 @@ def run(self, **kw) -> Tuple[bool]:
else:
val[i] = random.randint(mn, mx)

extra = parse_value(val, typ, val) or [0]
ret = [val]
extra = parse_value(val, typ, val) or [0, 0, 0, 0]
ret = []
ret.extend(extra)
results.append(ret)
pbar.update_absolute(idx)
Expand Down Expand Up @@ -1094,19 +1095,19 @@ def run(self, **kw) -> Tuple[float, int]:
op = parse_param(kw, Lexicon.WAVE, EnumWave, EnumWave.SIN.name)
freq = parse_param(kw, Lexicon.FREQ, EnumConvertType.FLOAT, 1, 0, sys.maxsize)
amp = parse_param(kw, Lexicon.AMP, EnumConvertType.FLOAT, 1, 0, sys.maxsize)
phase = parse_param(kw, Lexicon.PHASE, EnumConvertType.FLOAT, 0, 1)
shift = parse_param(kw, Lexicon.OFFSET, EnumConvertType.FLOAT, 0, 1)
phase = parse_param(kw, Lexicon.PHASE, EnumConvertType.FLOAT, 0)
shift = parse_param(kw, Lexicon.OFFSET, EnumConvertType.FLOAT, 0)
delta_time = parse_param(kw, Lexicon.TIME, EnumConvertType.FLOAT, 0, 0, sys.maxsize)
invert = parse_param(kw, Lexicon.INVERT, EnumConvertType.BOOLEAN, False)
abs = parse_param(kw, Lexicon.ABSOLUTE, EnumConvertType.BOOLEAN, False)
results = []
params = list(zip_longest_fill(op, freq, amp, phase, shift, delta_time, invert, abs))
pbar = ProgressBar(len(params))
for idx, (op, freq, amp, phase, shift, delta_time, invert, abs) in enumerate(params):
val = wave_op(op, phase, freq, amp, shift, delta_time)
# freq = 1. / freq
if invert:
amp = 1. / val
val = wave_op(op, phase, freq, amp, shift, delta_time)
if abs:
val = np.abs(val)
val = max(-sys.maxsize, min(val, sys.maxsize))
Expand Down
5 changes: 2 additions & 3 deletions core/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,8 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
if pA is None:
if pB is None:
if mask is None:
images.append(img)
pbar.update_absolute(idx)
continue
if mode != EnumScaleMode.MATTE:
width, height = wihi
else:
height, width = mask.shape[:2]
else:
Expand Down
19 changes: 12 additions & 7 deletions core/utility/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ def __contains__(self, key) -> Literal[True]:
class ArrayNode(JOVBaseNode):
NAME = "ARRAY (JOV) 📚"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (JOV_TYPE_ANY, "INT", JOV_TYPE_ANY, "INT")
RETURN_NAMES = (Lexicon.ANY_OUT, Lexicon.LENGTH, Lexicon.LIST, Lexicon.LENGTH2)
INPUT_IS_LIST = True
RETURN_TYPES = (JOV_TYPE_ANY, "INT", JOV_TYPE_ANY, "INT", JOV_TYPE_ANY)
RETURN_NAMES = (Lexicon.ANY_OUT, Lexicon.LENGTH, Lexicon.LIST, Lexicon.LENGTH2, Lexicon.LIST)
OUTPUT_IS_LIST = (False, False, False, False, True)
SORT = 50
DESCRIPTION = """
Processes a batch of data based on the selected mode, such as merging, picking, slicing, random selection, or indexing. Allows for flipping the order of processed items and dividing the data into chunks.
Expand All @@ -73,14 +75,15 @@ def INPUT_TYPES(cls) -> dict:
Lexicon.STRING: ("STRING", {"default": "", "tooltips":"Comma separated list of indicies to export"}),
Lexicon.SEED: ("INT", {"default": 0, "mij": 0, "maj": sys.maxsize}),
Lexicon.COUNT: ("INT", {"default": 0, "mij": 0, "maj": sys.maxsize, "tooltips":"How many items to return"}),
Lexicon.FLIP: ("BOOLEAN", {"default": False, "tooltips":"invert the calculated output list"}),
Lexicon.FLIP: ("BOOLEAN", {"default": False, "tooltips":"reverse the calculated output list"}),
Lexicon.BATCH_CHUNK: ("INT", {"default": 0, "mij": 0,}),
},
"outputs": {
0: (Lexicon.ANY_OUT, {"tooltips":"Output list from selected operation"}),
1: (Lexicon.LENGTH, {"tooltips":"Length of output list"}),
2: (Lexicon.LIST, {"tooltips":"Full list"}),
3: (Lexicon.LENGTH2, {"tooltips":"Length of all input elements"}),
4: (Lexicon.LIST, {"tooltips":"The elements as a COMFYUI list output"}),
}
})
return Lexicon._parse(d, cls)
Expand Down Expand Up @@ -137,10 +140,12 @@ def run(self, **kw) -> Tuple[int, list]:
logger.warning("no data for list")
return None, 0, None, 0

data = full_list.copy()
print(full_list)

if flip:
data = data[::-1]
full_list.reverse()

data = full_list.copy()

if mode == EnumBatchMode.PICK:
index = index if index < len(data) else -1
Expand Down Expand Up @@ -188,7 +193,7 @@ def run(self, **kw) -> Tuple[int, list]:

size = len(data)
if output_is_image:
_, w, h = image_by_size(data)
# _, w, h = image_by_size(data)
result = []
for d in data:
d = tensor2cv(d)
Expand All @@ -209,7 +214,7 @@ def run(self, **kw) -> Tuple[int, list]:
if not output_is_image and len(data) == 1:
data = data[0]

return data, size, full_list, len(full_list)
return data, size, full_list, len(full_list), data

class QueueBaseNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "jovimetrix"
description = "Integrates Webcam, MIDI, Spout and GLSL shader support. Animation via tick. Parameter manipulation with wave generator. Math operations with Unary and Binary support. Value conversion for all major types (int, string, list, dict, Image, Mask). Shape mask generation, image stacking and channel ops, batch splitting, merging and randomizing, load images and video from anywhere, dynamic bus routing with a single node, export support for GIPHY, save output anywhere! flatten, crop, transform; check colorblindness, make stereogram or stereoscopic images, or liner interpolate values and more."
version = "1.2.46"
version = "1.2.47"
license = { file = "LICENSE" }
dependencies = [
"aenum>=3.1.15,<4",
Expand Down
4 changes: 3 additions & 1 deletion sup/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import numpy as np
from numba import jit

from loguru import logger

__all__ = ["Ease", "Wave"]

TYPE_NUMBER = Union[int|float|np.ndarray]
Expand Down Expand Up @@ -331,7 +333,7 @@ def wave_gaussian(phase: float, mean: float, amplitude: float, offset: float,
def wave_op(op: EnumEase, phase: float, frequency: float, amplitude: float,
offset: float, timestep: float, std_dev: float=1) -> np.ndarray:

op = op.lower()
op = op.name.lower()
if (func := getattr(MODULE, f"wave_{op}", None)) is None:
raise BadOperatorException(str(op))
"""
Expand Down
7 changes: 5 additions & 2 deletions sup/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def parse_value(val:Any, typ:EnumConvertType, default: Any,

def parse_param(data:dict, key:str, typ:EnumConvertType, default: Any,
clip_min: Optional[float]=None, clip_max: Optional[float]=None,
zero:int=0) -> List[Any]:
zero:int=0, skip_list=False) -> List[Any]:
"""Convenience because of the dictionary parameters.
Convert list of values into a list of specified type.
"""
Expand Down Expand Up @@ -331,7 +331,10 @@ def parse_param(data:dict, key:str, typ:EnumConvertType, default: Any,
if len(val) == 0:
val = [None]
elif isinstance(val, (tuple, set,)):
val = list(val)
if skip_list == False:
val = list(val)
else:
val = val[0][0]
elif issubclass(type(val), (Enum,)):
val = [str(val.name)]

Expand Down

0 comments on commit 6f36d7f

Please sign in to comment.