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

def count_images_in_folders(base_path):
    """Counts the number of images in each class subdirectory under test, train, and val."""
    subsets = ['test', 'train', 'val']
    
    for subset in subsets:
        subset_path = os.path.join(base_path, subset)
        if not os.path.exists(subset_path):
            continue
        
        for class_name in os.listdir(subset_path):
            class_path = os.path.join(subset_path, class_name)
            if os.path.isdir(class_path):
                image_count = len([f for f in os.listdir(class_path) if f.endswith('.jpg')])
                print(f"Folder {subset}/{class_name} has {image_count} images")

# Define base path
base_directory = "classify"

# Run the function
count_images_in_folders(base_directory)