Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c9e24148 | ||
|
|
5809fcdcb9 | ||
|
|
74db20c95e | ||
|
|
6dfb6e1acd | ||
|
|
7ba0e2760c | ||
|
|
2074152852 | ||
|
|
979f356783 | ||
|
|
f5467e1a37 | ||
|
|
769bc0f14a | ||
|
|
3345986dd7 | ||
|
|
d21517351d | ||
|
|
3d54756136 | ||
|
|
b61465c06f | ||
|
|
55dd4ccef5 | ||
|
|
4401965637 | ||
|
|
d22e2fa534 |
@@ -7,15 +7,19 @@ on:
|
||||
paths:
|
||||
- "pyproject.toml"
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
publish-node:
|
||||
name: Publish Custom Node to registry
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository_owner == 'ltdrdata' }}
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
- name: Publish Custom Node
|
||||
uses: Comfy-Org/publish-node-action@main
|
||||
uses: Comfy-Org/publish-node-action@v1
|
||||
with:
|
||||
## Add your own personal access token to your Github Repository secrets and reference it here.
|
||||
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
|
||||
@@ -15,6 +15,13 @@ This node pack provides nodes that complement the [ComfyUI Impact Pack](https://
|
||||
* civitai/[adetailer](https://civitai.com/search/models?sortBy=models_v5&query=adetailer) - You can download various types detection models....Many models are associated with NSFW content.
|
||||
|
||||
|
||||
## Paths
|
||||
* In `extra_model_paths.yaml`, you can add the following entries:
|
||||
- `ultralytics_bbox` - Specifies the paths for bbox YOLO models.
|
||||
- `ultralytics_segm` - Specifies the paths for segm YOLO models.
|
||||
- `ultralytics` - Allows the presence of `bbox/` and `segm/` subdirectories.
|
||||
|
||||
|
||||
## How To Install?
|
||||
|
||||
### Install via ComfyUI-Manager (Recommended)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
import importlib
|
||||
import logging
|
||||
|
||||
version_code = [1, 2, 1]
|
||||
version_code = [1, 2, 10]
|
||||
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
logging.info(f"### Loading: ComfyUI-Impact-Subpack ({version_str})")
|
||||
|
||||
|
||||
+5
-4
@@ -1,21 +1,22 @@
|
||||
import os
|
||||
import sys
|
||||
from torchvision.datasets.utils import download_url
|
||||
import logging
|
||||
|
||||
subpack_path = os.path.join(os.path.dirname(__file__))
|
||||
|
||||
comfy_path = os.environ.get('COMFYUI_PATH')
|
||||
if comfy_path is None:
|
||||
comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
print(f"\nWARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{comfy_path}` as the ComfyUI path.", file=sys.stderr)
|
||||
|
||||
logging.warning(f"\nWARN: The `COMFYUI_PATH` environment variable is not set. Assuming `{comfy_path}` as the ComfyUI path.")
|
||||
|
||||
sys.path.append(comfy_path)
|
||||
|
||||
model_path = os.environ.get('COMFYUI_MODEL_PATH')
|
||||
if model_path is None:
|
||||
model_path = os.path.abspath(os.path.join(comfy_path, 'models'))
|
||||
print(f"\nWARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.", file=sys.stderr)
|
||||
|
||||
logging.warning(f"\nWARN: The `COMFYUI_MODEL_PATH` environment variable is not set. Assuming `{model_path}` as the ComfyUI path.")
|
||||
|
||||
|
||||
ultralytics_bbox_path = os.path.join(model_path, "ultralytics", "bbox")
|
||||
ultralytics_segm_path = os.path.join(model_path, "ultralytics", "segm")
|
||||
|
||||
+39
-8
@@ -37,6 +37,18 @@ def create_segmasks(results):
|
||||
return results
|
||||
|
||||
|
||||
# Limit the commands that can be executed through `getattr` to `ultralytics.nn.modules.head.Detect.forward`.
|
||||
def restricted_getattr(obj, name, *args):
|
||||
if name != "forward":
|
||||
logging.error(f"Access to potentially dangerous attribute '{obj.__module__}.{obj.__name__}.{name}' is blocked.\nIf you believe the use of this code is genuinely safe, please report it.\nhttps://github.com/ltdrdata/ComfyUI-Impact-Subpack/issues")
|
||||
raise RuntimeError(f"Access to potentially dangerous attribute '{obj.__module__}.{obj.__name__}.{name}' is blocked.")
|
||||
|
||||
return getattr(obj, name, *args)
|
||||
|
||||
restricted_getattr.__module__ = 'builtins'
|
||||
restricted_getattr.__name__ = 'getattr'
|
||||
|
||||
|
||||
try:
|
||||
from ultralytics import YOLO
|
||||
from ultralytics.nn.tasks import DetectionModel
|
||||
@@ -49,8 +61,13 @@ try:
|
||||
import ultralytics.utils.loss as loss_modules
|
||||
import dill._dill
|
||||
from numpy.core.multiarray import scalar
|
||||
from numpy import dtype
|
||||
from numpy.dtypes import Float64DType
|
||||
try:
|
||||
from numpy import dtype
|
||||
from numpy.dtypes import Float64DType
|
||||
except:
|
||||
logging.error("[Impact Subpack] installed 'numpy' is outdated. Please update 'numpy' to 1.26.4")
|
||||
raise Exception("[Impact Subpack] installed 'numpy' is outdated. Please update 'numpy' to 1.26.4")
|
||||
|
||||
|
||||
torch_whitelist = []
|
||||
|
||||
@@ -108,7 +125,7 @@ try:
|
||||
|
||||
torch_whitelist += [DetectionModel, aliasYOLOv10DetectionModel, SegmentationModel, IterableSimpleNamespace,
|
||||
aliasIterableSimpleNamespace, TaskAlignedAssigner, aliasTaskAlignedAssigner, aliasv10DetectLoss,
|
||||
getattr, dill._dill._load_type, scalar, dtype, Float64DType]
|
||||
restricted_getattr, dill._dill._load_type, scalar, dtype, Float64DType]
|
||||
|
||||
build_torch_whitelist()
|
||||
|
||||
@@ -120,11 +137,25 @@ except Exception as e:
|
||||
# HOTFIX: https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/754
|
||||
# importing YOLO breaking original torch.load capabilities
|
||||
def torch_wrapper(*args, **kwargs):
|
||||
if hasattr(torch.serialization, 'safe_globals'):
|
||||
return orig_torch_load(*args, **kwargs)
|
||||
# NOTE: A trick to support code based on `'weights_only' in torch.load.__code__.co_varnames`.
|
||||
if 'weights_only' in kwargs:
|
||||
weights_only = kwargs.pop('weights_only')
|
||||
else:
|
||||
logging.warning("[Impact Subpack] Your torch version is outdated, and security features cannot be applied properly.")
|
||||
return orig_torch_load(*args, **kwargs, weights_only=False)
|
||||
weights_only = None
|
||||
|
||||
if hasattr(torch.serialization, 'safe_globals'):
|
||||
if weights_only is not None:
|
||||
kwargs['weights_only'] = weights_only
|
||||
|
||||
return orig_torch_load(*args, **kwargs) # NOTE: This code simply delegates the call to torch.load, and any errors that occur here are not the responsibility of Subpack.
|
||||
else:
|
||||
if weights_only is not None:
|
||||
kwargs['weights_only'] = weights_only
|
||||
else:
|
||||
logging.warning("[Impact Subpack] Your torch version is outdated, and security features cannot be applied properly.")
|
||||
kwargs['weights_only'] = False
|
||||
|
||||
return orig_torch_load(*args, **kwargs)
|
||||
|
||||
torch.load = torch_wrapper
|
||||
|
||||
@@ -354,4 +385,4 @@ class UltraSegmDetector:
|
||||
return utils.combine_masks(segmasks)
|
||||
|
||||
def setAux(self, x):
|
||||
pass
|
||||
pass
|
||||
|
||||
@@ -30,6 +30,22 @@ class UltralyticsDetectorProvider:
|
||||
|
||||
def doit(self, model_name):
|
||||
model_path = folder_paths.get_full_path("ultralytics", model_name)
|
||||
|
||||
if model_path is None:
|
||||
logging.error(f"[Impact Subpack] model file '{model_name}' is not found in one of the following directories:")
|
||||
|
||||
cands = []
|
||||
cands.extend(folder_paths.get_folder_paths("ultralytics"))
|
||||
if model_name.startswith('bbox/'):
|
||||
cands.extend(folder_paths.get_folder_paths("ultralytics_bbox"))
|
||||
elif model_name.startswith('segm/'):
|
||||
cands.extend(folder_paths.get_folder_paths("ultralytics_segm"))
|
||||
|
||||
formatted_cands = "\n\t".join(cands)
|
||||
logging.error(f'\t{formatted_cands}\n')
|
||||
|
||||
raise ValueError(f"[Impact Subpack] model file '{model_name}' is not found.")
|
||||
|
||||
model = subcore.load_yolo(model_path)
|
||||
|
||||
if model_name.startswith("bbox"):
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ def crop_ndarray2(npimg, crop_region):
|
||||
|
||||
return cropped
|
||||
|
||||
|
||||
|
||||
def crop_ndarray4(npimg, crop_region):
|
||||
x1 = crop_region[0]
|
||||
y1 = crop_region[1]
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-impact-subpack"
|
||||
description = "This node pack provides nodes that complement the Impact Pack, such as the UltralyticsDetectorProvider."
|
||||
version = "1.2.1"
|
||||
version = "1.2.10"
|
||||
license = { file = "LICENSE.txt" }
|
||||
dependencies = ["matplotlib", "ultralytics==8.3.40"]
|
||||
|
||||
|
||||
+4
-3
@@ -1,4 +1,5 @@
|
||||
matplotlib
|
||||
ultralytics==8.3.40
|
||||
numpy<2
|
||||
opencv-python-headless
|
||||
ultralytics
|
||||
numpy==1.26.4
|
||||
opencv-python-headless
|
||||
dill
|
||||
Reference in New Issue
Block a user