{
  "id": 316242,
  "title": "ImageDataGenerator can't save augmented data via save_to_dir.",
  "url": "/competitions/happy-whale-and-dolphin/discussion/316242",
  "author_name": "Brian Salamone",
  "post_date": "2022-04-01T00:28:29.806000",
  "votes": 2,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Hello everybody! I am having trouble saving augmented images on kaggle via keras' <code>ImageDataGenerator</code>. Did you use this, or know why would this be happening to me? It says \"File not found\", as if it tried to save the augmented image, couldn't, didn't err, tried to fetch it afterwards and didn't find it.</p>\n<pre><code>X_gen = ImageDataGenerator(rescale=1./255, validation_split=0.1)\nX_train = X_gen.flow_from_dataframe(train_df,\n        x_col='image',\n        y_col='individual_id',\n        directory=\"../input/happy-whale-and-dolphin/train_images\",\n        target_size=(256, 256),\n        batch_size=32,\n        class_mode='categorical',\n        subset='training',\n        save_to_dir='train_images_augmented')\n</code></pre>\n<p>When <code>model.fit</code> (or simply <code>X_train.next()</code>…):<br>\n<code>FileNotFoundError: [Errno 2] No such file or directory: 'train_images_augmented/_1171_2754782.png'</code></p>\n<p>Is there any trick I'm failing to see to make it work? I already successfully saved a <code>submission.csv</code> but I can't save this augmented data.</p>",
  "messages": [
    {
      "id": 1741584,
      "postDate": "2022-04-01T01:09:44.200Z",
      "content": "<p>I solved it… I feel dumb. In case anyone is having the same problem: I was missing the rest of the path. <code>\"/kaggle/working/...\"</code>, and also I was missing the line of code that actually creates that folder, as <code>ImageDataGenerator</code> doesn't do it for us.</p>\n<p><code>os.makedirs('/kaggle/working/train_images_augmented', exist_ok=True)</code></p>",
      "rawMarkdown": "I solved it... I feel dumb. In case anyone is having the same problem: I was missing the rest of the path. `\"/kaggle/working/...\"`, and also I was missing the line of code that actually creates that folder, as `ImageDataGenerator` doesn't do it for us.\n\n`os.makedirs('/kaggle/working/train_images_augmented', exist_ok=True)`",
      "votes": 1
    },
    {
      "id": 1741563,
      "postDate": "2022-04-01T00:28:29.807Z",
      "content": "<p>Hello everybody! I am having trouble saving augmented images on kaggle via keras' <code>ImageDataGenerator</code>. Did you use this, or know why would this be happening to me? It says \"File not found\", as if it tried to save the augmented image, couldn't, didn't err, tried to fetch it afterwards and didn't find it.</p>\n<pre><code>X_gen = ImageDataGenerator(rescale=1./255, validation_split=0.1)\nX_train = X_gen.flow_from_dataframe(train_df,\n        x_col='image',\n        y_col='individual_id',\n        directory=\"../input/happy-whale-and-dolphin/train_images\",\n        target_size=(256, 256),\n        batch_size=32,\n        class_mode='categorical',\n        subset='training',\n        save_to_dir='train_images_augmented')\n</code></pre>\n<p>When <code>model.fit</code> (or simply <code>X_train.next()</code>…):<br>\n<code>FileNotFoundError: [Errno 2] No such file or directory: 'train_images_augmented/_1171_2754782.png'</code></p>\n<p>Is there any trick I'm failing to see to make it work? I already successfully saved a <code>submission.csv</code> but I can't save this augmented data.</p>",
      "rawMarkdown": "Hello everybody! I am having trouble saving augmented images on kaggle via keras' `ImageDataGenerator`. Did you use this, or know why would this be happening to me? It says \"File not found\", as if it tried to save the augmented image, couldn't, didn't err, tried to fetch it afterwards and didn't find it.\n\n```\nX_gen = ImageDataGenerator(rescale=1./255, validation_split=0.1)\nX_train = X_gen.flow_from_dataframe(train_df,\n        x_col='image',\n        y_col='individual_id',\n        directory=\"../input/happy-whale-and-dolphin/train_images\",\n        target_size=(256, 256),\n        batch_size=32,\n        class_mode='categorical',\n        subset='training',\n        save_to_dir='train_images_augmented')\n```\nWhen `model.fit` (or simply `X_train.next()`...):\n`FileNotFoundError: [Errno 2] No such file or directory: 'train_images_augmented/_1171_2754782.png'`\n\n\nIs there any trick I'm failing to see to make it work? I already successfully saved a `submission.csv` but I can't save this augmented data.",
      "votes": 2
    },
    {
      "id": 2068043,
      "postDate": "2022-12-17T12:55:51.423Z",
      "rawMarkdown": "",
      "isDeleted": true
    }
  ],
  "comments": [
    {
      "id": 1741584,
      "author_name": "Brian Salamone",
      "author_url": "",
      "post_date": "2022-04-01T01:09:44.200000",
      "content": "<p>I solved it… I feel dumb. In case anyone is having the same problem: I was missing the rest of the path. <code>\"/kaggle/working/...\"</code>, and also I was missing the line of code that actually creates that folder, as <code>ImageDataGenerator</code> doesn't do it for us.</p>\n<p><code>os.makedirs('/kaggle/working/train_images_augmented', exist_ok=True)</code></p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 2068043,
      "author_name": "",
      "author_url": "",
      "post_date": "2022-12-17T12:55:51.423000",
      "content": "",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1741584": "I solved it... I feel dumb. In case anyone is having the same problem: I was missing the rest of the path. `\"/kaggle/working/...\"`, and also I was missing the line of code that actually creates that folder, as `ImageDataGenerator` doesn't do it for us.\n\n`os.makedirs('/kaggle/working/train_images_augmented', exist_ok=True)`",
    "1741563": "Hello everybody! I am having trouble saving augmented images on kaggle via keras' `ImageDataGenerator`. Did you use this, or know why would this be happening to me? It says \"File not found\", as if it tried to save the augmented image, couldn't, didn't err, tried to fetch it afterwards and didn't find it.\n\n```\nX_gen = ImageDataGenerator(rescale=1./255, validation_split=0.1)\nX_train = X_gen.flow_from_dataframe(train_df,\n        x_col='image',\n        y_col='individual_id',\n        directory=\"../input/happy-whale-and-dolphin/train_images\",\n        target_size=(256, 256),\n        batch_size=32,\n        class_mode='categorical',\n        subset='training',\n        save_to_dir='train_images_augmented')\n```\nWhen `model.fit` (or simply `X_train.next()`...):\n`FileNotFoundError: [Errno 2] No such file or directory: 'train_images_augmented/_1171_2754782.png'`\n\n\nIs there any trick I'm failing to see to make it work? I already successfully saved a `submission.csv` but I can't save this augmented data.",
    "2068043": ""
  }
}