Update README.md
Browse files
README.md
CHANGED
|
@@ -1,92 +1,106 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-nc-4.0
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
from
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
This README serves as the primary documentation for Hugging Face and provides an overview of the model's purpose, data requirements, and usage.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
datasets:
|
| 4 |
+
- rfcx/frugalai
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
metrics:
|
| 8 |
+
- accuracy
|
| 9 |
+
pipeline_tag: audio-classification
|
| 10 |
+
tags:
|
| 11 |
+
- acoustics
|
| 12 |
+
- lgbm
|
| 13 |
+
- frugality
|
| 14 |
+
- signal-processing
|
| 15 |
+
- climate
|
| 16 |
+
- chainsaw
|
| 17 |
+
---
|
| 18 |
+
# Quefrency Guardian: Chainsaw Noise Detector
|
| 19 |
+
|
| 20 |
+
An efficient model to detect chainsaw activity in forest soundscapes using spectral and cepstral audio features. The model is designed for environmental conservation and is based on a LightGBM classifier, capable of low-energy inference on both CPU and GPU devices. This repository provides the complete code and configuration for feature extraction, model implementation, and deployment.
|
| 21 |
+
|
| 22 |
+
## Installation
|
| 23 |
+
|
| 24 |
+
To use the model, clone the repository and install the dependencies:
|
| 25 |
+
|
| 26 |
+
```bash
|
| 27 |
+
git clone https://huggingface.co/your_username/your_model_name
|
| 28 |
+
cd your_model_name
|
| 29 |
+
pip install -r requirements.txt
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Model Overview
|
| 33 |
+
|
| 34 |
+
### Features
|
| 35 |
+
|
| 36 |
+
The model uses:
|
| 37 |
+
- **Spectrogram Features**: Extracted from frequencies between 70-1525 Hz.
|
| 38 |
+
- **Cepstral Features**: Calculated as the FFT of the log spectrogram in a filtered quefrency range.
|
| 39 |
+
- **Time Averaging**: Both feature sets are averaged over the time domain for robustness in noisy settings.
|
| 40 |
+
|
| 41 |
+
### LightGBM Model
|
| 42 |
+
|
| 43 |
+
The model is a **binary classifier** (chainsaw vs environment) trained on the `rfcx/frugalai` dataset. Key model parameters are included in `model/lgbm_params.json`.
|
| 44 |
+
|
| 45 |
+
## Usage
|
| 46 |
+
|
| 47 |
+
### Load the Model and Parameters
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
import json
|
| 51 |
+
from fast_model import FastModel
|
| 52 |
+
|
| 53 |
+
# Load parameters
|
| 54 |
+
with open("model/features.json", "r") as f:
|
| 55 |
+
features = json.load(f)
|
| 56 |
+
|
| 57 |
+
with open("model/lgbm_params.json", "r") as f:
|
| 58 |
+
lgbm_params = json.load(f)
|
| 59 |
+
|
| 60 |
+
# Initialize the model
|
| 61 |
+
model = FastModel(
|
| 62 |
+
feature_params=features,
|
| 63 |
+
lgbm_params=lgbm_params,
|
| 64 |
+
model_file="model/model.txt", # Path to the serialized model file
|
| 65 |
+
device="cuda" # Use 'cpu' if GPU is unavailable
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
# Predict on a Dataset
|
| 69 |
+
from datasets import load_dataset
|
| 70 |
+
dataset = load_dataset("rfcx/frugalai")
|
| 71 |
+
predictions = model.predict(dataset["test"])
|
| 72 |
+
print(predictions)
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### Performance
|
| 76 |
+
|
| 77 |
+
- **Accuracy**: 95% on the test set with a 4.5% FPR at the default threshold.
|
| 78 |
+
- **Low-Energy Mode**: Using only 1 second of audio inference reduces energy consumption by 50%, at the cost of ~1% accuracy.
|
| 79 |
+
- **Environmental Impact**: Inference energy consumption is **0.21 Wh**, tracked using CodeCarbon.
|
| 80 |
+
|
| 81 |
+
### License
|
| 82 |
+
|
| 83 |
+
This project is licensed under the [Creative Commons Attribution Non-Commercial 4.0 International](https://creativecommons.org/licenses/by-nc/4.0/). You are free to share and adapt the work for non-commercial purposes, provided attribution is given.
|
| 84 |
+
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
## File Structure
|
| 88 |
+
π your_model_name/ βββ π model/ β βββ model.txt # Pre-trained LightGBM model β βββ features.json # Feature extraction parameters β βββ lgbm_params.json # LightGBM parameters βββ π README.md # Documentation βββ π LICENSE.md # CC BY-NC 4.0 license βββ π requirements.txt # Python dependencies βββ π fast_model.py # Model implementation
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
## Dataset
|
| 92 |
+
|
| 93 |
+
The model was trained and evaluated on the [Rainforest Connection (RFCx) Frugal AI](https://huggingface.co/datasets/rfcx/frugalai) dataset.
|
| 94 |
+
|
| 95 |
+
#### Labels:
|
| 96 |
+
- `0`: Chainsaw
|
| 97 |
+
- `1`: Environment
|
| 98 |
+
|
| 99 |
+
## Limitations
|
| 100 |
+
|
| 101 |
+
- **Audio Length**: The classifier is designed for 1 to 3 seconds of audio sampled at either 12 kHz or 24 kHz.
|
| 102 |
+
- **Environmental Noise**: The model might misclassify if recordings are noisy or machinery similar to chainsaws is present.
|
| 103 |
+
|
| 104 |
+
---
|
| 105 |
+
|
| 106 |
This README serves as the primary documentation for Hugging Face and provides an overview of the model's purpose, data requirements, and usage.
|