Compare commits

...

3 Commits

Author SHA1 Message Date
CFionaF
8d4157e8b0
Merge 0878ec8e5f into b08debceca 2026-07-06 17:34:00 +08:00
CFionaBF
0878ec8e5f Allowlist dataset conditioning hook classes for safe loading
Datasets built with CLIP hooks store comfy.hooks objects in conditioning;
register them as safe globals so they still load with weights_only=True.
2026-06-14 01:37:33 -04:00
CFionaBF
1b877e583f Load training dataset tensors with weights_only 2026-06-07 11:20:20 -04:00

View File

@ -10,6 +10,30 @@ from typing_extensions import override
import folder_paths
import node_helpers
from comfy_api.latest import ComfyExtension, io
import comfy.hooks
# Datasets produced by MakeTrainingDataset can embed comfy.hooks objects in their
# conditioning (clip.encode_from_tokens_scheduled stores a HookGroup under "hooks"
# when the CLIP has hooks applied). LoadTrainingDataset loads shards with
# weights_only=True, so register these known classes as safe globals; otherwise such
# datasets fail to load. Only data-bearing hooks (e.g. WeightHook) round-trip this way.
torch.serialization.add_safe_globals([
comfy.hooks.HookGroup,
comfy.hooks.Hook,
comfy.hooks.WeightHook,
comfy.hooks.ObjectPatchHook,
comfy.hooks.AdditionalModelsHook,
comfy.hooks.TransformerOptionsHook,
comfy.hooks.InjectionsHook,
comfy.hooks._HookRef,
comfy.hooks.HookKeyframe,
comfy.hooks.HookKeyframeGroup,
comfy.hooks.EnumHookMode,
comfy.hooks.EnumHookType,
comfy.hooks.EnumWeightTarget,
comfy.hooks.EnumHookScope,
comfy.hooks.default_should_register,
])
def load_and_process_images(image_files, input_dir):