scieee AI-readable full text Open interactive document viewer

Domain‐specific neural networks improve automated bird sound recognition already with small amount of local data

Lauha, Patrik,Somervuo, Panu,Lehikoinen, Petteri,Geres, Lisa,Richter, Tobias,Seibold, Sebastian,Ovaskainen, Otso

Full text

This is a self-archived version of an original article. This version may differ from the original in pagination and typographic details. Author(s): Title: Year: Version: Copyright: Rights: Rights url: Please cite the original version: CC BY-NC 4.0 https://creativecommons.org/licenses/by-nc/4.0/ Domain‐specific neural networks improve automated bird sound recognition already with small amount of local data © 2022 The Authors. Methods in Ecology and Evolution published by John Wiley & Sons Ltd on behalf of British Ecological Society. Published version Lauha, Patrik; Somervuo, Panu; Lehikoinen, Petteri; Geres, Lisa; Richter, Tobias; Seibold, Sebastian; Ovaskainen, Otso Lauha, P., Somervuo, P., Lehikoinen, P., Geres, L., Richter, T., Seibold, S., & Ovaskainen, O. (2022). Domain‐specific neural networks improve automated bird sound recognition already with small amount of local data. Methods in Ecology and Evolution, 13(12), 2799-2810. https://doi.org/10.1111/2041-210x.14003 2022 Methods Ecol Evol. 2022;00:1–12. | 1wileyonlinelibrary.com/journal/mee3 Received: 6 June 2022 | Accepted: 31 August 2022 DOI: 10.1111/2041-210X.14003 RESEARCH ARTICLE Domainspecific neural networks improve automated bird sound recognition already with small amount of local data Patrik Lauha1 | Panu Somervuo1 | Petteri Lehikoinen1 | Lisa Geres2,3 | Tobias Richter4,2 | Sebastian Seibold4,2 | Otso Ovaskainen1,5,6 1Organismal and Evolutionary Biology Research Programme, Faculty of Biological and Environmental Sciences, University of Helsinki, Helsinki, Finland; 2Berchtesgaden National Park, Berchtesgaden, Germany; 3Goethe University Frankfurt, Faculty of Biological Sciences, Institute for Ecology, Evolution and Diversity, Conservation Biology, Frankfurt am Main, Germany; 4TUM School of Life Sciences, Ecosystem Dynamics and Forest Management, Technical University of Munich, Freising, Germany; 5Department of Biological and Environmental Science, University of Jyväskylä, Jyväskylä, Finland and 6Department of Biology, Centre for Biodiversity Dynamics, Norwegian University of Science and Technology, Trondheim, Norway This is an open access article under the terms of the Creative Commons Attribution-NonCommercial License, which permits use, distribution and reproduction in any medium, provided the original work is properly cited and is not used for commercial purposes. © 2022 The Authors. Methods in Ecology and Evolution published by John Wiley & Sons Ltd on behalf of British Ecological Society. Correspondence Patrik Lauha Email: [email protected] Funding information H2020 European Research Council, Grant/Award Number: 856506; Jane ja Aatos Erkon Säätiö; Norges Forskningsråd, Grant/Award Number: 223257; Suomen Akatemia, Grant/Award Number: 309581 Handling Editor: Sarab Sethi Abstract 1. An automatic bird sound recognition system is a useful tool for collecting data of different bird species for ecological analysis. Together with autonomous recording units (ARUs), such a system provides a possibility to collect bird observations on a scale that no human observer could ever match. During the last decades, progress has been made in the field of automatic bird sound recognition, but recognizing bird species from untargeted soundscape recordings remains a challenge. 2. In this article, we demonstrate the workflow for building a global identification model and adjusting it to perform well on the data of autonomous recorders from a specific region. We show how data augmentation and a combination of global and local data can be used to train a convolutional neural network to classify vocalizations of 101 bird species. We construct a model and train it with a global data set to obtain a base model. The base model is then finetuned with local data from Southern Finland in order to adapt it to the sound environment of a specific location and tested with two data sets: one originating from the same Southern Finnish region and another originating from a different region in German Alps. 3. Our results suggest that finetuning with local data significantly improves the network performance. Classification accuracy was improved for test recordings from the same area as the local training data (Southern Finland) but not for recordings from a different region (German Alps). Data augmentation enables training with a limited number of training data and even with few local data samples significant improvement over the base model can be achieved. Our model outperforms the current state- of- theart tool for automatic bird sound classification. 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License 2 | Methods in Ecology and Evoluon LAUHA et al. 1 | INTRODUCTION Birds are important indicators of the state of the environment (Carignan & Villard, 2002; Fraixedas et al., 2020; O'Connell et al., 2000) and one of the most wellstudied groups of taxa. As ecosystems are suffering from ongoing global biodiversity loss, bird populations all over the world are also decreasing at an alarming rate (Burns et al., 2021; Rosenberg et al., 2019; Sanderson et al., 2006; Xu et al., 2019). Collecting information about the changes in bird communities to efficiently target conservation measures is thus especially important at the moment. Birds are easiest to detect by their vocalizations and passive acoustic monitoring has recently been applied in various studies (Aide et al., 2013; Farina et al., 2011; Frommolt, 2017; Furnas & Callas, 2015; Matsubayashi et al., 2017; Sethi et al., 2022; Shonfield & Bayne, 2017). Autonomous recording units (ARU) are a costeffective tool for collecting audio data and the reliability of the species occurrence data produced by them is comparable to traditionally used humanmade point counts (Darras et al., 2018; Shonfield & Bayne, 2017). ARUs may even outperform human observers in logistically challenging terrain such as mountains, because they can be setup anytime while observers need to get on site each morning. Another advantage of ARUs is that they can stay on site for days or weeks and thus provide a better coverage of bird species than human observers. However, even with the ARUs producing species level identifications for audio data often requires a human expert and can be a laborious task especially when the data collection period is long. The poor scalability of humanbased annotation production motivates the demand for reliable and efficient automatic identification systems. Automated bird sound identification has been studied since the late 1990s (Anderson et al., 1996; Kogan & Margoliash, 1998). Various techniques, such as multilayer perceptrons (McIlraith & Card, 1997), decision trees (Lasseck, 2015), support vector machines (Fagerlund, 2007), classification of singular vectors (Hansson- Sandsten, 2015) or sinusoidal modelling (Härmä, 2003) have been applied and proven to work at least for a limited set of species. However, expanding to dozens or hundreds of species has been considered difficult (Priyadarshani et al., 2018). Currently convolutional neural networks (CNN) are the best performing and most widely used method in automated bird sound recognition (Joly et al., 2021; Kahl et al., 2021). Typically CNNs are applied on spectrogram images, which are obtained from audio data through shorttime Fourier transform. An overview of the development of bird sound identification methods during recent years can be obtained by observing the results of the annual BirdCLEF challenge organized as a part of the Cross Language Evaluation Forum (CLEF). The BirdCLEF challenge has been organized since 2014 to promote the development of machine learning algorithms identifying bird vocalizations. The main task in the competition was initially to build a model for identifying the foreground species in a recording that is primarily targeted at a single bird (Joly et al., 2014), but has afterwards been extended to identifying and localizing all bird species from soundscapes of multiple possibly overlapping vocalizations from varying distances. In the early years of the BirdCLEF competition, the best performing solutions were based on calculating some lowlevel statistics from short audio segments and using these as input for a classifier (Joly et al., 2014, 2015). CNNs were first applied in the challenge in 2016 and have been victorious ever since (Joly et al., 2016, 2017, 2021). Already in the year 2017, all submitted solutions applied CNNs (Joly et al., 2017). The current state- of- theart solution for general bird species identification tasks covering hundreds of species is BirdNET (Kahl et al., 2021) by the Cornell Lab of Ornithology. The number of species (2400 by May, 2022) included in BirdNET clearly exceeds all other existing methods and in terms of mean average precision and F0.5 score, the performance is still comparable with other applications (LeBien et al., 2020; Ruff et al., 2020). Another version of BirdNET, BirdNET- Lite (Kahl, 2020) achieves an even greater number of classes, covering impressive 6000 species, which is more than half of all bird species of the world. Targeted singlespecies recordings can be accurately classified with current CNN- based solutions (Joly et al., 2021; Kahl et al., 2021). However, being able to generalize to noisy soundscapes with overlapping vocalizations from varying distances and adapting to different acoustic environments remains the key challenge in automatic bird sound identification. In this work, we propose a solution to the problem through parameter finetuning. In general, the task of constructing a wellperforming classifier with limited amount of training data is challenging. Transfer learning and finetuning are commonly used methods to address the problem. Transfer learning often refers to reusing a model trained for one task for constructing another model for another task, while finetuning means that a model (or part of it) is simply retrained with new data to adjust the model output for better performance with the new target data (Chollet, 2017). However, transfer learning and 4. Using local data to adjust the recognition model for the target domain leads to improvement over general nontailored solutions. The process introduced in this article can be applied to build a finetuned bird sound classification model for a specific environment. KEYWORDS autonomous recording units, bioacoustics, biomonitoring, bird sound recognition, convolutional neural networks, deep learning, model finetuning 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License | 3 Methods in Ecology and Evoluon LAUHA et al. finetuning as such are general concepts and there are many ways to implement the details in practice. One of the early papers to investigate the issue is Yosinski et al. (2014). Different finetuning strategies for CNNs have been compared by Chu et al. (2016) and Pittaras et al. (2017). An example of applying transfer learning for a network pretrained on ImageNet (Deng et al., 2009) and finetuned with mel spectrogram images computed from the bird audio data is given by Lasseck (2018) and Sevilla and Glotin (2017). In this article, we introduce a workflow for combining global data from existing sound libraries and local data from a specific target domain, to build bird sound identification models for recognizing bird species in a particular region with a specific set of species and a unique acoustic environment. We start by building an identification model based on global training data and show how this socalled global model can be finetuned with local data on Finnish birds to create a local model. Local finetuning is applied by freezing the convolutional layers of the network and retraining the parameters of the remaining two layers. We demonstrate the performance of our model and the advantage given by local finetuning through a case study of 101 bird species from Southern Finland. We also show that the improvement in classification accuracy only applies for test data from the same Southern Finnish domain and not for another test data set from the German Alps. Our solution can be applied for automatic collection of bird occurrence data in different locations around the world, by constructing and finetuning several sitespecific recognition models. One example of this kind of scheme is the international LIFEPLAN Project (2022), which collects bird and bat vocalization data with 1000 globally distributed ARUs and has motivated the methodological development reported in this paper. 2 | MATERIALS AND METHODS The process of training the classification model consisted of extracting bird vocalizations from raw audio data, converting the sound data into spectrograms, and using these as inputs for a convolutional neural network. First we extracted 1000 example vocalizations for 101 bird species from a global bird sound library and trained a socalled global base model with these data. This global model was then finetuned with a local data set, which contains data originating from the same source as the final test data. The local data set contained samples of 72 bird species, on average 146 samples and up to 1089 samples per species. For those 29 species, for which no local data were available, we reused the global data in the finetuning phase. To enable neural network training with a limited number of training samples, we applied data augmentation during both training and finetuning. 2.1 | Audio data We used two main sources of audio data: Macaulay Library (2021) as “global data” and Kerttu data (Lehikoinen et al., 2022), that were collected specifically for the purpose of this project, as “local data”. Macaulay Library (2021) is the world's largest archive of animal sounds and contains over 30 million media files of more than 10,000 bird species and other animals. From the Macaulay Library, we obtained high quality recordings for 101 Finnish bird species (12– 1186 recordings per species). The length of the recordings ranged from a few seconds to several minutes and all recordings were labelled for one main species but could also contain other background species. The 101 species were selected based on their potentiality to appear in the Finnish test data set from Kerttu. The Kerttu data set (Lehikoinen et al., 2022) was collected in Southern Finland during the summer of 2018 with ARUs and contains 1.8 million minutes of audio. The data were labelled in the citizen science platform Kerttu producing two types of data: speciesspecific short time- and frequencyspecified templates with binary labels (target species present or not) and longer 10 s clips labelled with a list of occurring species. We used the as additional local training data for the models and the latter as a test data set. The labelled data for local finetuning contained 13,898 samples (0– 1089 per species). The test data contained 2039 samples excluding clips that were flagged by data annotators to be poor quality and were thus rejected. As a third data set, we used ARU recordings collected in Berchtesgaden National Park, Southern Germany during spring and summer 2021. Recordings were part of a biodiversity monitoring program conducted by national park staff (L. Geres, T. Richter, S. Seibold). To avoid unintended recording of people, notification signs were installed at each site. No further permissions for field work were required. The data contained 2318 twominute recordings from 215 sites in forests and open habitats with species labels generated by expert ornithologists. The data set contained 47 species of the 101 species that were included in our model and was used as an additional test data set to evaluate the model performance. The geographical distribution of different data sets is visualized in Supplement I. The species included in our model and in the different data sets are listed in Supplement II. 2.2 | Data preprocessing To extract the training data from Macaulay data, we applied the Matlab implementation of the Animal Sound Identifier (ASI) (Ovaskainen et al., 2018). Thus, we scanned through the spectrograms of all recordings searching for patterns that based on crosscorrelation repeat within the recordings of one species but not in the recordings of other species. A more detailed description of the process is given in Supplement III. We used the ASI algorithm to find 1000 vocalization candidates for each species. These candidates were used in the training data set as such. In addition, we selected 10 best candidates for each species to be verified by human experts. To do so, we used the crosscorrelation as a ranking score to the best match within the same file, penalized by correlation to already selected candidates. The 10 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License 4 | Methods in Ecology and Evoluon LAUHA et al. automatically extracted candidates were refined and verified manually to ensure that they belong to the correct species and form a set that represents the repertoire of the specific species as well as possible. These 10 manually verified candidates were used as a reserve set to ensure that there were at least some manually curated samples available even for those species that were not found from the finetuning data set. We formed the training data set by extracting 4- s clips around the selected vocalizations from Macaulay and Kerttu data sets. The training data was randomly split into a training set and a validation set to monitor the training process of the model. Each clip was further split into three 3- s subclips with an overlap of 2.5 s between consecutive frames, in order to increase the size of the training data set and introduce temporal variation to the location of vocalizations within the final spectrogram images. We transformed the audio data to spectrogram images using Python library librosa (McFee et al., 2015). All audio files were resampled to 22,050 Hz and converted to logarithmic melscale spectrograms with default parameters of librosa functions librosa. load (sr = 22,050), librosa.feature.melspectrogram (n_fft = 2048, hop_length = 512) and librosa.power_to_db (ref = max). Pixel values of each individual sample were standardized to have zero mean and unit variance. By standardizing each sample individually, information about the intensity differences between the samples were lost. However, this was not considered to be harmful, because the intensity of the signal depends mainly on the distance between the microphone and the vocalizing bird and not on the species to be classified. 2.3 | Classification model We used a simple convolutional neural network as the classification model. For model input, we used 128 × 129 matrices, which correspond to audio clips of 3 s. The inputs can be interpreted as images, where each pixel value corresponds to the intensity of the certain frequency bin at a certain time point. The model structure follows the basic CNN architecture (Chollet, 2017) with four convolutional layers and a classification head of two fully connected layers. The structure of the model is described in Supplement IV. Since any number of bird species can be present at the same time in a recording, we have a multilabel, multiclass classification problem. Consequently, we used sigmoid activations in the output layer. In hidden layers, we used rectified linear unit (ReLU) activations. The model was trained for 10 epochs with binary crossentropy loss function and RMSprop optimizer with learning rate 0.0001 using batch size 64. To train the local model, the two last fully connected layers of the global model were finetuned with the local data for 20 epochs, while other training parameters and the rest of the model weights remained unchanged. The number of epochs was selected by observing the development of validation accuracy over the epochs. The training was stopped when the validation accuracy plateaued. 2.4 | Data augmentation Data augmentation was applied in the training phase mainly for three reasons: to increase the size and diversity of the training data set, to avoid overfitting and to modify the training data to resemble the test data in terms of background noise and signal- to- noise ratio. Augmentation was applied for spectrogram images before logtransformation and standardizing. The set of selected augmentations consisted of methods that are meaningful with audio data. For example, rotation and flipping, which are commonly used for natural images, were not applied since they would result in a spectrogram that no longer represents the same vocalization as the original one. The augmentation methods applied were horizontal and vertical stretch, horizontal and vertical shift, raising to random power, adding noise, mixup and horizontal and vertical masking. Descriptions and visualizations of included augmentation methods are provided in Supplement V. Similar methods have been used by various authors such as Lasseck (2018), Kahl et al. (2021) and several participants in the Cornell Birdcall Identification Contest (2020). 2.5 | Model evaluation The models were tested with the Kerttu test data set. Model predictions were produced by splitting the 10- s test files into slightly overlapping 3- s chunks, predicting for all of them and selecting the maximum prediction for each species. From these predictions, we calculated the area under the ROC- curve (AUC) for each species and compared the performance of our models with the current state- of- theart model BirdNET (Kahl et al., 2021). Since the prevalence of different species varied significantly in the test data, we selected for each species all samples where the species was present and an equal number of randomly selected samples, where the species was not present. Speciesspecific AUCs were calculated for these subsets. The final results were averaged over 20 runs to minimize the random effect regarding the selection of the evaluation set. 2.6 | Quantifying the domain shift To understand the difference between global and local data sets, we used the activations of the last convolutional layer of the global model to represent the data, that is each data point was represented by a 512- dimensional feature vector. Domain shift was quantified by calculating the average Euclidean distance between the local data and the speciesspecific mean of the global data. 3 | RESULTS Our results show that local data are very useful for training the identification model and already 50 samples per class can significantly improve the model performance and help outperform nonlocalized 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License | 5 Methods in Ecology and Evoluon LAUHA et al. models. Finetuning only improves model performance with test data originating from the same domain as finetuning data and not for test data from another source. 3.1 | Performance of global and local models We compared the performance of our models with the current state- of- theart bird sound recognition model BirdNET. We used two versions of BirdNET, the recently published BirdNET- Analyser (Kahl, 2022) and the older BirdNET- Lite (Kahl, 2020). BirdNET- Lite was included in the comparisons, since BirdNET- Analyser does not cover all of the species that were studied. The models were tested with those 43 species that occurred in the test data at least 15 times, to ensure the reliability of test results. When comparing speciesspecific AUCs of different models, the global model matches and exceeds the performance of BirdNET and finetuning with local data improves the performance even further (Figure 1d). The mean of the AUCs was 0.835 for BirdNET- Lite, 0.830 for BirdNET- Analyser, 0.862 for the global model and 0.903 for the local model. Local model produced the best results for almost all species (Figure 1a). We also studied the connection between the number of finetuning samples and the improvement obtained compared to the global model. The amount of local data needed to improve the AUC depends on the species. Even 50– 100 finetuning samples can lead to significant improvement in model performance and help overcome nonfine- tuned methods (Figure 1c). The same effect can be seen in Figure 2, which shows the results from fitting the models with restricted amounts of local data both with and without global pretraining. Even small amounts of local data increase the average of the speciesspecific AUCs. When the amount of local data is large enough, the performance of the model trained with local data only matches the performance of the globally pretrained model. However, when there is not enough local data (for example less than a few hundred samples per species), pretraining with global data is the best solution. To examine the reasons for improved performance of the localized model, we tested the models with the data collected from Berchtesgaden National Park, Southern Germany. Overall, Berchtesgaden data contained vocalizations of 81 species. We evaluated the model performance for those 37 bird species that were included in the Finnish models and occurred in the Berchtesgaden data at least 15 times. Our results show that with German data the performance of the Finnish local model does not exceed the performance of the global model (Figure 1e). This suggests that the improvement achieved with the localized model is not only caused by covering the domain shift between targeted recordings and ARU recordings, but also due to adapting to a specific type of sound environment and locationdependent vocalization types. Speciesspecific AUCs are not directly comparable between Finnish Kerttu data and German data from Berchtesgaden, since the data sets differ from each other in terms of recording duration and quality of labels. However, different models can still be compared in relation to each other. Whereas with Kerttu data set our global model performed better than BirdNET and locally finetuned model still better than the global model, with Berchtesgaden data there are no differences between our models and BirdNET- Lite. BirdNET- Analyser performs better for most species than other models, but for some species the performance is very poor. Compared to truly global BirdNET, which is trained for 2400 bird species worldwide (BirdNET- Lite for over 6000), our “global” model benefits from being trained for only those species that occur in the Finnish data and using local data for finetuning further improves the results. When applying the models on data collected in a different location, these advantages vanish. 3.2 | Inspection of model results While selecting the set of augmentation methods, we tested different combinations of methods with a restricted data set of four species (Fringilla coelebs, Phylloscopus trochilus, Turdus merula and Turdus philomelos) to understand how individual augmentation methods affect the model results. Augmentation trials revealed that none of the augmentation techniques were very effective by themselves, but when random combinations of the techniques were applied together, data augmentation improved the specieswise AUCs by 8– 22 percentage points. The most significant improvement was caused by adding noise and mixup. Mixup did not improve the validation accuracy in the validation data set originating from the same domain as training data, but yielded significant improvement for soundscape data and was therefore included. Heavy use of data augmentation provided two important advantages. Firstly, models could be fit and eligible results obtained with a very limited number of training data. Secondly, it helps to avoid overfitting. We also investigated the difference between local and global data. Local data can be considered as a subset of the global data. We used tdistributed stochastic neighbour embedding (t- SNE) (Van der Maaten & Hinton, 2008) to project the data into 2- dimensional space. As an input to the t- SNE, we used 512- dimensional activations of the last convolutional layer of the network. In all data projections, local data form dense and visually distinct clusters among the broader set of global data, typically located at the edge of global data. We quantified the magnitude of the domain shift as explained in section 2.6 and studied how the domain shift affects the improvement achieved by local finetuning. The correlation between domain shift and AUC improvement was weak (0.314), but statistically significant (p = 0.026). Visualizations of t- SNE embeddings and the relation between domain shift and AUC improvement are provided in Supplement VI. Further inspection of model predictions shows that even though no object detection techniques were explicitly applied, our models are capable of focusing on the important parts of the spectrogram. We studied how different parts of the test set spectrogram affect the prediction produced by the models with perturbationbased class 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License 6 | Methods in Ecology and Evoluon LAUHA et al. activation maps (Zeiler & Fergus, 2014). The class activation maps were created by covering different parts of the spectrogram by setting all pixels of a certain area to zero and comparing the model outputs for the original spectrogram and modified spectrograms. The class activation map reveals, if masking a certain area considerably affects the model output, which means that this area is especially important for producing the original classification. Figure 3 shows how the local model performs on an example clip, where vocalizations of several birds temporally overlap with each other. Overall, the models seem to perform well with most foreground vocalizations. Local model produces more confident predictions and seems to perform better with the background species than the other FIGURE 1 Speciesspecific model comparison for test data from Southern Finland (a– d) and German Alps (e– h). Panels A and E show speciesspecific AUCs for all models ordered according to the AUCs of the locally finetuned model. With Finnish test data our global model exceeds the performance of BirdNET and finetuning with local data further improves the performance for almost all species. Finetuning with Finnish data does not improve the performance with German test data. Panels (b and f) show the distributions of AUCs across different species for all models and panels (d and h) the summary statistics for the same distributions. Panels (c and g) show how the number of local finetuning samples affects the improvement of AUCs compared to the global model. There is no obvious connection between the number of finetuning samples and improvement in local model performance. In all analysis the model performance was only evaluated for those species that occurred at least 15 times in the test data. (a) (b) (d) (c) (e) (f) (h) (g) 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License | 7 Methods in Ecology and Evoluon LAUHA et al. models. However, predicted probabilities for background species are still typically quite low. Moreover, the predictions of all models seem to be rather conservative and the predicted probabilities are often too low. Comparison of model predictions with two 10 s example recordings from the test set is shown in Figure 4. 4 | DISCUSSION The results of our case study demonstrate that our approach can be used to construct bird sound identification models with improved performance compared to existing nonlocalized solutions. The same steps could in principle be repeated with different data to build a localized model for specific type of data, such as data from another location or from specific type of microphones. The number of layers and parameters in our model is small compared to very deep networks used for image classification, such as Inception (Szegedy et al., 2015) or Resnet (He et al., 2016) architectures. Also BirdNET (Kahl et al., 2021) has a more complex model architecture than our model. However, spectrograms have a simpler structure than natural images, and our results indicate that even a shallow model has enough capacity to learn a high number of different vocalizations. Another notable difference between our approach and widely used models such as BirdNET (Kahl et al., 2021) is the processing and use of training data. We have used a relatively small number of training samples selected by either human expert (10 hand curated samples for each species from Macaulay data & 0– 1089 samples for each species from Kerttu data) or machine (1000 training data samples per species from Macaulay data), whereas BirdNET uses enormous amounts of uncurated data for training (Kahl et al., 2021). Generally neural networks benefit from large amounts of data, but with weakly labelled bird sound data, inclusive data selection might cause problems. For example, common species often occur in the background of the recordings labelled to other species. When background calls of common species are FIGURE 2 The importance of local and global data. Red and orange curves show the average AUCs of the model, when the size of the training set was restricted to 5/20/100/ all available samples per species. The more local data are available for finetuning, the better are the results, but already 20 samples per species brings some improvement over the global model. The model performance was evaluated for those species that occurred at least 15 times in the test data, and the AUC was calculated as an average of the speciesspecific AUCs. FIGURE 3 Class activation maps for the locally finetuned model for an example sample extracted from a 10 s test recording. The sample shown on panel (a) contains vocalizations of three species highlighted with manually drawn boxes. Regulus regulus (goldcrest) sings on the high frequencies, ending at 1.5 s. Cuculus canorus (common cuckoo) vocalizes through the whole sample on the lower frequencies and Fringilla coelebs (common chaffinch) starts to sing at 1.5 s on the higher frequencies just below the goldcrest. Panels (b– d) show class activation heatmaps for each species given by the local model. Red areas indicate which parts of the spectrogram have yielded higher predictions for the given class and should roughly correspond to the boxes on panel (a). Locally finetuned model gives predictions 0.324 for goldcrest, 0.485 for common cuckoo and 0.070 for common chaffinch (0.672, 0.732 and 0.256 for the whole 10 s clip). All predictions are based on correct parts of the spectrogram. (a) (b) (c) (d) 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License 8 | Methods in Ecology and Evoluon LAUHA et al. FIGURE 4 Two examples of model predictions for 10- s field recordings from the test data. The species occurring in the recordings are listed on the left panel and highlighted in the spectrogram with manually drawn coloured boxes. All species that were predicted with a confidence higher than 0.15 are listed for all models. In the first example, all models give fairly high predictions for both foreground species Cuculus canorus (common cuckoo) and Anthus trivialis (tree pipit), but the localized model is generally more confident than other models. The localized model is the only model to recognize also the background species Turdus philomelos (song thrush), but with a significantly lower confidence. In the second example, both global and local models recognize both species, but the confidence of the predictions is significantly higher with the local model. BirdNET fails to recognize Fringilla coelebs (common chaffinch), probably because it is a very common and widespread species and the model has learned to ignore it in the background of other vocalizations. 2041210x, 0, Downloaded from https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.14003 by University Of Jyväskylä Library, Wiley Online Library on [18/10/2022]. See the Terms and Conditions (https://onlinelibrary.wiley.com/terms-and-conditions) on Wiley Online Library for rules of use; OA articles are governed by the applicable Creative Commons License