File size: 988 Bytes
f177f7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pickle

# Define the path to your pickle file
file_path = 'class_indices.pkl'

try:
    # Open the file in binary read mode ('rb')
    with open(file_path, 'rb') as f:
        # Load the data from the file
        class_indices = pickle.load(f)
        
        # The number of classes is the length of the dictionary/list
        num_classes = len(class_indices)
        
        print(f"✅ Found {num_classes} classes in '{file_path}'.")
        
        # Optional: Print the first 5 class mappings to see what they look like
        if isinstance(class_indices, dict):
            print("\nHere are a few examples:")
            for i, (class_name, index) in enumerate(class_indices.items()):
                if i >= 5:
                    break
                print(f"  - '{class_name}': {index}")

except FileNotFoundError:
    print(f"❌ Error: The file '{file_path}' was not found.")
except Exception as e:
    print(f"An error occurred: {e}")