mirror of
https://github.com/mrdbourke/pytorch-deep-learning.git
synced 2026-11-27 06:07:09 +00:00
update pytorch custom dataset code
This commit is contained in:
1 parent
369d80b11c
commit
53e092fa0c
1 file changed
+57
-2
@@ -1218,10 +1218,65 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 85,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
"source": [
|
||||
"import os\n",
|
||||
"def walk_through_dir(dir_path):\n",
|
||||
" \"\"\"\n",
|
||||
" Walks through dir_path returning its contents.\n",
|
||||
" Args:\n",
|
||||
" dir_path (str): target directory\n",
|
||||
" \n",
|
||||
" Returns:\n",
|
||||
" A print out of:\n",
|
||||
" number of subdiretories in dir_path\n",
|
||||
" number of images (files) in each subdirectory\n",
|
||||
" name of each subdirectory\n",
|
||||
" \"\"\"\n",
|
||||
" for dirpath, dirnames, filenames in os.walk(dir_path):\n",
|
||||
" print(f\"There are {len(dirnames)} directories and {len(filenames)} images in '{dirpath}'.\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 86,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"There are 2 directories and 1 images in '10_whole_foods'.\n",
|
||||
"There are 10 directories and 0 images in '10_whole_foods/test'.\n",
|
||||
"There are 0 directories and 17 images in '10_whole_foods/test/carrots'.\n",
|
||||
"There are 0 directories and 11 images in '10_whole_foods/test/mushrooms'.\n",
|
||||
"There are 0 directories and 17 images in '10_whole_foods/test/apple'.\n",
|
||||
"There are 0 directories and 10 images in '10_whole_foods/test/strawberries'.\n",
|
||||
"There are 0 directories and 19 images in '10_whole_foods/test/blueberries'.\n",
|
||||
"There are 0 directories and 20 images in '10_whole_foods/test/banana'.\n",
|
||||
"There are 0 directories and 21 images in '10_whole_foods/test/beef'.\n",
|
||||
"There are 0 directories and 15 images in '10_whole_foods/test/egg'.\n",
|
||||
"There are 0 directories and 19 images in '10_whole_foods/test/honey'.\n",
|
||||
"There are 0 directories and 15 images in '10_whole_foods/test/chicken_wings'.\n",
|
||||
"There are 10 directories and 0 images in '10_whole_foods/train'.\n",
|
||||
"There are 0 directories and 70 images in '10_whole_foods/train/carrots'.\n",
|
||||
"There are 0 directories and 66 images in '10_whole_foods/train/mushrooms'.\n",
|
||||
"There are 0 directories and 57 images in '10_whole_foods/train/apple'.\n",
|
||||
"There are 0 directories and 64 images in '10_whole_foods/train/strawberries'.\n",
|
||||
"There are 0 directories and 59 images in '10_whole_foods/train/blueberries'.\n",
|
||||
"There are 0 directories and 58 images in '10_whole_foods/train/banana'.\n",
|
||||
"There are 0 directories and 74 images in '10_whole_foods/train/beef'.\n",
|
||||
"There are 0 directories and 65 images in '10_whole_foods/train/egg'.\n",
|
||||
"There are 0 directories and 63 images in '10_whole_foods/train/honey'.\n",
|
||||
"There are 0 directories and 78 images in '10_whole_foods/train/chicken_wings'.\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"walk_through_dir(\"10_whole_foods\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
||||
Reference in new issue
Block a user