{
  "id": 492135,
  "title": "Complete Workflow: Spectrograms->ImageNet->.56 LB",
  "url": "/competitions/birdclef-2024/discussion/492135",
  "author_name": "",
  "post_date": "2024-04-08T18:42:20.725028500Z",
  "votes": 3,
  "comment_count": 1,
  "views": 0,
  "content": "<p>Short version -  just made my first successful submission at .56 on LB - sharing the notebooks:</p>\n<p><a href=\"https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/</a><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train</a><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run</a></p>\n<p>My goal here was just to quickly build something from-scratch that scores better-than-chance.  There are easy things that I think will boost the score.</p>\n<p>Here's the breakdown:</p>\n<p><strong>Generate Mel Spectrograms:</strong><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/</a><br>\n<a href=\"https://www.kaggle.com/datasets/richolson/birdclef-2024-mel-spectrograms\" target=\"_blank\">https://www.kaggle.com/datasets/richolson/birdclef-2024-mel-spectrograms</a></p>\n<p>14,522 224x224 images - representing 5-sec clips.  This is just a subset of the full data. Took about 45-minutes to generate.</p>\n<p>Generating a more complete dataset would just be re-running (I'll probably do that at some point).</p>\n<p><strong>Fine-tune an ImageNet (MobileNetV2) on Spectrograms:</strong><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train</a></p>\n<p>Trained for 10-epochs - takes only an hour on CPU.  Model performance seemed to level-off about there (0.18 validation accuracy).  I haven't played around with hyperparameters much - but I suspect adding more training data is next step.</p>\n<p>I chose MobileNetV2 since I knew runtime would be a bottle-neck with the CPU-only limitation.</p>\n<p><strong>Run the Model:</strong><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run</a></p>\n<p>So - it turns out it needs about 7 seconds to generate the spectrograms for each 4-minute soundscape - and then another 7 seconds to run the model.  So - 14-seconds total per file.</p>\n<p>To handle 1100 files in the 2-hour time limit - we need to be closer to 6.5 / seconds per 4-minute file.</p>\n<p>Wanted to get things working - so I made a compromise..  The notebook just predicts 1 out of every 3 5-second segment - and then copies those predictions for the next 2 segments.  That gets it down to about 4.5 seconds per 4-minute file.  I'm sure this hurts me on the LB - but I was happy to get things running.</p>\n<p>The current run notebook doesn't utilize all the CPU cores well - so I'm optimistic I can get the model running fully (or more fully) with some further tweaks.</p>\n<p>Hope this is useful to someone - please feel free to build on this!</p>",
  "messages": [
    {
      "id": "2742120",
      "postDate": "04/08/2024 18:42:20",
      "content": "<p>Short version -  just made my first successful submission at .56 on LB - sharing the notebooks:</p>\n<p><a href=\"https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/</a><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train</a><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run</a></p>\n<p>My goal here was just to quickly build something from-scratch that scores better-than-chance.  There are easy things that I think will boost the score.</p>\n<p>Here's the breakdown:</p>\n<p><strong>Generate Mel Spectrograms:</strong><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/</a><br>\n<a href=\"https://www.kaggle.com/datasets/richolson/birdclef-2024-mel-spectrograms\" target=\"_blank\">https://www.kaggle.com/datasets/richolson/birdclef-2024-mel-spectrograms</a></p>\n<p>14,522 224x224 images - representing 5-sec clips.  This is just a subset of the full data. Took about 45-minutes to generate.</p>\n<p>Generating a more complete dataset would just be re-running (I'll probably do that at some point).</p>\n<p><strong>Fine-tune an ImageNet (MobileNetV2) on Spectrograms:</strong><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train</a></p>\n<p>Trained for 10-epochs - takes only an hour on CPU.  Model performance seemed to level-off about there (0.18 validation accuracy).  I haven't played around with hyperparameters much - but I suspect adding more training data is next step.</p>\n<p>I chose MobileNetV2 since I knew runtime would be a bottle-neck with the CPU-only limitation.</p>\n<p><strong>Run the Model:</strong><br>\n<a href=\"https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\" target=\"_blank\">https://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run</a></p>\n<p>So - it turns out it needs about 7 seconds to generate the spectrograms for each 4-minute soundscape - and then another 7 seconds to run the model.  So - 14-seconds total per file.</p>\n<p>To handle 1100 files in the 2-hour time limit - we need to be closer to 6.5 / seconds per 4-minute file.</p>\n<p>Wanted to get things working - so I made a compromise..  The notebook just predicts 1 out of every 3 5-second segment - and then copies those predictions for the next 2 segments.  That gets it down to about 4.5 seconds per 4-minute file.  I'm sure this hurts me on the LB - but I was happy to get things running.</p>\n<p>The current run notebook doesn't utilize all the CPU cores well - so I'm optimistic I can get the model running fully (or more fully) with some further tweaks.</p>\n<p>Hope this is useful to someone - please feel free to build on this!</p>",
      "rawMarkdown": "Short version -  just made my first successful submission at .56 on LB - sharing the notebooks:\n\nhttps://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\n\nMy goal here was just to quickly build something from-scratch that scores better-than-chance.  There are easy things that I think will boost the score.\n\nHere's the breakdown:\n\n**Generate Mel Spectrograms:**\nhttps://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\nhttps://www.kaggle.com/datasets/richolson/birdclef-2024-mel-spectrograms\n\n14,522 224x224 images - representing 5-sec clips.  This is just a subset of the full data. Took about 45-minutes to generate.\n\nGenerating a more complete dataset would just be re-running (I'll probably do that at some point).\n\n**Fine-tune an ImageNet (MobileNetV2) on Spectrograms:**\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\n\nTrained for 10-epochs - takes only an hour on CPU.  Model performance seemed to level-off about there (0.18 validation accuracy).  I haven't played around with hyperparameters much - but I suspect adding more training data is next step.\n\nI chose MobileNetV2 since I knew runtime would be a bottle-neck with the CPU-only limitation.\n\n**Run the Model:**\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\n\nSo - it turns out it needs about 7 seconds to generate the spectrograms for each 4-minute soundscape - and then another 7 seconds to run the model.  So - 14-seconds total per file.\n\nTo handle 1100 files in the 2-hour time limit - we need to be closer to 6.5 / seconds per 4-minute file.\n\nWanted to get things working - so I made a compromise..  The notebook just predicts 1 out of every 3 5-second segment - and then copies those predictions for the next 2 segments.  That gets it down to about 4.5 seconds per 4-minute file.  I'm sure this hurts me on the LB - but I was happy to get things running.\n\nThe current run notebook doesn't utilize all the CPU cores well - so I'm optimistic I can get the model running fully (or more fully) with some further tweaks.\n\nHope this is useful to someone - please feel free to build on this!",
      "votes": null
    },
    {
      "id": "2742609",
      "postDate": "04/09/2024 01:41:42",
      "content": "<p>I made some adjustments - and managed to get things running fast enough to predict on each 5-second interval.</p>\n<p>Unfortunately - this dropped my score from .56 down to .55 on the LB.   Go figure…</p>",
      "rawMarkdown": "I made some adjustments - and managed to get things running fast enough to predict on each 5-second interval.\n\nUnfortunately - this dropped my score from .56 down to .55 on the LB.   Go figure...",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2742609,
      "author_name": "richolson",
      "author_url": "",
      "post_date": "04/09/2024 01:41:42",
      "content": "<p>I made some adjustments - and managed to get things running fast enough to predict on each 5-second interval.</p>\n<p>Unfortunately - this dropped my score from .56 down to .55 on the LB.   Go figure…</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "2742120": "Short version -  just made my first successful submission at .56 on LB - sharing the notebooks:\n\nhttps://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\n\nMy goal here was just to quickly build something from-scratch that scores better-than-chance.  There are easy things that I think will boost the score.\n\nHere's the breakdown:\n\n**Generate Mel Spectrograms:**\nhttps://www.kaggle.com/code/richolson/birdclef2024-simple-mel-spectrogram-generator/\nhttps://www.kaggle.com/datasets/richolson/birdclef-2024-mel-spectrograms\n\n14,522 224x224 images - representing 5-sec clips.  This is just a subset of the full data. Took about 45-minutes to generate.\n\nGenerating a more complete dataset would just be re-running (I'll probably do that at some point).\n\n**Fine-tune an ImageNet (MobileNetV2) on Spectrograms:**\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-train\n\nTrained for 10-epochs - takes only an hour on CPU.  Model performance seemed to level-off about there (0.18 validation accuracy).  I haven't played around with hyperparameters much - but I suspect adding more training data is next step.\n\nI chose MobileNetV2 since I knew runtime would be a bottle-neck with the CPU-only limitation.\n\n**Run the Model:**\nhttps://www.kaggle.com/code/richolson/birdclef-2024-spectrograms-imagenet-run\n\nSo - it turns out it needs about 7 seconds to generate the spectrograms for each 4-minute soundscape - and then another 7 seconds to run the model.  So - 14-seconds total per file.\n\nTo handle 1100 files in the 2-hour time limit - we need to be closer to 6.5 / seconds per 4-minute file.\n\nWanted to get things working - so I made a compromise..  The notebook just predicts 1 out of every 3 5-second segment - and then copies those predictions for the next 2 segments.  That gets it down to about 4.5 seconds per 4-minute file.  I'm sure this hurts me on the LB - but I was happy to get things running.\n\nThe current run notebook doesn't utilize all the CPU cores well - so I'm optimistic I can get the model running fully (or more fully) with some further tweaks.\n\nHope this is useful to someone - please feel free to build on this!",
    "2742609": "I made some adjustments - and managed to get things running fast enough to predict on each 5-second interval.\n\nUnfortunately - this dropped my score from .56 down to .55 on the LB.   Go figure..."
  },
  "source": "meta"
}