Skip to content

Commit

Permalink
feat: ImpactCount_Elts_in_SEGS
Browse files Browse the repository at this point in the history
improve: ImpactLogger
  • Loading branch information
ltdrdata committed Jun 11, 2024
1 parent 04f9f07 commit c5fe4b7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ This custom node helps to conveniently enhance images through Detector, Detailer
* `Dilate SEG_ELT` - Dilate the mask of SEG_ELT.
* `From SEG_ELT` bbox - Extract coordinate from bbox in SEG_ELT
* `From SEG_ELT` crop_region - Extract coordinate from crop_region in SEG_ELT
* `Count Elt in SEGS` - Number of Elts ins SEGS

### Pipe nodes
* `ToDetailerPipe`, `FromDetailerPipe` - These nodes are used to bundle multiple inputs used in the detailer, such as models and vae, ..., into a single DETAILER_PIPE or extract the elements that are bundled in the DETAILER_PIPE.
Expand Down
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def do_install():
"ImpactScaleBy_BBOX_SEG_ELT": SEG_ELT_BBOX_ScaleBy,
"ImpactFrom_SEG_ELT_bbox": From_SEG_ELT_bbox,
"ImpactFrom_SEG_ELT_crop_region": From_SEG_ELT_crop_region,
"ImpactCount_Elts_in_SEGS": Count_Elts_in_SEGS,

"BboxDetectorCombined_v2": BboxDetectorCombined,
"SegmDetectorCombined_v2": SegmDetectorCombined,
Expand Down Expand Up @@ -380,6 +381,7 @@ def do_install():
"ImpactFrom_SEG_ELT_crop_region": "From SEG_ELT crop_region",
"ImpactDilate_Mask_SEG_ELT": "Dilate Mask (SEG_ELT)",
"ImpactScaleBy_BBOX_SEG_ELT": "ScaleBy BBOX (SEG_ELT)",
"ImpactCount_Elts_in_SEGS": "Count Elts in SEGS",
"ImpactDilateMask": "Dilate Mask",
"ImpactGaussianBlurMask": "Gaussian Blur Mask",
"ImpactDilateMaskInSEGS": "Dilate Mask (SEGS)",
Expand Down
2 changes: 1 addition & 1 deletion modules/impact/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import configparser
import os

version_code = [5, 11, 5]
version_code = [5, 12]
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')

dependency_version = 21
Expand Down
17 changes: 17 additions & 0 deletions modules/impact/segs_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,23 @@ def doit(self, **kwargs):
return ((dim, res), )


class Count_Elts_in_SEGS:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"segs": ("SEGS", ),
},
}

RETURN_TYPES = ("INT",)
FUNCTION = "doit"

CATEGORY = "ImpactPack/Util"

def doit(self, segs):
return (len(segs[1]), )


class DecomposeSEGS:
@classmethod
def INPUT_TYPES(s):
Expand Down
9 changes: 6 additions & 3 deletions modules/impact/util_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import nodes
import re
from server import PromptServer


class GeneralSwitch:
Expand Down Expand Up @@ -196,8 +197,9 @@ class ImpactLogger:
def INPUT_TYPES(s):
return {"required": {
"data": (any_typ, ""),
"text": ("STRING", {"multiline": True}),
},
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO", "unique_id": "UNIQUE_ID"},
}

CATEGORY = "ImpactPack/Debug"
Expand All @@ -207,7 +209,7 @@ def INPUT_TYPES(s):
RETURN_TYPES = ()
FUNCTION = "doit"

def doit(self, data, prompt, extra_pnginfo):
def doit(self, data, text, prompt, extra_pnginfo, unique_id):
shape = ""
if hasattr(data, "shape"):
shape = f"{data.shape} / "
Expand All @@ -218,12 +220,13 @@ def doit(self, data, prompt, extra_pnginfo):

# for x in prompt:
# if 'inputs' in x and 'populated_text' in x['inputs']:
# print(f"PROMP: {x['10']['inputs']['populated_text']}")
# print(f"PROMPT: {x['10']['inputs']['populated_text']}")
#
# for x in extra_pnginfo['workflow']['nodes']:
# if x['type'] == 'ImpactWildcardProcessor':
# print(f" WV : {x['widgets_values'][1]}\n")

PromptServer.instance.send_sync("impact-node-feedback", {"node_id": unique_id, "widget_name": "text", "type": "TEXT", "value": f"{data}"})
return {}


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 = "comfyui-impact-pack"
description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
version = "5.11.5"
version = "5.12"
license = "LICENSE"
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]

Expand Down

0 comments on commit c5fe4b7

Please sign in to comment.