<p>It looks like the <a href="http://opensoundscape.org/en/latest/" rel="nofollow noreferrer">OpenSoundscape</a> package provides capacity for generating class activation maps. It's possible you could dig into <a href="https://github.com/kitzeslab/opensoundscape" rel="nofollow noreferrer">the OpenSoundscape code</a> and figure out how to apply it to your BirdNET workflow (I haven't tried). CAMs are mentioned in <a href="http://opensoundscape.org/en/latest/tutorials/cnn.html" rel="nofollow noreferrer">this tutorial</a> and additionally documented <a href="http://opensoundscape.org/en/latest/api/modules.html#module-opensoundscape.ml.cam" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2023-07-21T20:38:59.850Z
Thank you, this is very interesting!
Camille Rondeau
CC BY-SA 4.0
2023-09-07T03:48:04.817Z
yes, OpenSoundscape supports class activation mapping of various flavors. I'm happy to help assist you with using them if you get stuck. Unfortunately, though, the full BirdNET model is not publicly available and its not possible to run gradCAM or similar methods using the publicly shared `.tflite` files. These files are compiled versions of the model, which do not allow full access to the architecture, a necessary component of activation mapping. If you train your own model in OpenSoundscape, you can create activation maps.
Sam Lapp
CC BY-SA 4.0
2023-07-20T17:52:16.993Z
2023-07-20T17:52:16.993Z
Cathleen B
<p>It is not entirely clear to me how the authors created their class activation maps, but it seems to be using directly some particular layer in their model.</p>
<p>Another approach would be to use <a href="https://github.com/marcotcr/lime" rel="nofollow noreferrer">LIME</a>. In particular, using the image-based explainers for spectrogram-based audio classification models. This has the advantage of working with any neural network, and the approach is documented - one can use the image guides as a starting point.</p>
<p>Some basic examples of this method being used on spectrograms can be found here:</p>
<ul>
<li><a href="https://se.mathworks.com/help/deeplearning/ug/investigate-audio-classifications-using-interpretability-techniques.html" rel="nofollow noreferrer">https://se.mathworks.com/help/deeplearning/ug/investigate-audio-classifications-using-interpretability-techniques.html</a></li>
<li><a href="https://se.mathworks.com/help/deeplearning/ug/investigate-spectrogram-classifications-using-lime.html" rel="nofollow noreferrer">https://se.mathworks.com/help/deeplearning/ug/investigate-spectrogram-classifications-using-lime.html</a></li>
</ul>

