fixed: torch_wrapper – When weights_only is explicitly provided, pass the arg as is.

This commit is contained in:
Dr.Lt.Data
2025-01-04 10:08:34 +09:00
parent 769bc0f14a
commit 0f5d67e60d
3 changed files with 17 additions and 4 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
import importlib
import logging
version_code = [1, 2, 6]
version_code = [1, 2, 7]
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})")
+15 -2
View File
@@ -137,11 +137,24 @@ 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):
# 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:
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:
logging.warning("[Impact Subpack] Your torch version is outdated, and security features cannot be applied properly.")
kwargs['weights_only'] = False
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
+1 -1
View File
@@ -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.6"
version = "1.2.7"
license = { file = "LICENSE.txt" }
dependencies = ["matplotlib", "ultralytics==8.3.40"]