Skip to content

Commit

Permalink
Add documentation to safetensors_object.py
Browse files Browse the repository at this point in the history
Examples of how it's used and the data it returns.
  • Loading branch information
duanemoody authored Dec 4, 2023
1 parent 384c7df commit 097ab7b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions safetensors_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
from safetensors_file import SafeTensorsFile
from safetensors_worker import _ParseMore

"""
$ 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
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
Error: File header does not contain a `__metadata__` item
$ python3 safetensors_m.py ss_tag_frequency /path/to/file/trina.safetensors
{
"6_trina": {
"trina": 26,
" black hair": 20,
" hands on hips": 1,
" looking at viewer": 7
}
}
"""

def get_object(tensorsfile: str) -> str:
s = SafeTensorsFile.open_file(tensorsfile, quiet=True)
js = s.get_header()
Expand Down

0 comments on commit 097ab7b

Please sign in to comment.