Row 8355

Row ID: 8355 | Dataset Entry | Axioma AXP Content Repository

Content Data

This page contains data entry 8355 from the Axioma AXP content repository. The structured data below represents the complete record for this entry.

*Sorry for my late response*

Here is how we can do it:

import tensorflow as tf images1_path = '/kaggle/input/sysucd/train/time1/*.png' images2_path = '/kaggle/input/sysucd/train/time2/*.png' masks_path = '/kaggle/input/sysucd/train/label/*.png' image1_files = tf.data.Dataset.list_files(images1_path, shuffle=False) image2_files = tf.data.Dataset.list_files(images2_path, shuffle=False) mask_files = tf.data.Dataset.list_files(masks_path, shuffle=False) def load_image(image_file): image = tf.io.read_file(image_file) image = tf.image.decode_jpeg(image, channels=3) image = tf.image.convert_image_dtype(image, tf.float32) return image def load_mask(mask_file): mask = tf.io.read_file(mask_file) mask = tf.image.decode_jpeg(mask, channels=1) mask = tf.image.convert_image_dtype(mask, tf.float32) return mask images1 = image1_files.map(load_image) images2 = image2_files.map(load_image) masks = mask_files.map(load_mask) dataset = tf.data.Dataset.zip((images1, images2, masks)) import matplotlib.pyplot as plt for image1, image2, mask in dataset.take(2): plt.figure(figsize=(10, 5)) plt.subplot(1, 3, 1) plt.title("Image 1") plt.imshow(image1) plt.axis('off') plt.subplot(1, 3, 2) plt.title("Image 2") plt.imshow(image2) plt.axis('off') plt.subplot(1, 3, 3) plt.title("Mask") plt.imshow(mask[:, :, 0], cmap='gray') plt.axis('off') plt.show()

