Spaces:
biodivx
/
Sleeping

Your Name commited on
Commit
dddb9f9
1 Parent(s): 36dbf7a

update app.py

Browse files
.gitignore CHANGED
@@ -1 +1,2 @@
1
  *.pth
 
 
1
  *.pth
2
+ assets/
BirdAST_Baseline_5folds_label_map.csv DELETED
@@ -1,729 +0,0 @@
1
- scientific_name,species_id
2
- Accipiter_superciliosus,0
3
- Akletos_melanoceps,1
4
- Amazona_amazonica,2
5
- Amazona_diadema,3
6
- Amazona_farinosa,4
7
- Amazona_festiva,5
8
- Amblycercus_holosericeus,6
9
- Ammodramus_aurifrons,7
10
- Ammonastes_pelzelni,8
11
- Ampelion_rufaxilla,9
12
- Anabazenops_dorsalis,10
13
- Anairetes_parulus,11
14
- Andigena_hypoglauca,12
15
- Anhima_cornuta,13
16
- Anisognathus_lacrymosus,14
17
- Anthracothorax_viridigula,15
18
- Antrostomus_rufus,16
19
- Ara_ararauna,17
20
- Ara_chloropterus,18
21
- Ara_severus,19
22
- Aramides_cajaneus,20
23
- "Aramus_Vieillot,",21
24
- Aratinga_leucophthalma,22
25
- Ardea_cocoi,23
26
- Arremon_abeillei,24
27
- Arremon_assimilis,25
28
- Arremon_taciturnus,26
29
- Asthenes_flammulata,27
30
- Atlapetes_latinuchus,28
31
- Atticora_tibialis,29
32
- Attila_bolivianus,30
33
- Attila_cinnamomeus,31
34
- Attila_citriniventris,32
35
- Attila_spadiceus,33
36
- Automolus_infuscatus,34
37
- Automolus_ochrolaemus,35
38
- Automolus_paraensis,36
39
- Automolus_rufipileatus,37
40
- Automolus_subulatus,38
41
- Basileuterus_tristriatus,39
42
- Berlepschia_rikeri,40
43
- Boissonneaua_matthewsii,41
44
- Brotogeris_chrysoptera,42
45
- Brotogeris_cyanoptera,43
46
- Brotogeris_sanctithomae,44
47
- Brotogeris_versicolurus,45
48
- Bucco_capensis,46
49
- Buteo_nitidus,47
50
- Buteogallus_schistaceus,48
51
- Buteogallus_urubitinga,49
52
- Buthraupis_montana,50
53
- Cacicus_cela,51
54
- Cacicus_chrysonotus,52
55
- Cacicus_haemorrhous,53
56
- Cacicus_leucoramphus,54
57
- Calidris_fuscicollis,55
58
- Campephilus_melanoleucos,56
59
- Campephilus_pollens,57
60
- Campephilus_rubricollis,58
61
- Camptostoma_obsoletum,59
62
- Campylorhamphus_procurvoides,60
63
- Campylorhynchus_fasciatus,61
64
- Cantorchilus_leucotis,62
65
- Capito_auratus,63
66
- Capito_aurovirens,64
67
- Capito_niger,65
68
- Capsiempis_flaveola,66
69
- Carduelis_magellanica,67
70
- Caryothraustes_canadensis,68
71
- Catharus_fuscater,69
72
- Celeus_elegans,70
73
- Celeus_flavus,71
74
- Celeus_grammicus,72
75
- Celeus_torquatus,73
76
- Celeus_undatus,74
77
- Cephalopterus_ornatus,75
78
- Ceratopipra_erythrocephala,76
79
- Ceratotriccus_granadensis,77
80
- Cercomacra_cinerascens,78
81
- Cercomacra_manu,79
82
- Cercomacra_nigrescens,80
83
- Cercomacroides_fuscicauda,81
84
- Cercomacroides_serva,82
85
- Cercomacroides_tyrannina,83
86
- Certhiasomus_stictolaemus,84
87
- Certhiaxis_cinnamomeus,85
88
- Certhiaxis_mustelinus,86
89
- Chaetura_brachyura,87
90
- Chaetura_spinicaudus,88
91
- Chamaeza_mollissima,89
92
- Chamaeza_nobilis,90
93
- Charadrius_collaris,91
94
- Chelidoptera_tenebrosa,92
95
- Chionomesa_fimbriata,93
96
- Chiroxiphia_pareola,94
97
- Chlorestes_cyanus,95
98
- Chloroceryle_americana,96
99
- Chlorophanes_spiza,97
100
- Chlorophonia_pyrrhophrys,98
101
- Chlorornis_riefferii,99
102
- Chlorospingus_flavopectus,100
103
- Chlorostilbon_mellisugus,101
104
- Chlorostilbon_olivaresi,102
105
- Chordeiles_pusillus,103
106
- Chrysomus_icterocephalus,104
107
- Ciccaba_albitarsis,105
108
- Cinnycerthia_peruana,106
109
- Cissopis_leverianus,107
110
- Cistothorus_platensis,108
111
- Cnemoscopus_rubrirostris,109
112
- Cnemotriccus_fuscatus,110
113
- Cnipodectes_subbrunneus,111
114
- Coccycua_minuta,112
115
- Coccyzus_melacoryphus,113
116
- Coeligena_violifer,114
117
- "Coereba_Vieillot,",115
118
- Colaptes_atricollis,116
119
- Colibri_coruscans,117
120
- Columba_speciosa,118
121
- Columbina_cruziana,119
122
- Columbina_minuta,120
123
- Conirostrum_bicolor,121
124
- Conirostrum_margaritae,122
125
- Conopias_parvus,123
126
- Conopias_trivirgatus,124
127
- Conopophaga_aurita,125
128
- Contopus_fumigatus,126
129
- Contopus_punensis,127
130
- Corythopis_torquatus,128
131
- Cranioleuca_antisiensis,129
132
- Cranioleuca_berlepschi,130
133
- Cranioleuca_gutturata,131
134
- Cranioleuca_muelleri,132
135
- Cranioleuca_vulpecula,133
136
- Cranioleuca_vulpina,134
137
- Crax_alector,135
138
- Crax_globulosa,136
139
- Crotophaga_ani,137
140
- Crotophaga_major,138
141
- Crypturellus_bartletti,139
142
- Crypturellus_casiquiare,140
143
- Crypturellus_cinereus,141
144
- Crypturellus_duidae,142
145
- Crypturellus_soui,143
146
- Crypturellus_undulatus,144
147
- Crypturellus_variegatus,145
148
- Cyanerpes_caeruleus,146
149
- Cyanicterus_cyanicterus,147
150
- Cyanocorax_heilprini,148
151
- Cyanocorax_violaceus,149
152
- Cyanocorax_yncas,150
153
- Cyanoloxia_rothschildii,151
154
- Cyanolyca_viridicyanus,152
155
- Cyclarhis_gujanensis,153
156
- Cymbilaimus_lineatus,154
157
- Cyphorhinus_arada,155
158
- Cyphorhinus_thoracicus,156
159
- Cyphos_macrodactylus,157
160
- Dacnis_albiventris,158
161
- Daptrius_ater,159
162
- Deconychura_longicauda,160
163
- Dendrexetastes_rufigula,161
164
- Dendrocincla_fuliginosa,162
165
- Dendrocincla_merula,163
166
- Dendrocolaptes_certhia,164
167
- Dendrocolaptes_hoffmannsi,165
168
- Dendrocolaptes_picumnus,166
169
- Dendrocygna_autumnalis,167
170
- Dendroplex_kienerii,168
171
- Deroptyus_accipitrinus,169
172
- Dichrozona_cincta,170
173
- Diglossa_cyanea,171
174
- Diglossa_mystacalis,172
175
- Diglossa_sittoides,173
176
- Donacobius_atricapilla,174
177
- Dromococcyx_phasianellus,175
178
- Drymophila_devillei,176
179
- Drymophila_striaticeps,177
180
- Dryocopus_lineatus,178
181
- Egretta_alba,179
182
- Egretta_thula,180
183
- Elaenia_flavogaster,181
184
- Elaenia_pallatangae,182
185
- Elaenia_pelzelni,183
186
- Elaenia_ruficeps,184
187
- Elliotomyia_chionogaster,185
188
- Empidonomus_varius,186
189
- Epinecrophylla_amazonica,187
190
- Epinecrophylla_gutturalis,188
191
- Epinecrophylla_haematonota,189
192
- Epinecrophylla_leucophthalma,190
193
- Epinecrophylla_ornata,191
194
- Eriocnemis_alinae,192
195
- Eubucco_richardsoni,193
196
- Euchrepomis_humeralis,194
197
- Eucometis_penicillata,195
198
- Euphonia_cayennensis,196
199
- Euphonia_chlorotica,197
200
- Euphonia_chrysopasta,198
201
- Euphonia_cyanocephala,199
202
- Euphonia_minuta,200
203
- Euphonia_plumbea,201
204
- Euphonia_rufiventris,202
205
- Euphonia_xanthogaster,203
206
- Eupsittula_pertinax,204
207
- Eurypygidae,205
208
- Falco_deiroleucus,206
209
- Falco_femoralis,207
210
- Falco_magnirostris,208
211
- Falco_rufigularis,209
212
- Florisuga_mellivora,210
213
- Formicarius_analis,211
214
- Formicarius_colma,212
215
- Formicivora_grisea,213
216
- Forpus_crassirostris,214
217
- Forpus_xanthops,215
218
- Frederickena_unduliger,216
219
- Frederickena_viridis,217
220
- Fringilla_capensis,218
221
- Fringilla_psaltria,219
222
- Furnarius_figulus,220
223
- Furnarius_leucopus,221
224
- Furnarius_minor,222
225
- Furnarius_torridus,223
226
- Galbacyrhynchus_leucotis,224
227
- Galbalcyrhynchus_purusianus,225
228
- Galbula_cyanescens,226
229
- Galbula_cyanicollis,227
230
- Galbula_dea,228
231
- Galbula_galbula,229
232
- Galbula_leucogastra,230
233
- Galbula_ruficauda,231
234
- Galbula_tombacea,232
235
- Gallinula_galeata,233
236
- Geothlypis_aequinoctialis,234
237
- Geranospiza_caerulescens,235
238
- Glaucidium_bolivianum,236
239
- Glaucidium_brasilianum,237
240
- Glaucidium_hardyi,238
241
- Glyphorynchus_spirurus,239
242
- Grallaria_blakei,240
243
- Grallaria_carrikeri,241
244
- Grallaria_obscura,242
245
- Grallaria_occabambae,243
246
- Grallaria_przewalskii,244
247
- Grallaria_quitensis,245
248
- Grallaria_ruficapilla,246
249
- Grallaria_squamigera,247
250
- Grallaricula_leymebambae,248
251
- Grallaricula_ochraceifrons,249
252
- Graydidascalus_brachyurus,250
253
- Gymnomystax_mexicanus,251
254
- Gymnopithys_leucaspis,252
255
- Gymnopithys_rufigula,253
256
- Gymnopithys_salvini,254
257
- Habia_rubica,255
258
- Hafferia_fortis,256
259
- Haplospiza_rustica,257
260
- Harpia_harpyja,258
261
- Heliangelus_amethysticollis,259
262
- Helicolestes_hamatus,260
263
- Heliornis_fulica,261
264
- Hemithraupis_flavicollis,262
265
- Hemitriccus_griseipectus,263
266
- Hemitriccus_inornatus,264
267
- Hemitriccus_josephinae,265
268
- Hemitriccus_minimus,266
269
- Hemitriccus_minor,267
270
- Hemitriccus_zosterops,268
271
- Henicorhina_leucophrys,269
272
- Henicorhina_leucoptera,270
273
- Henicorhina_leucosticta,271
274
- Herpetotheres_cachinnans,272
275
- Herpsilochmus_axillaris,273
276
- Herpsilochmus_dorsimaculatus,274
277
- Herpsilochmus_dugandi,275
278
- Herpsilochmus_parkeri,276
279
- Herpsilochmus_praedictus,277
280
- Herpsilochmus_stotzi,278
281
- Heterocercus_aurantiivertex,279
282
- Heterocercus_flavivertex,280
283
- Hoploxypterus_cayanus,281
284
- Hylexetastes_perrotii,282
285
- Hylexetastes_uniformis,283
286
- Hylocharis_sapphirina,284
287
- Hylopezus_macularius,285
288
- Hylophilus_brunneiceps,286
289
- Hylophilus_muscicapinus,287
290
- Hylophilus_olivaceus,288
291
- Hylophilus_pectoralis,289
292
- Hylophilus_semicinereus,290
293
- Hylophilus_thoracicus,291
294
- Hylophylax_naevius,292
295
- Hylophylax_punctulatus,293
296
- Hypnelus_bicinctus,294
297
- Hypocnemis_cantator,295
298
- Hypocnemis_flavescens,296
299
- Hypocnemis_hypoxantha,297
300
- Hypocnemis_peruviana,298
301
- Hypocnemis_rondoni,299
302
- Hypocnemis_striata,300
303
- Hypocnemoides_maculicauda,301
304
- Hypocnemoides_melanopogon,302
305
- Ibycter_americanus,303
306
- Icterus_cayanensis,304
307
- Ictinia_plumbea,305
308
- Incaspiza_laeta,306
309
- Incaspiza_watkinsi,307
310
- Inezia_subflava,308
311
- Iodopleura_isabellae,309
312
- Iridosornis_reinhardti,310
313
- Isleria_guttata,311
314
- Islerothraupis_luctuosa,312
315
- Jacamerops_aureus,313
316
- Jacana_jacana,314
317
- Kleinothraupis_atropileus,315
318
- Knipolegus_orenocensis,316
319
- Lampropsar_tanagrinus,317
320
- Lamprospiza_melanoleuca,318
321
- Lanio_fulvus,319
322
- Lanio_versicolor,320
323
- Laniocera_hypopyrra,321
324
- Larus_serranus,322
325
- Laterallus_exilis,323
326
- Lathrotriccus_euleri,324
327
- Leistes_bellicosus,325
328
- Lepidocolaptes_duidae,326
329
- Lepidocolaptes_fatimalimae,327
330
- Lepidocolaptes_fuscicapillus,328
331
- Lepidothrix_coronata,329
332
- Lepidothrix_nattereri,330
333
- Lepidothrix_serena,331
334
- Leptodon_cayanensis,332
335
- Leptopogon_taczanowskii,333
336
- Leptotila_rufaxilla,334
337
- Leptotila_verreauxi,335
338
- Leuconotopicus_fumigatus,336
339
- Leucopternis_kuhli,337
340
- Liosceles_thoracicus,338
341
- Lipaugus_vociferans,339
342
- Loddigesia_mirabilis,340
343
- Lophostrix_cristata,341
344
- Lophotriccus_galeatus,342
345
- Lophotriccus_vitiosus,343
346
- Lurocalis_rufiventris,344
347
- Malacoptila_fusca,345
348
- Manacus_manacus,346
349
- Margarornis_squamiger,347
350
- Mazaria_propinqua,348
351
- Mecocerculus_stictopterus,349
352
- Megascops_albogularis,350
353
- Megascops_choliba,351
354
- Megascops_ingens,352
355
- Megascops_petersoni,353
356
- Megascops_watsonii,354
357
- Megastictus_margaritatus,355
358
- Melanerpes_cruentatus,356
359
- Melanopareia_maranonica,357
360
- Micrastur_gilvicollis,358
361
- Micrastur_mintoni,359
362
- Micrastur_mirandollei,360
363
- Micrastur_ruficollis,361
364
- Micrastur_semitorquatus,362
365
- Microbates_collaris,363
366
- Microcerculus_bambla,364
367
- Microcerculus_marginatus,365
368
- Microrhopias_quixensis,366
369
- Milvago_chimachima,367
370
- Mimus_longicaudatus,368
371
- Mionectes_oleagineus,369
372
- Mionectes_striaticollis,370
373
- Mitrephanes_olivaceus,371
374
- Monasa_atra,372
375
- Monasa_morphoeus,373
376
- Monasa_nigrifrons,374
377
- Muscicapa_similis,375
378
- Myadestes_ralloides,376
379
- Myiarchus_cephalotes,377
380
- Myiarchus_swainsoni,378
381
- Myiarchus_tuberculifer,379
382
- Myiarchus_tyrannulus,380
383
- Myioborus_melanocephalus,381
384
- Myioborus_miniatus,382
385
- Myiodynastes_maculatus,383
386
- Myiopagis_caniceps,384
387
- Myiopagis_flavivertex,385
388
- Myiopagis_gaimardii,386
389
- Myiophobus_cryptoxanthus,387
390
- Myiornis_ecaudatus,388
391
- Myiotheretes_fumigatus,389
392
- Myiothlypis_coronata,390
393
- Myiothlypis_luteoviridis,391
394
- Myiothlypis_nigrocristata,392
395
- Myiozetetes_cayanensis,393
396
- Myiozetetes_luteiventris,394
397
- Myornis_senilis,395
398
- Myrmeciza_atrothorax,396
399
- Myrmeciza_longipes,397
400
- Myrmelastes_humaythae,398
401
- Myrmelastes_hyperythrus,399
402
- Myrmelastes_leucostigma,400
403
- Myrmelastes_rufifacies,401
404
- Myrmoborus_leucophrys,402
405
- Myrmoborus_lugubris,403
406
- Myrmoborus_melanurus,404
407
- Myrmoborus_myotherinus,405
408
- Myrmochanes_hemileucus,406
409
- Myrmoderus_ferruginea,407
410
- Myrmornis_torquata,408
411
- Myrmothera_campanisona,409
412
- Myrmotherula_ambigua,410
413
- Myrmotherula_assimilis,411
414
- Myrmotherula_axillaris,412
415
- Myrmotherula_brachyura,413
416
- Myrmotherula_cherriei,414
417
- Myrmotherula_iheringi,415
418
- Myrmotherula_klagesi,416
419
- Myrmotherula_longipennis,417
420
- Myrmotherula_menetriesii,418
421
- Nasica_longirostris,419
422
- Nemosia_pileata,420
423
- Neoctantes_niger,421
424
- Neopelma_chrysocephalum,422
425
- Neopipo_cinnamomea,423
426
- Nesotriccus_tumbezanus,424
427
- Nonnula_sclateri,425
428
- Notharchus_hyperrhynchus,426
429
- Notharchus_ordii,427
430
- Notharchus_tectus,428
431
- Nothocrax_urumutum,429
432
- Nyctalops_stygius,430
433
- Nyctibius_grandis,431
434
- Nyctibius_leucopterus,432
435
- Nyctidromus_albicollis,433
436
- Nyctiprogne_leucopyga,434
437
- Nystactes_tamatia,435
438
- Nystalus_obamai,436
439
- Ochthoeca_cinnamomeiventris,437
440
- Ochthoeca_diadema,438
441
- Ochthoeca_pulchella,439
442
- Ochthoeca_thoracica,440
443
- Ocreatus_underwoodii,441
444
- Odontophorus_gujanensis,442
445
- Onychorhynchus_coronatus,443
446
- Opisthocomidae,444
447
- Ornithion_inerme,445
448
- Ortalis_guttata,446
449
- Ortalis_motmot,447
450
- Pachyramphus_castaneus,448
451
- Pachyramphus_marginatus,449
452
- Pachyramphus_minor,450
453
- Pachyramphus_polychopterus,451
454
- Pachyramphus_rufus,452
455
- Pachyramphus_surinamus,453
456
- Pachyramphus_versicolor,454
457
- Pachysylvia_hypoxantha,455
458
- Pardirallus_sanguinolentus,456
459
- Paroaria_gularis,457
460
- Patagioenas_cayennensis,458
461
- Patagioenas_plumbea,459
462
- Patagioenas_subvinacea,460
463
- Penelope_jacquacu,461
464
- Penelope_montagnii,462
465
- Percnostola_rufifrons,463
466
- Perissocephalus_tricolor,464
467
- Phacellodomus_rufifrons,465
468
- Phaeomyias_murina,466
469
- Phaeothlypis_fulvicauda,467
470
- Phaeothlypis_rivularis,468
471
- Phaethornis_guy,469
472
- Phaethornis_hispidus,470
473
- Phaethornis_malaris,471
474
- Phaethornis_ruber,472
475
- Phaethornis_rupurumii,473
476
- Phaethornis_superciliosus,474
477
- Phaetusa_simplex,475
478
- Pharomachrus_auriceps,476
479
- Pharomachrus_pavoninus,477
480
- Pheucticus_chrysogaster,478
481
- Pheugopedius_coraya,479
482
- Pheugopedius_euophrys,480
483
- Pheugopedius_genibarbis,481
484
- Pheugopedius_paucimaculatus,482
485
- Philydor_erythropterum,483
486
- Philydor_pyrrhodes,484
487
- Phlegopsis_erythroptera,485
488
- Phlegopsis_nigromaculata,486
489
- Phoenicircus_carnifex,487
490
- Phoenicircus_nigricollis,488
491
- Phyllaemulor_bracteatus,489
492
- Phyllomyias_plumbeiceps,490
493
- Phylloscartes_gualaquizae,491
494
- Phylloscartes_ventralis,492
495
- Piaya_cayana,493
496
- Piaya_melanogaster,494
497
- Piculus_chrysochloros,495
498
- Piculus_flavigula,496
499
- Picumnus_castelnau,497
500
- Picumnus_exilis,498
501
- Picumnus_lafresnayi,499
502
- Picumnus_steindachneri,500
503
- Picumnus_varzeae,501
504
- Pionites_melanocephalus,502
505
- Pionus_fuscus,503
506
- Pionus_menstruus,504
507
- Pipile_cumanensis,505
508
- Pipra_aureola,506
509
- Pipra_pipra,507
510
- Pipraeidea_bonariensis,508
511
- Pipreola_arcuata,509
512
- Piprites_chloris,510
513
- Piranga_hepatica,511
514
- Pitangus_lictor,512
515
- Pitangus_sulphuratus,513
516
- Pithys_albifrons,514
517
- Platyrinchus_coronatus,515
518
- Platyrinchus_platyrhynchos,516
519
- Poecilotriccus_calopterus,517
520
- Poecilotriccus_capitalis,518
521
- Poecilotriccus_latirostris,519
522
- Poecilotriccus_luluae,520
523
- Poecilotriccus_senex,521
524
- Polioptila_attenboroughi,522
525
- Polioptila_guianensis,523
526
- Polioptila_plumbea,524
527
- Polytmus_theresiae,525
528
- Progne_subis,526
529
- Psarocolius_angustifrons,527
530
- Psarocolius_bifasciatus,528
531
- Psarocolius_decumanus,529
532
- Psarocolius_viridis,530
533
- Pseudastur_albicollis,531
534
- Pseudocolaptes_boissonneauii,532
535
- Pseudotriccus_ruficeps,533
536
- Psittacara_frontatus,534
537
- Psittacara_mitratus,535
538
- Psophia_crepitans,536
539
- Pteroglossus_aracari,537
540
- Pteroglossus_azara,538
541
- Pteroglossus_beauharnaisii,539
542
- Pteroglossus_castanotis,540
543
- Pulsatrix_perspicillata,541
544
- Pygiptila_stellaris,542
545
- Pygochelidon_melanoleuca,543
546
- Pyriglena_maura,544
547
- Pyrilia_aurantiocephala,545
548
- Pyrilia_barrabandi,546
549
- Pyrilia_caica,547
550
- Pyrrhomyias_cinnamomeus,548
551
- Pyrrhura_roseifrons,549
552
- Querula_purpurata,550
553
- Ramphastos_sulfuratus,551
554
- Ramphastos_tucanus,552
555
- Ramphastos_vitellinus,553
556
- Ramphocaenus_melanurus,554
557
- Ramphocelus_carbo,555
558
- Ramphocelus_nigrogularis,556
559
- Ramphotrigon_megacephalum,557
560
- Ramphotrigon_ruficauda,558
561
- Rhegmatorhina_berlepschi,559
562
- Rhegmatorhina_cristata,560
563
- Rhegmatorhina_hoffmannsi,561
564
- Rhegmatorhina_melanosticta,562
565
- Rhynchocyclus_olivaceus,563
566
- Rhytipterna_immunda,564
567
- Rhytipterna_simplex,565
568
- Rostrhamus_sociabilis,566
569
- Rufirallus_castaneiceps,567
570
- Rufirallus_viridis,568
571
- Rupicola_rupicola,569
572
- Rynchops_niger,570
573
- Sakesphorus_canadensis,571
574
- Sakesphorus_luctuosus,572
575
- Saltator_coerulescens,573
576
- Saltator_grossus,574
577
- Saltator_maximus,575
578
- Saltator_striatipectus,576
579
- Schiffornis_major,577
580
- Schiffornis_turdina,578
581
- Schistocichla_schistacea,579
582
- Schizoeaca_fuliginosa,580
583
- Sciaphylax_castanea,581
584
- Sciaphylax_hemimelaena,582
585
- Sclateria_naevia,583
586
- Sclerurus_obscurior,584
587
- Sclerurus_rufigularis,585
588
- Scytalopus_altirostris,586
589
- Scytalopus_atratus,587
590
- Scytalopus_femoralis,588
591
- Scytalopus_intermedius,589
592
- Scytalopus_parvirostris,590
593
- Selenidera_gouldii,591
594
- Selenidera_nattereri,592
595
- Selenidera_piperivora,593
596
- Selenidera_reinwardtii,594
597
- Sericossypha_albocristata,595
598
- Serpophaga_hypoleuca,596
599
- Serpophaga_subcristata,597
600
- Sicalis_columbiana,598
601
- Sirystes_sibilator,599
602
- Sirystes_subcanescens,600
603
- Sittasomus_griseicapillus,601
604
- Spinus_olivaceus,602
605
- Spizaetus_ornatus,603
606
- Sporophila_angolensis,604
607
- Sporophila_bouvronides,605
608
- Sporophila_castaneiventris,606
609
- Sporophila_fringilloides,607
610
- Sporophila_luctuosa,608
611
- Sporophila_simplex,609
612
- Sternula_superciliaris,610
613
- Stilpnia_viridicollis,611
614
- Sturnella_militaris,612
615
- Sublegatus_obscurior,613
616
- Synallaxis_albescens,614
617
- Synallaxis_albigularis,615
618
- Synallaxis_azarae,616
619
- Synallaxis_gujanensis,617
620
- Synallaxis_hypospodia,618
621
- Synallaxis_maranonica,619
622
- Synallaxis_rutilans,620
623
- Synallaxis_unirufa,621
624
- Syndactyla_rufosuperciliata,622
625
- Syndactyla_ucayalae,623
626
- Tachycineta_albiventer,624
627
- Tachyphonus_cristatus,625
628
- Tachyphonus_phoenicius,626
629
- Tachyphonus_surinamus,627
630
- Talaphorus_chlorocercus,628
631
- Tangara_cayana,629
632
- Tangara_chilensis,630
633
- Tangara_nigroviridis,631
634
- Tangara_punctata,632
635
- Tangara_varia,633
636
- Tangara_velia,634
637
- Tapera_naevia,635
638
- Taraba_major,636
639
- Terenura_spodioptila,637
640
- Tersina_viridis,638
641
- Thamnomanes_ardesiacus,639
642
- Thamnomanes_caesius,640
643
- Thamnomanes_saturninus,641
644
- Thamnomanes_schistogynus,642
645
- Thamnophilus_aethiops,643
646
- Thamnophilus_amazonicus,644
647
- Thamnophilus_bernardi,645
648
- Thamnophilus_cryptoleucus,646
649
- Thamnophilus_doliatus,647
650
- Thamnophilus_murinus,648
651
- Thamnophilus_nigrocinereus,649
652
- Thamnophilus_punctatus,650
653
- Thamnophilus_ruficapillus,651
654
- Thamnophilus_schistaceus,652
655
- Thamnophilus_stictocephalus,653
656
- Thamnophilus_unicolor,654
657
- Thaumasius_taczanowskii,655
658
- Thlypopsis_inornata,656
659
- Thlypopsis_superciliaris,657
660
- Thraupis_episcopus,658
661
- Thripadectes_scrutator,659
662
- Thripophaga_fusciceps,660
663
- Thryothorus_griseus,661
664
- Tiaris_obscurus,662
665
- Tinamus_major,663
666
- Tityra_cayana,664
667
- Tityra_semifasciata,665
668
- Todirostrum_chrysocrotaphum,666
669
- Todirostrum_maculatum,667
670
- Todirostrum_pictum,668
671
- Tolmomyias_assimilis,669
672
- Tolmomyias_flaviventris,670
673
- Tolmomyias_poliocephalus,671
674
- Tolmomyias_sulphurescens,672
675
- Tolmomyias_traylori,673
676
- Tolmomyias_viridiceps,674
677
- Topaza_pella,675
678
- Topaza_pyra,676
679
- Touit_purpuratus,677
680
- Troglodytes_aedon,678
681
- Troglodytes_solstitialis,679
682
- Trogon_collaris,680
683
- Trogon_curucui,681
684
- Trogon_melanurus,682
685
- Trogon_ramonianus,683
686
- Trogon_rufus,684
687
- Trogon_violaceus,685
688
- Trogon_viridis,686
689
- Tunchiornis_ochraceiceps,687
690
- Turdus_albicollis,688
691
- Turdus_hauxwelli,689
692
- Turdus_ignobilis,690
693
- Turdus_lawrencii,691
694
- Turdus_leucomelas,692
695
- Turdus_maranonicus,693
696
- Turdus_nigriceps,694
697
- Turdus_sanchezorum,695
698
- Turdus_serranus,696
699
- Tyranneutes_stolzmanni,697
700
- Tyranneutes_virescens,698
701
- Tyranniscus_cinereiceps,699
702
- Tyranniscus_uropygialis,700
703
- Tyrannulus_elatus,701
704
- Tyrannus_melancholicus,702
705
- Tyrannus_savana,703
706
- Uranomitra_franciae,704
707
- Uromyias_agraphia,705
708
- Uropsalis_segmentata,706
709
- Veniliornis_cassini,707
710
- Vireo_chivi,708
711
- Vireolanius_leucotis,709
712
- Volatinia_jacarina,710
713
- Wetmorethraupis_sterrhopteron,711
714
- Willisornis_poecilinotus,712
715
- Xenoglaux_loweryi,713
716
- Xenopipo_atronitens,714
717
- Xenops_milleri,715
718
- Xenops_minutus,716
719
- Xiphocolaptes_promeropirhynchus,717
720
- Xipholena_punicea,718
721
- Xiphorhynchus_elegans,719
722
- Xiphorhynchus_guttatus,720
723
- Xiphorhynchus_obsoletus,721
724
- Xiphorhynchus_ocellatus,722
725
- Xiphorhynchus_pardalotus,723
726
- Xiphorhynchus_picus,724
727
- Zimmerius_acer,725
728
- Zimmerius_gracilipes,726
729
- Zimmerius_viridiflavus,727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
BirdAST_Baseline_GroupKFold_label_map.csv DELETED
@@ -1,729 +0,0 @@
1
- scientific_name,species_id
2
- Accipiter_superciliosus,0
3
- Akletos_melanoceps,1
4
- Amazona_amazonica,2
5
- Amazona_diadema,3
6
- Amazona_farinosa,4
7
- Amazona_festiva,5
8
- Amblycercus_holosericeus,6
9
- Ammodramus_aurifrons,7
10
- Ammonastes_pelzelni,8
11
- Ampelion_rufaxilla,9
12
- Anabazenops_dorsalis,10
13
- Anairetes_parulus,11
14
- Andigena_hypoglauca,12
15
- Anhima_cornuta,13
16
- Anisognathus_lacrymosus,14
17
- Anthracothorax_viridigula,15
18
- Antrostomus_rufus,16
19
- Ara_ararauna,17
20
- Ara_chloropterus,18
21
- Ara_severus,19
22
- Aramides_cajaneus,20
23
- "Aramus_Vieillot,",21
24
- Aratinga_leucophthalma,22
25
- Ardea_cocoi,23
26
- Arremon_abeillei,24
27
- Arremon_assimilis,25
28
- Arremon_taciturnus,26
29
- Asthenes_flammulata,27
30
- Atlapetes_latinuchus,28
31
- Atticora_tibialis,29
32
- Attila_bolivianus,30
33
- Attila_cinnamomeus,31
34
- Attila_citriniventris,32
35
- Attila_spadiceus,33
36
- Automolus_infuscatus,34
37
- Automolus_ochrolaemus,35
38
- Automolus_paraensis,36
39
- Automolus_rufipileatus,37
40
- Automolus_subulatus,38
41
- Basileuterus_tristriatus,39
42
- Berlepschia_rikeri,40
43
- Boissonneaua_matthewsii,41
44
- Brotogeris_chrysoptera,42
45
- Brotogeris_cyanoptera,43
46
- Brotogeris_sanctithomae,44
47
- Brotogeris_versicolurus,45
48
- Bucco_capensis,46
49
- Buteo_nitidus,47
50
- Buteogallus_schistaceus,48
51
- Buteogallus_urubitinga,49
52
- Buthraupis_montana,50
53
- Cacicus_cela,51
54
- Cacicus_chrysonotus,52
55
- Cacicus_haemorrhous,53
56
- Cacicus_leucoramphus,54
57
- Calidris_fuscicollis,55
58
- Campephilus_melanoleucos,56
59
- Campephilus_pollens,57
60
- Campephilus_rubricollis,58
61
- Camptostoma_obsoletum,59
62
- Campylorhamphus_procurvoides,60
63
- Campylorhynchus_fasciatus,61
64
- Cantorchilus_leucotis,62
65
- Capito_auratus,63
66
- Capito_aurovirens,64
67
- Capito_niger,65
68
- Capsiempis_flaveola,66
69
- Carduelis_magellanica,67
70
- Caryothraustes_canadensis,68
71
- Catharus_fuscater,69
72
- Celeus_elegans,70
73
- Celeus_flavus,71
74
- Celeus_grammicus,72
75
- Celeus_torquatus,73
76
- Celeus_undatus,74
77
- Cephalopterus_ornatus,75
78
- Ceratopipra_erythrocephala,76
79
- Ceratotriccus_granadensis,77
80
- Cercomacra_cinerascens,78
81
- Cercomacra_manu,79
82
- Cercomacra_nigrescens,80
83
- Cercomacroides_fuscicauda,81
84
- Cercomacroides_serva,82
85
- Cercomacroides_tyrannina,83
86
- Certhiasomus_stictolaemus,84
87
- Certhiaxis_cinnamomeus,85
88
- Certhiaxis_mustelinus,86
89
- Chaetura_brachyura,87
90
- Chaetura_spinicaudus,88
91
- Chamaeza_mollissima,89
92
- Chamaeza_nobilis,90
93
- Charadrius_collaris,91
94
- Chelidoptera_tenebrosa,92
95
- Chionomesa_fimbriata,93
96
- Chiroxiphia_pareola,94
97
- Chlorestes_cyanus,95
98
- Chloroceryle_americana,96
99
- Chlorophanes_spiza,97
100
- Chlorophonia_pyrrhophrys,98
101
- Chlorornis_riefferii,99
102
- Chlorospingus_flavopectus,100
103
- Chlorostilbon_mellisugus,101
104
- Chlorostilbon_olivaresi,102
105
- Chordeiles_pusillus,103
106
- Chrysomus_icterocephalus,104
107
- Ciccaba_albitarsis,105
108
- Cinnycerthia_peruana,106
109
- Cissopis_leverianus,107
110
- Cistothorus_platensis,108
111
- Cnemoscopus_rubrirostris,109
112
- Cnemotriccus_fuscatus,110
113
- Cnipodectes_subbrunneus,111
114
- Coccycua_minuta,112
115
- Coccyzus_melacoryphus,113
116
- Coeligena_violifer,114
117
- "Coereba_Vieillot,",115
118
- Colaptes_atricollis,116
119
- Colibri_coruscans,117
120
- Columba_speciosa,118
121
- Columbina_cruziana,119
122
- Columbina_minuta,120
123
- Conirostrum_bicolor,121
124
- Conirostrum_margaritae,122
125
- Conopias_parvus,123
126
- Conopias_trivirgatus,124
127
- Conopophaga_aurita,125
128
- Contopus_fumigatus,126
129
- Contopus_punensis,127
130
- Corythopis_torquatus,128
131
- Cranioleuca_antisiensis,129
132
- Cranioleuca_berlepschi,130
133
- Cranioleuca_gutturata,131
134
- Cranioleuca_muelleri,132
135
- Cranioleuca_vulpecula,133
136
- Cranioleuca_vulpina,134
137
- Crax_alector,135
138
- Crax_globulosa,136
139
- Crotophaga_ani,137
140
- Crotophaga_major,138
141
- Crypturellus_bartletti,139
142
- Crypturellus_casiquiare,140
143
- Crypturellus_cinereus,141
144
- Crypturellus_duidae,142
145
- Crypturellus_soui,143
146
- Crypturellus_undulatus,144
147
- Crypturellus_variegatus,145
148
- Cyanerpes_caeruleus,146
149
- Cyanicterus_cyanicterus,147
150
- Cyanocorax_heilprini,148
151
- Cyanocorax_violaceus,149
152
- Cyanocorax_yncas,150
153
- Cyanoloxia_rothschildii,151
154
- Cyanolyca_viridicyanus,152
155
- Cyclarhis_gujanensis,153
156
- Cymbilaimus_lineatus,154
157
- Cyphorhinus_arada,155
158
- Cyphorhinus_thoracicus,156
159
- Cyphos_macrodactylus,157
160
- Dacnis_albiventris,158
161
- Daptrius_ater,159
162
- Deconychura_longicauda,160
163
- Dendrexetastes_rufigula,161
164
- Dendrocincla_fuliginosa,162
165
- Dendrocincla_merula,163
166
- Dendrocolaptes_certhia,164
167
- Dendrocolaptes_hoffmannsi,165
168
- Dendrocolaptes_picumnus,166
169
- Dendrocygna_autumnalis,167
170
- Dendroplex_kienerii,168
171
- Deroptyus_accipitrinus,169
172
- Dichrozona_cincta,170
173
- Diglossa_cyanea,171
174
- Diglossa_mystacalis,172
175
- Diglossa_sittoides,173
176
- Donacobius_atricapilla,174
177
- Dromococcyx_phasianellus,175
178
- Drymophila_devillei,176
179
- Drymophila_striaticeps,177
180
- Dryocopus_lineatus,178
181
- Egretta_alba,179
182
- Egretta_thula,180
183
- Elaenia_flavogaster,181
184
- Elaenia_pallatangae,182
185
- Elaenia_pelzelni,183
186
- Elaenia_ruficeps,184
187
- Elliotomyia_chionogaster,185
188
- Empidonomus_varius,186
189
- Epinecrophylla_amazonica,187
190
- Epinecrophylla_gutturalis,188
191
- Epinecrophylla_haematonota,189
192
- Epinecrophylla_leucophthalma,190
193
- Epinecrophylla_ornata,191
194
- Eriocnemis_alinae,192
195
- Eubucco_richardsoni,193
196
- Euchrepomis_humeralis,194
197
- Eucometis_penicillata,195
198
- Euphonia_cayennensis,196
199
- Euphonia_chlorotica,197
200
- Euphonia_chrysopasta,198
201
- Euphonia_cyanocephala,199
202
- Euphonia_minuta,200
203
- Euphonia_plumbea,201
204
- Euphonia_rufiventris,202
205
- Euphonia_xanthogaster,203
206
- Eupsittula_pertinax,204
207
- Eurypygidae,205
208
- Falco_deiroleucus,206
209
- Falco_femoralis,207
210
- Falco_magnirostris,208
211
- Falco_rufigularis,209
212
- Florisuga_mellivora,210
213
- Formicarius_analis,211
214
- Formicarius_colma,212
215
- Formicivora_grisea,213
216
- Forpus_crassirostris,214
217
- Forpus_xanthops,215
218
- Frederickena_unduliger,216
219
- Frederickena_viridis,217
220
- Fringilla_capensis,218
221
- Fringilla_psaltria,219
222
- Furnarius_figulus,220
223
- Furnarius_leucopus,221
224
- Furnarius_minor,222
225
- Furnarius_torridus,223
226
- Galbacyrhynchus_leucotis,224
227
- Galbalcyrhynchus_purusianus,225
228
- Galbula_cyanescens,226
229
- Galbula_cyanicollis,227
230
- Galbula_dea,228
231
- Galbula_galbula,229
232
- Galbula_leucogastra,230
233
- Galbula_ruficauda,231
234
- Galbula_tombacea,232
235
- Gallinula_galeata,233
236
- Geothlypis_aequinoctialis,234
237
- Geranospiza_caerulescens,235
238
- Glaucidium_bolivianum,236
239
- Glaucidium_brasilianum,237
240
- Glaucidium_hardyi,238
241
- Glyphorynchus_spirurus,239
242
- Grallaria_blakei,240
243
- Grallaria_carrikeri,241
244
- Grallaria_obscura,242
245
- Grallaria_occabambae,243
246
- Grallaria_przewalskii,244
247
- Grallaria_quitensis,245
248
- Grallaria_ruficapilla,246
249
- Grallaria_squamigera,247
250
- Grallaricula_leymebambae,248
251
- Grallaricula_ochraceifrons,249
252
- Graydidascalus_brachyurus,250
253
- Gymnomystax_mexicanus,251
254
- Gymnopithys_leucaspis,252
255
- Gymnopithys_rufigula,253
256
- Gymnopithys_salvini,254
257
- Habia_rubica,255
258
- Hafferia_fortis,256
259
- Haplospiza_rustica,257
260
- Harpia_harpyja,258
261
- Heliangelus_amethysticollis,259
262
- Helicolestes_hamatus,260
263
- Heliornis_fulica,261
264
- Hemithraupis_flavicollis,262
265
- Hemitriccus_griseipectus,263
266
- Hemitriccus_inornatus,264
267
- Hemitriccus_josephinae,265
268
- Hemitriccus_minimus,266
269
- Hemitriccus_minor,267
270
- Hemitriccus_zosterops,268
271
- Henicorhina_leucophrys,269
272
- Henicorhina_leucoptera,270
273
- Henicorhina_leucosticta,271
274
- Herpetotheres_cachinnans,272
275
- Herpsilochmus_axillaris,273
276
- Herpsilochmus_dorsimaculatus,274
277
- Herpsilochmus_dugandi,275
278
- Herpsilochmus_parkeri,276
279
- Herpsilochmus_praedictus,277
280
- Herpsilochmus_stotzi,278
281
- Heterocercus_aurantiivertex,279
282
- Heterocercus_flavivertex,280
283
- Hoploxypterus_cayanus,281
284
- Hylexetastes_perrotii,282
285
- Hylexetastes_uniformis,283
286
- Hylocharis_sapphirina,284
287
- Hylopezus_macularius,285
288
- Hylophilus_brunneiceps,286
289
- Hylophilus_muscicapinus,287
290
- Hylophilus_olivaceus,288
291
- Hylophilus_pectoralis,289
292
- Hylophilus_semicinereus,290
293
- Hylophilus_thoracicus,291
294
- Hylophylax_naevius,292
295
- Hylophylax_punctulatus,293
296
- Hypnelus_bicinctus,294
297
- Hypocnemis_cantator,295
298
- Hypocnemis_flavescens,296
299
- Hypocnemis_hypoxantha,297
300
- Hypocnemis_peruviana,298
301
- Hypocnemis_rondoni,299
302
- Hypocnemis_striata,300
303
- Hypocnemoides_maculicauda,301
304
- Hypocnemoides_melanopogon,302
305
- Ibycter_americanus,303
306
- Icterus_cayanensis,304
307
- Ictinia_plumbea,305
308
- Incaspiza_laeta,306
309
- Incaspiza_watkinsi,307
310
- Inezia_subflava,308
311
- Iodopleura_isabellae,309
312
- Iridosornis_reinhardti,310
313
- Isleria_guttata,311
314
- Islerothraupis_luctuosa,312
315
- Jacamerops_aureus,313
316
- Jacana_jacana,314
317
- Kleinothraupis_atropileus,315
318
- Knipolegus_orenocensis,316
319
- Lampropsar_tanagrinus,317
320
- Lamprospiza_melanoleuca,318
321
- Lanio_fulvus,319
322
- Lanio_versicolor,320
323
- Laniocera_hypopyrra,321
324
- Larus_serranus,322
325
- Laterallus_exilis,323
326
- Lathrotriccus_euleri,324
327
- Leistes_bellicosus,325
328
- Lepidocolaptes_duidae,326
329
- Lepidocolaptes_fatimalimae,327
330
- Lepidocolaptes_fuscicapillus,328
331
- Lepidothrix_coronata,329
332
- Lepidothrix_nattereri,330
333
- Lepidothrix_serena,331
334
- Leptodon_cayanensis,332
335
- Leptopogon_taczanowskii,333
336
- Leptotila_rufaxilla,334
337
- Leptotila_verreauxi,335
338
- Leuconotopicus_fumigatus,336
339
- Leucopternis_kuhli,337
340
- Liosceles_thoracicus,338
341
- Lipaugus_vociferans,339
342
- Loddigesia_mirabilis,340
343
- Lophostrix_cristata,341
344
- Lophotriccus_galeatus,342
345
- Lophotriccus_vitiosus,343
346
- Lurocalis_rufiventris,344
347
- Malacoptila_fusca,345
348
- Manacus_manacus,346
349
- Margarornis_squamiger,347
350
- Mazaria_propinqua,348
351
- Mecocerculus_stictopterus,349
352
- Megascops_albogularis,350
353
- Megascops_choliba,351
354
- Megascops_ingens,352
355
- Megascops_petersoni,353
356
- Megascops_watsonii,354
357
- Megastictus_margaritatus,355
358
- Melanerpes_cruentatus,356
359
- Melanopareia_maranonica,357
360
- Micrastur_gilvicollis,358
361
- Micrastur_mintoni,359
362
- Micrastur_mirandollei,360
363
- Micrastur_ruficollis,361
364
- Micrastur_semitorquatus,362
365
- Microbates_collaris,363
366
- Microcerculus_bambla,364
367
- Microcerculus_marginatus,365
368
- Microrhopias_quixensis,366
369
- Milvago_chimachima,367
370
- Mimus_longicaudatus,368
371
- Mionectes_oleagineus,369
372
- Mionectes_striaticollis,370
373
- Mitrephanes_olivaceus,371
374
- Monasa_atra,372
375
- Monasa_morphoeus,373
376
- Monasa_nigrifrons,374
377
- Muscicapa_similis,375
378
- Myadestes_ralloides,376
379
- Myiarchus_cephalotes,377
380
- Myiarchus_swainsoni,378
381
- Myiarchus_tuberculifer,379
382
- Myiarchus_tyrannulus,380
383
- Myioborus_melanocephalus,381
384
- Myioborus_miniatus,382
385
- Myiodynastes_maculatus,383
386
- Myiopagis_caniceps,384
387
- Myiopagis_flavivertex,385
388
- Myiopagis_gaimardii,386
389
- Myiophobus_cryptoxanthus,387
390
- Myiornis_ecaudatus,388
391
- Myiotheretes_fumigatus,389
392
- Myiothlypis_coronata,390
393
- Myiothlypis_luteoviridis,391
394
- Myiothlypis_nigrocristata,392
395
- Myiozetetes_cayanensis,393
396
- Myiozetetes_luteiventris,394
397
- Myornis_senilis,395
398
- Myrmeciza_atrothorax,396
399
- Myrmeciza_longipes,397
400
- Myrmelastes_humaythae,398
401
- Myrmelastes_hyperythrus,399
402
- Myrmelastes_leucostigma,400
403
- Myrmelastes_rufifacies,401
404
- Myrmoborus_leucophrys,402
405
- Myrmoborus_lugubris,403
406
- Myrmoborus_melanurus,404
407
- Myrmoborus_myotherinus,405
408
- Myrmochanes_hemileucus,406
409
- Myrmoderus_ferruginea,407
410
- Myrmornis_torquata,408
411
- Myrmothera_campanisona,409
412
- Myrmotherula_ambigua,410
413
- Myrmotherula_assimilis,411
414
- Myrmotherula_axillaris,412
415
- Myrmotherula_brachyura,413
416
- Myrmotherula_cherriei,414
417
- Myrmotherula_iheringi,415
418
- Myrmotherula_klagesi,416
419
- Myrmotherula_longipennis,417
420
- Myrmotherula_menetriesii,418
421
- Nasica_longirostris,419
422
- Nemosia_pileata,420
423
- Neoctantes_niger,421
424
- Neopelma_chrysocephalum,422
425
- Neopipo_cinnamomea,423
426
- Nesotriccus_tumbezanus,424
427
- Nonnula_sclateri,425
428
- Notharchus_hyperrhynchus,426
429
- Notharchus_ordii,427
430
- Notharchus_tectus,428
431
- Nothocrax_urumutum,429
432
- Nyctalops_stygius,430
433
- Nyctibius_grandis,431
434
- Nyctibius_leucopterus,432
435
- Nyctidromus_albicollis,433
436
- Nyctiprogne_leucopyga,434
437
- Nystactes_tamatia,435
438
- Nystalus_obamai,436
439
- Ochthoeca_cinnamomeiventris,437
440
- Ochthoeca_diadema,438
441
- Ochthoeca_pulchella,439
442
- Ochthoeca_thoracica,440
443
- Ocreatus_underwoodii,441
444
- Odontophorus_gujanensis,442
445
- Onychorhynchus_coronatus,443
446
- Opisthocomidae,444
447
- Ornithion_inerme,445
448
- Ortalis_guttata,446
449
- Ortalis_motmot,447
450
- Pachyramphus_castaneus,448
451
- Pachyramphus_marginatus,449
452
- Pachyramphus_minor,450
453
- Pachyramphus_polychopterus,451
454
- Pachyramphus_rufus,452
455
- Pachyramphus_surinamus,453
456
- Pachyramphus_versicolor,454
457
- Pachysylvia_hypoxantha,455
458
- Pardirallus_sanguinolentus,456
459
- Paroaria_gularis,457
460
- Patagioenas_cayennensis,458
461
- Patagioenas_plumbea,459
462
- Patagioenas_subvinacea,460
463
- Penelope_jacquacu,461
464
- Penelope_montagnii,462
465
- Percnostola_rufifrons,463
466
- Perissocephalus_tricolor,464
467
- Phacellodomus_rufifrons,465
468
- Phaeomyias_murina,466
469
- Phaeothlypis_fulvicauda,467
470
- Phaeothlypis_rivularis,468
471
- Phaethornis_guy,469
472
- Phaethornis_hispidus,470
473
- Phaethornis_malaris,471
474
- Phaethornis_ruber,472
475
- Phaethornis_rupurumii,473
476
- Phaethornis_superciliosus,474
477
- Phaetusa_simplex,475
478
- Pharomachrus_auriceps,476
479
- Pharomachrus_pavoninus,477
480
- Pheucticus_chrysogaster,478
481
- Pheugopedius_coraya,479
482
- Pheugopedius_euophrys,480
483
- Pheugopedius_genibarbis,481
484
- Pheugopedius_paucimaculatus,482
485
- Philydor_erythropterum,483
486
- Philydor_pyrrhodes,484
487
- Phlegopsis_erythroptera,485
488
- Phlegopsis_nigromaculata,486
489
- Phoenicircus_carnifex,487
490
- Phoenicircus_nigricollis,488
491
- Phyllaemulor_bracteatus,489
492
- Phyllomyias_plumbeiceps,490
493
- Phylloscartes_gualaquizae,491
494
- Phylloscartes_ventralis,492
495
- Piaya_cayana,493
496
- Piaya_melanogaster,494
497
- Piculus_chrysochloros,495
498
- Piculus_flavigula,496
499
- Picumnus_castelnau,497
500
- Picumnus_exilis,498
501
- Picumnus_lafresnayi,499
502
- Picumnus_steindachneri,500
503
- Picumnus_varzeae,501
504
- Pionites_melanocephalus,502
505
- Pionus_fuscus,503
506
- Pionus_menstruus,504
507
- Pipile_cumanensis,505
508
- Pipra_aureola,506
509
- Pipra_pipra,507
510
- Pipraeidea_bonariensis,508
511
- Pipreola_arcuata,509
512
- Piprites_chloris,510
513
- Piranga_hepatica,511
514
- Pitangus_lictor,512
515
- Pitangus_sulphuratus,513
516
- Pithys_albifrons,514
517
- Platyrinchus_coronatus,515
518
- Platyrinchus_platyrhynchos,516
519
- Poecilotriccus_calopterus,517
520
- Poecilotriccus_capitalis,518
521
- Poecilotriccus_latirostris,519
522
- Poecilotriccus_luluae,520
523
- Poecilotriccus_senex,521
524
- Polioptila_attenboroughi,522
525
- Polioptila_guianensis,523
526
- Polioptila_plumbea,524
527
- Polytmus_theresiae,525
528
- Progne_subis,526
529
- Psarocolius_angustifrons,527
530
- Psarocolius_bifasciatus,528
531
- Psarocolius_decumanus,529
532
- Psarocolius_viridis,530
533
- Pseudastur_albicollis,531
534
- Pseudocolaptes_boissonneauii,532
535
- Pseudotriccus_ruficeps,533
536
- Psittacara_frontatus,534
537
- Psittacara_mitratus,535
538
- Psophia_crepitans,536
539
- Pteroglossus_aracari,537
540
- Pteroglossus_azara,538
541
- Pteroglossus_beauharnaisii,539
542
- Pteroglossus_castanotis,540
543
- Pulsatrix_perspicillata,541
544
- Pygiptila_stellaris,542
545
- Pygochelidon_melanoleuca,543
546
- Pyriglena_maura,544
547
- Pyrilia_aurantiocephala,545
548
- Pyrilia_barrabandi,546
549
- Pyrilia_caica,547
550
- Pyrrhomyias_cinnamomeus,548
551
- Pyrrhura_roseifrons,549
552
- Querula_purpurata,550
553
- Ramphastos_sulfuratus,551
554
- Ramphastos_tucanus,552
555
- Ramphastos_vitellinus,553
556
- Ramphocaenus_melanurus,554
557
- Ramphocelus_carbo,555
558
- Ramphocelus_nigrogularis,556
559
- Ramphotrigon_megacephalum,557
560
- Ramphotrigon_ruficauda,558
561
- Rhegmatorhina_berlepschi,559
562
- Rhegmatorhina_cristata,560
563
- Rhegmatorhina_hoffmannsi,561
564
- Rhegmatorhina_melanosticta,562
565
- Rhynchocyclus_olivaceus,563
566
- Rhytipterna_immunda,564
567
- Rhytipterna_simplex,565
568
- Rostrhamus_sociabilis,566
569
- Rufirallus_castaneiceps,567
570
- Rufirallus_viridis,568
571
- Rupicola_rupicola,569
572
- Rynchops_niger,570
573
- Sakesphorus_canadensis,571
574
- Sakesphorus_luctuosus,572
575
- Saltator_coerulescens,573
576
- Saltator_grossus,574
577
- Saltator_maximus,575
578
- Saltator_striatipectus,576
579
- Schiffornis_major,577
580
- Schiffornis_turdina,578
581
- Schistocichla_schistacea,579
582
- Schizoeaca_fuliginosa,580
583
- Sciaphylax_castanea,581
584
- Sciaphylax_hemimelaena,582
585
- Sclateria_naevia,583
586
- Sclerurus_obscurior,584
587
- Sclerurus_rufigularis,585
588
- Scytalopus_altirostris,586
589
- Scytalopus_atratus,587
590
- Scytalopus_femoralis,588
591
- Scytalopus_intermedius,589
592
- Scytalopus_parvirostris,590
593
- Selenidera_gouldii,591
594
- Selenidera_nattereri,592
595
- Selenidera_piperivora,593
596
- Selenidera_reinwardtii,594
597
- Sericossypha_albocristata,595
598
- Serpophaga_hypoleuca,596
599
- Serpophaga_subcristata,597
600
- Sicalis_columbiana,598
601
- Sirystes_sibilator,599
602
- Sirystes_subcanescens,600
603
- Sittasomus_griseicapillus,601
604
- Spinus_olivaceus,602
605
- Spizaetus_ornatus,603
606
- Sporophila_angolensis,604
607
- Sporophila_bouvronides,605
608
- Sporophila_castaneiventris,606
609
- Sporophila_fringilloides,607
610
- Sporophila_luctuosa,608
611
- Sporophila_simplex,609
612
- Sternula_superciliaris,610
613
- Stilpnia_viridicollis,611
614
- Sturnella_militaris,612
615
- Sublegatus_obscurior,613
616
- Synallaxis_albescens,614
617
- Synallaxis_albigularis,615
618
- Synallaxis_azarae,616
619
- Synallaxis_gujanensis,617
620
- Synallaxis_hypospodia,618
621
- Synallaxis_maranonica,619
622
- Synallaxis_rutilans,620
623
- Synallaxis_unirufa,621
624
- Syndactyla_rufosuperciliata,622
625
- Syndactyla_ucayalae,623
626
- Tachycineta_albiventer,624
627
- Tachyphonus_cristatus,625
628
- Tachyphonus_phoenicius,626
629
- Tachyphonus_surinamus,627
630
- Talaphorus_chlorocercus,628
631
- Tangara_cayana,629
632
- Tangara_chilensis,630
633
- Tangara_nigroviridis,631
634
- Tangara_punctata,632
635
- Tangara_varia,633
636
- Tangara_velia,634
637
- Tapera_naevia,635
638
- Taraba_major,636
639
- Terenura_spodioptila,637
640
- Tersina_viridis,638
641
- Thamnomanes_ardesiacus,639
642
- Thamnomanes_caesius,640
643
- Thamnomanes_saturninus,641
644
- Thamnomanes_schistogynus,642
645
- Thamnophilus_aethiops,643
646
- Thamnophilus_amazonicus,644
647
- Thamnophilus_bernardi,645
648
- Thamnophilus_cryptoleucus,646
649
- Thamnophilus_doliatus,647
650
- Thamnophilus_murinus,648
651
- Thamnophilus_nigrocinereus,649
652
- Thamnophilus_punctatus,650
653
- Thamnophilus_ruficapillus,651
654
- Thamnophilus_schistaceus,652
655
- Thamnophilus_stictocephalus,653
656
- Thamnophilus_unicolor,654
657
- Thaumasius_taczanowskii,655
658
- Thlypopsis_inornata,656
659
- Thlypopsis_superciliaris,657
660
- Thraupis_episcopus,658
661
- Thripadectes_scrutator,659
662
- Thripophaga_fusciceps,660
663
- Thryothorus_griseus,661
664
- Tiaris_obscurus,662
665
- Tinamus_major,663
666
- Tityra_cayana,664
667
- Tityra_semifasciata,665
668
- Todirostrum_chrysocrotaphum,666
669
- Todirostrum_maculatum,667
670
- Todirostrum_pictum,668
671
- Tolmomyias_assimilis,669
672
- Tolmomyias_flaviventris,670
673
- Tolmomyias_poliocephalus,671
674
- Tolmomyias_sulphurescens,672
675
- Tolmomyias_traylori,673
676
- Tolmomyias_viridiceps,674
677
- Topaza_pella,675
678
- Topaza_pyra,676
679
- Touit_purpuratus,677
680
- Troglodytes_aedon,678
681
- Troglodytes_solstitialis,679
682
- Trogon_collaris,680
683
- Trogon_curucui,681
684
- Trogon_melanurus,682
685
- Trogon_ramonianus,683
686
- Trogon_rufus,684
687
- Trogon_violaceus,685
688
- Trogon_viridis,686
689
- Tunchiornis_ochraceiceps,687
690
- Turdus_albicollis,688
691
- Turdus_hauxwelli,689
692
- Turdus_ignobilis,690
693
- Turdus_lawrencii,691
694
- Turdus_leucomelas,692
695
- Turdus_maranonicus,693
696
- Turdus_nigriceps,694
697
- Turdus_sanchezorum,695
698
- Turdus_serranus,696
699
- Tyranneutes_stolzmanni,697
700
- Tyranneutes_virescens,698
701
- Tyranniscus_cinereiceps,699
702
- Tyranniscus_uropygialis,700
703
- Tyrannulus_elatus,701
704
- Tyrannus_melancholicus,702
705
- Tyrannus_savana,703
706
- Uranomitra_franciae,704
707
- Uromyias_agraphia,705
708
- Uropsalis_segmentata,706
709
- Veniliornis_cassini,707
710
- Vireo_chivi,708
711
- Vireolanius_leucotis,709
712
- Volatinia_jacarina,710
713
- Wetmorethraupis_sterrhopteron,711
714
- Willisornis_poecilinotus,712
715
- Xenoglaux_loweryi,713
716
- Xenopipo_atronitens,714
717
- Xenops_milleri,715
718
- Xenops_minutus,716
719
- Xiphocolaptes_promeropirhynchus,717
720
- Xipholena_punicea,718
721
- Xiphorhynchus_elegans,719
722
- Xiphorhynchus_guttatus,720
723
- Xiphorhynchus_obsoletus,721
724
- Xiphorhynchus_ocellatus,722
725
- Xiphorhynchus_pardalotus,723
726
- Xiphorhynchus_picus,724
727
- Zimmerius_acer,725
728
- Zimmerius_gracilipes,726
729
- Zimmerius_viridiflavus,727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
__pycache__/app.cpython-310.pyc ADDED
Binary file (9.8 kB). View file
 
