khoaliamle/Garbage_Classification_YOLO
Notice: train set include 80% of original dataset, test and val sets have 10%.
3551
1import os2 3def count_images_in_folders(base_path):4 """Counts the number of images in each class subdirectory under test, train, and val."""5 subsets = ['test', 'train', 'val']6 7 for subset in subsets:8 subset_path = os.path.join(base_path, subset)9 if not os.path.exists(subset_path):10 continue11 12 for class_name in os.listdir(subset_path):13 class_path = os.path.join(subset_path, class_name)14 if os.path.isdir(class_path):15 image_count = len([f for f in os.listdir(class_path) if f.endswith('.jpg')])16 print(f"Folder {subset}/{class_name} has {image_count} images")17 18# Define base path19base_directory = "classify"20 21# Run the function22count_images_in_folders(base_directory)23 