diff --git a/docs/examples/notebooks/decoder_examples.ipynb b/docs/examples/notebooks/decoder_examples.ipynb index 30be5a7c8..b452528a2 100644 --- a/docs/examples/notebooks/decoder_examples.ipynb +++ b/docs/examples/notebooks/decoder_examples.ipynb @@ -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", @@ -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", @@ -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" ] }, { @@ -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" ] }, { @@ -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" ] }, { @@ -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\")" ] @@ -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\")" ]