__pycache__/audio_class_predictor.cpython-310.pyc ADDED
Binary file (1.81 kB). View file
 
__pycache__/bird_ast_model.cpython-310.pyc ADDED
Binary file (4.48 kB). View file
 
__pycache__/bird_ast_seq_model.cpython-310.pyc ADDED
Binary file (5.67 kB). View file
 
__pycache__/utils.cpython-310.pyc ADDED
Binary file (1.95 kB). View file
 
app.py CHANGED
@@ -1,148 +1,155 @@
1
- import json
2
- import gradio as gr
3
- import matplotlib.pyplot as plt
4
- import numpy as np
5
  import os
6
- import requests
7
- from config import Config
8
- from model import BirdAST
9
- import torch
10
- import librosa
11
- import noisereduce as nr
12
- import timm
13
  from typing import Iterable
 
14
  import gradio as gr
15
  from gradio.themes.base import Base
16
  from gradio.themes.utils import colors, fonts, sizes
17
- import time
18
- import pandas as pd
19
- from classpred import predict_class
20
  import torch.nn.functional as F
21
- import random
22
- from torchaudio.compliance import kaldi
23
- from torchaudio.functional import resample
24
- from transformers import ASTFeatureExtractor
25
-
26
- #TAG = "gaunernst/vit_base_patch16_1024_128.audiomae_as2m_ft_as20k"
27
- #MODEL = timm.create_model(f"hf_hub:{TAG}", pretrained=True).eval()
28
-
29
- #LABEL_URL = "https://huggingface.co/datasets/huggingface/label-files/raw/main/audioset-id2label.json"
30
- #AUDIOSET_LABELS = list(json.loads(requests.get(LABEL_URL).content).values())
31
-
32
- FEATURE_EXTRACTOR = ASTFeatureExtractor()
33
-
34
- def plot_mel(sr, x):
35
- mel_spec = librosa.feature.melspectrogram(y=x, sr=sr, n_mels=128, fmax=10000)
36
- mel_spec_db = librosa.power_to_db(mel_spec, ref=np.max)
37
- mel_spec_db = (mel_spec_db - mel_spec_db.min()) / (mel_spec_db.max() - mel_spec_db.min()) # normalize spectrogram to [0,1]
38
- mel_spec_db = np.stack([mel_spec_db, mel_spec_db, mel_spec_db], axis=-1) # Convert to 3-channel
39
- fig, ax = plt.subplots(nrows=1, ncols=1, sharex=True)
40
- librosa.display.specshow(mel_spec_db[:, :, 0], sr=sr, x_axis='time', y_axis='mel', fmin = 0, fmax=10000, ax = ax)
41
- return fig
42
-
43
- def plot_wave(sr, x):
44
- ry = nr.reduce_noise(y=x, sr=sr)
45
- fig, ax = plt.subplots(2, 1, figsize=(12, 8))
46
-
47
- # Plot the original waveform
48
- librosa.display.waveshow(x, sr=sr, ax=ax[0])
49
- ax[0].set(title='Original Waveform')
50
- ax[0].set_xlabel('Time (s)')
51
- ax[0].set_ylabel('Amplitude')
52
-
53
- # Plot the noise-reduced waveform
54
- librosa.display.waveshow(ry, sr=sr, ax=ax[1])
55
- ax[1].set(title='Noise Reduced Waveform')
56
- ax[1].set_xlabel('Time (s)')
57
- ax[1].set_ylabel('Amplitude')
58
-
59
- plt.tight_layout()
60
- return fig
61
-
62
- def predict(audio, start, end):
63
- sr, x = audio
64
-
65
- x = np.array(x, dtype=np.float32)/32768.0
66
- x = x[int(start*sr) : int(end*sr)]
67
- res = preprocess_for_inference(x, sr)
68
-
69
- if start >= end:
70
- raise gr.Error(f"`start` ({start}) must be smaller than end ({end}s)")
71
-
72
- if x.shape[0] < start * sr:
73
- raise gr.Error(f"`start` ({start}) must be smaller than audio duration ({x.shape[0] / sr:.0f}s)")
74
-
75
- if x.shape[0] > end * sr:
76
- end = x.shape[0]/(1.0*sr)
77
-
78
- fig1 = plot_mel(sr, x)
79
- fig2 = plot_wave(sr, x)
80
 
 
 
 
 
