Update README.md
Browse files
README.md
CHANGED
|
@@ -46,20 +46,44 @@ tags:
|
|
| 46 |
|
| 47 |
### For small pre-trained model
|
| 48 |
|
|
|
|
|
|
|
|
|
|
| 49 |
```discover_midi_dataset_37292_genres_midis_embeddings_cc_by_nc_sa.npy``` - 37292 genre MIDIs embeddings for genre (artist and song) identification tasks
|
| 50 |
|
| 51 |
```discover_midi_dataset_202400_identified_midis_embeddings_cc_by_nc_sa.npy``` - 202400 identified MIDIs embeddings for MIDI identification tasks
|
| 52 |
|
| 53 |
```discover_midi_dataset_3480123_clean_midis_embeddings_cc_by_nc_sa.npy``` - 3480123 select clean MIDIs embeddings for large scale similarity search and analysis tasks
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
### For large pre-trained model
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
```discover_midi_dataset_37303_genres_midis_embeddings_large_cc_by_nc_sa.npy``` - 37303 genre MIDIs embeddings for genre (artist and song) identification tasks
|
| 58 |
|
| 59 |
```discover_midi_dataset_202400_identified_midis_embeddings_large_cc_by_nc_sa.npy``` - 202400 identified MIDIs embeddings for MIDI identification tasks
|
| 60 |
|
| 61 |
```discover_midi_dataset_3480123_clean_midis_embeddings_large_cc_by_nc_sa.npy``` - 3480123 select clean MIDIs embeddings for large scale similarity search and analysis tasks
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
#### Source MIDI dataset: [Discover MIDI Dataset](https://huggingface.co/datasets/projectlosangeles/Discover-MIDI-Dataset)
|
| 64 |
|
| 65 |
***
|
|
@@ -68,6 +92,8 @@ tags:
|
|
| 68 |
|
| 69 |
```midisim-similarity-search-output-samples-CC-BY-NC-SA.zip``` - ~300000 MIDIs indentified with midisim music discovery pipeline with both pre-trained models
|
| 70 |
|
|
|
|
|
|
|
| 71 |
#### Source MIDI dataset: [Discover MIDI Dataset](https://huggingface.co/datasets/projectlosangeles/Discover-MIDI-Dataset)
|
| 72 |
|
| 73 |
***
|
|
@@ -122,7 +148,7 @@ corpus_midi_names, corpus_emb = midisim.load_embeddings(emb_path)
|
|
| 122 |
model_path = midisim.download_model()
|
| 123 |
|
| 124 |
# Option 2: Use main pre-trained midisim model included in midisim PyPI package
|
| 125 |
-
# model_path = get_package_models()[0]['path']
|
| 126 |
|
| 127 |
# Load midisim model
|
| 128 |
model, ctx, dtype = midisim.load_model(model_path)
|
|
@@ -152,7 +178,7 @@ idxs, sims = midisim.cosine_similarity_topk(query_emb, corpus_emb)
|
|
| 152 |
idxs_sims_tvs_list = midisim.idxs_sims_to_sorted_list(idxs, sims)
|
| 153 |
|
| 154 |
# Print corpus matches (and optionally) convert the final result to a handy list for further processing
|
| 155 |
-
corpus_matches_list
|
| 156 |
|
| 157 |
# ================================================================================================
|
| 158 |
# Copy matched MIDIs from the MIDI corpus for listening and further evaluation and analysis
|
|
@@ -166,7 +192,7 @@ out_dir_path = midisim.copy_corpus_files(corpus_matches_list)
|
|
| 166 |
|
| 167 |
### Raw/custom use example
|
| 168 |
|
| 169 |
-
#### Small model (2 epochs)
|
| 170 |
|
| 171 |
```python
|
| 172 |
import torch
|
|
@@ -209,7 +235,7 @@ model.eval()
|
|
| 209 |
autocast_ctx = torch.amp.autocast(device_type=DEVICE, dtype=DTYPE)
|
| 210 |
```
|
| 211 |
|
| 212 |
-
#### Large model (2 epochs)
|
| 213 |
|
| 214 |
```python
|
| 215 |
import torch
|
|
@@ -297,7 +323,7 @@ midi_corpus_file_names, midi_corpus_tokens = map(list, zip(*sorted_midi_corpus))
|
|
| 297 |
model, ctx, dtype = midisim.load_model(verbose=False)
|
| 298 |
|
| 299 |
# Generate MIDI corpus embeddings
|
| 300 |
-
midi_corpus_embeddings = midisim.get_embeddings_bf16(model, midi_corpus_tokens)
|
| 301 |
|
| 302 |
# ================================================================================================
|
| 303 |
|
|
@@ -341,7 +367,7 @@ fast_parallel_extract.fast_parallel_extract()
|
|
| 341 |
|
| 342 |
### Choose and prepare one midisim model and corresponding embeddings set
|
| 343 |
|
| 344 |
-
#### Small model
|
| 345 |
|
| 346 |
```python
|
| 347 |
model_ckpt = 'midisim_small_pre_trained_model_2_epochs_43117_steps_0.3148_loss_0.9229_acc.pth'
|
|
@@ -350,7 +376,7 @@ model_depth = 8
|
|
| 350 |
embeddings_file = 'discover_midi_dataset_3480123_clean_midis_embeddings_cc_by_nc_sa.npy'
|
| 351 |
```
|
| 352 |
|
| 353 |
-
#### Large model
|
| 354 |
|
| 355 |
```python
|
| 356 |
model_ckpt = 'midisim_large_pre_trained_model_2_epochs_86275_steps_0.2054_loss_0.9385_acc.pth'
|
|
@@ -412,10 +438,17 @@ for fa in tqdm.tqdm(filez):
|
|
| 412 |
# ================================================================================================
|
| 413 |
|
| 414 |
# Compute source/query embeddings
|
| 415 |
-
query_emb = midisim.get_embeddings_bf16(model,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
|
| 417 |
# Calculate cosine similarity between source/query MIDI embeddings and embeddings corpus
|
| 418 |
-
idxs, sims = midisim.cosine_similarity_topk(query_emb,
|
|
|
|
|
|
|
|
|
|
| 419 |
|
| 420 |
# ================================================================================================
|
| 421 |
# Processs, print and save results
|
|
@@ -533,4 +566,4 @@ for fa in tqdm.tqdm(filez):
|
|
| 533 |
***
|
| 534 |
|
| 535 |
### Project Los Angeles
|
| 536 |
-
### Tegridy Code
|
|
|
|
| 46 |
|
| 47 |
### For small pre-trained model
|
| 48 |
|
| 49 |
+
#### Mean Pool Embeddings
|
| 50 |
+
* These are standard general purpose embeddings which work best for comparing overall MIDI-to-MIDI similarity
|
| 51 |
+
|
| 52 |
```discover_midi_dataset_37292_genres_midis_embeddings_cc_by_nc_sa.npy``` - 37292 genre MIDIs embeddings for genre (artist and song) identification tasks
|
| 53 |
|
| 54 |
```discover_midi_dataset_202400_identified_midis_embeddings_cc_by_nc_sa.npy``` - 202400 identified MIDIs embeddings for MIDI identification tasks
|
| 55 |
|
| 56 |
```discover_midi_dataset_3480123_clean_midis_embeddings_cc_by_nc_sa.npy``` - 3480123 select clean MIDIs embeddings for large scale similarity search and analysis tasks
|
| 57 |
|
| 58 |
+
#### Weighted Mean Pool Embeddings
|
| 59 |
+
* These embeddings work best for comparing MIDI-tp=MIDI music structure (MIDI pitches) similarity.
|
| 60 |
+
|
| 61 |
+
```discover_midi_dataset_37302_genre_midis_embeddings_1_1_2_weighted_cc_by_nc_sa.npy``` - 37302 genre MIDIs weighted embeddings for genre (artist and song) identification tasks
|
| 62 |
+
|
| 63 |
+
```discover_midi_dataset_190032_identified_midis_embeddings_1_1_2_weighted_cc_by_nc_sa.npy``` - 190032 identified MIDIs weighted embeddings for MIDI identification tasks
|
| 64 |
+
|
| 65 |
+
```discover_midi_dataset_3480123_clean_midis_embeddings_1_1_2_weighted_cc_by_nc_sa.npy``` - 3480123 select clean MIDIs weighted embeddings for large scale similarity search and analysis tasks
|
| 66 |
+
|
| 67 |
### For large pre-trained model
|
| 68 |
|
| 69 |
+
#### Mean Pool Embeddings
|
| 70 |
+
* These are standard general purpose embeddings which work best for comparing overall MIDI-to-MIDI similarity
|
| 71 |
+
|
| 72 |
```discover_midi_dataset_37303_genres_midis_embeddings_large_cc_by_nc_sa.npy``` - 37303 genre MIDIs embeddings for genre (artist and song) identification tasks
|
| 73 |
|
| 74 |
```discover_midi_dataset_202400_identified_midis_embeddings_large_cc_by_nc_sa.npy``` - 202400 identified MIDIs embeddings for MIDI identification tasks
|
| 75 |
|
| 76 |
```discover_midi_dataset_3480123_clean_midis_embeddings_large_cc_by_nc_sa.npy``` - 3480123 select clean MIDIs embeddings for large scale similarity search and analysis tasks
|
| 77 |
|
| 78 |
+
#### Weighted Mean Pool Embeddings
|
| 79 |
+
* These embeddings work best for comparing MIDI-tp=MIDI music structure (MIDI pitches) similarity.
|
| 80 |
+
|
| 81 |
+
```discover_midi_dataset_37287_genres_midis_embeddings_1_1_2_weighted_large_cc_by_nc_sa.npy``` - 37287 genre MIDIs weighted embeddings for genre (artist and song) identification tasks
|
| 82 |
+
|
| 83 |
+
```discover_midi_dataset_190032_identified_midis_embeddings_1_1_2_weighted_large_cc_by_nc_sa.npy``` - 190032 identified MIDIs weighted embeddings for MIDI identification tasks
|
| 84 |
+
|
| 85 |
+
```discover_midi_dataset_3480123_clean_midis_embeddings_1_1_2_weighted_large_cc_by_nc_sa.npy``` - 3480123 select clean MIDIs weighted embeddings for large scale similarity search and analysis tasks
|
| 86 |
+
|
| 87 |
#### Source MIDI dataset: [Discover MIDI Dataset](https://huggingface.co/datasets/projectlosangeles/Discover-MIDI-Dataset)
|
| 88 |
|
| 89 |
***
|
|
|
|
| 92 |
|
| 93 |
```midisim-similarity-search-output-samples-CC-BY-NC-SA.zip``` - ~300000 MIDIs indentified with midisim music discovery pipeline with both pre-trained models
|
| 94 |
|
| 95 |
+
```midisim-similarity-search-output-samples-1-1-2-weighted-CC-BY-NC-SA.zip``` - ~366000 MIDIs indentified with weighted midisim music discovery pipeline with both pre-trained models
|
| 96 |
+
|
| 97 |
#### Source MIDI dataset: [Discover MIDI Dataset](https://huggingface.co/datasets/projectlosangeles/Discover-MIDI-Dataset)
|
| 98 |
|
| 99 |
***
|
|
|
|
| 148 |
model_path = midisim.download_model()
|
| 149 |
|
| 150 |
# Option 2: Use main pre-trained midisim model included in midisim PyPI package
|
| 151 |
+
# model_path = midisim.get_package_models()[0]['path']
|
| 152 |
|
| 153 |
# Load midisim model
|
| 154 |
model, ctx, dtype = midisim.load_model(model_path)
|
|
|
|
| 178 |
idxs_sims_tvs_list = midisim.idxs_sims_to_sorted_list(idxs, sims)
|
| 179 |
|
| 180 |
# Print corpus matches (and optionally) convert the final result to a handy list for further processing
|
| 181 |
+
corpus_matches_list = midisim.print_sorted_idxs_sims_list(idxs_sims_tvs_list, corpus_midi_names, return_as_list=True)
|
| 182 |
|
| 183 |
# ================================================================================================
|
| 184 |
# Copy matched MIDIs from the MIDI corpus for listening and further evaluation and analysis
|
|
|
|
| 192 |
|
| 193 |
### Raw/custom use example
|
| 194 |
|
| 195 |
+
#### Small model (8 layers - 2 epochs)
|
| 196 |
|
| 197 |
```python
|
| 198 |
import torch
|
|
|
|
| 235 |
autocast_ctx = torch.amp.autocast(device_type=DEVICE, dtype=DTYPE)
|
| 236 |
```
|
| 237 |
|
| 238 |
+
#### Large model (16 layers - 2 epochs)
|
| 239 |
|
| 240 |
```python
|
| 241 |
import torch
|
|
|
|
| 323 |
model, ctx, dtype = midisim.load_model(verbose=False)
|
| 324 |
|
| 325 |
# Generate MIDI corpus embeddings
|
| 326 |
+
midi_corpus_embeddings = midisim.get_embeddings_bf16(model, midi_corpus_tokens, verbose=False)
|
| 327 |
|
| 328 |
# ================================================================================================
|
| 329 |
|
|
|
|
| 367 |
|
| 368 |
### Choose and prepare one midisim model and corresponding embeddings set
|
| 369 |
|
| 370 |
+
#### Small model (8 layers)
|
| 371 |
|
| 372 |
```python
|
| 373 |
model_ckpt = 'midisim_small_pre_trained_model_2_epochs_43117_steps_0.3148_loss_0.9229_acc.pth'
|
|
|
|
| 376 |
embeddings_file = 'discover_midi_dataset_3480123_clean_midis_embeddings_cc_by_nc_sa.npy'
|
| 377 |
```
|
| 378 |
|
| 379 |
+
#### Large model (16 layers)
|
| 380 |
|
| 381 |
```python
|
| 382 |
model_ckpt = 'midisim_large_pre_trained_model_2_epochs_86275_steps_0.2054_loss_0.9385_acc.pth'
|
|
|
|
| 438 |
# ================================================================================================
|
| 439 |
|
| 440 |
# Compute source/query embeddings
|
| 441 |
+
query_emb = midisim.get_embeddings_bf16(model,
|
| 442 |
+
input_toks_seqs,
|
| 443 |
+
verbose=False,
|
| 444 |
+
show_progress_bar=False
|
| 445 |
+
)
|
| 446 |
|
| 447 |
# Calculate cosine similarity between source/query MIDI embeddings and embeddings corpus
|
| 448 |
+
idxs, sims = midisim.cosine_similarity_topk(query_emb,
|
| 449 |
+
corpus_emb,
|
| 450 |
+
verbose=False
|
| 451 |
+
)
|
| 452 |
|
| 453 |
# ================================================================================================
|
| 454 |
# Processs, print and save results
|
|
|
|
| 566 |
***
|
| 567 |
|
| 568 |
### Project Los Angeles
|
| 569 |
+
### Tegridy Code 2026
|