Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Individual tensor metadata object query tool
``` $ 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 } } ``` This is a proof of concept utility for retrieving the value of a named object inside `__metadata__` from a safetensors file, with the intention of eventually moving the code into `safetensors_util.py` as its own separate `cli.command()` block. I wrote this because so far I haven't seen any other utilities for retrieving these values from safetensors files, e.g. checking `ss_network_module` to tell whether a file is LoRA (`networks.lora`) or Lycoris (`lycoris.kohya`) before trying to install it into a potentially incompatible SD client, or just debugging troublesome safetensors files without having to dump/parse the entire metadata block. Applies `_ParseMore()` to all output for readability's sake but this could be optionally disabled.
- Loading branch information