81
 
82
- return predict_class(x, sr, start, end), res, fig1, fig2
83
 
84
- def download_model(url, model_path):
85
- if not os.path.exists(model_path):
86
- response = requests.get(url)
87
- response.raise_for_status() # Ensure the request was successful
88
- with open(model_path, 'wb') as f:
89
- f.write(response.content)
90
 
91
- # Model URL and path
92
- model_urls = [f'https://huggingface.co/shiyi-li/BirdAST/resolve/main/BirdAST_Baseline_GroupKFold_fold_{i}.pth' for i in range(5)]
93
- model_paths = [f'BirdAST_Baseline_GroupKFold_fold_{i}.pth' for i in range(5)]
94
 
95
- for (model_url, model_path) in zip(model_urls, model_paths):
96
- download_model(model_url, model_path)
97
 
98
- # Load the model (assumes you have the model architecture defined)
99
- eval_models = [BirdAST(Config().backbone_name, Config().n_classes, n_mlp_layers=1, activation='silu') for i in range(5)]
100
- state_dicts = [torch.load(f'BirdAST_Baseline_GroupKFold_fold_{i}.pth', map_location='cpu') for i in range(5)]
101
- for idx, sd in enumerate(state_dicts):
102
- eval_models[idx].load_state_dict(sd)
103
 
