Skip to content

Commit

Permalink
Add direct handling of embedding files
Browse files Browse the repository at this point in the history
Specific error for textual inversion/embedding files
  • Loading branch information
duanemoody authored Dec 11, 2023
1 parent 097ab7b commit 23e494a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions safetensors_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
$ python3 safetensors_m.py ss_network_module /path/to/file/summer_dress.safetensors
"networks.lora"
$ python3 safetensors_m.py nonexistent_module /path/to/file/summer_dress.safetensors
$ python3 safetensors_object.py nonexistent_module /path/to/file/summer_dress.safetensors
Error: Metadata does not contain a `nonexistent_module` item, did you spell it right?
$ python3 safetensors_m.py ss_network_module /path/to/file/weird_file.safetensors
$ python3 safetensors_object.py ss_network_module /path/to/file/Joanne.safetensors
Error: File is embedding/textual inversion, not a LoRA/Lycoris training set
$ python3 safetensors_object.py ss_network_module /path/to/file/weird_file.safetensors
Error: File header does not contain a `__metadata__` item
$ python3 safetensors_m.py ss_tag_frequency /path/to/file/trina.safetensors
Expand All @@ -29,6 +32,8 @@ def get_object(tensorsfile: str) -> str:
js = s.get_header()
s.close_file()

if "emp_params" in js:
return "Error: File is embedding/textual inversion, not a LoRA/Lycoris training set"
if "__metadata__" not in js:
return "Error: File header does not contain a `__metadata__` item"
md = js["__metadata__"]
Expand Down

0 comments on commit 23e494a

Please sign in to comment.