Skip to content

Commit

Permalink
header cleanup, variable cleanup, license for comfyui.org
Browse files Browse the repository at this point in the history
  • Loading branch information
Amorano committed Jul 17, 2024
1 parent 0442d0b commit 10e4c8b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Byte-compiled / optimized / DLL files
__pycache__/
__pycache__
*.py[cod]
*$py.class
_*
*.code-workspace
.vscode/
.vscode
config.json
ignore.txt
.env
.env
.DS_Store
*.egg-info
*.bak
checkpoints
results
backup
38 changes: 12 additions & 26 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 12 additions & 14 deletions core/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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 = []
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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(','):
Expand All @@ -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) 📽"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions sup/lexicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 10e4c8b

Please sign in to comment.