{
  "id": 218930,
  "title": "tfa.image.cutout replacement for SpecAugment",
  "url": "/competitions/rfcx-species-audio-detection/discussion/218930",
  "author_name": "",
  "post_date": "2021-02-12T17:28:04.952226600Z",
  "votes": 6,
  "comment_count": 1,
  "views": 0,
  "content": "<p><code>tfa.image.cutout</code> is not working with current Kaggle TF version, so you can replace it with <code>tfio.experimental.audio.freq_mask</code> and <code>tfio.experimental.audio.time_mask</code> if you want to fix SpecAugment function.</p>",
  "messages": [
    {
      "id": "1198075",
      "postDate": "02/12/2021 17:28:04",
      "content": "<p><code>tfa.image.cutout</code> is not working with current Kaggle TF version, so you can replace it with <code>tfio.experimental.audio.freq_mask</code> and <code>tfio.experimental.audio.time_mask</code> if you want to fix SpecAugment function.</p>",
      "rawMarkdown": "`tfa.image.cutout` is not working with current Kaggle TF version, so you can replace it with `tfio.experimental.audio.freq_mask` and `tfio.experimental.audio.time_mask` if you want to fix SpecAugment function.",
      "votes": null
    },
    {
      "id": "1198275",
      "postDate": "02/12/2021 21:11:57",
      "content": "<p>Here's modification of <code>__specaugment</code> function from the notebooks by <a href=\"https://www.kaggle.com/aikhmelnytskyy\" target=\"_blank\">@aikhmelnytskyy</a> , which is compatible with TF 2.4</p>\n<pre><code>@tf.function\ndef _specaugment(image):\n    ERASE_TIME = 50\n    ERASE_MEL = 16\n    image = tf.squeeze(image, axis=2)\n    image = tfio.experimental.audio.time_mask(image, param=ERASE_TIME)\n    image = tfio.experimental.audio.freq_mask(image, param=ERASE_MEL)\n    image = tf.expand_dims(image, axis=2)\n    return image\n</code></pre>\n<p>Don't forget to install tensorflow_io with <code>!pip install -q tensorflow_io</code></p>",
      "rawMarkdown": "Here's modification of `__specaugment` function from the notebooks by @aikhmelnytskyy , which is compatible with TF 2.4\n\n```\n@tf.function\ndef _specaugment(image):\n    ERASE_TIME = 50\n    ERASE_MEL = 16\n    image = tf.squeeze(image, axis=2)\n    image = tfio.experimental.audio.time_mask(image, param=ERASE_TIME)\n    image = tfio.experimental.audio.freq_mask(image, param=ERASE_MEL)\n    image = tf.expand_dims(image, axis=2)\n    return image\n```\n\nDon't forget to install tensorflow_io with `!pip install -q tensorflow_io `",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1198275,
      "author_name": "atamazian",
      "author_url": "",
      "post_date": "02/12/2021 21:11:57",
      "content": "<p>Here's modification of <code>__specaugment</code> function from the notebooks by <a href=\"https://www.kaggle.com/aikhmelnytskyy\" target=\"_blank\">@aikhmelnytskyy</a> , which is compatible with TF 2.4</p>\n<pre><code>@tf.function\ndef _specaugment(image):\n    ERASE_TIME = 50\n    ERASE_MEL = 16\n    image = tf.squeeze(image, axis=2)\n    image = tfio.experimental.audio.time_mask(image, param=ERASE_TIME)\n    image = tfio.experimental.audio.freq_mask(image, param=ERASE_MEL)\n    image = tf.expand_dims(image, axis=2)\n    return image\n</code></pre>\n<p>Don't forget to install tensorflow_io with <code>!pip install -q tensorflow_io</code></p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1198075": "`tfa.image.cutout` is not working with current Kaggle TF version, so you can replace it with `tfio.experimental.audio.freq_mask` and `tfio.experimental.audio.time_mask` if you want to fix SpecAugment function.",
    "1198275": "Here's modification of `__specaugment` function from the notebooks by @aikhmelnytskyy , which is compatible with TF 2.4\n\n```\n@tf.function\ndef _specaugment(image):\n    ERASE_TIME = 50\n    ERASE_MEL = 16\n    image = tf.squeeze(image, axis=2)\n    image = tfio.experimental.audio.time_mask(image, param=ERASE_TIME)\n    image = tfio.experimental.audio.freq_mask(image, param=ERASE_MEL)\n    image = tf.expand_dims(image, axis=2)\n    return image\n```\n\nDon't forget to install tensorflow_io with `!pip install -q tensorflow_io `"
  },
  "source": "meta"
}