File size: 1,278 Bytes
7bf7aa7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
"""
Script to inspect the saved model structure
"""

import torch
import os

def inspect_model():
    """Inspect the structure of the saved model"""
    model_path = 'siamese_model.t7'
    
    if not os.path.exists(model_path):
        print(f"Model file {model_path} not found!")
        return
    
    try:
        # Load the model
        model_data = torch.load(model_path, map_location='cpu')
        
        print("Model file loaded successfully!")
        print(f"Type: {type(model_data)}")
        
        if isinstance(model_data, dict):
            print("\nDictionary keys:")
            for key in model_data.keys():
                print(f"  - {key}")
                
            if 'net_dict' in model_data:
                print(f"\n'net_dict' contains {len(model_data['net_dict'])} items:")
                for key in list(model_data['net_dict'].keys())[:10]:  # Show first 10 keys
                    print(f"  - {key}")
                if len(model_data['net_dict']) > 10:
                    print(f"  ... and {len(model_data['net_dict']) - 10} more keys")
        else:
            print("Model data is not a dictionary")
            
    except Exception as e:
        print(f"Error loading model: {e}")

if __name__ == "__main__":
    inspect_model()