{
  "id": 176808,
  "title": "Notebook Timeout",
  "url": "/competitions/birdsong-recognition/discussion/176808",
  "author_name": "",
  "post_date": "2020-08-23T14:51:59.238972100Z",
  "votes": 1,
  "comment_count": 6,
  "views": 0,
  "content": "<p>Hi, </p>\n<p>I'm using my own evaluation notebook and It works great for the dataset birdcall-check from <a href=\"https://www.kaggle.com/shonenkov\" target=\"_blank\">@shonenkov</a> when submitting it for the \"real\" <code>test_audio</code> it always times out. I used a batch-size of 1 and 32 both timed out, I load my audio files with <strong>AudioSegment</strong>, I heard that torchaudio is faster but I could not see any differences. This is how I load the audio files (e.g. for site_1 or site_2):</p>\n<pre><code>sound = AudioSegment.from_mp3(path)\nsound = sound.set_frame_rate(self.sr)\nend = seconds * 1000\nstart = end - 5000\nsound = sound[start:end]\nsound_array = np.array(sound.get_array_of_samples(), dtype=np.float32)\n</code></pre>\n<p>Batch-size seems not to be the key problem here, so I assume its about loading the files. Evaluation on birdcall-check takes around <strong>19 seconds</strong></p>\n<ol>\n<li>Does anyone have an idea, what it could be?</li>\n<li>How long does the evaluation on birdcall-check take for you?</li>\n</ol>\n<p>Thank you.</p>",
  "messages": [
    {
      "id": "982650",
      "postDate": "08/23/2020 14:51:59",
      "content": "<p>Hi, </p>\n<p>I'm using my own evaluation notebook and It works great for the dataset birdcall-check from <a href=\"https://www.kaggle.com/shonenkov\" target=\"_blank\">@shonenkov</a> when submitting it for the \"real\" <code>test_audio</code> it always times out. I used a batch-size of 1 and 32 both timed out, I load my audio files with <strong>AudioSegment</strong>, I heard that torchaudio is faster but I could not see any differences. This is how I load the audio files (e.g. for site_1 or site_2):</p>\n<pre><code>sound = AudioSegment.from_mp3(path)\nsound = sound.set_frame_rate(self.sr)\nend = seconds * 1000\nstart = end - 5000\nsound = sound[start:end]\nsound_array = np.array(sound.get_array_of_samples(), dtype=np.float32)\n</code></pre>\n<p>Batch-size seems not to be the key problem here, so I assume its about loading the files. Evaluation on birdcall-check takes around <strong>19 seconds</strong></p>\n<ol>\n<li>Does anyone have an idea, what it could be?</li>\n<li>How long does the evaluation on birdcall-check take for you?</li>\n</ol>\n<p>Thank you.</p>",
      "rawMarkdown": "Hi, \n\nI'm using my own evaluation notebook and It works great for the dataset birdcall-check from @shonenkov when submitting it for the \"real\" `test_audio` it always times out. I used a batch-size of 1 and 32 both timed out, I load my audio files with **AudioSegment**, I heard that torchaudio is faster but I could not see any differences. This is how I load the audio files (e.g. for site_1 or site_2):\n\n```\nsound = AudioSegment.from_mp3(path)\nsound = sound.set_frame_rate(self.sr)\nend = seconds * 1000\nstart = end - 5000\nsound = sound[start:end]\nsound_array = np.array(sound.get_array_of_samples(), dtype=np.float32)\n```\n\nBatch-size seems not to be the key problem here, so I assume its about loading the files. Evaluation on birdcall-check takes around **19 seconds**\n\n1. Does anyone have an idea, what it could be?\n2. How long does the evaluation on birdcall-check take for you?\n\nThank you.",
      "votes": null
    },
    {
      "id": "982947",
      "postDate": "08/23/2020 20:42:58",
      "content": "<p>Cache your last loaded file in memory. If you load \"each roughly 10 minutes long.\" mp3s from test data each time when you just need a 5 seconds segment - your notebook will timeout.</p>\n<p>I submit on CPU notebook, birdcall-check takes 80-100 seconds, full submission around 2 hours.</p>",
      "rawMarkdown": "Cache your last loaded file in memory. If you load \"each roughly 10 minutes long.\" mp3s from test data each time when you just need a 5 seconds segment - your notebook will timeout.\n\nI submit on CPU notebook, birdcall-check takes 80-100 seconds, full submission around 2 hours.",
      "votes": null
    },
    {
      "id": "983549",
      "postDate": "08/24/2020 11:54:47",
      "content": "<p>Thank you very much! birdcall-check takes 6 seconds now when caching files.</p>",
      "rawMarkdown": "Thank you very much! birdcall-check takes 6 seconds now when caching files.",
      "votes": null
    },
    {
      "id": "991349",
      "postDate": "08/30/2020 10:41:08",
      "content": "<p>How do you cache audio files?</p>",
      "rawMarkdown": "How do you cache audio files?",
      "votes": null
    },
    {
      "id": "991357",
      "postDate": "08/30/2020 10:50:40",
      "content": "<p>I implemented it in my dataset, I show you how:<br>\nFirst define a dict in your dataset:</p>\n<p><code>self.cache = {'filename': None, 'soundfile': None}</code></p>\n<p>Then when loading the audio files you can just check if its already in cache otherwise you save it as a variable in a dict:</p>\n<pre><code>if self.cache['filename'] == filename:\n    soundfile = self.cache['soundfile']\nelse:\n    soundfile = AudioSegment.from_mp3(path)\n    self.cache['filename'] = filename\n    self.cache['soundfile'] = soundfile\n</code></pre>",
      "rawMarkdown": "I implemented it in my dataset, I show you how:\nFirst define a dict in your dataset:\n\n`self.cache = {'filename': None, 'soundfile': None}`\n\nThen when loading the audio files you can just check if its already in cache otherwise you save it as a variable in a dict:\n\n```\nif self.cache['filename'] == filename:\n    soundfile = self.cache['soundfile']\nelse:\n    soundfile = AudioSegment.from_mp3(path)\n    self.cache['filename'] = filename\n    self.cache['soundfile'] = soundfile\n```",
      "votes": null
    },
    {
      "id": "991379",
      "postDate": "08/30/2020 11:16:53",
      "content": "<p>Thank you Ali.</p>\n<p>In the \"example_test_audio_summary.csv\" file, there are values such as follows, having the same audio filename \"BLKFR-10-CPL\":</p>\n<p>BLKFR-10-CPL_20190611_093000_5<br>\nBLKFR-10-CPL_20190611_093000_10<br>\nBLKFR-10-CPL_20190611_093000_15<br>\n…<br>\n…</p>\n<p>So, if you group by the audio  filename \"BLKFR-10-CPL\", you would get the above rows as a group. So you would pass this audio clip (\"BLKFR-10-CPL\"), to \"AudioSegment.from_mp3\", right? If so, how would you predict for different rows considering you would read the first 5 seconds of the audio clip only once?</p>",
      "rawMarkdown": "Thank you Ali.\n\nIn the \"example_test_audio_summary.csv\" file, there are values such as follows, having the same audio filename \"BLKFR-10-CPL\":\n\nBLKFR-10-CPL_20190611_093000_5\nBLKFR-10-CPL_20190611_093000_10\nBLKFR-10-CPL_20190611_093000_15\n...\n...\n\nSo, if you group by the audio  filename \"BLKFR-10-CPL\", you would get the above rows as a group. So you would pass this audio clip (\"BLKFR-10-CPL\"), to \"AudioSegment.from_mp3\", right? If so, how would you predict for different rows considering you would read the first 5 seconds of the audio clip only once?",
      "votes": null
    },
    {
      "id": "991425",
      "postDate": "08/30/2020 12:06:18",
      "content": "<p>I do it the following.</p>\n<p>I read the audio_file complete audio_file and the seconds to cut a clip from it, from the CSV File and pass all of these values to my <code>load_audio</code> function. I also read the <code>site</code> from the CSV and check if its<code>site_1 or site_2</code> then I take the seconds and minus them with 5 so you only have a 5 seconds clip of it. This continues for all the audio files. If its <code>site_3</code> I take the whole clip (or only the first 5 seconds I have to investigate which is better) and predict on these.</p>",
      "rawMarkdown": "I do it the following.\n\nI read the audio_file complete audio_file and the seconds to cut a clip from it, from the CSV File and pass all of these values to my `load_audio` function. I also read the `site` from the CSV and check if its` site_1 or site_2` then I take the seconds and minus them with 5 so you only have a 5 seconds clip of it. This continues for all the audio files. If its `site_3` I take the whole clip (or only the first 5 seconds I have to investigate which is better) and predict on these.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 982947,
      "author_name": "fffrrt",
      "author_url": "",
      "post_date": "08/23/2020 20:42:58",
      "content": "<p>Cache your last loaded file in memory. If you load \"each roughly 10 minutes long.\" mp3s from test data each time when you just need a 5 seconds segment - your notebook will timeout.</p>\n<p>I submit on CPU notebook, birdcall-check takes 80-100 seconds, full submission around 2 hours.</p>",
      "votes": null,
      "replies": [
        {
          "id": 983549,
          "author_name": "aliabdin1",
          "author_url": "",
          "post_date": "08/24/2020 11:54:47",
          "content": "<p>Thank you very much! birdcall-check takes 6 seconds now when caching files.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 991349,
      "author_name": "karthikrg",
      "author_url": "",
      "post_date": "08/30/2020 10:41:08",
      "content": "<p>How do you cache audio files?</p>",
      "votes": null,
      "replies": [
        {
          "id": 991357,
          "author_name": "aliabdin1",
          "author_url": "",
          "post_date": "08/30/2020 10:50:40",
          "content": "<p>I implemented it in my dataset, I show you how:<br>\nFirst define a dict in your dataset:</p>\n<p><code>self.cache = {'filename': None, 'soundfile': None}</code></p>\n<p>Then when loading the audio files you can just check if its already in cache otherwise you save it as a variable in a dict:</p>\n<pre><code>if self.cache['filename'] == filename:\n    soundfile = self.cache['soundfile']\nelse:\n    soundfile = AudioSegment.from_mp3(path)\n    self.cache['filename'] = filename\n    self.cache['soundfile'] = soundfile\n</code></pre>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 991379,
      "author_name": "karthikrg",
      "author_url": "",
      "post_date": "08/30/2020 11:16:53",
      "content": "<p>Thank you Ali.</p>\n<p>In the \"example_test_audio_summary.csv\" file, there are values such as follows, having the same audio filename \"BLKFR-10-CPL\":</p>\n<p>BLKFR-10-CPL_20190611_093000_5<br>\nBLKFR-10-CPL_20190611_093000_10<br>\nBLKFR-10-CPL_20190611_093000_15<br>\n…<br>\n…</p>\n<p>So, if you group by the audio  filename \"BLKFR-10-CPL\", you would get the above rows as a group. So you would pass this audio clip (\"BLKFR-10-CPL\"), to \"AudioSegment.from_mp3\", right? If so, how would you predict for different rows considering you would read the first 5 seconds of the audio clip only once?</p>",
      "votes": null,
      "replies": [
        {
          "id": 991425,
          "author_name": "aliabdin1",
          "author_url": "",
          "post_date": "08/30/2020 12:06:18",
          "content": "<p>I do it the following.</p>\n<p>I read the audio_file complete audio_file and the seconds to cut a clip from it, from the CSV File and pass all of these values to my <code>load_audio</code> function. I also read the <code>site</code> from the CSV and check if its<code>site_1 or site_2</code> then I take the seconds and minus them with 5 so you only have a 5 seconds clip of it. This continues for all the audio files. If its <code>site_3</code> I take the whole clip (or only the first 5 seconds I have to investigate which is better) and predict on these.</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "982650": "Hi, \n\nI'm using my own evaluation notebook and It works great for the dataset birdcall-check from @shonenkov when submitting it for the \"real\" `test_audio` it always times out. I used a batch-size of 1 and 32 both timed out, I load my audio files with **AudioSegment**, I heard that torchaudio is faster but I could not see any differences. This is how I load the audio files (e.g. for site_1 or site_2):\n\n```\nsound = AudioSegment.from_mp3(path)\nsound = sound.set_frame_rate(self.sr)\nend = seconds * 1000\nstart = end - 5000\nsound = sound[start:end]\nsound_array = np.array(sound.get_array_of_samples(), dtype=np.float32)\n```\n\nBatch-size seems not to be the key problem here, so I assume its about loading the files. Evaluation on birdcall-check takes around **19 seconds**\n\n1. Does anyone have an idea, what it could be?\n2. How long does the evaluation on birdcall-check take for you?\n\nThank you.",
    "982947": "Cache your last loaded file in memory. If you load \"each roughly 10 minutes long.\" mp3s from test data each time when you just need a 5 seconds segment - your notebook will timeout.\n\nI submit on CPU notebook, birdcall-check takes 80-100 seconds, full submission around 2 hours.",
    "983549": "Thank you very much! birdcall-check takes 6 seconds now when caching files.",
    "991349": "How do you cache audio files?",
    "991357": "I implemented it in my dataset, I show you how:\nFirst define a dict in your dataset:\n\n`self.cache = {'filename': None, 'soundfile': None}`\n\nThen when loading the audio files you can just check if its already in cache otherwise you save it as a variable in a dict:\n\n```\nif self.cache['filename'] == filename:\n    soundfile = self.cache['soundfile']\nelse:\n    soundfile = AudioSegment.from_mp3(path)\n    self.cache['filename'] = filename\n    self.cache['soundfile'] = soundfile\n```",
    "991379": "Thank you Ali.\n\nIn the \"example_test_audio_summary.csv\" file, there are values such as follows, having the same audio filename \"BLKFR-10-CPL\":\n\nBLKFR-10-CPL_20190611_093000_5\nBLKFR-10-CPL_20190611_093000_10\nBLKFR-10-CPL_20190611_093000_15\n...\n...\n\nSo, if you group by the audio  filename \"BLKFR-10-CPL\", you would get the above rows as a group. So you would pass this audio clip (\"BLKFR-10-CPL\"), to \"AudioSegment.from_mp3\", right? If so, how would you predict for different rows considering you would read the first 5 seconds of the audio clip only once?",
    "991425": "I do it the following.\n\nI read the audio_file complete audio_file and the seconds to cut a clip from it, from the CSV File and pass all of these values to my `load_audio` function. I also read the `site` from the CSV and check if its` site_1 or site_2` then I take the seconds and minus them with 5 so you only have a 5 seconds clip of it. This continues for all the audio files. If its `site_3` I take the whole clip (or only the first 5 seconds I have to investigate which is better) and predict on these."
  },
  "source": "meta"
}