Torch working

This commit is contained in:
KeshavAnandCode
2026-03-18 17:26:52 -05:00
parent 69e4f4a584
commit 64ed10e95c
2 changed files with 111 additions and 0 deletions

View File

@@ -51,6 +51,14 @@
" print(f\"{class_name}: {count} images\")"
]
},
{
"cell_type": "markdown",
"id": "64122ad4",
"metadata": {},
"source": [
"Check out sample image from dataset"
]
},
{
"cell_type": "code",
"execution_count": 3,
@@ -91,6 +99,80 @@
"plt.title(first_class)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "c19ec00a",
"metadata": {},
"source": [
"Ensure that all images are RGB, all of same resolution"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "3cedd586",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Unique sizes: {(64, 64)}\n",
"Unique modes: {'RGB'}\n"
]
}
],
"source": [
"sizes = set()\n",
"modes = set()\n",
"\n",
"for class_name in os.listdir(data_dir):\n",
" class_path = os.path.join(data_dir, class_name)\n",
" if not os.path.isdir(class_path):\n",
" continue\n",
" for img_name in os.listdir(class_path):\n",
" img = Image.open(os.path.join(class_path, img_name))\n",
" sizes.add(img.size)\n",
" modes.add(img.mode)\n",
"\n",
"print(f\"Unique sizes: {sizes}\")\n",
"print(f\"Unique modes: {modes}\")"
]
},
{
"cell_type": "markdown",
"id": "88ac961b",
"metadata": {},
"source": [
"Ensure that torch works with GPU (5080) [Credit: Claude]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "8f556b22",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"True\n",
"NVIDIA GeForce RTX 5080\n",
"GPU works! torch.Size([1000, 1000])\n"
]
}
],
"source": [
"import torch\n",
"print(torch.cuda.is_available()) \n",
"print(torch.cuda.get_device_name(0)) \n",
"\n",
"x = torch.randn(1000, 1000).cuda()\n",
"y = x @ x\n",
"print(\"GPU works!\", y.shape)"
]
}
],
"metadata": {