{
  "id": 436213,
  "title": "Need Help with KerasCV Starter Notebook : 'keras_cv.layers' has no attribute 'Augmenter'",
  "url": "/competitions/rsna-2023-abdominal-trauma-detection/discussion/436213",
  "author_name": "Jude TCHAYE",
  "post_date": "2023-09-01T11:37:57.994000",
  "votes": 0,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Hello Kaggle community,</p>\n<p>I've been working with the <a href=\"https://www.kaggle.com/code/aritrag/kerascv-starter-notebook-train\" target=\"_blank\">KerasCV starter notebook </a>  recently, and I've encountered an issue.</p>\n<p>I'm trying to run the following code snippet \" <a href=\"https://www.kaggle.com/code/tchaye59/attributeerror-augmenter-not-found\" target=\"_blank\">https://www.kaggle.com/code/tchaye59/attributeerror-augmenter-not-found</a> \":</p>\n<pre><code>augmenter = keras_cv.layers.Augmenter(\n        [\n            keras_cv.layers.RandomFlip(mode=),\n            keras_cv.layers.RandomCutout(height_factor=, width_factor=),\n\n        ]\n    )\n</code></pre>\n<p>However, I'm getting the following error:</p>\n<p><code>AttributeError: module 'keras_cv.layers' has no attribute 'Augmenter'</code></p>\n<p>I've spent a considerable amount of time trying to troubleshoot this error, but I'm still unable to find a solution. Any help or guidance on how to resolve this issue would be greatly appreciated.</p>\n<p>Thank you in advance for your assistance!</p>",
  "messages": [
    {
      "id": 2418888,
      "postDate": "2023-09-01T15:13:07.107Z",
      "content": "<p>just replace <code>keras_cv.layers.Augmenter</code> with <code>keras.Sequential</code><br>\nmore details here: <a href=\"https://github.com/keras-team/keras-cv/issues/1548\" target=\"_blank\">https://github.com/keras-team/keras-cv/issues/1548</a><br>\nThe notebook will be updated too.</p>",
      "rawMarkdown": "just replace ```keras_cv.layers.Augmenter``` with ```keras.Sequential```\nmore details here: https://github.com/keras-team/keras-cv/issues/1548\nThe notebook will be updated too.",
      "votes": 4
    },
    {
      "id": 2420818,
      "postDate": "2023-09-03T00:18:56.573Z",
      "content": "<p>Found an alternative way to do it as well</p>\n<p>def apply_augmentation(image,labels):<br>\n    image = preprocessing.RandomFlip(mode=\"horizontal_and_vertical\")(image)  <br>\n    image = preprocessing.RandomTranslation(height_factor=0.2, width_factor=0.2)(image)<br>\n    return (image, labels)</p>",
      "rawMarkdown": "Found an alternative way to do it as well\n\ndef apply_augmentation(image,labels):\n    image = preprocessing.RandomFlip(mode=\"horizontal_and_vertical\")(image)  \n    image = preprocessing.RandomTranslation(height_factor=0.2, width_factor=0.2)(image)\n    return (image, labels)\n\n\n",
      "votes": 2
    },
    {
      "id": 2419267,
      "postDate": "2023-09-01T21:55:26.197Z",
      "content": "<p>Thank you, everyone! Here's how I successfully worked around the issue:</p>\n<pre><code> os\n\n\nos.environ[] = \n\n keras_cv\n\n tensorflow  keras\n\n tensorflow.keras  layers\n\naugmenter = keras.Sequential(\n  layers = [\n      tf.keras.layers.Lambda(keras_cv.layers.RandomCutout(height_factor=, \n                                             width_factor=)),\n      tf.keras.layers.Lambda(keras_cv.layers.RandomFlip(mode=)),\n   ]\n)\n</code></pre>",
      "rawMarkdown": "Thank you, everyone! Here's how I successfully worked around the issue:\n\n```python\n\nimport os\n# You can use `tensorflow`, `pytorch`, `jax` here\n# KerasCore makes the notebook backend agnostic :)\nos.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\n\nimport keras_cv\n#import keras_core as keras\nfrom tensorflow import keras\n#from keras_core import layers\nfrom tensorflow.keras import layers\n\naugmenter = keras.Sequential(\n  layers = [\n      tf.keras.layers.Lambda(keras_cv.layers.RandomCutout(height_factor=0.2, \n                                             width_factor=0.2)),\n      tf.keras.layers.Lambda(keras_cv.layers.RandomFlip(mode=\"horizontal_and_vertical\")),\n   ]\n)\n```",
      "votes": 2
    },
    {
      "id": 2418838,
      "postDate": "2023-09-01T14:47:56.720Z",
      "content": "<p>I get the same error running with either of the two GPU resources on kaggle.</p>\n<p>When running on my local machine it does NOT fail at that same point </p>\n<pre><code> -  fails   model.fit cell apparently  a   NVIDIA hell.  Tensorflow  Keras always a bitch   working   system when you want your GPU's  play nicely.  \n</code></pre>",
      "rawMarkdown": "I get the same error running with either of the two GPU resources on kaggle.\n\nWhen running on my local machine it does NOT fail at that same point \n\n     - but fails in the model.fit cell apparently as a result of NVIDIA hell.  Tensorflow and Keras always a bitch to get working on local system when you want your GPU's to play nicely.  "
    },
    {
      "id": 2418835,
      "postDate": "2023-09-01T14:45:19.117Z",
      "content": "<p>I'm facing the same issue and haven't had any luck trying to solve it so far.<br>\nCould you please help here? <a href=\"https://www.kaggle.com/awsaf49\" target=\"_blank\">@awsaf49</a> <a href=\"https://www.kaggle.com/fchollet\" target=\"_blank\">@fchollet</a> <a href=\"https://www.kaggle.com/gusthema\" target=\"_blank\">@gusthema</a> <a href=\"https://www.kaggle.com/ianstenbit\" target=\"_blank\">@ianstenbit</a> <a href=\"https://www.kaggle.com/philculliton\" target=\"_blank\">@philculliton</a> </p>",
      "rawMarkdown": "I'm facing the same issue and haven't had any luck trying to solve it so far.\nCould you please help here? @awsaf49 @fchollet @gusthema @ianstenbit @philculliton "
    },
    {
      "id": 2418564,
      "postDate": "2023-09-01T11:37:57.993Z",
      "content": "<p>Hello Kaggle community,</p>\n<p>I've been working with the <a href=\"https://www.kaggle.com/code/aritrag/kerascv-starter-notebook-train\" target=\"_blank\">KerasCV starter notebook </a>  recently, and I've encountered an issue.</p>\n<p>I'm trying to run the following code snippet \" <a href=\"https://www.kaggle.com/code/tchaye59/attributeerror-augmenter-not-found\" target=\"_blank\">https://www.kaggle.com/code/tchaye59/attributeerror-augmenter-not-found</a> \":</p>\n<pre><code>augmenter = keras_cv.layers.Augmenter(\n        [\n            keras_cv.layers.RandomFlip(mode=),\n            keras_cv.layers.RandomCutout(height_factor=, width_factor=),\n\n        ]\n    )\n</code></pre>\n<p>However, I'm getting the following error:</p>\n<p><code>AttributeError: module 'keras_cv.layers' has no attribute 'Augmenter'</code></p>\n<p>I've spent a considerable amount of time trying to troubleshoot this error, but I'm still unable to find a solution. Any help or guidance on how to resolve this issue would be greatly appreciated.</p>\n<p>Thank you in advance for your assistance!</p>",
      "rawMarkdown": "Hello Kaggle community,\n\nI've been working with the [KerasCV starter notebook ](https://www.kaggle.com/code/aritrag/kerascv-starter-notebook-train)  recently, and I've encountered an issue.\n\nI'm trying to run the following code snippet \" https://www.kaggle.com/code/tchaye59/attributeerror-augmenter-not-found \":\n\n```python\n\naugmenter = keras_cv.layers.Augmenter(\n        [\n            keras_cv.layers.RandomFlip(mode=\"horizontal_and_vertical\"),\n            keras_cv.layers.RandomCutout(height_factor=0.2, width_factor=0.2),\n            \n        ]\n    )\n\n\n```\nHowever, I'm getting the following error:\n\n`AttributeError: module 'keras_cv.layers' has no attribute 'Augmenter'`\n\nI've spent a considerable amount of time trying to troubleshoot this error, but I'm still unable to find a solution. Any help or guidance on how to resolve this issue would be greatly appreciated.\n\nThank you in advance for your assistance!"
    }
  ],
  "comments": [
    {
      "id": 2418888,
      "author_name": "Martin Görner",
      "author_url": "",
      "post_date": "2023-09-01T15:13:07.107000",
      "content": "<p>just replace <code>keras_cv.layers.Augmenter</code> with <code>keras.Sequential</code><br>\nmore details here: <a href=\"https://github.com/keras-team/keras-cv/issues/1548\" target=\"_blank\">https://github.com/keras-team/keras-cv/issues/1548</a><br>\nThe notebook will be updated too.</p>",
      "votes": 4,
      "replies": []
    },
    {
      "id": 2420818,
      "author_name": "Neeraj Karoshi",
      "author_url": "",
      "post_date": "2023-09-03T00:18:56.573000",
      "content": "<p>Found an alternative way to do it as well</p>\n<p>def apply_augmentation(image,labels):<br>\n    image = preprocessing.RandomFlip(mode=\"horizontal_and_vertical\")(image)  <br>\n    image = preprocessing.RandomTranslation(height_factor=0.2, width_factor=0.2)(image)<br>\n    return (image, labels)</p>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2419267,
      "author_name": "Jude TCHAYE",
      "author_url": "",
      "post_date": "2023-09-01T21:55:26.197000",
      "content": "<p>Thank you, everyone! Here's how I successfully worked around the issue:</p>\n<pre><code> os\n\n\nos.environ[] = \n\n keras_cv\n\n tensorflow  keras\n\n tensorflow.keras  layers\n\naugmenter = keras.Sequential(\n  layers = [\n      tf.keras.layers.Lambda(keras_cv.layers.RandomCutout(height_factor=, \n                                             width_factor=)),\n      tf.keras.layers.Lambda(keras_cv.layers.RandomFlip(mode=)),\n   ]\n)\n</code></pre>",
      "votes": 2,
      "replies": []
    },
    {
      "id": 2418838,
      "author_name": "PC Jimmmy",
      "author_url": "",
      "post_date": "2023-09-01T14:47:56.720000",
      "content": "<p>I get the same error running with either of the two GPU resources on kaggle.</p>\n<p>When running on my local machine it does NOT fail at that same point </p>\n<pre><code> -  fails   model.fit cell apparently  a   NVIDIA hell.  Tensorflow  Keras always a bitch   working   system when you want your GPU's  play nicely.  \n</code></pre>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 2418835,
      "author_name": "the real L",
      "author_url": "",
      "post_date": "2023-09-01T14:45:19.117000",
      "content": "<p>I'm facing the same issue and haven't had any luck trying to solve it so far.<br>\nCould you please help here? <a href=\"https://www.kaggle.com/awsaf49\" target=\"_blank\">@awsaf49</a> <a href=\"https://www.kaggle.com/fchollet\" target=\"_blank\">@fchollet</a> <a href=\"https://www.kaggle.com/gusthema\" target=\"_blank\">@gusthema</a> <a href=\"https://www.kaggle.com/ianstenbit\" target=\"_blank\">@ianstenbit</a> <a href=\"https://www.kaggle.com/philculliton\" target=\"_blank\">@philculliton</a> </p>",
      "votes": 0,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2418888": "just replace ```keras_cv.layers.Augmenter``` with ```keras.Sequential```\nmore details here: https://github.com/keras-team/keras-cv/issues/1548\nThe notebook will be updated too.",
    "2420818": "Found an alternative way to do it as well\n\ndef apply_augmentation(image,labels):\n    image = preprocessing.RandomFlip(mode=\"horizontal_and_vertical\")(image)  \n    image = preprocessing.RandomTranslation(height_factor=0.2, width_factor=0.2)(image)\n    return (image, labels)\n\n\n",
    "2419267": "Thank you, everyone! Here's how I successfully worked around the issue:\n\n```python\n\nimport os\n# You can use `tensorflow`, `pytorch`, `jax` here\n# KerasCore makes the notebook backend agnostic :)\nos.environ[\"KERAS_BACKEND\"] = \"tensorflow\"\n\nimport keras_cv\n#import keras_core as keras\nfrom tensorflow import keras\n#from keras_core import layers\nfrom tensorflow.keras import layers\n\naugmenter = keras.Sequential(\n  layers = [\n      tf.keras.layers.Lambda(keras_cv.layers.RandomCutout(height_factor=0.2, \n                                             width_factor=0.2)),\n      tf.keras.layers.Lambda(keras_cv.layers.RandomFlip(mode=\"horizontal_and_vertical\")),\n   ]\n)\n```",
    "2418838": "I get the same error running with either of the two GPU resources on kaggle.\n\nWhen running on my local machine it does NOT fail at that same point \n\n     - but fails in the model.fit cell apparently as a result of NVIDIA hell.  Tensorflow and Keras always a bitch to get working on local system when you want your GPU's to play nicely.  ",
    "2418835": "I'm facing the same issue and haven't had any luck trying to solve it so far.\nCould you please help here? @awsaf49 @fchollet @gusthema @ianstenbit @philculliton ",
    "2418564": "Hello Kaggle community,\n\nI've been working with the [KerasCV starter notebook ](https://www.kaggle.com/code/aritrag/kerascv-starter-notebook-train)  recently, and I've encountered an issue.\n\nI'm trying to run the following code snippet \" https://www.kaggle.com/code/tchaye59/attributeerror-augmenter-not-found \":\n\n```python\n\naugmenter = keras_cv.layers.Augmenter(\n        [\n            keras_cv.layers.RandomFlip(mode=\"horizontal_and_vertical\"),\n            keras_cv.layers.RandomCutout(height_factor=0.2, width_factor=0.2),\n            \n        ]\n    )\n\n\n```\nHowever, I'm getting the following error:\n\n`AttributeError: module 'keras_cv.layers' has no attribute 'Augmenter'`\n\nI've spent a considerable amount of time trying to troubleshoot this error, but I'm still unable to find a solution. Any help or guidance on how to resolve this issue would be greatly appreciated.\n\nThank you in advance for your assistance!"
  }
}