diff --git a/helper_functions.py b/helper_functions.py index 6d7745d..ca2de3d 100644 --- a/helper_functions.py +++ b/helper_functions.py @@ -16,6 +16,24 @@ from pathlib import Path import requests +# Walk through an image classification directory and find out how many files (images) +# are in each subdirectory. +import os + +def walk_through_dir(dir_path): + """ + Walks through dir_path returning its contents. + Args: + dir_path (str): target directory + + Returns: + A print out of: + number of subdiretories in dir_path + number of images (files) in each subdirectory + name of each subdirectory + """ + for dirpath, dirnames, filenames in os.walk(dir_path): + print(f"There are {len(dirnames)} directories and {len(filenames)} images in '{dirpath}'.") def plot_decision_boundary(model: torch.nn.Module, X: torch.Tensor, y: torch.Tensor): """Plots decision boundaries of model predicting on X in comparison to y. @@ -273,4 +291,4 @@ def download_data(source: str, if remove_source: os.remove(data_path / target_file) - return image_path \ No newline at end of file + return image_path