Spaces:
Sleeping

File size: 659 Bytes
98d701b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import torch

# Load the fat checkpoint
ckpt = torch.load("best_model.pt", map_location="cpu")

print("Keys in checkpoint:", list(ckpt.keys()))
for k, v in ckpt.items():
    try:
        size = sum(p.numel() for p in v.values()) * 4 / 1e6 if isinstance(v, dict) else "scalar"
        print(f"  {k}: {size} MB" if size != "scalar" else f"  {k}: {v}")
    except Exception:
        print(f"  {k}: (unknown)")

# Keep ONLY what app.py needs
slim = {
    "mapping_network_state_dict": ckpt["mapping_network_state_dict"],
    "epoch": ckpt.get("epoch"),
    "val_loss": ckpt.get("val_loss"),
}

torch.save(slim, "best_model_slim.pt")
print("Saved slim checkpoint")