-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_models.py
More file actions
39 lines (34 loc) · 1.32 KB
/
verify_models.py
File metadata and controls
39 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Proprietary / All Rights Reserved - Non-Commercial Use Only
Source-available for portfolio viewing only. Commercial use, unauthorized modification, reproduction, or distribution is strictly prohibited. All rights reserved.
"""
import glob
import os
import torch
from utils_v3_0 import setup_logging
logger = setup_logging(__name__)
def check_model(filename):
logger.info(f"Checking {filename}...")
if not os.path.exists(filename):
logger.info(f"File {filename} not found.")
return
try:
checkpoint = torch.load(filename, map_location="cpu", weights_only=False)
logger.info(f"Loaded {filename}")
if "model" in checkpoint:
logger.info(f" state_dict keys: {len(checkpoint['model'])}")
else:
logger.warning(" Missing 'model' key")
if "config" in checkpoint:
logger.info(f" config: {checkpoint['config']}")
if "step" in checkpoint:
logger.info(f" step: {checkpoint['step']}")
except Exception as e:
logger.error(f"Failed to load {filename}: {e}")
if __name__ == "__main__":
logger.info("--- Verifying Saved Models ---")
files = glob.glob("checkpoint_step_*.pt") + glob.glob("best_model.pt")
if not files:
logger.info("No models found.")
for f in sorted(files):
check_model(f)