Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -49,16 +49,16 @@ A compelling musical piece might exhibit both high SDC (it's coherent) and high
|
|
| 49 |
Install the package and its dependencies directly from the GitHub repository:
|
| 50 |
|
| 51 |
```bash
|
| 52 |
-
pip install git+
|
| 53 |
```
|
| 54 |
|
| 55 |
### 2. Example Usage
|
| 56 |
|
| 57 |
-
The following script loads the model from Hugging Face, processes a list of audio files, and prints the resulting scores. The `
|
| 58 |
|
| 59 |
```python
|
| 60 |
import torch
|
| 61 |
-
from structure_derivation.
|
| 62 |
from structure_derivation.model.model import StructureDerivationModel
|
| 63 |
|
| 64 |
# 1. Set up the device and load the model
|
|
@@ -80,13 +80,14 @@ my_audio_files = [
|
|
| 80 |
|
| 81 |
# 3. Analyze the files to get the scores
|
| 82 |
# This function returns a dictionary with file paths as keys
|
| 83 |
-
|
| 84 |
|
| 85 |
# 4. Print the results
|
| 86 |
-
for path,
|
| 87 |
-
print(f"\
|
| 88 |
-
print(
|
| 89 |
-
print(
|
|
|
|
| 90 |
```
|
| 91 |
|
| 92 |
### 3. Model Architecture & Training
|
|
|
|
| 49 |
Install the package and its dependencies directly from the GitHub repository:
|
| 50 |
|
| 51 |
```bash
|
| 52 |
+
pip install git+https://github.com/keshavbhandari/musical_structure_metrics.git
|
| 53 |
```
|
| 54 |
|
| 55 |
### 2. Example Usage
|
| 56 |
|
| 57 |
+
The following script loads the model from Hugging Face, processes a list of audio files, and prints the resulting scores. The `process_audio_files` function handles splitting the audio, batching, and computing both metrics.
|
| 58 |
|
| 59 |
```python
|
| 60 |
import torch
|
| 61 |
+
from structure_derivation.inference.batch_inference import process_audio_files
|
| 62 |
from structure_derivation.model.model import StructureDerivationModel
|
| 63 |
|
| 64 |
# 1. Set up the device and load the model
|
|
|
|
| 80 |
|
| 81 |
# 3. Analyze the files to get the scores
|
| 82 |
# This function returns a dictionary with file paths as keys
|
| 83 |
+
results = process_audio_files(audio_paths=my_audio_files, model=model, batch_size=128, segment_seconds=10, target_sr=32000)
|
| 84 |
|
| 85 |
# 4. Print the results
|
| 86 |
+
for path, res in results.items():
|
| 87 |
+
print(f"\nResults for {path}:")
|
| 88 |
+
print("Cosine similarities with S1:", res["similarities"])
|
| 89 |
+
print("Average Structure Derivation:", res["avg_structure_derivation"])
|
| 90 |
+
print("Vendi score:", res["vendi_score"])
|
| 91 |
```
|
| 92 |
|
| 93 |
### 3. Model Architecture & Training
|