{
  "id": 406932,
  "title": "Quick Question",
  "url": "/competitions/gan-getting-started/discussion/406932",
  "author_name": "",
  "post_date": "2023-05-04T12:35:28.347919500Z",
  "votes": 1,
  "comment_count": 1,
  "views": 0,
  "content": "<p>How do I organize the files as input and output? The real images and the monet paintings are not in order, and I was wondering how I could fix this? Is it filenames, the way I load the data, please let me know.</p>",
  "messages": [
    {
      "id": "2245529",
      "postDate": "05/04/2023 12:35:28",
      "content": "<p>How do I organize the files as input and output? The real images and the monet paintings are not in order, and I was wondering how I could fix this? Is it filenames, the way I load the data, please let me know.</p>",
      "rawMarkdown": "How do I organize the files as input and output? The real images and the monet paintings are not in order, and I was wondering how I could fix this? Is it filenames, the way I load the data, please let me know.",
      "votes": null
    },
    {
      "id": "2247429",
      "postDate": "05/06/2023 02:04:37",
      "content": "<p>Usually, GANs use unpaired data unless you're using a conditional GAN like pix2pix. So, just creating iterable datasets would be enough. No need for sorting or arranging the images. </p>\n<p>Nonetheless, you just need to sort the files, assuming they are named correctly.</p>\n<p>Here is some boiler-plate pytorch code to help you out:</p>\n<pre><code> ():\n     ():\n        \n        self.files_A = (os.listdir(root+))\n        self.files_B = (os.listdir(root+))\n        \n\n      ():\n         \n        image_A = Image.(self.files_A[id_x])\n        image_B = Image.(self.files_B[id_x])\n\n         {:item_A, :item_B}\n\n     ():\n         ((self.files_A), (self.files_B))\n</code></pre>\n<p>Hope it helps</p>",
      "rawMarkdown": "Usually, GANs use unpaired data unless you're using a conditional GAN like pix2pix. So, just creating iterable datasets would be enough. No need for sorting or arranging the images. \n\nNonetheless, you just need to sort the files, assuming they are named correctly.\n\nHere is some boiler-plate pytorch code to help you out:\n\n```python\nclass ImageDataset(Dataset):\n    def __init__(self, root):\n        '''\n              Do other settings here ...\n        '''\n        self.files_A = sorted(os.listdir(root+\" path to your files\"))\n        self.files_B = sorted(os.listdir(root+\"path to your files\"))\n        # Sorting will ensure that the same index has similarly named files\n\n    def  __getitem__(self, id_x):\n         '''\n              Apply transforms and mode-based formatting(train/test) here ...\n        '''\n        image_A = Image.open(self.files_A[id_x])\n        image_B = Image.open(self.files_B[id_x])\n    \n        return {'A':item_A, 'B':item_B}\n    \n    def __len__(self):\n        return max(len(self.files_A), len(self.files_B))\n```\n\nHope it helps",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2247429,
      "author_name": "aryangarg01",
      "author_url": "",
      "post_date": "05/06/2023 02:04:37",
      "content": "<p>Usually, GANs use unpaired data unless you're using a conditional GAN like pix2pix. So, just creating iterable datasets would be enough. No need for sorting or arranging the images. </p>\n<p>Nonetheless, you just need to sort the files, assuming they are named correctly.</p>\n<p>Here is some boiler-plate pytorch code to help you out:</p>\n<pre><code> ():\n     ():\n        \n        self.files_A = (os.listdir(root+))\n        self.files_B = (os.listdir(root+))\n        \n\n      ():\n         \n        image_A = Image.(self.files_A[id_x])\n        image_B = Image.(self.files_B[id_x])\n\n         {:item_A, :item_B}\n\n     ():\n         ((self.files_A), (self.files_B))\n</code></pre>\n<p>Hope it helps</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2245529": "How do I organize the files as input and output? The real images and the monet paintings are not in order, and I was wondering how I could fix this? Is it filenames, the way I load the data, please let me know.",
    "2247429": "Usually, GANs use unpaired data unless you're using a conditional GAN like pix2pix. So, just creating iterable datasets would be enough. No need for sorting or arranging the images. \n\nNonetheless, you just need to sort the files, assuming they are named correctly.\n\nHere is some boiler-plate pytorch code to help you out:\n\n```python\nclass ImageDataset(Dataset):\n    def __init__(self, root):\n        '''\n              Do other settings here ...\n        '''\n        self.files_A = sorted(os.listdir(root+\" path to your files\"))\n        self.files_B = sorted(os.listdir(root+\"path to your files\"))\n        # Sorting will ensure that the same index has similarly named files\n\n    def  __getitem__(self, id_x):\n         '''\n              Apply transforms and mode-based formatting(train/test) here ...\n        '''\n        image_A = Image.open(self.files_A[id_x])\n        image_B = Image.open(self.files_B[id_x])\n    \n        return {'A':item_A, 'B':item_B}\n    \n    def __len__(self):\n        return max(len(self.files_A), len(self.files_B))\n```\n\nHope it helps"
  },
  "source": "meta"
}