From 10e4c8b42c88b4a1940e9dc191cf1623ed4507ea Mon Sep 17 00:00:00 2001 From: "Alexander G. Morano" Date: Wed, 17 Jul 2024 10:21:02 -0700 Subject: [PATCH] header cleanup, variable cleanup, license for comfyui.org --- .gitattributes | 2 ++ .gitignore | 13 +++++++++---- __init__.py | 38 ++++++++++++-------------------------- core/utility.py | 26 ++++++++++++-------------- pyproject.toml | 4 ++-- sup/lexicon.py | 1 + 6 files changed, 38 insertions(+), 46 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore index ae437f8..e67081c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,15 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ +__pycache__ *.py[cod] *$py.class _* *.code-workspace -.vscode/ +.vscode config.json ignore.txt -.env \ No newline at end of file +.env +.DS_Store +*.egg-info +*.bak +checkpoints +results +backup \ No newline at end of file diff --git a/__init__.py b/__init__.py index fd9cc6c..d16c5a0 100644 --- a/__init__.py +++ b/__init__.py @@ -8,36 +8,22 @@ Animation, Image Compositing & Procedural Creation http://www.github.com/amorano/jovimetrix - Copyright Alexander G. Morano (Joviex) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -GO NUTS; JUST TRY NOT TO DO IT IN YOUR HEAD. - @title: Jovimetrix @author: amorano @category: Compositing @reference: https://github.com/Amorano/Jovimetrix -@tags: adjust, animate, compose, compositing, composition, device, flow, video, mask, shape, webcam, animation, logic -@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 converstion 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. +@tags: adjust, animate, compose, compositing, composition, device, flow, video, +mask, shape, webcam, animation, logic +@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 converstion 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. @node list: - ConstantNode, ConstantNode, ShapeNode, StereogramNode, StereoscopicNode, TextNode, WaveGraphNode, + ConstantNode, GLSLNode, ShapeNode, StereogramNode, StereoscopicNode, TextNode, WaveGraphNode, AdjustNode, ColorBlindNode, ColorMatchNode, FilterMaskNode, ThresholdNode, BlendNode, ColorTheoryNode, CropNode, FlattenNode, PixelMergeNode, PixelSplitNode, PixelSwapNode, StackNode, TransformNode @@ -48,7 +34,7 @@ StreamReaderNode, StreamWriterNode, SpoutWriter, AkashicNode, ArrayNode, BatchLoadNode, DynamicNode, ValueGraphNode, ExportNode, QueueNode, RouteNode, SaveOutputNode -@version: 1.2.0 +@version: 1.2.6 """ import os diff --git a/core/utility.py b/core/utility.py index f6040ca..7c8a4ba 100644 --- a/core/utility.py +++ b/core/utility.py @@ -129,7 +129,7 @@ class ArrayNode(JOVBaseNode): NAME = "ARRAY (JOV) πŸ“š" CATEGORY = f"JOVIMETRIX πŸ”ΊπŸŸ©πŸ”΅/{JOV_CATEGORY}" RETURN_TYPES = (JOV_TYPE_ANY, JOV_TYPE_ANY, "INT") - RETURN_NAMES = (Lexicon.ANY_OUT, Lexicon.LIST, Lexicon.VALUE) + RETURN_NAMES = (Lexicon.ANY_OUT, Lexicon.LIST, Lexicon.LENGTH) 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. @@ -145,14 +145,14 @@ def INPUT_TYPES(cls) -> dict: Lexicon.RANGE: ("VEC3", {"default": (0, 0, 1), "min": 0, "step": 1}), Lexicon.STRING: ("STRING", {"default": "", "tooltip":"Comma separated list of indicies to export"}), Lexicon.SEED: ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1}), - Lexicon.COUNT: ("INT", {"default": 1, "min": 1, "max": sys.maxsize, "step": 1, "tooltip":"How many items to return"}), + Lexicon.COUNT: ("INT", {"default": 0, "min": 0, "max": sys.maxsize, "step": 1, "tooltip":"How many items to return"}), Lexicon.FLIP: ("BOOLEAN", {"default": False, "tooltip":"invert the calculated output list"}), Lexicon.BATCH_CHUNK: ("INT", {"default": 0, "min": 0, "step": 1}), }, "outputs": { 0: (Lexicon.ANY_OUT, {"tooltip":"Output list from selected operation"}), 1: (Lexicon.LIST, {"tooltip":"Full list"}), - 2: (Lexicon.VALUE, {"tooltip":"Length of output list"}), + 2: (Lexicon.LENGTH, {"tooltip":"Length of output list"}), } }) return Lexicon._parse(d, cls) @@ -175,7 +175,7 @@ def run(self, **kw) -> Tuple[int, list]: slice_range = parse_param(kw, Lexicon.RANGE, EnumConvertType.VEC3INT, [(0, 0, 1)]) indices = parse_param(kw, Lexicon.STRING, EnumConvertType.STRING, "") seed = parse_param(kw, Lexicon.SEED, EnumConvertType.INT, 0) - count = parse_param(kw, Lexicon.COUNT, EnumConvertType.INT, 1, 1) + count = parse_param(kw, Lexicon.COUNT, EnumConvertType.INT, 0, 0) flip = parse_param(kw, Lexicon.FLIP, EnumConvertType.BOOLEAN, False) batch_chunk = parse_param(kw, Lexicon.BATCH_CHUNK, EnumConvertType.INT, 0, 0) extract = [] @@ -206,6 +206,7 @@ def run(self, **kw) -> Tuple[int, list]: pbar = ProgressBar(len(params)) for idx, (mode, index, slice_range, indices, seed, flip, batch_chunk, count) in enumerate(params): loop_extract = extract.copy() + if len(loop_extract) == 0: results.append([None, None, 0]) pbar.update_absolute(idx) @@ -217,7 +218,7 @@ def run(self, **kw) -> Tuple[int, list]: mode = EnumBatchMode[mode] if mode == EnumBatchMode.PICK: index = index if index < len(loop_extract) else -1 - loop_extract = loop_extract[index] + loop_extract = [loop_extract[index]] elif mode == EnumBatchMode.SLICE: start, end, step = slice_range end = len(loop_extract) if end == 0 else end @@ -226,11 +227,9 @@ def run(self, **kw) -> Tuple[int, list]: if self.__seed is None or self.__seed != seed: random.seed(seed) self.__seed = seed - val = [] - for i in range(count): - index = random.randrange(0, len(loop_extract)) - val.append(loop_extract[index]) - loop_extract = val + if count == 0: + count = len(loop_extract) + loop_extract = random.sample(loop_extract, k=count) elif mode == EnumBatchMode.INDEX_LIST: junk = [] for x in indices.strip().split(','): @@ -248,24 +247,23 @@ def run(self, **kw) -> Tuple[int, list]: elif mode == EnumBatchMode.CARTESIAN: logger.warning("NOT IMPLEMENTED - CARTESIAN") - if not isinstance(loop_extract, (list,)): - loop_extract = [loop_extract] - if len(loop_extract) == 0: loop_extract = extract.copy() if batch_chunk > 0: loop_extract = self.batched(loop_extract, batch_chunk) + if not output_is_image: results.append([*loop_extract, loop_extract, len(loop_extract)]) else: img.extend(loop_extract) + print(len(img)) results.append([loop_extract, len(loop_extract)]) pbar.update_absolute(idx) if not output_is_image: return list(zip(*results)) ret = torch.stack(img, dim=0) - return ret, *results + return ret, list(zip(*results)) class ExportNode(JOVBaseNode): NAME = "EXPORT (JOV) πŸ“½" diff --git a/pyproject.toml b/pyproject.toml index a956ccf..6f97a97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,8 @@ [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.5" -license = "MIT" +version = "1.2.6" +license = { file = "LICENSE" } dependencies = [ "aenum>=3.1.15, <4", "blendmodes>=2024.1.1", diff --git a/sup/lexicon.py b/sup/lexicon.py index fdcdc29..28c8840 100644 --- a/sup/lexicon.py +++ b/sup/lexicon.py @@ -131,6 +131,7 @@ class Lexicon(metaclass=LexiconMeta): KEY = 'πŸ”‘', "Key" LACUNARITY = 'LACUNARITY', "LACUNARITY" LEFT = '◀️', "Left" + LENGTH = 'LENGTH', "Length" LETTER = 'LETTER', "If each letter be generated and output in a batch" LINEAR = 'πŸ›Ÿ', "Linear" LIST = '🧾', "List"