You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a3e5cce
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: comfy/utils.py
+43-7Lines changed: 43 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -82,33 +82,69 @@ def encode(*args, **kwargs): # no longer necessary on newer torch
82
82
"U16": torch.uint16,
83
83
}
84
84
85
+
_SAFETENSORS_MAX_HEADER_SIZE=100_000_000
86
+
87
+
88
+
def_invalid_safetensors_error(message, ckpt):
89
+
returnValueError("{}\n\nFile path: {}\n\nThe safetensors file is corrupt or invalid. Make sure this is actually a safetensors file and not a ckpt or pt or other filetype.".format(message, ckpt))
90
+
91
+
92
+
def_incomplete_safetensors_error(message, ckpt):
93
+
returnValueError("{}\n\nFile path: {}\n\nThe safetensors file is corrupt/incomplete. Check the file size and make sure you have copied/downloaded it correctly.".format(message, ckpt))
94
+
95
+
85
96
defload_safetensors(ckpt):
86
97
importcomfy_aimdo.model_mmap
87
98
99
+
file_size=os.path.getsize(ckpt)
100
+
iffile_size<8:
101
+
raise_incomplete_safetensors_error("The safetensors header is incomplete.", ckpt)
raiseValueError("{}\n\nFile path: {}\n\nThe safetensors file is corrupt or invalid. Make sure this is actually a safetensors file and not a ckpt or pt or other filetype.".format(message, ckpt))
182
+
raise_invalid_safetensors_error(message, ckpt)
147
183
if"MetadataIncompleteBuffer"inmessage:
148
-
raiseValueError("{}\n\nFile path: {}\n\nThe safetensors file is corrupt/incomplete. Check the file size and make sure you have copied/downloaded it correctly.".format(message, ckpt))
0 commit comments