]f43 :ddlZejdddlZddlZddlZddlmZddl Z ddl m Z ddl mZmZmZddlZddlZddlZddlmcmZddlmZddlmZmZddlmZmZdd l m!Z!m"Z"m#Z#m$Z$d Z%d Z&d Z'd Z(ej)*rdndZ+e,de+ej-.e%sej/e%de0dDdeedZ1de0dDdeedZ2e1e2dZ3dZ4dZ5dZ6e5e6Z7dHdZ8e7Z9dZ:Gdde Z;e;Zd"Z?e j@e?ZTe jSd@?ZUdddn #1swxYwYe jVgdAgdBgdCgeOeLeMgDe jWdEXe8eOeLeMeEgeQeReTeUge jBe>dddn #1swxYwYeAYdFGdS)INignore)Iterable)Base)colorsfontssizes) predict_class)birdast_preprocessbirdast_inference)birdast_seq_preprocessbirdast_seq_inference) plot_waveplot_meldownload_modelbandpass_filterz./assetsi>i@icudacpuz Use Device: cg|]}d|d S)zVhttps://huggingface.co/shiyi-li/BirdAST/resolve/main/BirdAST_Baseline_GroupKFold_fold_.pth.0is D:\submisso\voj\app.py r's5  iabhhhz^https://huggingface.co/shiyi-li/BirdAST/resolve/main/BirdAST_Baseline_GroupKFold_label_map.csv) model_weights label_mapping preprocess_fn inference_fncg|]}d|d S)zYhttps://huggingface.co/shiyi-li/BirdAST_Seq/resolve/main/BirdAST_SeqPool_GroupKFold_fold_rrrs rrr1s5  ldekkkrzahttps://huggingface.co/shiyi-li/BirdAST_Seq/resolve/main/BirdAST_SeqPool_GroupKFold_label_map.csv)BirdAST BirdAST_Seqc0t|}|d}|d}|d}|d}g}|D]} tjt| dd} tj| st| | || tjt|dd} tj| st|| tj | } d| D} |||}|||t }| d }tjtj|d \}}g}t#||D]M\}}| |}|d z}|||gN|S)Nrrr r!/c2i|]\}}|d|dS) species_idscientific_namer)r_rows r z,run_inference_with_model..Ys)kkk3#l+S1B-Ckkkr)sr)deviceraxis d) ASSET_DICTospathjoin ASSET_DIRsplitexistsrappendpdread_csviterrowsDEVICEmeantorchtopk from_numpyzipitem) audio_clipr. model_nameassetsmodel_weights_url label_map_urlr r!r model_weight weight_file label_map_csvrspecies_id_to_name spectrogram predictionsfinal_predicts topk_values topk_indicesresultsidxscores species_name probabilitys rrun_inference_with_modelrYAs #F/?+M?+M.)LM)** gll9l.@.@.E.Eb.IJJ w~~k** 6 < 5 5 5[))))GLLM,?,?,D,DR,HIIM 7>>- ( (5}m444K ..MkkR_RhRhRjRjkkk - r222K,}k&IIIK!%%1%--N % 5+;N+K+KR P PKG<5544 V)#((**5 kkmmc)  k23333 Nrc`tj|}||jS)N)requestsgetraise_for_statustext)urlresponses rload_markdown_from_urlraos+|C  H  =rz9https://github.com/AmroAbdrabo/amroa/raw/main/img/desc.mdr$c|\}}|jdkr|d}td|jd||jd|z }||krt jd|d|d|jd||zkrt jd|d |d d|jd||zkr|jdd |zz }t j|t j d z }|t||zt||z}|tkrnt|tt|}tj||t}td|j|t j}t#|}t%t|}t't|} td|t)|t|} || | |fS)Nr0zAudio shape raw: z, sr: rz `start` (z) must be smaller than end (zs)z') must be smaller than audio duration (z.0fg?)dtypeg@)orig_sr target_srzResampled Audio shape: zRunning inference with model: )ndimr@printshapegrErrornparrayfloat32int DEFUALT_SRrDEFUALT_LOW_CUTDEFUALT_HIGH_CUTlibrosaresampleastyper rrrY) audiostartendrGraw_sr audio_array len_audio audio_classfig_spectrogram fig_waveform species_classs rpredictrws FK!!&&A&..  ?k/ ? ?v ? ?@@@!!$v-I ||hM5MMcMMMNNNefn,,hb5bbQZbbbbccccFl**"c&j1(;bj999GCKc%,//#c&j//ABK %k?DTV\]] &{FjYYY  ; (9;;<<<!((44  ,,Kz;77OZ55L 7: 7 7888,[*jQQM  |_ DDra #gradio-animation { font-size: 2em; font-weight: bold; text-align: center; margin-bottom: 20px; } .logo-container img { width: 14%; /* Adjust width as necessary */ display: block; margin: auto; } .number-input { height: 100%; padding-bottom: 60px; /* Adust the value as needed for more or less space */ } .full-height { height: 100%; } .column-container { height: 100%; } ceZdZejejejejej ej e j dddfe j dddfddej ezd ej ezd ej ezd ejezd ejezd ejezde jezee jezzde jezee jezzffdZxZS)Seafoam Quicksandz ui-sans-serifz sans-serifz IBM Plex Monoz ui-monospace monospace primary_hue secondary_hue neutral_hue spacing_size radius_size text_sizefont font_monorrrrrrrrc Zt||||||||dS)Nr)super__init__) selfrrrrrrrr __class__s rrzSeafoam.__init__sH0 #'#%#  r)__name__ __module__ __qualname__remeraldbluegrayr spacing_md radius_mdtext_lgr GoogleFontColorstrSizeFontrr __classcell__)rs@rrrsX+1.,2K*0+).)9(-&+m E [ ) )  (  E _ - -  ( %! ! ! \C'! |c) ! \C' ! j3& ! Z#%! :#! j  5:# $%! :  5:# $%!! ! ! ! ! ! ! ! ! ! rra function createGradioAnimation() { var container = document.getElementById('gradio-animation'); var text = 'Voice of Jungle'; for (var i = 0; i < text.length; i++) { (function(i){ setTimeout(function(){ var letter = document.createElement('span'); letter.style.opacity = '0'; letter.style.transition = 'opacity 0.5s'; letter.innerText = text[i]; container.appendChild(letter); setTimeout(function() { letter.style.opacity = '1'; }, 50); }, i * 250); })(i); } } u # Appendix We have applied the AudioMAE model to pre-classify the 23000+ unlabelled audio clips collected from the Greater Manaus region in the Amazon rainforest. The results of the audio type classification can be found in the following [link](https://drive.google.com/file/d/1uOT88LDnBD-Z3YcFz1e9XjvW2ugCo6EI/view?usp=drive_link). We hope that the pre-classification results can help researchers better exploring the vast collection of audio recordings and facilitate the study of biodiversity in the Amazon rainforest. # References [1] Torkington, S. (2023, February 7). 50% of the global economy is under threat from biodiversity loss. World Economic Forum. Retrieved from https://www.weforum.org/agenda/2023/02/biodiversity-nature-loss-cop15/. [2] Huang, P.-Y., Xu, H., Li, J., Baevski, A., Auli, M., Galuba, W., Metze, F., & Feichtenhofer, C. (2022). Masked Autoencoders that Listen. In NeurIPS. [3] https://www.kaggle.com/code/dima806/bird-species-by-sound-detection # Acknowledgements We would like to thank all organizers, mentors and participants of the AI+Environment EcoHackathon 2024 event for their unwavering support and collaboration. We extend our gratitude to ETH BiodivX, GainForest and ETH AI Center for providing data, facilities and resources that enabled us to analyse the rich data in different ways. Our special thanks to David Dao, Sarah Tariq, Alessandro Amodio for always being there to help us! 🙏🙏🙏 c|td|d|d}t|}|d}d} t|}t|D]\}}tjt|dd}t|tj |sd|d zd |}t||tj |sd }n|r d |d t }nd}n#t$r } d}Yd} ~ nd} ~ wwxYw|S)NzDownloading model weights for z...r#rTr&r'z Downloading rcz of FzModel is ready! 🎉🎉🎉 Using Device: z2An error occurred while downloading model weights.)rhr4len enumerater5r6r7r8r9r:rr?upper Exception) rGdownload_statusrHrI download_flag total_filesrUrKrLes rhandle_model_selectionrs} :: : : :;;;  #F/MP+,, !*+>+.. :"Kq"K"Kk"K"K|[9997>>+..  %    Tmmm]c]i]i]k]kmmOOSO PPPOP sC2D## D9-D44D9)themecssjszm
vojlogo
z!
r#zChoose a model)labelchoicesz Model StatusF)rlinesvalue interactive)inputsoutputszcolumn-container) elem_classesz Start Timeznumber-input full-height)rrrzEnd Timer2z Input Audioz full-height)rrClassz Score [%]zClass Prediction)headers row_countrzSpecies PredictionWaveform)r Spectrogram)z6XC226833-Chestnut-belted_20Chat-Tyrant_20A_2010989.mp3rr2)zAXC812290-Many-striped-Canastero_Teaben_Pe_1jul2022_FSchmitt_1.mp3rr2)z9XC763511-Synallaxis-maronica_Bagua-grande_MixPre-1746.mp3rr2)examplesrPredictT)share)r$)Zwarningsfilterwarningsr5numpyrlpandasr<typingrgradiorjgradio.themes.basergradio.themes.utilsrrrr[rArstorch.nn.functionalnn functionalFaudio_class_predictorr bird_ast_modelr r bird_ast_seq_modelr r utilsrrrrr8rprrrqr is_availabler?rhr6r:makedirsrangebirdast_assetsbirdast_seq_assetsr4rYra markdown_urlmarkdown_contentr DESCRIPTIONrrseafoamr REFERENCESrBlocksdemoMarkdown model_namesDropdownmodel_dropdownTextboxrchangeRowColumnNumberstart_time_inputend_time_inputAudio audio_input Dataframeraw_class_outputspecies_outputPlotwaveform_outputspectrogram_outputExamplesButtonclicklaunchrrrrs!!! ######4444444444 0/////@@@@@@@@LLLLLLLLFFFFFFFFFFFF   :**,, 7%V w~~i  BK  qv'%qy+)% ***\ K )),77)E)E)E)E\ 8" " " " " d" " " J '))* &   FRYwc333(tBKAAABK3444BK m,K R['7MMMN bj~QbV[\\\O0./9Zdsttt TT RY$6 7 7 7 l l(ry|1Smnnn &RYZrPjkkkN l l l l l l l l l l l l l l lRY[[ T T""(]SSSK T T T T T T T T T T T T T T T TTTTTTTTTTTTTTT pp'2<+0FRT\nooo%w .DPRZnoooppppppppppppppp ::!"' 333$RW=999:::::::::::::::BK M M M X X X P P P -~> BIiw6FXf(gjz}KM\^pjqrrrBK Q(((((((((((((((T D sBM:I.+'H I.H" "I.%H" &I.8I I.I I.I I." M:.I2 2M:5I2 6M:+J?3 M:?K M:K M:#L< M:L M:L AM::M>M>