Remove unsafe embedding load for very old pytorch.

This commit is contained in:
comfyanonymous 2025-01-15 04:32:23 -05:00
parent 2feb8d0b77
commit cba58fff0b

View File

@ -388,13 +388,10 @@ def load_embed(embedding_name, embedding_directory, embedding_size, embed_key=No
import safetensors.torch import safetensors.torch
embed = safetensors.torch.load_file(embed_path, device="cpu") embed = safetensors.torch.load_file(embed_path, device="cpu")
else: else:
if 'weights_only' in torch.load.__code__.co_varnames:
try: try:
embed = torch.load(embed_path, weights_only=True, map_location="cpu") embed = torch.load(embed_path, weights_only=True, map_location="cpu")
except: except:
embed_out = safe_load_embed_zip(embed_path) embed_out = safe_load_embed_zip(embed_path)
else:
embed = torch.load(embed_path, map_location="cpu")
except Exception: except Exception:
logging.warning("{}\n\nerror loading embedding, skipping loading: {}".format(traceback.format_exc(), embedding_name)) logging.warning("{}\n\nerror loading embedding, skipping loading: {}".format(traceback.format_exc(), embedding_name))
return None return None