>>102089793
Not that hard to add safetensors support. Go to the custom node and open up longclip.py. Add in an import line for safetensors
from safetensors.torch import load_file
and then replace what used to be line 68 or now line 69 after the above change with the following block.
if any(model_path.endswith(x) for x in [".ckpt", ".pt", ".bin", ".pth"]):
state_dict = torch.load(model_path, map_location="cpu", weights_only=True)
else:
state_dict = load_file(model_path)
Easy peasy. For those who know how to use this, this is the git diff.
diff --git a/long_clip_model/longclip.py b/long_clip_model/longclip.py
index ad8e888..96ece57 100644
--- a/long_clip_model/longclip.py
+++ b/long_clip_model/longclip.py
@@ -7,6 +7,7 @@ from pkg_resources import packaging
from torch import nn
import torch
from PIL import Image
+from safetensors.torch import load_file
from torchvision.transforms import Compose, Resize, CenterCrop, ToTensor, Normalize
from tqdm import tqdm
@@ -65,7 +66,10 @@ def load(name: str, device: Union[str, torch.device] = "cuda" if torch.cuda.is_a
model_path = name
- state_dict = torch.load(model_path, map_location="cpu")
+ if any(model_path.endswith(x) for x in [".ckpt", ".pt", ".bin", ".pth"]):
+ state_dict = torch.load(model_path, map_location="cpu", weights_only=True)
+ else:
+ state_dict = load_file(model_path)
model = build_model(state_dict or model.state_dict(), load_from_clip = False).to(device)