Introduction nan
Syantis yo itilize sistèm otomatik yo etidye gwo ekosistèm. Nan ka a nan zòn forè ak jungle,autonomous recording units (ARUs)se itilize pou anrejistre odyo ki ka itilize pou ede identifye diferan espès nan bèt ak insektis. enfòmasyon sa a ka itilize pou devlope yon pi bon konprann nan distribisyon an nan espès nan yon anviwònman bay. Nan ka a nan zwazo, Google Rechèch note nan mak li yoSepare Birdsong nan Wild pou Klasizasyon"Ekologists sèvi ak zwazo yo konprann sistèm manje ak sante forè - pou egzanp, si gen plis peckers nan yon forè, sa vle di gen yon anpil nan bois moute." Anplis, yo note valè a nan identification ki baze sou odyo: "[Pou] zwazo kominikasyon ak makèt teritwa ak chante ak apèl, li se pi efikas yo identifye yo pa odyo. An reyalite, ekspè ka identifye jiska 10x plis zwazo pa odyo kòm pa vizyon."
Separe Birdsong nan Wild pou Klasizasyondènyèman, nanBirdCLEF+ nan 2025Konpetisyon lanse nanKaggleSoti nan ombrè a nanImèlòganizasyon. ImageCLEF sipòte rechèch nan anotasyon ant lang ak retrè imaj atravè yon varyete domèn. Objektif la nan konpetisyon an se dirèkteman: konsepsyon yon modèl klasifikasyon ki ka presize espès la nan zwazo soti nan yon enskripsyon odyo.
BirdCLEF+ nan 2025ImèlNan kòmansman an, travay la sanble trivial akòz disponiblite a nanGoogle Bird Vocalization (GBV) klasifikasyonEpitou li te ye kòmPerchGBV klasifikatè a se fòmasyon sou prèske 11,000 espès zwazo ak se konsa yon chwa evidan kòm modèl klasifikasyon an.
Google Bird Vocalization (GBV) klasifikasyonSepandan, konpetisyon an gen ladan zwazo sa yo ki deyò fòmasyon an GBV klasifikatè. Kòm yon rezilta, GBV klasifikatè a sèlman reyalize ~60% akòzite sou konpetisyon an tès dataset la BirdCLEF + 2025. Kòm yon rezilta, yon modèl Custom dwe devlope.
Nan gid sa a detaye yon apwòch pou bati pwòp ou klasifikasyon vocalization zwazo ki ka itilize ansanm ak klasifikasyon an GBV yo klasifye yon seleksyon pi lajè nan espès zwazo. Aplikasyon an ap itilize menm teknik baz ki dekri nan Google RechèchRèglemankonsepsyon an sèvi ak dataset la nan konpetisyon an BirdCLEF+ 2025 pou fòmasyon.
Data fòmasyon
The BirdCLEF+ 2025 fòmasyon Dataset, ki gen ladan dosye sipòte, se apeprè 12 GB. Katarye prensipal yo ak dosye ki konpoze estrikti dataset yo:
birdclef_2025
|__ train_audio
|__ train_soundscapes
|__ test_soundscapes
recording_location.txt
taxonomy.csv
train.csv
train_audio
nantrain_audio
direktori a se pi gwo eleman an nan dataset la, ki gen 28,564 enskripsyon odyo fòmasyon nan.ogg
fòma odyo. Enskripsyon odyo yo grupye nan sous-directory ki chak reprezante yon espesyalize zwazo, egzanp:
train_audio
|__amakin1
|__ [AUDIO FILES]
|__amekes
|__ [AUDIO FILES]
...
nantaxonomy.csv
dosye a ka itilize pou rechèch nan non yo syantifik ak komen reyèl nan espès la zwazo reprezante pa non sub-direktori, egzanp:
SUB-DIRECTORY NAME SCIENTIFIC NAME COMMON NAME
amakin1 Chloroceryle amazona Amazon Kingfisher
amekes Falco sparverius American Kestrel
...
Dataset konpetisyon an gen ladan 206 espès zwazo inik, sa vle di 206 klas.Introduction63 nan klas sa yo sepaKouvri nanGBV Classifiersa yoNon-GBVklas yo anjeneral etikèt lè l sèvi avèk yon nimewo klas nimewo:
1139490, 1192948, 1194042, 126247, 1346504, 134933, 135045, 1462711, 1462737, 1564122, 21038, 21116, 21211, 22333, 22973, 22976, 24272, 24292, 24322, 41663, 41778, 41970, 42007, 42087, 42113, 46010, 47067, 476537, 476538, 48124, 50186, 517119, 523060, 528041, 52884, 548639, 555086, 555142, 566513, 64862, 65336, 65344, 65349, 65373, 65419, 65448, 65547, 65962, 66016, 66531, 66578, 66893, 67082, 67252, 714022, 715170, 787625, 81930, 868458, 963335, grasal4, verfly, y00678
Yon kèk nanNon-GBVKlas yo karakterize pa:
- Limited training data.
- Class
1139490
, for example, only contains 2 audio recordings. By contrast, classamakin1
, which is a “known” GBV class, contains 89 recordings.
- Class
- Poor recording quality.
- Highlighting class
1139490
again, both training recordings are of poor quality with one being particularly difficult to discern.
- Highlighting class
Dwa kondisyon sa yo mennen nan yon echilibre enpòtan ant klas nan kantite kalite odyo ak odyo ki disponib.
Pifò nan enstriksyon an odyo anrejistreman nan tou deGBVakNon-GBVklas yo tou gen ladan pale moun, ak paleur anotasyon anrejistreman ak detay tankou kalite a nan zwazo ki te anrejistre ak kote a nan anrejistreman an. Nan pifò -Men, pa tout- ka, anotasyon yo swiv vokalizasyon an nan zwazo anrejistre.
Taktik ki itilize pou fè fas a debalans klas ak prezans anotasyon nan lang moun yo diskite nanBuilding the ClassifierSegondè
train_soundscapes
nantrain_soundscapes
Directory gen ladan prèske 10,000unlabeledenskripsyon odyo nan zwazo. Kòm pral diskite nanBuilding the Classifierseksyon, sa yo anrejistreman odyo ka entegre nan done fòmasyonpseudo-labeling.
test_soundscapes
nantest_soundscapes
Directory a se vè, san yo pa yonreadme.txt
dosye. Kataloz sa a se popilè ak yon seri occulte nan odyo tès lè soumèt rezilta pratik nan konpetisyon an BirdCLEF+ 2025.
Kreye klassifye a
Basic Approach ak Background
Yon prensip prensipal ki itilize paGoogle Rechèchpou fòmasyon klasifikasyon vocalization zwazo yo se tankou sa a:
- Divize anrejistre odyo nan 5 segments segonn.
- Konvèti segman odyo nan mel spectrograms.
- Train yon classifier imaj sou spectrograms mel la.
Yon metòd menm jan an pral swiv nan gid sa a. Classifiateur imaj ki pral fòme se Google aEfficientNet B0modèl. Si ou gen konesans akEfficientNetfanmi modèl, ou konnen ke yo te fèt pou pwosesis imaj efikas.
EfficientNet B0Sepandan, anvan echantiyon odyo ka divize ak konvèti nan mel spectrograms, nou gen pou fè fas a debalans klas ak pwoblèm anotasyon imen an nanTraining DataJeneralman, pwoblèm sa yo pral rezoud respektivman nan agrandi done ak koupe echantiyon odyo.
Anvan plonje nan konsepsyon an aktyèl, sous-seksyon sa yo bay kèk enfòmasyon kout background.
Modèl efikas
Google Rechèch prezante fanmi li yo nanEfficientNetmodèl nan 2019 kòm yon seri deconvolutional neural networkmodèl ki depase modèl state-of-the-art, nan moman sa a, nan tou de gwosè ak pèfòmans.
efikasite2modèl, lanse nan 2021, ofri pi bon pèfòmans ak efikasite paramèt.
Malgre ke fòmasyon nanImèlModèl EfficientNet yo te demontre utilite yo lè transfere nan lòt dataset, fè yo yon chwa atraksyon kòm teknoloji klasifikasyon pou pwojè sa a.
Spectrograms nan Mel
Yon spectrogram mel se yon reprezantan vizyèl nan yon sinyal odyo. Li ta ka pi bon analogize ak yon tèmik pou son.
X-aks nan yon spectrogram mel reprezante dimansyon tan nan sinyal la odyo, ak y-aks reprezante frekans yo nan son yo nan sinyal la. Sepandan, olye pou yo montre tout frekans sou yon skala kontinyèl, frekans yo grupye nanmel bands. Bann sa yo, nan chemen an, espasye soti lè l sèvi avèkmel scaleScale nan mel se yonlogarithmicYon koulè ki apwopriye sistèm odyo moun ak ki jan moun perceive son. koulè yo nan spectrogram la mel reprezante amplitid la nan son yo nan band yo. koulè pi klè reprezante amplitid ki pi wo pandan y ap koulè ki pi fon reprezante amplitid ki pi ba.
konsepsyon
Objè m 'nan diskite sou konsepsyon an se bay yon revizyon segondè-nivo nan apwòch la san yo pa antre nan plis detay. Lojisyèl la fòmasyon prensipal la (fine-tuning) se capture nan sa aPwodwi pou Telefòn("notè fòmasyon") ki konsiste de 4 seksyon prensipal:
- Seksyon 1: Loading done odyo.
- Seksyon 2: pwosesis done odyo.
- Seksyon 3: Mel jenerasyon spectrogram ak preparasyon envantè.
- Seksyon 4: Modèl fòmasyon.
Ou pral observe ke premye 2 selil nan chak seksyon prensipal yo (1) imports itilize pa seksyon sa a ak (2) aConfigselil definye konstan yo itilize nan seksyon sa a ak seksyon ki sot pase yo.
Kòm yon fòmasyon notebook reyèlman kòmanse akSection 0kote pakè baz Python itilize nan tout notebook yo enpòte. Seksyon sa a gen ladan tou logik la pou login nanWeights & Biases("WandB") pou kontwole fòmasyon kouri. Ou pral bezwen anbake pwòp WandB ouAPI keynan notebook la kòm yonKaggle SecretSèvi ak nonWANDB_API_KEY
.
Kòm diskite nanTraining Datanan seksyon an, son nan fòmasyon ki pa etikèt ka entegre nan done yo fòmasyon via pseudo-labeling. Sèvi ak pseudo-labeled done yo diskite nanSection 3.5 - Pseudo-LabelingRemake ke Kaggle anviwònman ki pa GPU yo limite nan 30 GiB nan memwa.
Yon modèl fòmasyon apre konfigirasyon an eksperyans ki dekri nan sous-seksyon yo anba a te pibliye nan Kaggle isit la. Si ou vle, ou ka sèvi ak modèl sa a san yo pa fòmasyon pwòp ou ak ale dirèkteman nan seksyon la Running Inference yo kouri inference sou zwazo odyo.
Yon modèl fòmasyon apre konfigirasyon an eksperyans ki dekri nan sous-seksyon yo anba a te pibliye nan Kaggle isit la. Si ou vle, ou ka sèvi ak modèl sa a san yo pa fòmasyon pwòp ou ak ale dirèkteman nan seksyon la Running Inference yo kouri inference sou zwazo odyo.
Section 1 - Audio Data Loading
nanAudio Data Loadingseksyon nan notebook la:
- Extracts sa yo klas nan set done konpetisyon an BirdCLEF+ 2025 ki pa kouvri pa klasifikasyon an GBV.
- Loader done odyo brik atravè metòd la load_training_audio.
- Kreye yon katwòch processed_audio ak sove yon kopi nan done a odyo chaje kòm dosye .wav nan katwòk sa a.
nanConfigselil nan seksyon sa a gen ladanMAX_FILES
konstan. Konstan sa a espesifye kantite maksimòm nan dosye odyo yo chaje soti nan yon klas bay. Konstan sa a se arbitre mete nan valè a gwo nan1000
pou asire w ke tout dosye odyo yo chaje pounon-GBVklas. Ou ka bezwen ajiste konstan sa a pou pwòp ou eksperimantyèl konfigirasyon. Pou egzanp, si ou chaje done odyo soti nanallklas, ou ta ka bezwen mete konstan sa a nan yon valè pi ba pou evite exhausting memwa disponib.
nanload_training_audio
metòd ka rele ak aclasses
paramèt, ki se yon lis nan klas ki odyo yo pral chaje. Pou pwojè sa a,non-GBVklas yo sove kòm yon lis ak bay nan varyab lamissing_classes
ki se apre sa a pase nanload_training_audio
method via the classes
nan paramèt.
# `missing_classes` list
['1139490', '1192948', '1194042', '126247', '1346504', '134933', '135045', '1462711', '1462737', '1564122', '21038', '21116', '21211', '22333', '22973', '22976', '24272', '24292', '24322', '41663', '41778', '41970', '42007', '42087', '42113', '46010', '47067', '476537', '476538', '48124', '50186', '517119', '523060', '528041', '52884', '548639', '555086', '555142', '566513', '64862', '65336', '65344', '65349', '65373', '65419', '65448', '65547', '65962', '66016', '66531', '66578', '66893', '67082', '67252', '714022', '715170', '787625', '81930', '868458', '963335', 'grasal4', 'verfly', 'y00678']
Ou ka chaje tout 206 klas BirdCLEF+ 2025 pa pase yon lis vid kòm paramèt la klas.
Ou ka chaje tout 206 klas BirdCLEF+ 2025 pa pase yon lis vid kòm paramèt la klas.
metòd la load_training_audio tou aksepte yon opsyon boolean use_slice paramèt. Parametre sa a travay ak konstan LOAD_SLICE defini nan selil la Config. Paramèt la use_slice ak konstan LOAD_SLICE pa itilize ak implemantasyon sa a. Sepandan, yo ka itilize yo chaje yon kantite sèten odyo soti nan chak dosye. Pou egzanp, pou chaje sèlman 5 segonn odyo soti nan chak dosye odyo, mete LOAD_SLICE nan 160000, ki se kalkil kòm 5 fwa vitès la echantiyon nan 32000; ak pase True nan paramèt la use_slice.
nanload_training_audio
metòd tou aksepte yon opsyon booleanuse_slice
paramèt. Sa a paramèt travay akLOAD_SLICE
konstante definye nanConfigselilè. nanuse_slice
paramèt yo akLOAD_SLICE
Kòmansenotitilize ak implemantasyon sa a. Sepandan, yo ka itilize yo chaje yon kantite espesifik nan odyo soti nan chak dosye. Pou egzanp, yo chaje sèlman 5 segonn odyo soti nan chak dosye odyo, meteLOAD_SLICE
nan160000
, ki se kalkil kòm5
times the sampling rate of 32000
Epi paseTrue
nanuse_slice
nan paramèt.
nanload_training_audio
metòd aksepte yon booleanmake_copy
paramèt. Lè paramèt sa a seTrue
Lojisyèl la kreye yonprocessed_audio
directory and saves a copy of each each audio sample as a .wav
dosye nan katwòk la. Kopi odyo yo sove nan sous-katwòk ki reflete klas la ki nan yo.processed_audio
Kataloy la se itilize nan seksyon an pwochen pou sove echantiyon odyo modifye nan disk la san yo pa afekte kataloy yo dataset BirdCLEF+ 2025.
nanload_training_audio
metòd retire yon dictionnaire nan done odyo chaje lè l sèvi avèk non klas yo kòm kle yo. Chak valè nan dictionnaire a se yon lis nan tuples nan fòm la(AUDIO_FILENAME, AUDIO_DATA)
:
{'1139490': [('CSA36389.ogg', tensor([[-7.3379e-06, 1.0008e-05, -8.9483e-06, ..., 2.9978e-06,
3.4201e-06, 3.8700e-06]])), ('CSA36385.ogg', tensor([[-2.9545e-06, 2.9259e-05, 2.8138e-05, ..., -5.8680e-09, -2.3467e-09, -2.6546e-10]]))], '1192948': [('CSA36388.ogg', tensor([[ 3.7417e-06, -5.4138e-06, -3.3517e-07, ..., -2.4159e-05, -1.6547e-05, -1.8537e-05]])), ('CSA36366.ogg', tensor([[ 2.6916e-06, -1.5655e-06, -2.1533e-05, ..., -2.0132e-05, -1.9063e-05, -2.4438e-05]])), ('CSA36373.ogg', tensor([[ 3.4144e-05, -8.0636e-06, 1.4903e-06, ..., -3.8835e-05, -4.1840e-05, -4.0731e-05]])), ('CSA36358.ogg', tensor([[-1.6201e-06, 2.8240e-05, 2.9543e-05, ..., -2.9203e-04, -3.1059e-04, -2.8100e-04]]))], '1194042': [('CSA18794.ogg', tensor([[ 3.0655e-05, 4.8817e-05, 6.2794e-05, ..., -5.1450e-05,
-4.8535e-05, -4.2476e-05]])), ('CSA18802.ogg', tensor([[ 6.6640e-05, 8.8530e-05, 6.4143e-05, ..., 5.3802e-07, -1.7509e-05, -4.8914e-06]])), ('CSA18783.ogg', tensor([[-8.6866e-06, -6.3421e-06, -3.1125e-05, ..., -1.7946e-04, -1.6407e-04, -1.5334e-04]]))] ...}
The method also returns basic statistics describing the data loaded for each class as a comma-separated-value string. You can optionally export these statistics to inspect the data.
class,sampling_rate,num_files,num_secs_loaded,num_files_loaded
1139490,32000,2,194,2
1192948,32000,4,420,4
1194042,32000,3,91,3
...
Section 2 - Audio Data Processing
The Audio Data Processingseksyon nan notebook la:
- Opsyonèlman strips segments silent ak strips odyo yo elimine pi anotasyon moun soti nan odyo grès. stripping segments silent elimine pati irrelevant nan sinyal odyo a.
- Optional Augmentes odyo pou klas minoritè yo ede rezoud echilib la klas. Augmentation odyo konsiste nan (1) ajoute yon sinyal odyo ki te kreye alegan, (2) chanje ritm la nan odyo a brik, oswa (3) ajoute yon sinyal odyo ki te kreye alegan ak chanje ritm la nan odyo a brik.
Seksyon 2.1 - Detekte segments silen
nandetect_silence
method is used to "slide" over each raw audio sample and identify silent segments by comparing the root-mean square (RMS)se valè a nan yon segman bay nan yon kouch espesifye. Si RMS a se anba kouch la, segman an se identifye kòm yon segman silan. Konstan yo sa yo espesifye nanConfigselil nan seksyon sa a kontwole konpòtman an nandetect_silence
Metòd :
SIL_FRAME_PCT_OF_SR = 0.25
SIL_FRAME = int(SR * SIL_FRAME_PCT_OF_SR)
SIL_HOP = int(1.0 * SIL_FRAME)
SIL_THRESHOLD = 5e-5
SIL_REPLACE_VAL = -1000 # Value used to replace audio signal values within silent segments
nanSIL_FRAME
and SIL_HOP
constants can be modified to adjust how the method "slides" over the raw audio. Similarly, the SIL_THRESHOLD
valè ka modifye yo fè metòd la plis agresif oswa konservatè akòz identification nan segments silent.
The method outputs a dictionary of silent segment markers for each file in each class. Audio files with no detected silent segments are identified by empty lists.
{'1139490': {'CSA36389.ogg': [0, 8000, 16000, 272000, 280000, 288000, 296000, 304000], 'CSA36385.ogg': [0, 8000, 16000, 24000, 240000, 248000, 256000]}, '1192948': {'CSA36388.ogg': [0, 8000, 16000, 24000, 256000, 264000, 272000, 288000], 'CSA36366.ogg': [0, 8000, 16000, 24000, 256000, 264000, 272000, 280000, 288000], 'CSA36373.ogg': [0, 8000, 16000, 24000, 256000, 264000, 272000, 288000], 'CSA36358.ogg': [8000]}, '1194042': {'CSA18794.ogg': [], 'CSA18802.ogg': [], 'CSA18783.ogg': [0, 8000, 16000, 24000, 600000, 608000, 616000]}, '126247': {'XC941297.ogg': [], 'iNat1109254.ogg': [], 'iNat888527.ogg': [], 'iNat320679.ogg': [0], 'iNat888729.ogg': [], 'iNat146584.ogg': []}, '1346504': {'CSA18803.ogg': [0, 8000, 16000, 24000, 3000000, 3008000, 3016000], 'CSA18791.ogg': [], 'CSA18792.ogg': [], 'CSA18784.ogg': [0, 8000, 16000, 1232000, 1240000, 1248000], 'CSA18793.ogg': [0, 8000, 16000, 24000, 888000]} ...}
Seksyon 2.2 - Retire segments silen ak elimine anotasyon moun
The USE_REMOVE_SILENCE_AND_HUMAN_ANNOT
konstante definye nanConfig cell of this section specifies if audio should be stripped of silent segments akPwodwi pou retiremost human annotations.
USE_REMOVE_SILENCE_AND_HUMAN_ANNOT = True
nanremove_silence_and_human_annot
metòd strips segman silen soti nan echantiyon odyo lè l sèvi avèk pwodiksyon an soti nandetect_silence
method. Further, it implements logic to handle human annotations based on a simple observation: many audio samples, namely those with human annotations, tendyo dwe gen estrikti sa yo:
| < 10s | ~1s | |
| BIRDSONG | SILENCE | HUMAN ANNOTATION |
The birdsong and human annotation sections themselves may contain silent segments. However, as seen in the diagram above, the bird vocalization recordings often occur within the first few seconds of audio. Therefore, a simple, if imperfect, approach to deal with human annotations is to slice audio samples at the first silent segment marker that occurs outside of a specified window, under the assumption that a human annotation follows that silent segment. The remove_silence_and_human_annot
Lojisyèl la itilizeANNOT_BREAKPOINT
constant in the Config cell to check if a silent segment marker lies outside the window specified by ANNOT_BREAKPOINT
, expressed in number of seconds. If it does, the logic slices the raw audio at that marker and only retains the data that occurs before it. A manual inspection of processed audio during experimentation revealed this approach to be satisfactory. However, as mentioned in the Training DataSegondè, genYon kèk audio recordings where the human annotation Premyeenskripsyon zwazo. Logik la deskripsyon isit la fèpa address those cases. Some audio samples feature long sequences of recorded birdsong and these samples often do not have silent segments. Such samples are unaffected by the previously described logic and kept in their entirety.
A second constant, SLICE_FRAME
, can be optionally used in a final processing step to return an even more refined slice of the processed audio. Set SLICE_FRAME
to the number of seconds of processed audio that you want to retain.
The remove_silence_and_human_annot
metòd sove processe odyo nan disk anba katwòk laprocessed_audio
atravèsave_audio
parameter, which is passed as True
Metòd la retire yon dictionary nanTotal nansekondè nan processe odyo pou chak klas.
{'1139490': 14, '1192948': 29, '1194042': 24, '126247': 48, '1346504': 40, '134933': 32, '135045': 77, ...}
The get_audio_stats
se metòd la itilize apreremove_silence_and_human_annot
to get the average number of seconds of audio across all classes.
Section 2.3 - Calculating Augmentation Turns for Minority Classes
Kòm te di nanTraining Dataseksyon, klas yo pa balans. Augmentation se itilize nan seksyon sa a notebook yo ede rezoud debalans la lè l sèvi avèk nimewo an mwayèn nan segonn nan odyo nan tout klas yo, tankou bay paget_audio_stats
method. Classes with total seconds of processed audio below the average are augmented. The get_augmentation_turns_per_class
metòd determines nimewo a nan augmentation tours pou chak klas minoritè lè l sèvi avèk nimewo an mwayèn nan segonn pou chak echantiyon odyo pwosesis.
TURNS = (AVG_SECS_AUDIO_ACROSS_CLASSES - TOTAL_SECS_AUDIO_FOR_CLASS)/AVG_SECS_PER_AUDIO_SAMPLE
Minority classes further below the average will have more augmentation turns versus minority classes nearer the average which will have fewer augmentation turns.
The get_augmentation_turns_per_class
Ki gen ladan aAVG_SECS_FACTOR
konstan ki ka itilize pou ajiste valè a pou
konstan ka itilize yo fè logik la plis konsèvatif oswa agresif lè kalkil nimewo a nan augmentation tours.
The get_augmentation_turns_per_class
Ki gen ladan aAVG_SECS_FACTOR
konstan ki ka itilize pou ajiste valè a pou
average number of seconds of audio across all classes. The constant can be used to make the logic more conservative or aggressive when calculating the number of augmentation turns.
Seksyon 2.4 - Kòmanse Augmentations
nanUSE_AUGMENTATIONS
konstante definye nanConfig cell of this section specifies if audio should be augmented.
USE_AUGMENTATIONS = True
As mentioned earlier, audio augmentation consists of (1) adding a randomly generated noise signal, (2) changing the tempo of the raw audio, or (3) adding a randomly generated noise signal and changing the tempo of the raw audio. The add_noise
and change_tempo
methods encapsulate the logic for adding a noise signal and changing the tempo respectively. The noise signal range and tempo change range can be adjusted via the following constants in the ConfigSelilè :
NOISE_RNG_LOW = 0.0001
NOISE_RNG_HIGH = 0.0009
TEMPO_RNG_LOW = 0.5
TEMPO_RNG_HIGH = 1.5
nanrun_augmentations
method runs the augmentations using the output from the get_augmentations_turns_per_class
method. For those classes that will be augmented, the logic:
- Randomly chwazi yon echantiyon odyo pwosesis (yo se segments silent deja retire) pou agrandi.
- Randomly selects the augmentation to perform: (1) adding noise, (2) changing the tempo, or (3) adding noise and changing the tempo.
- Saves the augmented audio to disk under the appropriate class within the
processed_audio
directory.
While the notebook logic augments minority classes with total seconds of audio below the average, it ignores those classes with total seconds of audio above the average. This approach was taken to manage available memory and with the understanding that the class imbalance is further addressed through choice of the loss function.
Section 3 - Mel Spectrogram Generation and Input Preparation
nanMel Spectrogram Generation and Input Preparation section of the notebook:
- Divize done odyo pwosesis nan fòmasyon ak lis validasyon.
- Splits audio into 5 second frames.
- Genere mel spectrograms pou chak 5 sekondè kad odyo.
- Resize spectrograms mel nan yon gwosè objektif nan (224, 224).
- Opsyonèlman chaje echantiyon done pseudo-labeled pou ogmante done fòmasyon.
- One-hot enkode done fòmasyon ak etikèt done validasyon.
- Konstriksyon objè TensorFlow Dataset soti nan lis done fòmasyon ak validasyon.
- Optionally uses MixUp logic to augment training data.
Section 3.1 - Splitting Processed Audio Data
Sèvi ak done a odyo se chaje soti nanprocessed_audio
dosye. Done a se divize an 4 lis:
training_audio
training_labels
validation_audio
validation_labels
Etikèt yo, nan kou, non klas yo ki asosye ak egzanp odyo yo.SPLIT
constant defined in the Config cell controls the split ratio between the training and validation data lists. Processed audio data is shuffled before splitting.
Section 3.2 - Splitting Audio into Frames
Audio is split into 5 second segments using the frame_audio
metòd, ki sèvi ak TensorFlowsignal.frame
metòd nan divize chak egzanp odyo. Konstan yo anba a nanConfig cell control the split operation:
FRAME_LENGTH = 5
FRAME_STEP = 5
Section 3.3 - Generating Mel Spectrograms
Mel spectrograms are generated for each 5 second audio frame generated in Section 3.2 via the audio2melspec
metòd. Konstan yo ki anba a nanConfigselil precifye paramèt yo itilize lè kreye spectrograms mel, tankou kantite band mel, frekans minimòm, ak frekans maksimòm:
# Mel spectrogram parameters
N_FFT = 1024 # FFT size
HOP_SIZE = 256
N_MELS = 256
FMIN = 50 # minimum frequency
FMAX = 14000 # maximum frequency
The frequency band was chosen to reflect the Potansyèlvaryete a nan pi fò vocalizations zwazo. Sepandan, kèk espès zwazo ka vocalize deyò nan varyete sa a.
Seksyon 3.4 - Resize Mel Spectrograms
The to_melspectrogram_image
se metòd la itilize pou konvèti chak spectrogram mel nan yonpillow
Image
object. Each Image
Objè a se ranplase nan(224, 224)
which is the input dimension expected by the EfficientNet B0 model.
Seksyon 3.5 - Loading nan Done Pseudo-Labeled
Kòm te di nanTraining DataSegondè, nantrain_soundscapes
Directory gen ladan prèske 10,000unlabeled audio recordings of birdsong. These audio recordings can be incorporated into the training data via pseudo-labeling. A simple process to create pseudo-labeled data is as follows:
- Train yon klasifikatè san yo pa pseudo-etikèt done.
- Load training soundscape audio files.
- Segment each audio soundscape into 5 second frames.
- Jere spectrograms mel pou chak kad 5 sekondè ak redimansyon nan (224, 224).
- Run predictions on each resized mel spectrogram using the classifier that you trained in the first step.
- Keep the predictions above a desired confidence level and save the mel spectrograms for those predictions to disk under the predicted class label.
- Train your classifier again using the psuedo-labeled data.
Pseudo-labeled data can improve the performance of your classifier. If you want to generate your own pseudo-labeled data, you should continue with the remaining sections to train a classifier Pa genpseudo-labeled done. Lè sa a, lè l sèvi avèk classifier ou kreye seri pwòp ou nan pseudo-labeled done lè l sèvi avèk pwosesis la desine pi wo a. Finalman, re-train classifier ou lè l sèvi avèk pseudo-labeled done ou.
This implementation does not use pseudo-labeled data. However, you can modify the inference notebook referenced in the Running Inference section to generate pseudo-labeled data.
mete nanUSE_PSEUDO_LABELS
Konstan nanConfigselilèFalse
to skip the use of pseudo-labeled data.
Seksyon 3.6 - Kòd etikèt
The process_labels
method is used to one-hot encode labels. One-hot encoded labels are returned as NumPy arrays and added to the training label and validation label lists.
Section 3.7 - Converting Training and Validation Data Lists to TensorFlow Dataset
Objè
Dataset
nan TensorFlowdata.Dataset.from_tensor_slices
se metòd la itilize yo kreye TensorFlowDataset
objects from the training and validation data lists. The shuffle
Metòd la se rele sou fòmasyon anDataset
objekte pou shuffle done fòmasyon anvan batching.batch
Metòd la se rele sou tou deDataset
Objè yo batch fòmasyon ak valizyon dataset.BATCH_SIZE
Konstan nanConfigselilè kontwole gwosè batch la.
Section 3.8 - Using MixUp to Augment Training Data
As you may already know, MixUp is a data augmentation technique that effectively mixes two images together to create a new data sample. The class for the blended image is a blend of the classes associated with the original 2 images. The mix_up
method, along with the sample_beta_distribution
metòd, enkapsule opsyonèl la Logic MixUp.
This implementation uses MixUp to augment the training data. To use MixUp, set the USE_MIXUP
Konstan nanConfig cell to True
.
Seksyon 4 - fòmasyon modèl
nanModel Trainingseksyon nan notebook la:
- Initializes and configures a WandB project to capture training run data.
- Kreye ak kompile modèl la EfficientNet B0.
- Trains the model.
- Save modèl la fòmasyon nan disk.
Section 4.1 - Initializing and Configuring WandB Project
Verifye ke ou te ajoute pwòp ou WandB API kle kòm yon Kaggle Secret nan notebook la ak ke metòd la WandB login nan seksyon 0 nan notebook la te retounen True.
Verifye ke ou te ajoute pwòp ou WandB API kle kòm yon Kaggle Secret nan notebook la ak ke metòd la WandB login nan seksyon 0 nan notebook la te retounen True.
nanConfigselil nan seksyon sa a gen lògik pou inisyalize ak konfigirasyon yon nouvo pwojè WandB (si pwojè a pa deja egziste) ki pral retire done kouri fòmasyon:
wandb.init(project="my-bird-vocalization-classifier")
config = wandb.config
config.batch_size = BATCH_SIZE
config.epochs = 30
config.image_size = IMG_SIZE
config.num_classes = len(LABELS)
Evidentman, ou ka chanje non nan pwojè amy-bird-vocalization-classifier
to your desired WandB project name.
Section 4.2 - Building and Compiling the EfficientNet B0 Model
nanbuild_model
method is used to load the pre-trained EfficientNet B0 model with ImageNet weights and without the top layer:
model = EfficientNetB0(include_top=False, input_tensor=inputs, weights="imagenet")
Modèl la se freze yo sèvi ak pèfòmans ImageNet pre-touche ak objektif la nan sèlmanunfreeze(i.e. tren) kouch nan etap final la nan modèl la:
# Unfreeze last `unfreeze_layers` layers and add regularization
for layer in model.layers[-unfreeze_layers:]:
if not isinstance(layer, layers.BatchNormalization):
layer.trainable = True
layer.kernel_regularizer = tf.keras.regularizers.l2(L2_RATE)
The constant UNFREEZE_LAYERS
nanConfig cell specifies the number of layers to unfreeze.
Top la nan modèl la se rekonstrue ak yon finalDense
kouch ki reflete kantite espesifikasyon an nan espesifikasyon an.Categorical focal cross-entropyse chwazi kòm fonksyon pèdi pou ede rezoud echilib la nan klas la.LOSS_ALPHA
akLOSS_GAMMA
Konstan nanConfigselil yo itilize ak fonksyon nan pèdi.
Seksyon 4.3 - Modèl fòmasyon
nanfit
method is called on the compiled model
soti nanSection 4.2 to run training. Note that a learning rate schedulerRetounen nanlr_scheduler
, se itilize nan plas nan yon vitès aprantisaj konstante. Yon vitès aprantisaj inisyal nan4.0e-4
se hardcoded nan callback la. Rate a aprantisaj diminye nan 2 etap ki baze sou kont epòk la. Nimewo a nan epòk fòmasyon se kontwole paEPOCHS
Konstan nanConfignan selil.
Section 4.4 - Model Saving
nansave
method is called on the compiled model
apre fòmasyon pou sove modèl la nan disk.
model.save("bird-vocalization-classifier.keras")
Rezilta nan fòmasyon
Running the notebook should produce the following training results, assuming you used the experimental setup that was described in the Building the ClassifierSegondè :
Kòm wè, egzatè a se yon ti kras pi wo pase 90% ak egzatè a validasyon se sou 70% apre fòmasyon pou 30 epòk. Sepandan, kòm wè, egzatè a validasyon fluctuate enpòtan. Varyasyon sa a se pati nan atribye a echilib la nan klas la ak memwa ki disponib limite itilizasyon an nan augmentations adisyonèl yo konplètman rezoud echilib la. Rezilta suggere ke modèl la peze soti nan overfitting sou done fòmasyon ak pa jeneralize kòm byen ke li ta dwe espere pou. Sepandan, modèl la ka itilize pou prediksyon ansanm ak klasifikasyon GBV dapre objektif la orijinal la.
Running Inference
sa aPwodwi pou Telefòn("Inferans notebook") ka itilize pou kouri inferans. Logik la inferans notebook sèvi ak tou de modèl la GBV klassifye ak modèl la ou te fòme nan seksyon an anvan. Li kouri inferans sou dosye yo soundcapes san etikèt nantrain_soundscapes
katagori. Chak soundcapes dosye odyo se divize nan 5 segonn kad.MAX_FILES
konstante definye nanConfigselilèSection 0 of the notebook controls the number of soundscapes audio files that are loaded for inference.
Notebook a inferans premye genere prediksyon lè l sèvi avèk GBV klasifikatè a. Prediksyon yo pou 143 BirdCLEF+ 2025 konpetisyon dataset klas yo konnen pou klasifikatè a GBV yo izolasyon. Si maksimòm probabilite nan mitan 143 "konnen" klas yo se pi wo a oswa menm jan ak:GBV_CLASSIFIER_THRESHOLD
, then the GBV predicted class is selected as the true class. If the maximum probability among the 143 "known" classes is below GBV_CLASSIFIER_THRESHOLD
, li se asume ke klas la reyèl se nan mitan 63 klas yo "eksepsyonèl" pou klasifikasyon an GBV - sa vle di klas yo itilize yo fòme modèl la nan seksyon an anvan. Lojisyèl la Lè sa a, kouri prediksyon lè l sèvi avèk modèl la finetuned. Klas la prezante soti nan set la prediksyon sa a se apre sa chwazi kòm klas la reyèl.
nanGBV_CLASSIFIER_THRESHOLD
constant is defined in the ConfigselilèSection 5nan notebook a enkyetid. prezantasyon yo se pwodiksyon nan 2 dosye:
- A
preds.csv
file that captures the prediction and prediction probability for each 5-second soundscape slice. - Yon dosye submission.csv ki retire tout probabilite klas nan fòma pou konpetisyon an BirdCLEF+ 2025.
Sitou wout la nan modèl la fini ou nan premye selil la nan seksyon 4 nan notebook a inferans.
Konfigire wout la nan modèl fin vye granmoun ou nan premye selil la nanSection 4soti nan notebook la inference.
Jodi a nan travay
Notebook la fòmasyon ka itilize yo fòme yon modèl sou tout 206 klas BirdCLEF+ 2025, elimine bezwen an pou GBV klasifikatè, omwen akòz konpetisyon dataset la. Kòm te di pi bonè, pase yon lis vid,[]
, to the load_training_audio
metòd la pral chaje done odyo soti nan tout klas yo.MAX_FILES
akLOAD_SLICE
konstan yo ka itilize yo limite kantite odyo chaje nan lòd yo travay nan limit nan yon anviwònman notebook Kaggle.
Natirèlman, yon modèl pi presizyon ka fòme lè l sèvi avèk yon kantite plis done fòmasyon. Ideyalman, yon kantite pi gwo nan augmentations ta dwe itilize pou rezoud echilib la nan klas la. Anplis de sa, lòt teknik augmentation, tankou CutMix, ta ka aplike pou plis ogmante done fòmasyon yo. Sepandan, estrateji sa yo mande pou yon anviwònman devlopman plis robust.