amroa commited on
Commit
7fb1c65
·
1 Parent(s): 00a5975
Files changed (2) hide show
  1. __pycache__/app.cpython-311.pyc +0 -0
  2. app.py +11 -50
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -9,7 +9,7 @@ from typing import Iterable
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
@@ -107,6 +107,15 @@ def run_inference_with_model(audio_clip, sr, model_name):
107
  return results
108
 
109
 
 
 
 
 
 
 
 
 
 
110
  def predict(audio, start, end, model_name="BirdAST_Seq"):
111
 
112
  raw_sr, audio_array = audio
@@ -151,57 +160,9 @@ def predict(audio, start, end, model_name="BirdAST_Seq"):
151
  return audio_class, species_class, fig_waveform, fig_spectrogram
152
 
153
 
154
- DESCRIPTION = """
155
-
156
- <div align="center">
157
- <b>Team Members: </b>
158
-
159
- Amro Abdrabo [[email protected] | [LinkedIn](https://www.linkedin.com/in/amroabdrabo/)]
160
-
161
- Shiyi Li [[email protected] | [LinkedIn](www.linkedin.com/in/shiyili01)]
162
-
163
- Thomas Radinger [ [email protected] | [LinkedIn](https://www.linkedin.com/in/thomas-radinger-743958142/) ]
164
- </div>
165
-
166
- # Introduction
167
-
168
- Birds are key indicators of ecosystem health and play pivotal roles in maintaining biodiversity [1]. To monitor and protect bird species, automatic bird sound recognition systems are essential. These systems can help in identifying bird species, monitoring their populations, and understanding their behavior. However, building such systems is challenging due to the diversity of bird sounds, complex acoustic interference and limited labeled data.
169
 
170
- To tackle these challenges, we expored the potential of deep learning models for bird sound recognition. In our work, we developed two Audio Spectrogram Transformer (AST) based models: BirdAST and BirdAST_Seq, to predict bird species from audio recordings. We evaluated the models on a dataset of 728 bird species and achieved promising results. Details of the models and evaluation results are provided in the table below. As the field-recordings may contain various types of audio rather than only bird songs/calls, we also employed an Audio Masked AutoEncoder (AudioMAE) model to pre-classify audio clips into bird, insects, rain, environmental noise, and other types [2]. For a full report on work workflow and results, please refer to [link](https://docs.google.com/document/d/17uRGEVz4hxShK4fvWQzIKFJlVwEg9p1rAT9XXDYGE3w/edit?usp=sharing).
171
-
172
- Our contributions have shown the potential of deep learning models for bird sound recognition. We hope that our work can contribute to the development of automatic bird sound recognition systems and help in monitoring and protecting bird species.
173
-
174
- <div align="center">
175
- <b>Model Details</b>
176
-
177
- | Model name | Architecture | ROC-AUC Score |
178
- | --------------- |:------------------------------:|:-------------:|
179
- | BirdAST | AST* + MLP | 0.6825 |
180
- | BirdAST_Seq | AST* + Sequence Pooling + MLP | 0.7335 |
181
-
182
- </div>
183
-
184
- # How to use the space:
185
-
186
- 1. Choose a model from the dropdown list. It will download the model weights automatically if not already downloaded (~30 seconds).
187
- 2. Upload an audio clip and specify the start and end time for prediction.
188
- 3. Click on the "Predict" button to get the predictions.
189
- 4. In the output, you will get the audio type classification (e.g., bird, insects, rain, etc.) in the panel "Class Prediction" and the predicted bird species in the panel "Species Prediction".
190
- * The audio types are predicted as multi-lable classification based on the AudioMAE model. The predicted classes indicate the possible presence of different types of audio in the recording.
191
- * The bird species are predicted as a multi-class classification using the selected model. The predicted classes indicate the most possible bird species present in the recording.
192
- 5. The waveform and spectrogram of the audio clip are displayed in the respective panels.
193
-
194
- **Notes:**
195
- - For an unknown bird species, the model may predict the most similar bird species based on the training data.
196
- - If an audio clip contains non-bird sounds (predicted by the AudioMAE), the bird species prediction may not be accurate.
197
-
198
- **Disclaimer**: The model predictions are based on the training data and may not be accurate for all audio clips. The model is trained on a dataset of 728 bird species and may not generalize well to all bird species.
199
-
200
- <div align="center">
201
- <b>Enjoy the Bird Songs! 🐦🎶
202
- </div>
203
- """
204
 
 
205
 
206
  css = """
207
  #gradio-animation {
 
9
  import gradio as gr
10
  from gradio.themes.base import Base
11
  from gradio.themes.utils import colors, fonts, sizes
12
+ import requests
13
  import torch
14
  import librosa
15
  import torch.nn.functional as F
 
107
  return results
108
 
109
 
110
+
111
+ def load_markdown_from_url(url):
112
+ response = requests.get(url)
113
+ response.raise_for_status()
114
+ return response.text
115
+
116
+ markdown_url = 'https://github.com/AmroAbdrabo/amroa/raw/main/img/desc.md'
117
+ markdown_content = load_markdown_from_url(markdown_url)
118
+
119
  def predict(audio, start, end, model_name="BirdAST_Seq"):
120
 
121
  raw_sr, audio_array = audio
 
160
  return audio_class, species_class, fig_waveform, fig_spectrogram
161
 
162
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
+ DESCRIPTION = markdown_content
166
 
167
  css = """
168
  #gradio-animation {