Skip to content

Commit

Permalink
allow slice reversal in ARRAY node
Browse files Browse the repository at this point in the history
GLSL nodes allow for IMAGE or MASK input for RGB(A)
  • Loading branch information
Amorano committed Sep 6, 2024
1 parent 090a32d commit 09c6cf1
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 105 deletions.
57 changes: 41 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,40 @@ If those nodes have descriptions written in HTML or Markdown, they will be conve

## UPDATES

**2024/09/04**:
**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+

**2024/09/04** @1.2.34:
* Import change for chromium tab crash
* Added ComfyUI default "tooltips" as last fallback for help docs
* Supports ComfyUI 0.2.1+, frontend 1.2.45+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/09/03**:
**2024/09/03** @1.2.33:
* New `QUEUE TOO` Node focused on efficient image media loading.
* Better reporting in `AKASHIC` Node for core ComfyUI types.
* `MODE` setting for most nodes has been defaulted to `MATTE`. The older `NONE` setting has been removed.
* Thanks to [christian-byrne](https://github.com/christian-byrne) for squashing a bug in [the help sidebar!](https://github.com/Amorano/Jovimetrix/pull/55)
* Thanks to [Ainaemaet](https://github.com/Ainaemaet) for cleaning up the `STREAM READER` Node device list [when no devices are present](https://github.com/Amorano/Jovimetrix/pull/53)!
* Supports ComfyUI 0.2.0+, frontend 1.2.45+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/08/31**:
**2024/08/31** @1.2.32:
* Better MASK/ALPHA support for `BLEND`, `ADJUST` and `QUEUE`
* Cleaner Markdown outputs
* Supports ComfyUI 0.1.3+, frontend 1.2.41+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/08/28**:
**2024/08/28** @1.2.31:

* New `STRINGER` Node for string operations: Split, Join, Replace and Slice.

Expand All @@ -94,25 +109,35 @@ If those nodes have descriptions written in HTML or Markdown, they will be conve

![QUEUE NODE](https://github.com/user-attachments/assets/9686b900-24a2-46ab-88ba-9e3c929b439c)

* Supports ComfyUI 0.1.3+, frontend 1.2.39+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/08/25**:
**2024/08/25** @1.2.30:
* Added conversion coercion for Mixlab Layer types
![Mixlab supports](https://github.com/user-attachments/assets/05a53b98-b620-4743-b7b5-26da4140d443)
* Supports ComfyUI 0.1.2+, frontend 1.2.34+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/08/24**:
**2024/08/24** @1.2.29:
* All node dynamic help
* Array node -- updated to return single values as their single value, not a list
* Supports ComfyUI 0.1.2+, frontend 1.2.30+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/08/23**:
**2024/08/23** @1.2.28:
* Colorization and Help panel only work on new frontend
* Supports ComfyUI 0.1.1+, frontend 1.2.29+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

**2024/08/20**:
**2024/08/20** @1.2.14:
* Complete Wiki and Examples revamp.
* Supports ComfyUI 0.0.8+, frontend 1.2.30+
* Supports Versions:
* ComfyUI 0.1.3+
* ComfyUI Frontend 1.2.30+

# INSTALLATION

Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
StreamReaderNode, StreamWriterNode, SpoutWriter,
AkashicNode, ArrayNode, BatchLoadNode, DynamicNode, ValueGraphNode, ExportNode, QueueNode,
RouteNode, SaveOutputNode
@version: 1.2.32
@version: 1.2.35
"""

import os
Expand Down
3 changes: 2 additions & 1 deletion core/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,6 @@ def run(self, **kw) -> Tuple[bool]:
pbar = ProgressBar(len(params))
old_seed = -1
for idx, (raw, r_x, r_y, r_z, r_w, typ, xyzw, seed, yyzw, x_str) in enumerate(params):
# logger.debug((raw, r_x, r_y, r_z, r_w, typ, xyzw, seed, yyzw, x_str))
typ = EnumConvertType[typ]
default = [x_str]
default2 = None
Expand Down Expand Up @@ -1016,6 +1015,8 @@ def run(self, **kw) -> Tuple[bool]:
ret.extend(extra)
results.append(ret)
pbar.update_absolute(idx)
if len(results) < 2:
return results[0]
return [x for x in zip(*results)]

class WaveGeneratorNode(JOVBaseNode):
Expand Down
39 changes: 23 additions & 16 deletions core/create_glsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
pass
from comfy.utils import ProgressBar

from Jovimetrix import JOVImageNode, comfy_message, deep_merge, Lexicon, ROOT
from Jovimetrix import JOVImageNode, comfy_message, deep_merge, Lexicon, ROOT, JOV_TYPE_ANY
from Jovimetrix.sup.util import load_file, parse_param, EnumConvertType, parse_value
from Jovimetrix.sup.image import EnumInterpolation, EnumScaleMode, cv2tensor_full, image_convert, image_scalefit, tensor2cv, MIN_IMAGE_SIZE
from Jovimetrix.sup.shader import PTYPE, shader_meta, CompileException, GLSLShader
Expand Down Expand Up @@ -135,19 +135,24 @@ def run(self, ident, **kw) -> tuple[torch.Tensor]:
step = 1. / self.__glsl.fps

images = []
vars = {}
batch = max(1, batch)
pbar = ProgressBar(batch)
for idx in range(batch):
vars = {}
firstImage = None
for k, v in variables.items():
var = v if not isinstance(v, (list, tuple,)) else v[idx % len(v)]
firstImage = None
# check if the input(s) have more than a single entry, get the max...
if batch == 1:
for k, var in variables.items():
if isinstance(var, (torch.Tensor)):
var = tensor2cv(var)
var = image_convert(var, 4)
batch = max(batch, var.shape[0])
var = [image_convert(tensor2cv(v), 4) for v in var]
if firstImage is None:
firstImage = var
vars[k] = var
firstImage = var[0]

variables[k] = var if isinstance(var, (list, tuple,)) else [var]

pbar = ProgressBar(batch)
for idx in range(batch):
for k, val in variables.items():
vars[k] = val[idx % len(val)]

w, h = wihi
if firstImage is not None and mode == EnumScaleMode.MATTE:
Expand Down Expand Up @@ -219,24 +224,26 @@ def INPUT_TYPES(cls) -> dict:
params = {"default": None}

d = None
type_name = typ.name
if glsl_type != 'sampler2D':
if default is not None:
d = default.split(',')
params['default'] = parse_value(d, typ, 0)

if val_min is not None:
params['val_min'] = parse_value(val_min, EnumConvertType.FLOAT, -sys.maxsize)
params['mij'] = parse_value(val_min, EnumConvertType.FLOAT, -sys.maxsize)

if val_max is not None:
params['val_max'] = parse_value(val_max, EnumConvertType.FLOAT, sys.maxsize)
params['maj'] = parse_value(val_max, EnumConvertType.FLOAT, sys.maxsize)

if val_step is not None:
d = 1 if typ.name.endswith('INT') else 0.01
params['val_step'] = parse_value(val_step, EnumConvertType.FLOAT, d)

params['step'] = parse_value(val_step, EnumConvertType.FLOAT, d)
else:
type_name = JOV_TYPE_ANY
if tooltip is not None:
params["tooltips"] = tooltip
data[name] = (typ.name, params,)
data[name] = (type_name, params,)

data.update(opts)
original_params['optional'] = data
Expand Down
5 changes: 5 additions & 0 deletions core/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ def run(self, **kw) -> Tuple[int, list]:
elif mode == EnumBatchMode.SLICE:
start, end, step = slice_range
end = len(data) if end == 0 else end
if step == 0:
step = 1
elif step < 0:
data = data[::-1]
step = abs(step)
data = data[start:end:step]
elif mode == EnumBatchMode.RANDOM:
if self.__seed is None or self.__seed != seed:
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.34"
version = "1.2.35"
license = { file = "LICENSE" }
dependencies = [
"aenum>=3.1.15,<4",
Expand Down
4 changes: 2 additions & 2 deletions sup/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ def pil2tensor(image: Image.Image) -> torch.Tensor:
def tensor2cv(tensor: torch.Tensor) -> TYPE_IMAGE:
"""Convert a torch Tensor to a numpy ndarray."""
tensor = tensor.cpu().squeeze().numpy()
if tensor.ndim == 1:
if tensor.ndim < 3:
tensor = np.expand_dims(tensor, -1)
image = np.clip(255.0 * tensor, 0, 255).astype(np.uint8)
if image.shape[2] == 4:
image_flatten_mask
# image_flatten_mask
mask = image_mask(image)
image = image_blend(image, image, mask)
image = image_mask_add(image, mask)
Expand Down
Loading

0 comments on commit 09c6cf1

Please sign in to comment.