keshavbhandari commited on
Commit
d41a884
·
verified ·
1 Parent(s): fcb224d

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +9 -8
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+[https://github.com/keshavbhandari/musical_structure_metrics.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 `analyze_audio_files` function handles splitting the audio, batching, and computing both metrics.
58
 
59
  ```python
60
  import torch
61
- from structure_derivation.analyzer import analyze_audio_files
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
- analysis_results = analyze_audio_files(my_audio_files, model, batch_size=128, segment_seconds=20, target_sr=32000)
84
 
85
  # 4. Print the results
86
- for path, scores in analysis_results.items():
87
- print(f"\n--- Results for: {path} ---")
88
- print(f" Structural Derivation Consistency: {scores['Structural Derivation Consistency']:.4f}")
89
- print(f" Structural Diversity: {scores['Structural Diversity']:.4f}")
 
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