Last active
May 15, 2023 17:23
-
-
Save takuma104/de3045680f9647209303695b0d959cb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import safetensors.torch | |
import sys | |
def dump_keys(parent, suffix=''): | |
for k in sorted(parent.keys()): | |
if isinstance(parent[k], torch.Tensor): | |
print(f'{suffix}{k} {list(parent[k].shape)}') | |
else: | |
dump_keys(parent[k], f'{suffix}{k}.') | |
if __name__ == '__main__': | |
fn = sys.argv[1] | |
if fn.endswith('.safetensors'): | |
checkpoint = safetensors.torch.load_file(fn) | |
else: | |
checkpoint = torch.load(fn) | |
dump_keys(checkpoint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment