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

path = r"C:\Users\Acer\Documents\myproject\medical imaging\medical imaging\best_student_cv.pt"
print(f"File size: {os.path.getsize(path) / (1024*1024):.2f} MB")

try:
    ckpt = torch.load(path, map_location='cpu')
    if isinstance(ckpt, dict):
        print("Checkpoint is dict with keys:", list(ckpt.keys())[:10])
        if 'model_state_dict' in ckpt:
            print("Found model_state_dict with layers:", len(ckpt['model_state_dict']))
        elif 'state_dict' in ckpt:
            print("Found state_dict with layers:", len(ckpt['state_dict']))
        else:
            print("Direct state_dict keys count:", len(ckpt))
            first_keys = list(ckpt.keys())[:5]
            print("Sample keys:", first_keys)
    else:
        print("Checkpoint type:", type(ckpt))
except Exception as e:
    print("Error loading checkpoint:", e)