CC BY-SA 4.0
2023-08-02T08:04:59.133Z
Good suggestion. I remember there has been some work on LIME for audio, from 2 different groups: [SoundLIME](https://doi.org/10.1109/IJCNN48605.2020.9207444) and [AudioLIME](https://arxiv.org/abs/2008.00582)
Dan Stowell
CC BY-SA 4.0
2023-06-04T18:07:48.453Z
2023-06-07T12:52:15.923Z
2023-06-07T12:52:15.923Z
Jon Nordby
<p>I played around with a <a href="https://github.com/jacobgil/pytorch-grad-cam" rel="nofollow noreferrer">pytorch implementation of this</a> last year but I gave up because my CAMs looked very weird. Not sure how helpful this as as BirdNET is implemented in Tensorflow / Keras? There will be other implementations out there which you might just be able to use out of the box? Potentially though there may be a conflict with what these packages are designed for (images) and the representation used by birdnet (log spectrogram)? I'm not sure how helpful that is!</p>

CC BY-SA 4.0
2023-05-10T14:33:55.217Z
2023-05-12T08:57:00.753Z
2023-05-12T08:57:00.753Z
Kieran Gibb
<p>It's unfortunately not possible to generate activation maps with the currently available BirdNET models. The publicly available <code>.tflite</code> files for the BirdNET model are &quot;compiled&quot; in a way that only allow inference (creating scores or embeddings on audio). Activation mapping requires full access to the  model architecture.</p>

CC BY-SA 4.0
2023-09-07T03:52:42.100Z
2023-09-07T03:52:42.100Z
Sam Lapp
<p>I am interested in class activation maps to interpret the results of classifications by a deep neural network, as shown in pages 173-180 (Figures 5.8 to 5.15) of the thesis of S. Kahl (2020) <a href="https://monarch.qucosa.de/api/qucosa%3A36986/attachment/ATT-0/" rel="noreferrer">https://monarch.qucosa.de/api/qucosa%3A36986/attachment/ATT-0/</a></p>
<p>I have not been able to find the detailed methods they used to produce these maps in BirdNET. I did find some sources and repositories in GitHub to make class activation maps from images, but I would need more information on how to make them out of audio clips and through BirdNET.</p>
<p>Has anyone else attempted this? Thank you!</p>

<machine-learning><spectrogram><birdnet>
How to make class activation maps from audio
# How to make class activation maps from audio

(Asked by: username_0 on 2023-05-06)

I am interested in class activation maps to interpret the results of classifications by a deep neural network, as shown in pages 173-180 (Figures 5.8 to 5.15) of the thesis of S. Kahl (2020) <https://monarch.qucosa.de/api/qucosa%3A36986/attachment/ATT-0/>

I have not been able to find the detailed methods they used to produce these maps in BirdNET. I did find some sources and repositories in GitHub to make class activation maps from images, but I would need more information on how to make them out of audio clips and through BirdNET.

Has anyone else attempted this? Thank you!

**Tags:** machine-learning, spectrogram, birdnet


---

## 4 answers

### Answer by username_1 on 2023-07-20. Score: 4

It looks like the [OpenSoundscape](http://opensoundscape.org/en/latest/) package provides capacity for generating class activation maps. It's possible you could dig into [the OpenSoundscape code](https://github.com/kitzeslab/opensoundscape) and figure out how to apply it to your BirdNET workflow (I haven't tried). CAMs are mentioned in [this tutorial](http://opensoundscape.org/en/latest/tutorials/cnn.html) and additionally documented [here](http://opensoundscape.org/en/latest/api/modules.html#module-opensoundscape.ml.cam).

> **Comments:**
> **username_0**: Thank you, this is very interesting!  
> **username_2**: yes, OpenSoundscape supports class activation mapping of various flavors. I'm happy to help assist you with using them if you get stuck. Unfortunately, though, the full BirdNET model is not publicly available and its not possible to run gradCAM or similar methods using the publicly shared `.tflite` files. These files are compiled versions of the model, which do not allow full access to the architecture, a necessary component of activation mapping. If you train your own model in OpenSoundscape, you can create activation maps.  

---

### Answer by username_3 on 2023-06-04. Score: 3

It is not entirely clear to me how the authors created their class activation maps, but it seems to be using directly some particular layer in their model.

Another approach would be to use [LIME](https://github.com/marcotcr/lime). In particular, using the image-based explainers for spectrogram-based audio classification models. This has the advantage of working with any neural network, and the approach is documented - one can use the image guides as a starting point.

Some basic examples of this method being used on spectrograms can be found here:

* <https://se.mathworks.com/help/deeplearning/ug/investigate-audio-classifications-using-interpretability-techniques.html>
* <https://se.mathworks.com/help/deeplearning/ug/investigate-spectrogram-classifications-using-lime.html>

> **Comments:**
> **username_4**: Good suggestion. I remember there has been some work on LIME for audio, from 2 different groups: [SoundLIME](https://doi.org/10.1109/IJCNN48605.2020.9207444) and [AudioLIME](https://arxiv.org/abs/2008.00582)  

---

### Answer by username_5 on 2023-05-10. Score: 2

I played around with a [pytorch implementation of this](https://github.com/jacobgil/pytorch-grad-cam) last year but I gave up because my CAMs looked very weird. Not sure how helpful this as as BirdNET is implemented in Tensorflow / Keras? There will be other implementations out there which you might just be able to use out of the box? Potentially though there may be a conflict with what these packages are designed for (images) and the representation used by birdnet (log spectrogram)? I'm not sure how helpful that is!


---

### Answer by username_2 on 2023-09-07. Score: 1

It's unfortunately not possible to generate activation maps with the currently available BirdNET models. The publicly available `.tflite` files for the BirdNET model are "compiled" in a way that only allow inference (creating scores or embeddings on audio). Activation mapping requires full access to the model architecture.


---