104
- # Set to evaluation mode
105
- for i in range(5):
106
- eval_models[i].eval()
 
 
 
 
 
 
 
107
 
108
- # Load the species mapping
109
- label_mapping = pd.read_csv('BirdAST_Baseline_GroupKFold_label_map.csv')
110
- species_id_to_name = {row['species_id']: row['scientific_name'] for index, row in label_mapping.iterrows()}
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
- def preprocess_for_inference(audio_arr, sr):
113
- print(sr)
114
- spec = FEATURE_EXTRACTOR(audio_arr, sampling_rate=sr, padding="max_length", return_tensors="pt")
115
- input_values = spec['input_values'] # Get the input values prepared for model input
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
- # Initialize a list to store predictions from all models
119
- model_outputs = []
 
 
 
 
 
 
 
120
 
121
- with torch.no_grad():
122
- # Accumulate predictions from each model
123
- for model in eval_models:
124
- output = model(input_values)
125
- predict_score = F.softmax(output['logits'], dim=1)
126
- model_outputs.append(predict_score)
127
- print(predict_score[0, 434])
 
 
128
 
 
129
 
130
- # Average the predictions across all models
131
- avg_predictions = torch.mean(torch.cat(model_outputs), dim=0) #.values
132
- print(avg_predictions[434])
133
 
