{"id":16538480,"url":"https://github.com/mujadded/pytorch_trainer","last_synced_at":"2026-05-08T22:01:49.384Z","repository":{"id":209050428,"uuid":"723080399","full_name":"Mujadded/pytorch_trainer","owner":"Mujadded","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-15T11:23:26.000Z","size":94,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-14T06:15:28.963Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mujadded.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-24T16:25:55.000Z","updated_at":"2023-11-24T17:54:04.000Z","dependencies_parsed_at":"2024-11-19T21:31:26.330Z","dependency_job_id":null,"html_url":"https://github.com/Mujadded/pytorch_trainer","commit_stats":null,"previous_names":["mujadded/pytorch_trainer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mujadded%2Fpytorch_trainer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mujadded%2Fpytorch_trainer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mujadded%2Fpytorch_trainer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mujadded%2Fpytorch_trainer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mujadded","download_url":"https://codeload.github.com/Mujadded/pytorch_trainer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241763754,"owners_count":20016162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T18:45:46.087Z","updated_at":"2025-11-30T23:05:07.026Z","avatar_url":"https://github.com/Mujadded.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README\n\n## Data Loading and Transformation Utilities\n\nThis set of Python functions provides utility functions for loading image datasets, creating PyTorch dataloaders, and visualizing transformations.\n\n### Requirements\n\n- Python 3.6 or later\n- PyTorch\n- Matplotlib\n- Pillow (PIL)\n\n### Installation\n\nNo installation is required, as these are utility functions that can be directly imported and used in your PyTorch projects.\n\n### Usage\n\n#### 1. Walk Through Data Folder\n\n```python\nwalk_through_datafolder(data_path: str)\n```\n\nThis function walks through the specified data folder and prints the number of directories and images in each subdirectory.\n\n#### 2. Create Dataloaders\n\n```python\ntrain_dataloader, valid_dataloader, test_dataloader, class_names = create_dataloaders(\n    train_dir: str,\n    valid_dir: str,\n    test_dir: str,\n    train_transforms: transforms.Compose,\n    test_transforms: transforms.Compose,\n    batch_size: int,\n    num_workers: int = NUM_WORKERS\n)\n```\n\nThis function creates training, validation, and testing dataloaders using PyTorch's `ImageFolder` dataset. It returns a tuple containing the training, validation, and testing dataloaders, along with the class names.\n\n#### 3. Plot Transformed Images\n\n```python\nplot_transformed_images(image_paths: str, transform: transforms.Compose, n: int = 3, seed: int = 42)\n```\n\nThis function plots a series of random images from the specified image paths. It applies the specified transformations and plots the original and transformed images side by side.\n\n#### 4. Plot Random Images from Dataloader\n\n```python\nplot_random_images_from_dataloader(dataloader: DataLoader, class_names: list)\n```\n\nThis function plots a batch of images from the given dataloader, along with their corresponding class names.\n\n### Examples\n\n#### Example 1: Creating Dataloaders\n\n```python\ntrain_dataloader, valid_dataloader, test_dataloader, class_names = create_dataloaders(\n    train_dir='path/to/train_data',\n    valid_dir='path/to/valid_data',\n    test_dir='path/to/test_data',\n    train_transforms=train_transform,\n    test_transforms=test_transform,\n    batch_size=32,\n    num_workers=4\n)\n```\n\n#### Example 2: Plotting Transformed Images\n\n```python\nplot_transformed_images(image_paths=['path/to/image1.jpg', 'path/to/image2.jpg'],\n                        transform=train_transform,\n                        n=2,\n                        seed=42)\n```\n\n#### Example 3: Plotting Random Images from Dataloader\n\n```python\nplot_random_images_from_dataloader(dataloader=train_dataloader, class_names=class_names)\n```\n\n### License\n\nThis code is provided under the MIT License. Feel free to use and modify as needed. Contributions are welcome!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmujadded%2Fpytorch_trainer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmujadded%2Fpytorch_trainer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmujadded%2Fpytorch_trainer/lists"}