ACCC1380 commited on
Commit
0213340
1 Parent(s): 93221b3

Upload lora-scripts/sd-scripts/tools/show_metadata.py with huggingface_hub

Browse files
lora-scripts/sd-scripts/tools/show_metadata.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import argparse
3
+ from safetensors import safe_open
4
+ from library.utils import setup_logging
5
+ setup_logging()
6
+ import logging
7
+ logger = logging.getLogger(__name__)
8
+
9
+ parser = argparse.ArgumentParser()
10
+ parser.add_argument("--model", type=str, required=True)
11
+ args = parser.parse_args()
12
+
13
+ with safe_open(args.model, framework="pt") as f:
14
+ metadata = f.metadata()
15
+
16
+ if metadata is None:
17
+ logger.error("No metadata found")
18
+ else:
19
+ # metadata is json dict, but not pretty printed
20
+ # sort by key and pretty print
21
+ print(json.dumps(metadata, indent=4, sort_keys=True))
22
+
23
+