Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions docs/examples/notebooks/decoder_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from amd.rocal.pipeline import pipeline_def\n",
"from amd.rocal.plugin.generic import ROCALClassificationIterator\n",
"import amd.rocal.fn as fn\n",
Expand All @@ -37,11 +38,11 @@
"%matplotlib inline\n",
"\n",
"seed = 1549361629\n",
"image_dir = \"../../../data/images/AMD-tinyDataSet/\"\n",
"image_dir = f\"{os.environ.get('ROCM_PATH', '/opt/rocm')}/share/rocal/test/data/images/AMD-tinyDataSet/\"\n",
"batch_size = 4\n",
"gpu_id = 0\n",
"\n",
"def show_images(image_batch, device):\n",
"def show_images(image_batch):\n",
" columns = 4\n",
" rows = (batch_size + 1) // (columns)\n",
" fig = plt.figure(figsize = (32,(32 // columns) * rows))\n",
Expand All @@ -50,17 +51,14 @@
" plt.subplot(gs[j])\n",
" img = image_batch[j]\n",
" plt.axis(\"off\")\n",
" if device == \"cpu\":\n",
" plt.imshow(img)\n",
" else:\n",
" plt.imshow(cp.asnumpy(img))\n",
" plt.imshow(img)\n",
"\n",
"\n",
"def show_pipeline_output(pipe, device, device_id=0):\n",
" pipe.build()\n",
" data_loader = ROCALClassificationIterator(pipe, device, device_id)\n",
" images = next(iter(data_loader))\n",
" show_images(images[0][0], device)\n"
" show_images(images[0][0])\n"
]
},
{
Expand All @@ -70,7 +68,7 @@
"source": [
"## Image Decoder (CPU)\n",
"\n",
"`decoders.image` decodes images stored in common formats (including JPEG, JPEG2000, TIFF, PNG)"
"`decoders.image` decodes images stored in JPEG format"
]
},
{
Expand Down Expand Up @@ -130,7 +128,7 @@
"\n",
"`decoders.image` with GPU backend uses rocJpeg to offload the JPEG decoding process to the GPU’s built-in hardware decoder, if supported\n",
"\n",
"Note, that we repeat the examples shown above, changing only the device parameter. Both the operator and its other parameters stay the same and offer the same functionality - but now we use GPU acceleration.\n"
"Note, that we repeat the examples shown above, changing only the device and rocal_cpu parameters. Both the operator and its other parameters stay the same and offer the same functionality - but now we use GPU acceleration.\n"
]
},
{
Expand All @@ -139,7 +137,7 @@
"metadata": {},
"outputs": [],
"source": [
"pipe = image_decoder_pipeline(batch_size=batch_size, num_threads=1, device_id=gpu_id, rocal_cpu=True, tensor_layout=types.NHWC, \n",
"pipe = image_decoder_pipeline(batch_size=batch_size, num_threads=1, device_id=gpu_id, rocal_cpu=False, tensor_layout=types.NHWC, \n",
" reverse_channels=True, mean=[0,0,0], std = [255,255,255], device=\"gpu\")\n",
"show_pipeline_output(pipe, device=\"gpu\")"
]
Expand All @@ -162,7 +160,7 @@
"metadata": {},
"outputs": [],
"source": [
"pipe = image_decoder_random_crop_pipeline(batch_size=batch_size, num_threads=1, device_id=gpu_id, rocal_cpu=True, tensor_layout=types.NHWC, reverse_channels=True, \n",
"pipe = image_decoder_random_crop_pipeline(batch_size=batch_size, num_threads=1, device_id=gpu_id, rocal_cpu=False, tensor_layout=types.NHWC, reverse_channels=True, \n",
" mean=[0,0,0], std = [255,255,255], device=\"gpu\")\n",
"show_pipeline_output(pipe, device=\"gpu\")"
]
Expand Down