134
- # Get the top 10 predictions based on the average prediction scores
135
- topk_values, topk_indices = torch.topk(avg_predictions, 10)
136
- print(topk_values.shape, topk_indices.shape)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
 
138
- # Initialize results list to store the species names and their associated probabilities
139
- results = []
140
- for idx, scores in zip(topk_indices, topk_values):
141
- species_name = species_id_to_name[idx.item()]
142
- probability = scores.item()*100
143
- results.append([species_name, probability])
 
 
 
 
 
 
 
144
 
145
- return results
146
 
147
  DESCRIPTION = """
148
  # Introduction
@@ -186,7 +193,6 @@ css = """
186
 
187
 
188
 
189
-
190
  class Seafoam(Base):
191
  def __init__(
192
  self,
@@ -257,11 +263,46 @@ References
257
 
258
  [3] https://www.kaggle.com/code/dima806/bird-species-by-sound-detection
259
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
261
 
262
  gr.Markdown('<div class="logo-container"><img src="https://i.ibb.co/vcG9kr0/vojlogo.jpg" width="50px" alt="vojlogo"></div>')
263
  gr.Markdown('<div id="gradio-animation"></div>')
264
  gr.Markdown(DESCRIPTION)
 
 
 
 
 
 
265
  with gr.Row():
266
  with gr.Column(elem_classes="column-container"):
267
  start_time_input = gr.Number(label="Start Time", value=0, elem_classes="number-input full-height")
@@ -269,7 +310,6 @@ with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
269
  with gr.Column():
270
  audio_input = gr.Audio(label="Input Audio", elem_classes="full-height")
271
 
272
-
273
  with gr.Row():
274
  raw_class_output = gr.Dataframe(headers=["Class", "Score [%]"], row_count=10, label="Class Prediction")
275
  species_output = gr.Dataframe(headers=["Class", "Score [%]"], row_count=10, label="Species Prediction")
@@ -278,14 +318,14 @@ with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
278
  waveform_output = gr.Plot(label="Waveform")
279
  spectrogram_output = gr.Plot(label="Spectrogram")
280
 
281
- gr.Examples(
282
- examples=[
283
- ["1094_Pionus_fuscus_2.wav", 0, 10],
284
- ],
285
- inputs=[audio_input, start_time_input, end_time_input]
286
- )
287
 
288
- gr.Button("Predict").click(predict, [audio_input, start_time_input, end_time_input], [raw_class_output, species_output, waveform_output, spectrogram_output])
289
 
290
  gr.Markdown(REFERENCES)
291
 
 
1
+ import warnings
2
+ warnings.filterwarnings("ignore")
3
+
 
4
  import os
5
+ import numpy as np
6
+ import pandas as pd
 
 
 
 
 
7
  from typing import Iterable
8
+
9
  import gradio as gr
10
  from gradio.themes.base import Base
11
  from gradio.themes.utils import colors, fonts, sizes
12
+
13
+ import torch
14
+ import librosa
15
  import torch.nn.functional as F
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ # Import the necessary functions from the voj package
18
+ from audio_class_predictor import predict_class
19
+ from bird_ast_model import birdast_preprocess, birdast_inference
20
+ from bird_ast_seq_model import birdast_seq_preprocess, birdast_seq_inference
21
 
22
+ from utils import plot_wave, plot_mel, download_model, bandpass_filter
23
 
24
+ # Define the default parameters
25
+ ASSET_DIR = "./assets"
26
+ DEFUALT_SR = 16_000
27
+ DEFUALT_HIGH_CUT = 8_000
28
+ DEFUALT_LOW_CUT = 1_000
29
+ DEVICE = "cpu" #"cuda" if torch.cuda.is_available() else "cpu"
30
 
31
+ print(f"Device: {DEVICE}")
 
 
32
 
33
+ if not os.path.exists(ASSET_DIR):
34
+ os.makedirs(ASSET_DIR)
35
 
 
 
 
 
 
36
 
37
+ # define the assets for the models
38
+ birdast_assets = {
39
+ "model_weights": [
40
+ f"https://huggingface.co/shiyi-li/BirdAST/resolve/main/BirdAST_Baseline_GroupKFold_fold_{i}.pth"
41
+ for i in range(5)
42
+ ],
43
+ "label_mapping": "https://huggingface.co/shiyi-li/BirdAST/resolve/main/BirdAST_Baseline_GroupKFold_label_map.csv",
44
+ "preprocess_fn": birdast_preprocess,
45
+ "inference_fn": birdast_inference,
46
+ }
47
 
48
+ birdast_seq_assets = {
49
+ "model_weights": [
50
+ f"https://huggingface.co/shiyi-li/BirdAST_Seq/resolve/main/BirdAST_SeqPool_GroupKFold_fold_{i}.pth"
51
+ for i in range(5)
52
+ ],
53
+ "label_mapping": "https://huggingface.co/shiyi-li/BirdAST_Seq/resolve/main/BirdAST_SeqPool_GroupKFold_label_map.csv",
54
+ "preprocess_fn": birdast_seq_preprocess,
55
+ "inference_fn": birdast_seq_inference,
56
+ }
57
+
58
+ # maintain a dictionary of assets
59
+ ASSET_DICT = {
60
+ "BirdAST": birdast_assets,
61
+ "BirdAST_Seq": birdast_seq_assets,
62
+ }
63
 
 
 
 
 
64
 
65
+ def run_inference_with_model(audio_clip, sr, model_name):
66
+
67
+ # download the model assets
68
+ assets = ASSET_DICT[model_name]
69
+ model_weights_url = assets["model_weights"]
70
+ label_map_url = assets["label_mapping"]
71
+ preprocess_fn = assets["preprocess_fn"]
72
+ inference_fn = assets["inference_fn"]
73
+
74
+ # download the model weights
75
+ model_weights = []
76
+ for model_weight in model_weights_url:
77
+ weight_file = os.path.join(ASSET_DIR, model_weight.split("/")[-1])
78
+ if not os.path.exists(weight_file):
79
+ download_model(model_weight, weight_file)
80
+ model_weights.append(weight_file)
81
+
82
+ # download the label mapping
83
+ label_map_csv = os.path.join(ASSET_DIR, label_map_url.split("/")[-1])
84
+ if not os.path.exists(label_map_csv):
85
+ download_model(label_map_url, label_map_csv)
86
 
87
+ # load the label mapping
88
+ label_mapping = pd.read_csv(label_map_csv)
89
+ species_id_to_name = {row["species_id"]: row["scientific_name"] for _, row in label_mapping.iterrows()}
90
+
91
+ # preprocess the audio clip
92
+ spectrogram = preprocess_fn(audio_clip, sr=sr)
93
+
94
+ # run inference
95
+ predictions = inference_fn(model_weights, spectrogram, device=DEVICE)
96
 
97
+ # aggregate the results
98
+ final_predicts = predictions.mean(axis=0)
99
+ topk_values, topk_indices = torch.topk(torch.from_numpy(final_predicts), 10)
100
+
101
+ results = []
102
+ for idx, scores in zip(topk_indices, topk_values):
103
+ species_name = species_id_to_name[idx.item()]
104
+ probability = scores.item() * 100
105
+ results.append([species_name, probability])
106
 
107
+ return results
108
 
 
 
 
109
 
110
+ def predict(audio, start, end, model_name="BirdAST_Seq"):
111
+
112
+ raw_sr, audio_array = audio
113
+
114
+ if audio_array.ndim > 1:
115
+ audio_array = audio_array.mean(axis=1) # convert to mono
116
+
117
+ print(f"Audio shape raw: {audio_array.shape}, sr: {raw_sr}")
118
+
119
+ # sainty checks
120
+ len_audio = audio_array.shape[0] / raw_sr
121
+ if start >= end:
122
+ raise gr.Error(f"`start` ({start}) must be smaller than end ({end}s)")
123
+
124
+ if audio_array.shape[0] < start * raw_sr:
125
+ raise gr.Error(f"`start` ({start}) must be smaller than audio duration ({len_audio:.0f}s)")
126
+
127
+ if audio_array.shape[0] > end * raw_sr:
128
+ end = audio_array.shape[0] / (1.0*raw_sr)
129
+
130
+ audio_array = np.array(audio_array, dtype=np.float32) / 32768.0
131
+ audio_array = audio_array[int(start*raw_sr) : int(end*raw_sr)]
132
+
133
+ if raw_sr != DEFUALT_SR:
134
+ # run bandpass filter & resample
135
+ audio_array = bandpass_filter(audio_array, DEFUALT_LOW_CUT, DEFUALT_HIGH_CUT, raw_sr)
136
+ audio_array = librosa.resample(audio_array, orig_sr=raw_sr, target_sr=DEFUALT_SR)
137
+ print(f"Resampled Audio shape: {audio_array.shape}")
138
 
139
+ audio_array = audio_array.astype(np.float32)
140
+
141
+ # predict audio class
142
+ audio_class = predict_class(audio_array)
143
+
144
+ fig_spectrogram = plot_mel(DEFUALT_SR, audio_array)
145
+ fig_waveform = plot_wave(DEFUALT_SR, audio_array)
146
+
147
+ # run inference with model
148
+ print(f"Running inference with model: {model_name}")
149
+ species_class = run_inference_with_model(audio_array, DEFUALT_SR, model_name)
150
+
151
+ return audio_class, species_class, fig_waveform, fig_spectrogram
152
 
 
153
 
154
  DESCRIPTION = """
155
  # Introduction
 
193
 
194
 
195
 
 
196
  class Seafoam(Base):
197
  def __init__(
198
  self,
 
263
 
264
  [3] https://www.kaggle.com/code/dima806/bird-species-by-sound-detection
265
  """
266
+
267
+ # Function to handle model selection
268
+ def handle_model_selection(model_name):
269
+ # Inform user that download is starting
270
+ # gr.Info(f"Downloading model weights for {model_name}...")
271
+ print(f"Downloading model weights for {model_name}...")
272
+ assets = ASSET_DICT[model_name]
273
+ model_weights_url = assets["model_weights"]
274
+ download_flag = True
275
+ try:
276
+ for model_weight in model_weights_url:
277
+ weight_file = os.path.join(ASSET_DIR, model_weight.split("/")[-1])
278
+ print(weight_file)
279
+ if not os.path.exists(weight_file):
280
+ download_model(model_weight, weight_file)
281
+
282
+ if not os.path.exists(weight_file):
283
+ download_flag = False
284
+ break
285
+
286
+ if download_flag:
287
+ gr.Info(f"Model {model_name} is ready for prediction!")
288
+ else:
289
+ gr.Error(f"An error occurred while downloading model weights!")
290
+
291
+ except Exception as e:
292
+ gr.Error(f"An error occurred while downloading model weights: {e}")
293
+
294
+
295
  with gr.Blocks(theme = seafoam, css = css, js = js) as demo:
296
 
297
  gr.Markdown('<div class="logo-container"><img src="https://i.ibb.co/vcG9kr0/vojlogo.jpg" width="50px" alt="vojlogo"></div>')
298
  gr.Markdown('<div id="gradio-animation"></div>')
299
  gr.Markdown(DESCRIPTION)
300
+
301
+ # add dropdown for model selection
302
+ model_names = ['BirdAST', 'BirdAST_Seq', 'EfficientNet']
303
+ model_dropdown = gr.Dropdown(label="Choose a model", choices=model_names)
304
+ model_dropdown.change(handle_model_selection, inputs=model_dropdown)
305
+
306
  with gr.Row():
307
  with gr.Column(elem_classes="column-container"):
308
  start_time_input = gr.Number(label="Start Time", value=0, elem_classes="number-input full-height")
 
310
  with gr.Column():
311
  audio_input = gr.Audio(label="Input Audio", elem_classes="full-height")
312
 
 
313
  with gr.Row():
314
  raw_class_output = gr.Dataframe(headers=["Class", "Score [%]"], row_count=10, label="Class Prediction")
315
  species_output = gr.Dataframe(headers=["Class", "Score [%]"], row_count=10, label="Species Prediction")
 
318
  waveform_output = gr.Plot(label="Waveform")
319
  spectrogram_output = gr.Plot(label="Spectrogram")
320
 
321
+ # gr.Examples(
322
+ # examples=[
323
+ # ["1094_Pionus_fuscus_2.wav", 0, 10],
324
+ # ],
325
+ # inputs=[audio_input, start_time_input, end_time_input]
326
+ # )
327
 
328
+ gr.Button("Predict").click(predict, [audio_input, start_time_input, end_time_input, model_dropdown], [raw_class_output, species_output, waveform_output, spectrogram_output])
329
 
330
  gr.Markdown(REFERENCES)
331
 
classpred.py → audio_class_predictor.py RENAMED
@@ -7,6 +7,7 @@ from torchaudio.compliance import kaldi
7
  import torch.nn.functional as F
8
  import requests
9
 
 
10
  TAG = "gaunernst/vit_base_patch16_1024_128.audiomae_as2m_ft_as20k"
11
  MODEL = timm.create_model(f"hf_hub:{TAG}", pretrained=True).eval()
12
 
@@ -27,12 +28,13 @@ def preprocess(x: torch.Tensor):
27
  melspec = (melspec - MEAN) / (STD * 2)
28
  return melspec
29
 
30
- def predict_class(x, sr, start, end):
 
31
  x = torch.from_numpy(x)
32
  if x.ndim > 1:
33
  x = x.mean(-1)
34
  assert x.ndim == 1
35
- x = resample(x[int(start * sr) : int(end * sr)], sr, SAMPLING_RATE)
36
  x = preprocess(x)
37
 
38
  with torch.inference_mode():
 
7
  import torch.nn.functional as F
8
  import requests
9
 
10
+
11
  TAG = "gaunernst/vit_base_patch16_1024_128.audiomae_as2m_ft_as20k"
12
  MODEL = timm.create_model(f"hf_hub:{TAG}", pretrained=True).eval()
13
 
 
28
  melspec = (melspec - MEAN) / (STD * 2)
29
  return melspec
30
 
31
+ def predict_class(x: np.ndarray):
32
+
33
  x = torch.from_numpy(x)
34
  if x.ndim > 1:
35
  x = x.mean(-1)
36
  assert x.ndim == 1
37
+
38
  x = preprocess(x)
39
 
40
  with torch.inference_mode():
bird_ast_model.py ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ import torch.nn.functional as F
4
+ from transformers import ASTConfig, ASTFeatureExtractor, ASTModel
5
+
6
+ BirdAST_FEATURE_EXTRACTOR = ASTFeatureExtractor()
7
+ DEFAULT_SR = 16_000
8
+ DEFAULT_BACKBONE = "MIT/ast-finetuned-audioset-10-10-0.4593"
9
+ DEFAULT_N_CLASSES = 728
10
+ DEFAULT_ACTIVATION = "silu"
11
+ DEFAULT_N_MLP_LAYERS = 1
12
+
13
+
14
+ def birdast_preprocess(audio_array, sr=DEFAULT_SR):
15
+ """
16
+ Preprocess audio array for BirdAST model
17
+ audio_array: np.array, audio array of the recording, shape (n_samples,) Note: The audio array should be normalized to [-1, 1]
18
+ sr: int, sampling rate of the audio array (default: 16_000)
19
+
20
+ Note:
21
+ 1. The audio array should be normalized to [-1, 1].
22
+ 2. The audio length should be 10 seconds (or 10.24 seconds). Longer audio will be truncated.
23
+ """
24
+ # Extract features
25
+ features = BirdAST_FEATURE_EXTRACTOR(audio_array, sampling_rate=sr, padding="max_length", return_tensors="pt")
26
+
27
+ # Convert to PyTorch tensor
28
+ spectrogram = torch.tensor(features['input_values']).squeeze(0)
29
+
30
+ return spectrogram
31
+
32
+
33
+ def birdast_inference(
34
+ model_weights,
35
+ spectrogram,
36
+ device = 'cpu',
37
+ backbone_name=DEFAULT_BACKBONE,
38
+ n_classes=DEFAULT_N_CLASSES,
39
+ activation=DEFAULT_ACTIVATION,
40
+ n_mlp_layers=DEFAULT_N_MLP_LAYERS
41
+ ):
42
+
43
+ """
44
+ Perform inference on BirdAST model
45
+ model_weights: list, list of model weights
46
+ spectrogram: torch.Tensor, spectrogram tensor, shape (batch_size, n_frames, n_mels,)
47
+ device: str, device to run inference (default: 'cpu')
48
+ backbone_name: str, name of the backbone model (default: 'MIT/ast-finetuned-audioset-10-10-0.4593')
49
+ n_classes: int, number of classes (default: 728)
50
+ activation: str, activation function (default: 'silu')
51
+ n_mlp_layers: int, number of MLP layers (default: 1)
52
+
53
+ Returns:
54
+ predictions: np.array, array of predictions, shape (n_models, batch_size, n_classes)
55
+ """
56
+
57
+ model = BirdAST(
58
+ backbone_name=backbone_name,
59
+ n_classes=n_classes,
60
+ n_mlp_layers=n_mlp_layers,
61
+ activation=activation
62
+ )
63
+
64
+ predict_collects = []
65
+ for _weights in model_weights:
66
+ model.load_state_dict(torch.load(_weights, map_location=device))
67
+ if device != 'cpu': model.to(device)
68
+ model.eval()
69
+
70
+ with torch.no_grad():
71
+ if device != 'cpu': spectrogram = spectrogram.to(device)
72
+
73
+ # check if the input tensor is in the correct shape
74
+ if spectrogram.dim() == 2:
75
+ spectrogram = spectrogram.unsqueeze(0) # -> (batch_size, n_frames, n_mels)
76
+
77
+ output = model(spectrogram)
78
+ logits = output['logits']
79
+ probs = F.softmax(logits, dim=-1)
80
+ predict_collects.append(probs)
81
+
82
+ if device != 'cpu':
83
+ predict_collects = [pred.cpu() for pred in predict_collects]
84
+
85
+ predict_collects = torch.cat(predict_collects, dim=0).numpy()
86
+
87
+ return predict_collects
88
+
89
+
90
+ class BirdAST(nn.Module):
91
+
92
+ def __init__(self, backbone_name, n_classes, n_mlp_layers=1, activation='silu'):
93
+ super(BirdAST, self).__init__()
94
+
95
+ # pre-trained backbone
96
+ backbone_config = ASTConfig.from_pretrained(backbone_name)
97
+ self.ast = ASTModel.from_pretrained(backbone_name, config=backbone_config)
98
+ self.hidden_size = backbone_config.hidden_size
99
+
100
+ # set activation functions
101
+ if activation == 'relu':
102
+ self.activation = nn.ReLU()
103
+ elif activation == 'silu':
104
+ self.activation = nn.SiLU()
105
+ else:
106
+ raise ValueError("Unsupported activation function. Choose 'relu' or 'silu'.")
107
+
108
+ # define MLP layers with activation
109
+ layers = []
110
+ for _ in range(n_mlp_layers):
111
+ layers.append(nn.Linear(self.hidden_size, self.hidden_size))
112
+ layers.append(self.activation)
113
+ layers.append(nn.Linear(self.hidden_size, n_classes))
114
+ self.mlp = nn.Sequential(*layers)
115
+
116
+ def forward(self, spectrogram):
117
+ # spectrogram: (batch_size, n_frames, n_mels)
118
+ # output: (batch_size, n_classes)
119
+
120
+ ast_output = self.ast(spectrogram, output_hidden_states=False)
121
+ logits = self.mlp(ast_output.last_hidden_state[:, 0, :]) # Use the CLS token
122
+
123
+ return {'logits': logits}
124
+
125
+
126
+
127
+ if __name__ == '__main__':
128
+
129
+ import numpy as np
130
+ import matplotlib.pyplot as plt
131
+
132
+ # example usage of BirdAST_Seq
133
+ # create random audio array
134
+ audio_array = np.random.randn(160_000 * 10)
135
+
136
+ # Preprocess audio array
137
+ spectrogram = birdast_preprocess(audio_array)
138
+
139
+ model_weights_dir = '/workspace/voice_of_jungle/training_logs'
140
+
141
+ # Load model weights
142
+ model_weights = [f'{model_weights_dir}/BirdAST_Baseline_GroupKFold_fold_{i}.pth' for i in range(5)]
143
+
144
+ # Perform inference
145
+ predictions = birdast_inference(model_weights, spectrogram.unsqueeze(0))
146
+
147
+ # Plot predictions
148
+ fig, ax = plt.subplots()
149
+ for i, pred in enumerate(predictions):
150
+ ax.plot(pred[0], label=f'model_{i}')
151
+ ax.legend()
152
+ fig.savefig('test_BirdAST_Seq.png')
153
+
154
+ print("Inference completed successfully!")
bird_ast_seq_model.py ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+ from transformers import ASTConfig, ASTFeatureExtractor, ASTModel
5
+
6
+ BirdAST_FEATURE_EXTRACTOR = ASTFeatureExtractor()
7
+ DEFAULT_SR = 16_000
8
+ DEFAULT_BACKBONE = "MIT/ast-finetuned-audioset-10-10-0.4593"
9
+ DEFAULT_N_CLASSES = 728
10
+ DEFAULT_ACTIVATION = "silu"
11
+ DEFAULT_N_MLP_LAYERS = 1
12
+
13
+
14
+ def birdast_seq_preprocess(audio_array, sr=DEFAULT_SR):
15
+ """
16
+ Preprocess audio array for BirdAST model
17
+ audio_array: np.array, audio array of the recording, shape (n_samples,) Note: The audio array should be normalized to [-1, 1]
18
+ sr: int, sampling rate of the audio array (default: 16_000)
19
+
20
+ Note:
21
+ 1. The audio array should be normalized to [-1, 1].
22
+ 2. The audio length should be 10 seconds (or 10.24 seconds). Longer audio will be truncated.
23
+ """
24
+ # Extract features
25
+ features = BirdAST_FEATURE_EXTRACTOR(audio_array, sampling_rate=sr, padding="max_length", return_tensors="pt")
26
+
27
+ # Convert to PyTorch tensor
28
+ spectrogram = torch.tensor(features['input_values']).squeeze(0)
29
+
30
+ return spectrogram
31
+
32
+
33
+ def birdast_seq_inference(
34
+ model_weights,
35
+ spectrogram,
36
+ device = 'cpu',
37
+ backbone_name=DEFAULT_BACKBONE,
38
+ n_classes=DEFAULT_N_CLASSES,
39
+ activation=DEFAULT_ACTIVATION,
40
+ n_mlp_layers=DEFAULT_N_MLP_LAYERS
41
+ ):
42
+
43
+ """
44
+ Perform inference on BirdAST model
45
+ model_weights: list, list of model weights
46
+ spectrogram: torch.Tensor, spectrogram tensor, shape (batch_size, n_frames, n_mels,)
47
+ device: str, device to run inference (default: 'cpu')
48
+ backbone_name: str, name of the backbone model (default: 'MIT/ast-finetuned-audioset-10-10-0.4593')
49
+ n_classes: int, number of classes (default: 728)
50
+ activation: str, activation function (default: 'silu')
51
+ n_mlp_layers: int, number of MLP layers (default: 1)
52
+
53
+ Returns:
54
+ predictions: np.array, array of predictions, shape (n_models, batch_size, n_classes)
55
+ """
56
+
57
+ model = BirdAST_Seq(
58
+ backbone_name=backbone_name,
59
+ n_classes=n_classes,
60
+ n_mlp_layers=n_mlp_layers,
61
+ activation=activation
62
+ )
63
+
64
+ predict_collects = []
65
+
66
+ for _weight in model_weights:
67
+ model.load_state_dict(torch.load(_weight, map_location=device))
68
+ if device != 'cpu': model.to(device)
69
+ model.eval()
70
+
71
+ with torch.no_grad():
72
+ if device != 'cpu': spectrogram = spectrogram.to(device)
73
+
74
+ #check if the input tensor is in the correct shape
75
+ if spectrogram.dim() == 2:
76
+ spectrogram = spectrogram.unsqueeze(0) #-> (batch_size, n_frames, n_mels)
77
+
78
+ output = model(spectrogram)
79
+ logits = output['logits']
80
+ predictions = F.softmax(logits, dim=1)
81
+ predict_collects.append(predictions)
82
+
83
+ if device != 'cpu':
84
+ predict_collects = [pred.cpu() for pred in predict_collects]
85
+
86
+ predict_collects = torch.cat(predict_collects, dim=0).numpy()
87
+
88
+ return predict_collects
89
+
90
+
91
+ class SelfAttentionPooling(nn.Module):
92
+ """
93
+ Implementation of SelfAttentionPooling
94
+ Original Paper: Self-Attention Encoding and Pooling for Speaker Recognition
95
+ https://arxiv.org/pdf/2008.01077v1.pdf
96
+ """
97
+ def __init__(self, input_dim):
98
+ super(SelfAttentionPooling, self).__init__()
99
+ self.W = nn.Linear(input_dim, 1)
100
+ self.softmax = nn.Softmax(dim=1)
101
+
102
+ def forward(self, batch_rep):
103
+ """
104
+ input:
105
+ batch_rep : size (N, T, H), N: batch size, T: sequence length, H: Hidden dimension
106
+ attention_weight:
107
+ att_w : size (N, T, 1)
108
+ return:
109
+ utter_rep: size (N, H)
110
+ """
111
+ att_w = self.softmax(self.W(batch_rep).squeeze(-1)).unsqueeze(-1)
112
+ utter_rep = torch.sum(batch_rep * att_w, dim=1)
113
+
114
+ return utter_rep
115
+
116
+
117
+ class BirdAST_Seq(nn.Module):
118
+
119
+ def __init__(self, backbone_name, n_classes, n_mlp_layers=1, activation='silu'):
120
+ super(BirdAST_Seq, self).__init__()
121
+
122
+ # pre-trained backbone
123
+ backbone_config = ASTConfig.from_pretrained(backbone_name)
124
+ self.ast = ASTModel.from_pretrained(backbone_name, config=backbone_config)
125
+ self.hidden_size = backbone_config.hidden_size
126
+
127
+ # set activation functions
128
+ if activation == 'relu':
129
+ self.activation = nn.ReLU()
130
+ elif activation == 'silu':
131
+ self.activation = nn.SiLU()
132
+ elif activation == 'gelu':
133
+ self.activation = nn.GELU()
134
+ else:
135
+ raise ValueError("Unsupported activation function. Choose 'relu', 'silu' or 'gelu'")
136
+
137
+ #define self-attention pooling layer
138
+ self.sa_pool = SelfAttentionPooling(self.hidden_size)
139
+
140
+ # define MLP layers with activation
141
+ layers = []
142
+ for _ in range(n_mlp_layers):
143
+ layers.append(nn.Linear(self.hidden_size, self.hidden_size))
144
+ layers.append(self.activation)
145
+ layers.append(nn.Linear(self.hidden_size, n_classes))
146
+ self.mlp = nn.Sequential(*layers)
147
+
148
+ def forward(self, spectrogram):
149
+ # spectrogram: (batch_size, n_mels, n_frames)
150
+ # output: (batch_size, n_classes)
151
+
152
+ ast_output = self.ast(spectrogram, output_hidden_states=False)
153
+ hidden_state = ast_output.last_hidden_state
154
+ pool_output = self.sa_pool(hidden_state)
155
+ logits = self.mlp(pool_output)
156
+
157
+ return {'logits': logits}
158
+
159
+
160
+
161
+ if __name__ == '__main__':
162
+
163
+ import numpy as np
164
+ import matplotlib.pyplot as plt
165
+
166
+ # example usage of BirdAST_Seq
167
+ # create random audio array
168
+ audio_array = np.random.randn(160_000 * 10)
169
+
170
+ # Preprocess audio array
171
+ spectrogram = birdast_seq_preprocess(audio_array)
172
+
173
+ model_weights_dir = '/workspace/voice_of_jungle/training_logs'
174
+
175
+ # Load model weights
176
+ model_weights = [f'{model_weights_dir}/BirdAST_SeqPool_GroupKFold_fold_{i}.pth' for i in range(5)]
177
+
178
+ # Perform inference
179
+ predictions = birdast_seq_inference(model_weights, spectrogram.unsqueeze(0))
180
+
181
+ # Plot predictions
182
+ fig, ax = plt.subplots()
183
+ for i, pred in enumerate(predictions):
184
+ ax.plot(pred[0], label=f'model_{i}')
185
+ ax.legend()
186
+ fig.savefig('test_BirdAST_Seq.png')
187
+
188
+ print("Inference completed successfully!")
efficientnet.py ADDED
File without changes
example.jpg DELETED
Binary file (17 kB)
 
label_mapping.csv DELETED
@@ -1,729 +0,0 @@
1
- scientific_name,species_id
2
- Accipiter_superciliosus,0
3
- Akletos_melanoceps,1
4
- Amazona_amazonica,2
5
- Amazona_diadema,3
6
- Amazona_farinosa,4
7
- Amazona_festiva,5
8
- Amblycercus_holosericeus,6
9
- Ammodramus_aurifrons,7
10
- Ammonastes_pelzelni,8
11
- Ampelion_rufaxilla,9
12
- Anabazenops_dorsalis,10
13
- Anairetes_parulus,11
14
- Andigena_hypoglauca,12
15
- Anhima_cornuta,13
16
- Anisognathus_lacrymosus,14
17
- Anthracothorax_viridigula,15
18
- Antrostomus_rufus,16
19
- Ara_ararauna,17
20
- Ara_chloropterus,18
21
- Ara_severus,19
22
- Aramides_cajaneus,20
23
- "Aramus_Vieillot,",21
24
- Aratinga_leucophthalma,22
25
- Ardea_cocoi,23
26
- Arremon_abeillei,24
27
- Arremon_assimilis,25
28
- Arremon_taciturnus,26
29
- Asthenes_flammulata,27
30
- Atlapetes_latinuchus,28
31
- Atticora_tibialis,29
32
- Attila_bolivianus,30
33
- Attila_cinnamomeus,31
34
- Attila_citriniventris,32
35
- Attila_spadiceus,33
36
- Automolus_infuscatus,34
37
- Automolus_ochrolaemus,35
38
- Automolus_paraensis,36
39
- Automolus_rufipileatus,37
40
- Automolus_subulatus,38
41
- Basileuterus_tristriatus,39
42
- Berlepschia_rikeri,40
43
- Boissonneaua_matthewsii,41
44
- Brotogeris_chrysoptera,42
45
- Brotogeris_cyanoptera,43
46
- Brotogeris_sanctithomae,44
47
- Brotogeris_versicolurus,45
48
- Bucco_capensis,46
49
- Buteo_nitidus,47
50
- Buteogallus_schistaceus,48
51
- Buteogallus_urubitinga,49
52
- Buthraupis_montana,50
53
- Cacicus_cela,51
54
- Cacicus_chrysonotus,52
55
- Cacicus_haemorrhous,53
56
- Cacicus_leucoramphus,54
57
- Calidris_fuscicollis,55
58
- Campephilus_melanoleucos,56
59
- Campephilus_pollens,57
60
- Campephilus_rubricollis,58
61
- Camptostoma_obsoletum,59
62
- Campylorhamphus_procurvoides,60
63
- Campylorhynchus_fasciatus,61
64
- Cantorchilus_leucotis,62
65
- Capito_auratus,63
66
- Capito_aurovirens,64
67
- Capito_niger,65
68
- Capsiempis_flaveola,66
69
- Carduelis_magellanica,67
70
- Caryothraustes_canadensis,68
71
- Catharus_fuscater,69
72
- Celeus_elegans,70
73
- Celeus_flavus,71
74
- Celeus_grammicus,72
75
- Celeus_torquatus,73
76
- Celeus_undatus,74
77
- Cephalopterus_ornatus,75
78
- Ceratopipra_erythrocephala,76
79
- Ceratotriccus_granadensis,77
80
- Cercomacra_cinerascens,78
81
- Cercomacra_manu,79
82
- Cercomacra_nigrescens,80
83
- Cercomacroides_fuscicauda,81
84
- Cercomacroides_serva,82
85
- Cercomacroides_tyrannina,83
86
- Certhiasomus_stictolaemus,84
87
- Certhiaxis_cinnamomeus,85
88
- Certhiaxis_mustelinus,86
89
- Chaetura_brachyura,87
90
- Chaetura_spinicaudus,88
91
- Chamaeza_mollissima,89
92
- Chamaeza_nobilis,90
93
- Charadrius_collaris,91
94
- Chelidoptera_tenebrosa,92
95
- Chionomesa_fimbriata,93
96
- Chiroxiphia_pareola,94
97
- Chlorestes_cyanus,95
98
- Chloroceryle_americana,96
99
- Chlorophanes_spiza,97
100
- Chlorophonia_pyrrhophrys,98
101
- Chlorornis_riefferii,99
102
- Chlorospingus_flavopectus,100
103
- Chlorostilbon_mellisugus,101
104
- Chlorostilbon_olivaresi,102
105
- Chordeiles_pusillus,103
106
- Chrysomus_icterocephalus,104
107
- Ciccaba_albitarsis,105
108
- Cinnycerthia_peruana,106
109
- Cissopis_leverianus,107
110
- Cistothorus_platensis,108
111
- Cnemoscopus_rubrirostris,109
112
- Cnemotriccus_fuscatus,110
113
- Cnipodectes_subbrunneus,111
114
- Coccycua_minuta,112
115
- Coccyzus_melacoryphus,113
116
- Coeligena_violifer,114
117
- "Coereba_Vieillot,",115
118
- Colaptes_atricollis,116
119
- Colibri_coruscans,117
120
- Columba_speciosa,118
121
- Columbina_cruziana,119
122
- Columbina_minuta,120
123
- Conirostrum_bicolor,121
124
- Conirostrum_margaritae,122
125
- Conopias_parvus,123
126
- Conopias_trivirgatus,124
127
- Conopophaga_aurita,125
128
- Contopus_fumigatus,126
129
- Contopus_punensis,127
130
- Corythopis_torquatus,128
131
- Cranioleuca_antisiensis,129
132
- Cranioleuca_berlepschi,130
133
- Cranioleuca_gutturata,131
134
- Cranioleuca_muelleri,132
135
- Cranioleuca_vulpecula,133
136
- Cranioleuca_vulpina,134
137
- Crax_alector,135
138
- Crax_globulosa,136
139
- Crotophaga_ani,137
140
- Crotophaga_major,138
141
- Crypturellus_bartletti,139
142
- Crypturellus_casiquiare,140
143
- Crypturellus_cinereus,141
144
- Crypturellus_duidae,142
145
- Crypturellus_soui,143
146
- Crypturellus_undulatus,144
147
- Crypturellus_variegatus,145
148
- Cyanerpes_caeruleus,146
149
- Cyanicterus_cyanicterus,147
150
- Cyanocorax_heilprini,148
151
- Cyanocorax_violaceus,149
152
- Cyanocorax_yncas,150
153
- Cyanoloxia_rothschildii,151
154
- Cyanolyca_viridicyanus,152
155
- Cyclarhis_gujanensis,153
156
- Cymbilaimus_lineatus,154
157
- Cyphorhinus_arada,155
158
- Cyphorhinus_thoracicus,156
159
- Cyphos_macrodactylus,157
160
- Dacnis_albiventris,158
161
- Daptrius_ater,159
162
- Deconychura_longicauda,160
163
- Dendrexetastes_rufigula,161
164
- Dendrocincla_fuliginosa,162
165
- Dendrocincla_merula,163
166
- Dendrocolaptes_certhia,164
167
- Dendrocolaptes_hoffmannsi,165
168
- Dendrocolaptes_picumnus,166
169
- Dendrocygna_autumnalis,167
170
- Dendroplex_kienerii,168
171
- Deroptyus_accipitrinus,169
172
- Dichrozona_cincta,170
173
- Diglossa_cyanea,171
174
- Diglossa_mystacalis,172
175
- Diglossa_sittoides,173
176
- Donacobius_atricapilla,174
177
- Dromococcyx_phasianellus,175
178
- Drymophila_devillei,176
179
- Drymophila_striaticeps,177
180
- Dryocopus_lineatus,178
181
- Egretta_alba,179
182
- Egretta_thula,180
183
- Elaenia_flavogaster,181
184
- Elaenia_pallatangae,182
185
- Elaenia_pelzelni,183
186
- Elaenia_ruficeps,184
187
- Elliotomyia_chionogaster,185
188
- Empidonomus_varius,186
189
- Epinecrophylla_amazonica,187
190
- Epinecrophylla_gutturalis,188
191
- Epinecrophylla_haematonota,189
192
- Epinecrophylla_leucophthalma,190
193
- Epinecrophylla_ornata,191
194
- Eriocnemis_alinae,192
195
- Eubucco_richardsoni,193
196
- Euchrepomis_humeralis,194
197
- Eucometis_penicillata,195
198
- Euphonia_cayennensis,196
199
- Euphonia_chlorotica,197
200
- Euphonia_chrysopasta,198
201
- Euphonia_cyanocephala,199
202
- Euphonia_minuta,200
203
- Euphonia_plumbea,201
204
- Euphonia_rufiventris,202
205
- Euphonia_xanthogaster,203
206
- Eupsittula_pertinax,204
207
- Eurypygidae,205
208
- Falco_deiroleucus,206
209
- Falco_femoralis,207
210
- Falco_magnirostris,208
211
- Falco_rufigularis,209
212
- Florisuga_mellivora,210
213
- Formicarius_analis,211
214
- Formicarius_colma,212
215
- Formicivora_grisea,213
216
- Forpus_crassirostris,214
217
- Forpus_xanthops,215
218
- Frederickena_unduliger,216
219
- Frederickena_viridis,217
220
- Fringilla_capensis,218
221
- Fringilla_psaltria,219
222
- Furnarius_figulus,220
223
- Furnarius_leucopus,221
224
- Furnarius_minor,222
225
- Furnarius_torridus,223
226
- Galbacyrhynchus_leucotis,224
227
- Galbalcyrhynchus_purusianus,225
228
- Galbula_cyanescens,226
229
- Galbula_cyanicollis,227
230
- Galbula_dea,228
231
- Galbula_galbula,229
232
- Galbula_leucogastra,230
233
- Galbula_ruficauda,231
234
- Galbula_tombacea,232
235
- Gallinula_galeata,233
236
- Geothlypis_aequinoctialis,234
237
- Geranospiza_caerulescens,235
238
- Glaucidium_bolivianum,236
239
- Glaucidium_brasilianum,237
240
- Glaucidium_hardyi,238
241
- Glyphorynchus_spirurus,239
242
- Grallaria_blakei,240
243
- Grallaria_carrikeri,241
244
- Grallaria_obscura,242
245
- Grallaria_occabambae,243
246
- Grallaria_przewalskii,244
247
- Grallaria_quitensis,245
248
- Grallaria_ruficapilla,246
249
- Grallaria_squamigera,247
250
- Grallaricula_leymebambae,248
251
- Grallaricula_ochraceifrons,249
252
- Graydidascalus_brachyurus,250
253
- Gymnomystax_mexicanus,251
254
- Gymnopithys_leucaspis,252
255
- Gymnopithys_rufigula,253
256
- Gymnopithys_salvini,254
257
- Habia_rubica,255
258
- Hafferia_fortis,256
259
- Haplospiza_rustica,257
260
- Harpia_harpyja,258
261
- Heliangelus_amethysticollis,259
262
- Helicolestes_hamatus,260
263
- Heliornis_fulica,261
264
- Hemithraupis_flavicollis,262
265
- Hemitriccus_griseipectus,263
266
- Hemitriccus_inornatus,264
267
- Hemitriccus_josephinae,265
268
- Hemitriccus_minimus,266
269
- Hemitriccus_minor,267
270
- Hemitriccus_zosterops,268
271
- Henicorhina_leucophrys,269
272
- Henicorhina_leucoptera,270
273
- Henicorhina_leucosticta,271
274
- Herpetotheres_cachinnans,272
275
- Herpsilochmus_axillaris,273
276
- Herpsilochmus_dorsimaculatus,274
277
- Herpsilochmus_dugandi,275
278
- Herpsilochmus_parkeri,276
279
- Herpsilochmus_praedictus,277
280
- Herpsilochmus_stotzi,278
281
- Heterocercus_aurantiivertex,279
282
- Heterocercus_flavivertex,280
283
- Hoploxypterus_cayanus,281
284
- Hylexetastes_perrotii,282
285
- Hylexetastes_uniformis,283
286
- Hylocharis_sapphirina,284
287
- Hylopezus_macularius,285
288
- Hylophilus_brunneiceps,286
289
- Hylophilus_muscicapinus,287
290
- Hylophilus_olivaceus,288
291
- Hylophilus_pectoralis,289
292
- Hylophilus_semicinereus,290
293
- Hylophilus_thoracicus,291
294
- Hylophylax_naevius,292
295
- Hylophylax_punctulatus,293
296
- Hypnelus_bicinctus,294
297
- Hypocnemis_cantator,295
298
- Hypocnemis_flavescens,296
299
- Hypocnemis_hypoxantha,297
300
- Hypocnemis_peruviana,298
301
- Hypocnemis_rondoni,299
302
- Hypocnemis_striata,300
303
- Hypocnemoides_maculicauda,301
304
- Hypocnemoides_melanopogon,302
305
- Ibycter_americanus,303
306
- Icterus_cayanensis,304
307
- Ictinia_plumbea,305
308
- Incaspiza_laeta,306
309
- Incaspiza_watkinsi,307
310
- Inezia_subflava,308
311
- Iodopleura_isabellae,309
312
- Iridosornis_reinhardti,310
313
- Isleria_guttata,311
314
- Islerothraupis_luctuosa,312
315
- Jacamerops_aureus,313
316
- Jacana_jacana,314
317
- Kleinothraupis_atropileus,315
318
- Knipolegus_orenocensis,316
319
- Lampropsar_tanagrinus,317
320
- Lamprospiza_melanoleuca,318
321
- Lanio_fulvus,319
322
- Lanio_versicolor,320
323
- Laniocera_hypopyrra,321
324
- Larus_serranus,322
325
- Laterallus_exilis,323
326
- Lathrotriccus_euleri,324
327
- Leistes_bellicosus,325
328
- Lepidocolaptes_duidae,326
329
- Lepidocolaptes_fatimalimae,327
330
- Lepidocolaptes_fuscicapillus,328
331
- Lepidothrix_coronata,329
332
- Lepidothrix_nattereri,330
333
- Lepidothrix_serena,331
334
- Leptodon_cayanensis,332
335
- Leptopogon_taczanowskii,333
336
- Leptotila_rufaxilla,334
337
- Leptotila_verreauxi,335
338
- Leuconotopicus_fumigatus,336
339
- Leucopternis_kuhli,337
340
- Liosceles_thoracicus,338
341
- Lipaugus_vociferans,339
342
- Loddigesia_mirabilis,340
343
- Lophostrix_cristata,341
344
- Lophotriccus_galeatus,342
345
- Lophotriccus_vitiosus,343
346
- Lurocalis_rufiventris,344
347
- Malacoptila_fusca,345
348
- Manacus_manacus,346
349
- Margarornis_squamiger,347
350
- Mazaria_propinqua,348
351
- Mecocerculus_stictopterus,349
352
- Megascops_albogularis,350
353
- Megascops_choliba,351
354
- Megascops_ingens,352
355
- Megascops_petersoni,353
356
- Megascops_watsonii,354
357
- Megastictus_margaritatus,355
358
- Melanerpes_cruentatus,356
359
- Melanopareia_maranonica,357
360
- Micrastur_gilvicollis,358
361
- Micrastur_mintoni,359
362
- Micrastur_mirandollei,360
363
- Micrastur_ruficollis,361
364
- Micrastur_semitorquatus,362
365
- Microbates_collaris,363
366
- Microcerculus_bambla,364
367
- Microcerculus_marginatus,365
368
- Microrhopias_quixensis,366
369
- Milvago_chimachima,367
370
- Mimus_longicaudatus,368
371
- Mionectes_oleagineus,369
372
- Mionectes_striaticollis,370
373
- Mitrephanes_olivaceus,371
374
- Monasa_atra,372
375
- Monasa_morphoeus,373
376
- Monasa_nigrifrons,374
377
- Muscicapa_similis,375
378
- Myadestes_ralloides,376
379
- Myiarchus_cephalotes,377
380
- Myiarchus_swainsoni,378
381
- Myiarchus_tuberculifer,379
382
- Myiarchus_tyrannulus,380
383
- Myioborus_melanocephalus,381
384
- Myioborus_miniatus,382
385
- Myiodynastes_maculatus,383
386
- Myiopagis_caniceps,384
387
- Myiopagis_flavivertex,385
388
- Myiopagis_gaimardii,386
389
- Myiophobus_cryptoxanthus,387
390
- Myiornis_ecaudatus,388
391
- Myiotheretes_fumigatus,389
392
- Myiothlypis_coronata,390
393
- Myiothlypis_luteoviridis,391
394
- Myiothlypis_nigrocristata,392
395
- Myiozetetes_cayanensis,393
396
- Myiozetetes_luteiventris,394
397
- Myornis_senilis,395
398
- Myrmeciza_atrothorax,396
399
- Myrmeciza_longipes,397
400
- Myrmelastes_humaythae,398
401
- Myrmelastes_hyperythrus,399
402
- Myrmelastes_leucostigma,400
403
- Myrmelastes_rufifacies,401
404
- Myrmoborus_leucophrys,402
405
- Myrmoborus_lugubris,403
406
- Myrmoborus_melanurus,404
407
- Myrmoborus_myotherinus,405
408
- Myrmochanes_hemileucus,406
409
- Myrmoderus_ferruginea,407
410
- Myrmornis_torquata,408
411
- Myrmothera_campanisona,409
412
- Myrmotherula_ambigua,410
413
- Myrmotherula_assimilis,411
414
- Myrmotherula_axillaris,412
415
- Myrmotherula_brachyura,413
416
- Myrmotherula_cherriei,414
417
- Myrmotherula_iheringi,415
418
- Myrmotherula_klagesi,416
419
- Myrmotherula_longipennis,417
420
- Myrmotherula_menetriesii,418
421
- Nasica_longirostris,419
422
- Nemosia_pileata,420
423
- Neoctantes_niger,421
424
- Neopelma_chrysocephalum,422
425
- Neopipo_cinnamomea,423
426
- Nesotriccus_tumbezanus,424
427
- Nonnula_sclateri,425
428
- Notharchus_hyperrhynchus,426
429
- Notharchus_ordii,427
430
- Notharchus_tectus,428
431
- Nothocrax_urumutum,429
432
- Nyctalops_stygius,430
433
- Nyctibius_grandis,431
434
- Nyctibius_leucopterus,432
435
- Nyctidromus_albicollis,433
436
- Nyctiprogne_leucopyga,434
437
- Nystactes_tamatia,435
438
- Nystalus_obamai,436
439
- Ochthoeca_cinnamomeiventris,437
440
- Ochthoeca_diadema,438
441
- Ochthoeca_pulchella,439
442
- Ochthoeca_thoracica,440
443
- Ocreatus_underwoodii,441
444
- Odontophorus_gujanensis,442
445
- Onychorhynchus_coronatus,443
446
- Opisthocomidae,444
447
- Ornithion_inerme,445
448
- Ortalis_guttata,446
449
- Ortalis_motmot,447
450
- Pachyramphus_castaneus,448
451
- Pachyramphus_marginatus,449
452
- Pachyramphus_minor,450
453
- Pachyramphus_polychopterus,451
454
- Pachyramphus_rufus,452
455
- Pachyramphus_surinamus,453
456
- Pachyramphus_versicolor,454
457
- Pachysylvia_hypoxantha,455
458
- Pardirallus_sanguinolentus,456
459
- Paroaria_gularis,457
460
- Patagioenas_cayennensis,458
461
- Patagioenas_plumbea,459
462
- Patagioenas_subvinacea,460
463
- Penelope_jacquacu,461
464
- Penelope_montagnii,462
465
- Percnostola_rufifrons,463
466
- Perissocephalus_tricolor,464
467
- Phacellodomus_rufifrons,465
468
- Phaeomyias_murina,466
469
- Phaeothlypis_fulvicauda,467
470
- Phaeothlypis_rivularis,468
471
- Phaethornis_guy,469
472
- Phaethornis_hispidus,470
473
- Phaethornis_malaris,471
474
- Phaethornis_ruber,472
475
- Phaethornis_rupurumii,473
476
- Phaethornis_superciliosus,474
477
- Phaetusa_simplex,475
478
- Pharomachrus_auriceps,476
479
- Pharomachrus_pavoninus,477
480
- Pheucticus_chrysogaster,478
481
- Pheugopedius_coraya,479
482
- Pheugopedius_euophrys,480
483
- Pheugopedius_genibarbis,481
484
- Pheugopedius_paucimaculatus,482
485
- Philydor_erythropterum,483
486
- Philydor_pyrrhodes,484
487
- Phlegopsis_erythroptera,485
488
- Phlegopsis_nigromaculata,486
489
- Phoenicircus_carnifex,487
490
- Phoenicircus_nigricollis,488
491
- Phyllaemulor_bracteatus,489
492
- Phyllomyias_plumbeiceps,490
493
- Phylloscartes_gualaquizae,491
494
- Phylloscartes_ventralis,492
495
- Piaya_cayana,493
496
- Piaya_melanogaster,494
497
- Piculus_chrysochloros,495
498
- Piculus_flavigula,496
499
- Picumnus_castelnau,497
500
- Picumnus_exilis,498
501
- Picumnus_lafresnayi,499
502
- Picumnus_steindachneri,500
503
- Picumnus_varzeae,501
504
- Pionites_melanocephalus,502
505
- Pionus_fuscus,503
506
- Pionus_menstruus,504
507
- Pipile_cumanensis,505
508
- Pipra_aureola,506
509
- Pipra_pipra,507
510
- Pipraeidea_bonariensis,508
511
- Pipreola_arcuata,509
512
- Piprites_chloris,510
513
- Piranga_hepatica,511
514
- Pitangus_lictor,512
515
- Pitangus_sulphuratus,513
516
- Pithys_albifrons,514
517
- Platyrinchus_coronatus,515
518
- Platyrinchus_platyrhynchos,516
519
- Poecilotriccus_calopterus,517
520
- Poecilotriccus_capitalis,518
521
- Poecilotriccus_latirostris,519
522
- Poecilotriccus_luluae,520
523
- Poecilotriccus_senex,521
524
- Polioptila_attenboroughi,522
525
- Polioptila_guianensis,523
526
- Polioptila_plumbea,524
527
- Polytmus_theresiae,525
528
- Progne_subis,526
529
- Psarocolius_angustifrons,527
530
- Psarocolius_bifasciatus,528
531
- Psarocolius_decumanus,529
532
- Psarocolius_viridis,530
533
- Pseudastur_albicollis,531
534
- Pseudocolaptes_boissonneauii,532
535
- Pseudotriccus_ruficeps,533
536
- Psittacara_frontatus,534
537
- Psittacara_mitratus,535
538
- Psophia_crepitans,536
539
- Pteroglossus_aracari,537
540
- Pteroglossus_azara,538
541
- Pteroglossus_beauharnaisii,539
542
- Pteroglossus_castanotis,540
543
- Pulsatrix_perspicillata,541
544
- Pygiptila_stellaris,542
545
- Pygochelidon_melanoleuca,543
546
- Pyriglena_maura,544
547
- Pyrilia_aurantiocephala,545
548
- Pyrilia_barrabandi,546
549
- Pyrilia_caica,547
550
- Pyrrhomyias_cinnamomeus,548
551
- Pyrrhura_roseifrons,549
552
- Querula_purpurata,550
553
- Ramphastos_sulfuratus,551
554
- Ramphastos_tucanus,552
555
- Ramphastos_vitellinus,553
556
- Ramphocaenus_melanurus,554
557
- Ramphocelus_carbo,555
558
- Ramphocelus_nigrogularis,556
559
- Ramphotrigon_megacephalum,557
560
- Ramphotrigon_ruficauda,558
561
- Rhegmatorhina_berlepschi,559
562
- Rhegmatorhina_cristata,560
563
- Rhegmatorhina_hoffmannsi,561
564
- Rhegmatorhina_melanosticta,562
565
- Rhynchocyclus_olivaceus,563
566
- Rhytipterna_immunda,564
567
- Rhytipterna_simplex,565
568
- Rostrhamus_sociabilis,566
569
- Rufirallus_castaneiceps,567
570
- Rufirallus_viridis,568
571
- Rupicola_rupicola,569
572
- Rynchops_niger,570
573
- Sakesphorus_canadensis,571
574
- Sakesphorus_luctuosus,572
575
- Saltator_coerulescens,573
576
- Saltator_grossus,574
577
- Saltator_maximus,575
578
- Saltator_striatipectus,576
579
- Schiffornis_major,577
580
- Schiffornis_turdina,578
581
- Schistocichla_schistacea,579
582
- Schizoeaca_fuliginosa,580
583
- Sciaphylax_castanea,581
584
- Sciaphylax_hemimelaena,582
585
- Sclateria_naevia,583
586
- Sclerurus_obscurior,584
587
- Sclerurus_rufigularis,585
588
- Scytalopus_altirostris,586
589
- Scytalopus_atratus,587
590
- Scytalopus_femoralis,588
591
- Scytalopus_intermedius,589
592
- Scytalopus_parvirostris,590
593
- Selenidera_gouldii,591
594
- Selenidera_nattereri,592
595
- Selenidera_piperivora,593
596
- Selenidera_reinwardtii,594
597
- Sericossypha_albocristata,595
598
- Serpophaga_hypoleuca,596
599
- Serpophaga_subcristata,597
600
- Sicalis_columbiana,598
601
- Sirystes_sibilator,599
602
- Sirystes_subcanescens,600
603
- Sittasomus_griseicapillus,601
604
- Spinus_olivaceus,602
605
- Spizaetus_ornatus,603
606
- Sporophila_angolensis,604
607
- Sporophila_bouvronides,605
608
- Sporophila_castaneiventris,606
609
- Sporophila_fringilloides,607
610
- Sporophila_luctuosa,608
611
- Sporophila_simplex,609
612
- Sternula_superciliaris,610
613
- Stilpnia_viridicollis,611
614
- Sturnella_militaris,612
615
- Sublegatus_obscurior,613
616
- Synallaxis_albescens,614
617
- Synallaxis_albigularis,615
618
- Synallaxis_azarae,616
619
- Synallaxis_gujanensis,617
620
- Synallaxis_hypospodia,618
621
- Synallaxis_maranonica,619
622
- Synallaxis_rutilans,620
623
- Synallaxis_unirufa,621
624
- Syndactyla_rufosuperciliata,622
625
- Syndactyla_ucayalae,623
626
- Tachycineta_albiventer,624
627
- Tachyphonus_cristatus,625
628
- Tachyphonus_phoenicius,626
629
- Tachyphonus_surinamus,627
630
- Talaphorus_chlorocercus,628
631
- Tangara_cayana,629
632
- Tangara_chilensis,630
633
- Tangara_nigroviridis,631
634
- Tangara_punctata,632
635
- Tangara_varia,633
636
- Tangara_velia,634
637
- Tapera_naevia,635
638
- Taraba_major,636
639
- Terenura_spodioptila,637
640
- Tersina_viridis,638
641
- Thamnomanes_ardesiacus,639
642
- Thamnomanes_caesius,640
643
- Thamnomanes_saturninus,641
644
- Thamnomanes_schistogynus,642
645
- Thamnophilus_aethiops,643
646
- Thamnophilus_amazonicus,644
647
- Thamnophilus_bernardi,645
648
- Thamnophilus_cryptoleucus,646
649
- Thamnophilus_doliatus,647
650
- Thamnophilus_murinus,648
651
- Thamnophilus_nigrocinereus,649
652
- Thamnophilus_punctatus,650
653
- Thamnophilus_ruficapillus,651
654
- Thamnophilus_schistaceus,652
655
- Thamnophilus_stictocephalus,653
656
- Thamnophilus_unicolor,654
657
- Thaumasius_taczanowskii,655
658
- Thlypopsis_inornata,656
659
- Thlypopsis_superciliaris,657
660
- Thraupis_episcopus,658
661
- Thripadectes_scrutator,659
662
- Thripophaga_fusciceps,660
663
- Thryothorus_griseus,661
664
- Tiaris_obscurus,662
665
- Tinamus_major,663
666
- Tityra_cayana,664
667
- Tityra_semifasciata,665
668
- Todirostrum_chrysocrotaphum,666
669
- Todirostrum_maculatum,667
670
- Todirostrum_pictum,668
671
- Tolmomyias_assimilis,669
672
- Tolmomyias_flaviventris,670
673
- Tolmomyias_poliocephalus,671
674
- Tolmomyias_sulphurescens,672
675
- Tolmomyias_traylori,673
676
- Tolmomyias_viridiceps,674
677
- Topaza_pella,675
678
- Topaza_pyra,676
679
- Touit_purpuratus,677
680
- Troglodytes_aedon,678
681
- Troglodytes_solstitialis,679
682
- Trogon_collaris,680
683
- Trogon_curucui,681
684
- Trogon_melanurus,682
685
- Trogon_ramonianus,683
686
- Trogon_rufus,684
687
- Trogon_violaceus,685
688
- Trogon_viridis,686
689
- Tunchiornis_ochraceiceps,687
690
- Turdus_albicollis,688
691
- Turdus_hauxwelli,689
692
- Turdus_ignobilis,690
693
- Turdus_lawrencii,691
694
- Turdus_leucomelas,692
695
- Turdus_maranonicus,693
696
- Turdus_nigriceps,694
697
- Turdus_sanchezorum,695
698
- Turdus_serranus,696
699
- Tyranneutes_stolzmanni,697
700
- Tyranneutes_virescens,698
701
- Tyranniscus_cinereiceps,699
702
- Tyranniscus_uropygialis,700
703
- Tyrannulus_elatus,701
704
- Tyrannus_melancholicus,702
705
- Tyrannus_savana,703
706
- Uranomitra_franciae,704
707
- Uromyias_agraphia,705
708
- Uropsalis_segmentata,706
709
- Veniliornis_cassini,707
710
- Vireo_chivi,708
711
- Vireolanius_leucotis,709
712
- Volatinia_jacarina,710
713
- Wetmorethraupis_sterrhopteron,711
714
- Willisornis_poecilinotus,712
715
- Xenoglaux_loweryi,713
716
- Xenopipo_atronitens,714
717
- Xenops_milleri,715
718
- Xenops_minutus,716
719
- Xiphocolaptes_promeropirhynchus,717
720
- Xipholena_punicea,718
721
- Xiphorhynchus_elegans,719
722
- Xiphorhynchus_guttatus,720
723
- Xiphorhynchus_obsoletus,721
724
- Xiphorhynchus_ocellatus,722
725
- Xiphorhynchus_pardalotus,723
726
- Xiphorhynchus_picus,724
727
- Zimmerius_acer,725
728
- Zimmerius_gracilipes,726
729
- Zimmerius_viridiflavus,727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
utils.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ import librosa
5
+ import noisereduce as nr
6
+ from scipy.signal import butter, lfilter
7
+
8
+
9
+ def bandpass_filter(data, lowcut, highcut, sr, order=5):
10
+ nyquist = 0.5 * sr
11
+ low = lowcut / nyquist
12
+ high = highcut / nyquist
13
+ b, a = butter(order, [low, high], btype='band')
14
+ y = lfilter(b, a, data)
15
+ return y
16
+
17
+
18
+ def plot_mel(sr, x):
19
+ mel_spec = librosa.feature.melspectrogram(y=x, sr=sr, n_mels=128, fmax=10000)
20
+ mel_spec_db = librosa.power_to_db(mel_spec, ref=np.max)
21
+ mel_spec_db = (mel_spec_db - mel_spec_db.min()) / (mel_spec_db.max() - mel_spec_db.min()) # normalize spectrogram to [0,1]
22
+ # mel_spec_db = np.stack([mel_spec_db, mel_spec_db, mel_spec_db], axis=-1) # Convert to 3-channel
23
+ fig, ax = plt.subplots(nrows=1, ncols=1, sharex=True)
24
+ librosa.display.specshow(mel_spec_db, sr=sr, x_axis='time', y_axis='mel', fmin = 0, fmax=10000, ax = ax)
25
+ return fig
26
+
27
+
28
+ def plot_wave(sr, x):
29
+ ry = nr.reduce_noise(y=x, sr=sr)
30
+ fig, ax = plt.subplots(2, 1, figsize=(12, 8))
31
+
32
+ # Plot the original waveform
33
+ librosa.display.waveshow(x, sr=sr, ax=ax[0])
34
+ ax[0].set(title='Original Waveform')
35
+ ax[0].set_xlabel('Time (s)')
36
+ ax[0].set_ylabel('Amplitude')
37
+
38
+ # Plot the noise-reduced waveform
39
+ librosa.display.waveshow(ry, sr=sr, ax=ax[1])
40
+ ax[1].set(title='Noise Reduced Waveform')
41
+ ax[1].set_xlabel('Time (s)')
42
+ ax[1].set_ylabel('Amplitude')
43
+
44
+ plt.tight_layout()
45
+ return fig
46
+
47
+
48
+ def download_model(url, model_path):
49
+ response = requests.get(url)
50
+ response.raise_for_status() # Ensure the request was successful
51
+ with open(model_path, 'wb') as f:
52
+ f.write(response.content)