mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-09 12:54:40 +08:00
Compare commits
3 Commits
c0368e2402
...
0763ac774e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0763ac774e | ||
|
|
f37df472df | ||
|
|
c116d3396f |
@ -3902,29 +3902,34 @@ class ImagePadKJ:
|
|||||||
class LoadVideosFromFolder:
|
class LoadVideosFromFolder:
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init__(cls):
|
def __init__(cls):
|
||||||
|
cls.vhs_nodes = None
|
||||||
|
vhs_pkg_name = "ComfyUI-VideoHelperSuite"
|
||||||
|
vhs_pkg_name_lower = vhs_pkg_name.lower()
|
||||||
|
vhs_pkg_name_suffix = vhs_pkg_name_lower.split("-")[-1]
|
||||||
|
vhs_submodule_name = "videohelpersuite"
|
||||||
try:
|
try:
|
||||||
cls.vhs_nodes = importlib.import_module("ComfyUI-VideoHelperSuite.videohelpersuite")
|
cls.vhs_nodes = importlib.import_module(vhs_pkg_name+"."+vhs_submodule_name)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
cls.vhs_nodes = importlib.import_module("comfyui-videohelpersuite.videohelpersuite")
|
cls.vhs_nodes = importlib.import_module(vhs_pkg_name_lower+"."+vhs_submodule_name)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Fallback to sys.modules search for Windows compatibility
|
# Fallback to sys.modules search for Windows compatibility
|
||||||
import sys
|
import sys
|
||||||
vhs_module = None
|
vhs_module = None
|
||||||
for module_name in sys.modules:
|
for module_name in sys.modules:
|
||||||
if 'videohelpersuite' in module_name and 'videohelpersuite' in sys.modules[module_name].__dict__:
|
if vhs_pkg_name_lower in module_name and vhs_submodule_name in sys.modules[module_name].__dict__:
|
||||||
vhs_module = sys.modules[module_name]
|
vhs_module = sys.modules[module_name]
|
||||||
break
|
break
|
||||||
|
|
||||||
if vhs_module is None:
|
if vhs_module is None:
|
||||||
# Try direct access to the videohelpersuite submodule
|
# Try direct access to the videohelpersuite submodule
|
||||||
for module_name in sys.modules:
|
for module_name in sys.modules:
|
||||||
if module_name.endswith('videohelpersuite'):
|
if module_name.endswith(vhs_pkg_name_suffix):
|
||||||
vhs_module = sys.modules[module_name]
|
vhs_module = sys.modules[module_name]
|
||||||
break
|
break
|
||||||
|
|
||||||
if vhs_module is not None:
|
if vhs_module is not None:
|
||||||
cls.vhs_nodes = vhs_module
|
cls.vhs_nodes = importlib.import_module(f"{vhs_module.__name__}.{vhs_submodule_name}")
|
||||||
else:
|
else:
|
||||||
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
|
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
|
||||||
|
|
||||||
@ -3960,16 +3965,26 @@ class LoadVideosFromFolder:
|
|||||||
FUNCTION = "load_video"
|
FUNCTION = "load_video"
|
||||||
|
|
||||||
def load_video(self, output_type, grid_max_columns, add_label=False, **kwargs):
|
def load_video(self, output_type, grid_max_columns, add_label=False, **kwargs):
|
||||||
|
VIDEO_EXTS = ['webm', 'mp4', 'mkv', 'gif', 'mov']
|
||||||
if self.vhs_nodes is None:
|
if self.vhs_nodes is None:
|
||||||
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
|
raise ImportError("This node requires ComfyUI-VideoHelperSuite to be installed.")
|
||||||
videos_list = []
|
root = kwargs['video']
|
||||||
filenames = []
|
pairs = []
|
||||||
for f in os.listdir(kwargs['video']):
|
for f in os.listdir(root):
|
||||||
if os.path.isfile(os.path.join(kwargs['video'], f)):
|
full = os.path.join(root, f)
|
||||||
file_parts = f.split('.')
|
# Skip non-files fast
|
||||||
if len(file_parts) > 1 and (file_parts[-1].lower() in ['webm', 'mp4', 'mkv', 'gif', 'mov']):
|
if not os.path.isfile(full):
|
||||||
videos_list.append(os.path.join(kwargs['video'], f))
|
continue
|
||||||
filenames.append(f)
|
# Check extension
|
||||||
|
ext = f.rsplit('.', 1)[-1].lower() if '.' in f else ''
|
||||||
|
if ext in VIDEO_EXTS:
|
||||||
|
pairs.append((full, f))
|
||||||
|
def _natural_key(s):
|
||||||
|
s = os.path.basename(s)
|
||||||
|
return [int(t) if t.isdigit() else t.lower() for t in re.split(r'(\d+)', s)]
|
||||||
|
pairs.sort(key=lambda x: _natural_key(x[1]))
|
||||||
|
videos_list = [p[0] for p in pairs]
|
||||||
|
filenames = [p[1] for p in pairs]
|
||||||
print(videos_list)
|
print(videos_list)
|
||||||
kwargs.pop('video')
|
kwargs.pop('video')
|
||||||
loaded_videos = []
|
loaded_videos = []
|
||||||
|
|||||||
@ -887,7 +887,7 @@ class TorchCompileModelAdvanced:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if compile_transformer_blocks_only:
|
if compile_transformer_blocks_only:
|
||||||
layer_types = ["double_blocks", "single_blocks", "layers", "transformer_blocks", "blocks"]
|
layer_types = ["double_blocks", "single_blocks", "layers", "transformer_blocks", "blocks", "visual_transformer_blocks", "text_transformer_blocks"]
|
||||||
compile_key_list = []
|
compile_key_list = []
|
||||||
for layer_name in layer_types:
|
for layer_name in layer_types:
|
||||||
if hasattr(diffusion_model, layer_name):
|
if hasattr(diffusion_model, layer_name):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user