Here is the kaggle notebook: [https://www.kaggle.com/code/maifeeulasad/tensorflow-memefficient-complex-dataset/notebook](https://www.kaggle.com/code/maifeeulasad/tensorflow-memefficient-complex-dataset/notebook)

If you have any issues understanding, please let me know. I would be happy to help.

At the end of the notebook, you will find I have posted another approach, that may prove itself super helpful based on what you are trying to do, afaik.

FieldValue
text *Sorry for my late response* Here is how we can do it: import tensorflow as tf images1_path = '/kaggle/input/sysucd/train/time1/*.png' images2_path = '/kaggle/input/sysucd/train/time2/*.png' masks_path = '/kaggle/input/sysucd/train/label/*.png' image1_files = tf.data.Dataset.list_files(images1_path, shuffle=False) image2_files = tf.data.Dataset.list_files(images2_path, shuffle=False) mask_files = tf.data.Dataset.list_files(masks_path, shuffle=False) …
label r/tensorflow
dataType comment
communityName r/tensorflow
datetime 2024-05-19
username_encoded Z0FBQUFBQm5Lakw0SHF0R2F6b0VYQW1UZUdVdnRmeGdxT2tPSWtkcGtOTml2NWQyNjU1TmxDOTNWS2tkazViVjdMcFdyMGNabXNEWEd0dTRPcDFHSHBtUGFUU2NWX3N1MFE9PQ==
url_encoded Z0FBQUFBQm5Lak9IbllPSlgxak9oNlI0WnhBNGtuQ1JhbHdxbG5lNV9CcjZwRmk0Ukl4YUlBSFc3d2lIVjdEdjc2T3R4aFQ0OTRHMTRtaW03WXhpcktQY0YwREo3RWcxb21NQVBCb0xNQlZ2Y1IxU2VPWmtRRzdUTlMxY0ZlTDU1ZmxfSGJzb3lPOGZ4Ymw2U2l4Q0V5SE5GY2FGUUViS091Y2U3d0g1TDFOOFVHOWVZaHJfdFhyVDlzN0ZtcXlodWpWLW5ybFZ1b1FrQ0pDd1EteERHY2h3TGZpdVdSbm9UUT09

Raw Record

{
  "text": "*Sorry for my late response*\n\nHere is how we can do it:\n\n    import tensorflow as tf\n    \n    images1_path = '/kaggle/input/sysucd/train/time1/*.png'\n    images2_path = '/kaggle/input/sysucd/train/time2/*.png'\n    masks_path = '/kaggle/input/sysucd/train/label/*.png'\n    \n    image1_files = tf.data.Dataset.list_files(images1_path, shuffle=False)\n    image2_files = tf.data.Dataset.list_files(images2_path, shuffle=False)\n    mask_files = tf.data.Dataset.list_files(masks_path, shuffle=False)\n    \n    def load_image(image_file):\n        image = tf.io.read_file(image_file)\n        image = tf.image.decode_jpeg(image, channels=3)\n        image = tf.image.convert_image_dtype(image, tf.float32)\n        return image\n    \n    def load_mask(mask_file):\n        mask = tf.io.read_file(mask_file)\n        mask = tf.image.decode_jpeg(mask, channels=1)\n        mask = tf.image.convert_image_dtype(mask, tf.float32)\n        return mask\n    \n    images1 = image1_files.map(load_image)\n    images2 = image2_files.map(load_image)\n    masks = mask_files.map(load_mask)\n    \n    dataset = tf.data.Dataset.zip((images1, images2, masks))\n    \n    import matplotlib.pyplot as plt\n    \n    for image1, image2, mask in dataset.take(2):\n        plt.figure(figsize=(10, 5))\n    \n        plt.subplot(1, 3, 1)\n        plt.title(\"Image 1\")\n        plt.imshow(image1)\n        plt.axis('off')\n    \n        plt.subplot(1, 3, 2)\n        plt.title(\"Image 2\")\n        plt.imshow(image2)\n        plt.axis('off')\n    \n        plt.subplot(1, 3, 3)\n        plt.title(\"Mask\")\n        plt.imshow(mask[:, :, 0], cmap='gray')\n        plt.axis('off')\n    \n        plt.show()\n\nHere is the kaggle notebook: [https://www.kaggle.com/code/maifeeulasad/tensorflow-memefficient-complex-dataset/notebook](https://www.kaggle.com/code/maifeeulasad/tensorflow-memefficient-complex-dataset/notebook)\n\nIf you have any issues understanding, please let me know. I would be happy to help.\n\nAt the end of the notebook, you will find I have posted another approach, that may prove itself super helpful based on what you are trying to do, afaik.",
  "label": "r/tensorflow",
  "dataType": "comment",
  "communityName": "r/tensorflow",
  "datetime": "2024-05-19",
  "username_encoded": "Z0FBQUFBQm5Lakw0SHF0R2F6b0VYQW1UZUdVdnRmeGdxT2tPSWtkcGtOTml2NWQyNjU1TmxDOTNWS2tkazViVjdMcFdyMGNabXNEWEd0dTRPcDFHSHBtUGFUU2NWX3N1MFE9PQ==",
  "url_encoded": "Z0FBQUFBQm5Lak9IbllPSlgxak9oNlI0WnhBNGtuQ1JhbHdxbG5lNV9CcjZwRmk0Ukl4YUlBSFc3d2lIVjdEdjc2T3R4aFQ0OTRHMTRtaW03WXhpcktQY0YwREo3RWcxb21NQVBCb0xNQlZ2Y1IxU2VPWmtRRzdUTlMxY0ZlTDU1ZmxfSGJzb3lPOGZ4Ymw2U2l4Q0V5SE5GY2FGUUViS091Y2U3d0g1TDFOOFVHOWVZaHJfdFhyVDlzN0ZtcXlodWpWLW5ybFZ1b1FrQ0pDd1EteERHY2h3TGZpdVdSbm9UUT09"
}

Entry Information