projectlosangeles
commited on
Commit
•
cdeaa72
1
Parent(s):
0440c3d
Upload 5 files
Browse files
Monster_MIDI_Dataset_GPU_Search_and_Filter.ipynb
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
"id": "SiTIpPjArIyr"
|
12 |
},
|
13 |
"source": [
|
14 |
-
"# Monster MIDI Dataset GPU Search and Filter (ver.
|
15 |
"\n",
|
16 |
"***\n",
|
17 |
"\n",
|
@@ -196,7 +196,7 @@
|
|
196 |
{
|
197 |
"cell_type": "markdown",
|
198 |
"source": [
|
199 |
-
"# (CREATE MIDI DATASET FILES LIST)"
|
200 |
],
|
201 |
"metadata": {
|
202 |
"id": "GE0hPlAEjCrs"
|
@@ -279,7 +279,7 @@
|
|
279 |
"print('Loading signatures...')\n",
|
280 |
"print('=' * 70)\n",
|
281 |
"\n",
|
282 |
-
"
|
283 |
"\n",
|
284 |
"print('Done!')\n",
|
285 |
"print('=' * 70)"
|
@@ -316,6 +316,25 @@
|
|
316 |
"\n",
|
317 |
"###########\n",
|
318 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
"print('Loading MIDI files...')\n",
|
320 |
"print('This may take a while on a large dataset in particular.')\n",
|
321 |
"\n",
|
@@ -338,8 +357,8 @@
|
|
338 |
"\n",
|
339 |
" ###################\n",
|
340 |
"\n",
|
341 |
-
" if not os.path.exists('/content/Output-MIDI-Dataset/'+search_matching_type):\n",
|
342 |
-
" os.makedirs('/content/Output-MIDI-Dataset/'+search_matching_type)\n",
|
343 |
"\n",
|
344 |
" ###################\n",
|
345 |
"\n",
|
@@ -387,7 +406,7 @@
|
|
387 |
" for c in cscore:\n",
|
388 |
"\n",
|
389 |
" pitches = sorted(set([p[4] for p in c if p[3] != 9]))\n",
|
390 |
-
" drums = sorted(set([p[4] for p in c if p[3] == 9]))\n",
|
391 |
"\n",
|
392 |
" if pitches:\n",
|
393 |
" if len(pitches) > 1:\n",
|
@@ -421,7 +440,10 @@
|
|
421 |
" src_signatures = cp.stack(cp.array(src_sigs))\n",
|
422 |
"\n",
|
423 |
" if not match_drums:\n",
|
424 |
-
" src_signatures =
|
|
|
|
|
|
|
425 |
"\n",
|
426 |
" #=======================================================\n",
|
427 |
"\n",
|
@@ -444,9 +466,6 @@
|
|
444 |
"\n",
|
445 |
" for target_sig in tqdm(src_signatures):\n",
|
446 |
"\n",
|
447 |
-
" if not match_drums:\n",
|
448 |
-
" target_sig = cp.where(target_sig < drums_offset, target_sig, epsilon)\n",
|
449 |
-
"\n",
|
450 |
" comps_lengths = cp.vstack((cp.repeat(cp.sum(target_sig != 0), signatures_data.shape[0]), cp.sum(signatures_data != 0, axis=1)))\n",
|
451 |
" comps_lengths_ratios = cp.divide(cp.min(comps_lengths, axis=0), cp.max(comps_lengths, axis=0))\n",
|
452 |
"\n",
|
@@ -493,9 +512,9 @@
|
|
493 |
"\n",
|
494 |
" filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]\n",
|
495 |
"\n",
|
496 |
-
" filtered_idxs = cp.
|
497 |
"\n",
|
498 |
-
" all_filtered_means.extend(results[
|
499 |
"\n",
|
500 |
" all_filtered_idxs.extend(filtered_idxs.tolist())\n",
|
501 |
"\n",
|
@@ -542,7 +561,7 @@
|
|
542 |
" #=======================================================\n",
|
543 |
"\n",
|
544 |
" dir_str = str(fn1)\n",
|
545 |
-
" copy_path = '/content/Output-MIDI-Dataset/'+search_matching_type+'/'+dir_str\n",
|
546 |
" if not os.path.exists(copy_path):\n",
|
547 |
" os.mkdir(copy_path)\n",
|
548 |
"\n",
|
@@ -675,9 +694,9 @@
|
|
675 |
"\n",
|
676 |
"number_of_top_matches_MIDIs_to_collect = 30 #@param {type:\"slider\", min:5, max:50, step:1}\n",
|
677 |
"maximum_match_ratio_to_search_for = 1 #@param {type:\"slider\", min:0, max:1, step:0.001}\n",
|
678 |
-
"match_results_weight =
|
679 |
-
"match_lengths_weight =
|
680 |
-
"match_counts_weight =
|
681 |
"epsilon = 0.5 # @param {type:\"slider\", min:0.001, max:1, step:0.001}\n",
|
682 |
"\n",
|
683 |
"print('=' * 70)\n",
|
@@ -686,6 +705,19 @@
|
|
686 |
"\n",
|
687 |
"###########\n",
|
688 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
689 |
"print('Loading MIDI files...')\n",
|
690 |
"print('This may take a while on a large dataset in particular.')\n",
|
691 |
"\n",
|
@@ -708,8 +740,8 @@
|
|
708 |
"\n",
|
709 |
" ###################\n",
|
710 |
"\n",
|
711 |
-
" if not os.path.exists('/content/Output-MIDI-Dataset/'+
|
712 |
-
" os.makedirs('/content/Output-MIDI-Dataset/'+
|
713 |
"\n",
|
714 |
" ###################\n",
|
715 |
"\n",
|
@@ -825,9 +857,9 @@
|
|
825 |
"\n",
|
826 |
" filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]\n",
|
827 |
"\n",
|
828 |
-
" filtered_idxs = cp.
|
829 |
"\n",
|
830 |
-
" all_filtered_means.extend(results[
|
831 |
"\n",
|
832 |
" all_filtered_idxs.extend(filtered_idxs.tolist())\n",
|
833 |
"\n",
|
@@ -874,7 +906,7 @@
|
|
874 |
" #=======================================================\n",
|
875 |
"\n",
|
876 |
" dir_str = str(fn1)\n",
|
877 |
-
" copy_path = '/content/Output-MIDI-Dataset/'+
|
878 |
" if not os.path.exists(copy_path):\n",
|
879 |
" os.mkdir(copy_path)\n",
|
880 |
"\n",
|
@@ -1004,7 +1036,7 @@
|
|
1004 |
"colab": {
|
1005 |
"private_outputs": true,
|
1006 |
"provenance": [],
|
1007 |
-
"gpuType": "
|
1008 |
"machine_shape": "hm"
|
1009 |
},
|
1010 |
"kernelspec": {
|
|
|
11 |
"id": "SiTIpPjArIyr"
|
12 |
},
|
13 |
"source": [
|
14 |
+
"# Monster MIDI Dataset GPU Search and Filter (ver. 2.0)\n",
|
15 |
"\n",
|
16 |
"***\n",
|
17 |
"\n",
|
|
|
196 |
{
|
197 |
"cell_type": "markdown",
|
198 |
"source": [
|
199 |
+
"# (CREATE MAIN MIDI DATASET FILES LIST)"
|
200 |
],
|
201 |
"metadata": {
|
202 |
"id": "GE0hPlAEjCrs"
|
|
|
279 |
"print('Loading signatures...')\n",
|
280 |
"print('=' * 70)\n",
|
281 |
"\n",
|
282 |
+
"signatures_data_full = cp.array(sigs_matrixes)\n",
|
283 |
"\n",
|
284 |
"print('Done!')\n",
|
285 |
"print('=' * 70)"
|
|
|
316 |
"\n",
|
317 |
"###########\n",
|
318 |
"\n",
|
319 |
+
"search_settings_string = ''\n",
|
320 |
+
"\n",
|
321 |
+
"if match_drums:\n",
|
322 |
+
" search_settings_string += 'Chords_Drums'\n",
|
323 |
+
"else:\n",
|
324 |
+
" search_settings_string += 'Chords'\n",
|
325 |
+
"\n",
|
326 |
+
"if search_matching_type == 'Distances':\n",
|
327 |
+
" search_settings_string += '_O_' + str(distances_norm_order)\n",
|
328 |
+
"\n",
|
329 |
+
"search_settings_string += '_W_'\n",
|
330 |
+
"search_settings_string += str(match_results_weight) + '_'\n",
|
331 |
+
"search_settings_string += str(match_lengths_weight) + '_'\n",
|
332 |
+
"search_settings_string += str(match_counts_weight)\n",
|
333 |
+
"\n",
|
334 |
+
"search_settings_string += '_E_' + str(epsilon)\n",
|
335 |
+
"\n",
|
336 |
+
"###########\n",
|
337 |
+
"\n",
|
338 |
"print('Loading MIDI files...')\n",
|
339 |
"print('This may take a while on a large dataset in particular.')\n",
|
340 |
"\n",
|
|
|
357 |
"\n",
|
358 |
" ###################\n",
|
359 |
"\n",
|
360 |
+
" if not os.path.exists('/content/Output-MIDI-Dataset/'+search_matching_type+'_'+search_settings_string):\n",
|
361 |
+
" os.makedirs('/content/Output-MIDI-Dataset/'+search_matching_type+'_'+search_settings_string)\n",
|
362 |
"\n",
|
363 |
" ###################\n",
|
364 |
"\n",
|
|
|
406 |
" for c in cscore:\n",
|
407 |
"\n",
|
408 |
" pitches = sorted(set([p[4] for p in c if p[3] != 9]))\n",
|
409 |
+
" drums = sorted(set([p[4]+drums_offset for p in c if p[3] == 9]))\n",
|
410 |
"\n",
|
411 |
" if pitches:\n",
|
412 |
" if len(pitches) > 1:\n",
|
|
|
440 |
" src_signatures = cp.stack(cp.array(src_sigs))\n",
|
441 |
"\n",
|
442 |
" if not match_drums:\n",
|
443 |
+
" src_signatures = src_signatures[:,:drums_offset]\n",
|
444 |
+
" signatures_data = signatures_data_full[:,:drums_offset]\n",
|
445 |
+
" else:\n",
|
446 |
+
" signatures_data = signatures_data_full\n",
|
447 |
"\n",
|
448 |
" #=======================================================\n",
|
449 |
"\n",
|
|
|
466 |
"\n",
|
467 |
" for target_sig in tqdm(src_signatures):\n",
|
468 |
"\n",
|
|
|
|
|
|
|
469 |
" comps_lengths = cp.vstack((cp.repeat(cp.sum(target_sig != 0), signatures_data.shape[0]), cp.sum(signatures_data != 0, axis=1)))\n",
|
470 |
" comps_lengths_ratios = cp.divide(cp.min(comps_lengths, axis=0), cp.max(comps_lengths, axis=0))\n",
|
471 |
"\n",
|
|
|
512 |
"\n",
|
513 |
" filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]\n",
|
514 |
"\n",
|
515 |
+
" filtered_idxs = cp.nonzero(cp.in1d(results, filtered_means))[0]\n",
|
516 |
"\n",
|
517 |
+
" all_filtered_means.extend(results[filtered_idxs].tolist())\n",
|
518 |
"\n",
|
519 |
" all_filtered_idxs.extend(filtered_idxs.tolist())\n",
|
520 |
"\n",
|
|
|
561 |
" #=======================================================\n",
|
562 |
"\n",
|
563 |
" dir_str = str(fn1)\n",
|
564 |
+
" copy_path = '/content/Output-MIDI-Dataset/'+search_matching_type+'_'+search_settings_string+'/'+dir_str\n",
|
565 |
" if not os.path.exists(copy_path):\n",
|
566 |
" os.mkdir(copy_path)\n",
|
567 |
"\n",
|
|
|
694 |
"\n",
|
695 |
"number_of_top_matches_MIDIs_to_collect = 30 #@param {type:\"slider\", min:5, max:50, step:1}\n",
|
696 |
"maximum_match_ratio_to_search_for = 1 #@param {type:\"slider\", min:0, max:1, step:0.001}\n",
|
697 |
+
"match_results_weight = 2 # @param {type:\"slider\", min:0.1, max:3, step:0.1}\n",
|
698 |
+
"match_lengths_weight = 1 # @param {type:\"slider\", min:0.1, max:3, step:0.1}\n",
|
699 |
+
"match_counts_weight = 1 # @param {type:\"slider\", min:0.1, max:3, step:0.1}\n",
|
700 |
"epsilon = 0.5 # @param {type:\"slider\", min:0.001, max:1, step:0.001}\n",
|
701 |
"\n",
|
702 |
"print('=' * 70)\n",
|
|
|
705 |
"\n",
|
706 |
"###########\n",
|
707 |
"\n",
|
708 |
+
"search_settings_string = ''\n",
|
709 |
+
"\n",
|
710 |
+
"search_settings_string += str(search_matching_type).replace('-', '_')\n",
|
711 |
+
"\n",
|
712 |
+
"search_settings_string += '_W_'\n",
|
713 |
+
"search_settings_string += str(match_results_weight) + '_'\n",
|
714 |
+
"search_settings_string += str(match_lengths_weight) + '_'\n",
|
715 |
+
"search_settings_string += str(match_counts_weight)\n",
|
716 |
+
"\n",
|
717 |
+
"search_settings_string += '_E_' + str(epsilon)\n",
|
718 |
+
"\n",
|
719 |
+
"###########\n",
|
720 |
+
"\n",
|
721 |
"print('Loading MIDI files...')\n",
|
722 |
"print('This may take a while on a large dataset in particular.')\n",
|
723 |
"\n",
|
|
|
740 |
"\n",
|
741 |
" ###################\n",
|
742 |
"\n",
|
743 |
+
" if not os.path.exists('/content/Output-MIDI-Dataset/'+search_settings_string):\n",
|
744 |
+
" os.makedirs('/content/Output-MIDI-Dataset/'+search_settings_string)\n",
|
745 |
"\n",
|
746 |
" ###################\n",
|
747 |
"\n",
|
|
|
857 |
"\n",
|
858 |
" filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]\n",
|
859 |
"\n",
|
860 |
+
" filtered_idxs = cp.nonzero(cp.in1d(results, filtered_means))[0]\n",
|
861 |
"\n",
|
862 |
+
" all_filtered_means.extend(results[filtered_idxs].tolist())\n",
|
863 |
"\n",
|
864 |
" all_filtered_idxs.extend(filtered_idxs.tolist())\n",
|
865 |
"\n",
|
|
|
906 |
" #=======================================================\n",
|
907 |
"\n",
|
908 |
" dir_str = str(fn1)\n",
|
909 |
+
" copy_path = '/content/Output-MIDI-Dataset/'+search_settings_string+'/'+dir_str\n",
|
910 |
" if not os.path.exists(copy_path):\n",
|
911 |
" os.mkdir(copy_path)\n",
|
912 |
"\n",
|
|
|
1036 |
"colab": {
|
1037 |
"private_outputs": true,
|
1038 |
"provenance": [],
|
1039 |
+
"gpuType": "A100",
|
1040 |
"machine_shape": "hm"
|
1041 |
},
|
1042 |
"kernelspec": {
|
monster_midi_dataset_gpu_search_and_filter.py
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
Automatically generated by Colaboratory.
|
5 |
|
6 |
Original file is located at
|
7 |
-
https://colab.research.google.com/
|
8 |
|
9 |
-
# Monster MIDI Dataset GPU Search and Filter (ver.
|
10 |
|
11 |
***
|
12 |
|
@@ -103,7 +103,7 @@ print('Done! Enjoy! :)')
|
|
103 |
print('=' * 70)
|
104 |
# %cd /content/
|
105 |
|
106 |
-
"""# (CREATE MIDI DATASET FILES LIST)"""
|
107 |
|
108 |
#@title Create Monster MIDI Dataset files list
|
109 |
print('=' * 70)
|
@@ -162,7 +162,7 @@ print('=' * 70)
|
|
162 |
print('Loading signatures...')
|
163 |
print('=' * 70)
|
164 |
|
165 |
-
|
166 |
|
167 |
print('Done!')
|
168 |
print('=' * 70)
|
@@ -189,6 +189,25 @@ print('=' * 70)
|
|
189 |
|
190 |
###########
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
print('Loading MIDI files...')
|
193 |
print('This may take a while on a large dataset in particular.')
|
194 |
|
@@ -211,8 +230,8 @@ if filez:
|
|
211 |
|
212 |
###################
|
213 |
|
214 |
-
if not os.path.exists('/content/Output-MIDI-Dataset/'+search_matching_type):
|
215 |
-
os.makedirs('/content/Output-MIDI-Dataset/'+search_matching_type)
|
216 |
|
217 |
###################
|
218 |
|
@@ -260,7 +279,7 @@ if filez:
|
|
260 |
for c in cscore:
|
261 |
|
262 |
pitches = sorted(set([p[4] for p in c if p[3] != 9]))
|
263 |
-
drums = sorted(set([p[4] for p in c if p[3] == 9]))
|
264 |
|
265 |
if pitches:
|
266 |
if len(pitches) > 1:
|
@@ -294,7 +313,10 @@ if filez:
|
|
294 |
src_signatures = cp.stack(cp.array(src_sigs))
|
295 |
|
296 |
if not match_drums:
|
297 |
-
src_signatures =
|
|
|
|
|
|
|
298 |
|
299 |
#=======================================================
|
300 |
|
@@ -317,9 +339,6 @@ if filez:
|
|
317 |
|
318 |
for target_sig in tqdm(src_signatures):
|
319 |
|
320 |
-
if not match_drums:
|
321 |
-
target_sig = cp.where(target_sig < drums_offset, target_sig, epsilon)
|
322 |
-
|
323 |
comps_lengths = cp.vstack((cp.repeat(cp.sum(target_sig != 0), signatures_data.shape[0]), cp.sum(signatures_data != 0, axis=1)))
|
324 |
comps_lengths_ratios = cp.divide(cp.min(comps_lengths, axis=0), cp.max(comps_lengths, axis=0))
|
325 |
|
@@ -366,9 +385,9 @@ if filez:
|
|
366 |
|
367 |
filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]
|
368 |
|
369 |
-
filtered_idxs = cp.
|
370 |
|
371 |
-
all_filtered_means.extend(results[
|
372 |
|
373 |
all_filtered_idxs.extend(filtered_idxs.tolist())
|
374 |
|
@@ -415,7 +434,7 @@ if filez:
|
|
415 |
#=======================================================
|
416 |
|
417 |
dir_str = str(fn1)
|
418 |
-
copy_path = '/content/Output-MIDI-Dataset/'+search_matching_type+'/'+dir_str
|
419 |
if not os.path.exists(copy_path):
|
420 |
os.mkdir(copy_path)
|
421 |
|
@@ -521,9 +540,9 @@ print('=' * 70)
|
|
521 |
|
522 |
number_of_top_matches_MIDIs_to_collect = 30 #@param {type:"slider", min:5, max:50, step:1}
|
523 |
maximum_match_ratio_to_search_for = 1 #@param {type:"slider", min:0, max:1, step:0.001}
|
524 |
-
match_results_weight =
|
525 |
-
match_lengths_weight =
|
526 |
-
match_counts_weight =
|
527 |
epsilon = 0.5 # @param {type:"slider", min:0.001, max:1, step:0.001}
|
528 |
|
529 |
print('=' * 70)
|
@@ -532,6 +551,19 @@ print('=' * 70)
|
|
532 |
|
533 |
###########
|
534 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
print('Loading MIDI files...')
|
536 |
print('This may take a while on a large dataset in particular.')
|
537 |
|
@@ -554,8 +586,8 @@ if filez:
|
|
554 |
|
555 |
###################
|
556 |
|
557 |
-
if not os.path.exists('/content/Output-MIDI-Dataset/'+
|
558 |
-
os.makedirs('/content/Output-MIDI-Dataset/'+
|
559 |
|
560 |
###################
|
561 |
|
@@ -671,9 +703,9 @@ if filez:
|
|
671 |
|
672 |
filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]
|
673 |
|
674 |
-
filtered_idxs = cp.
|
675 |
|
676 |
-
all_filtered_means.extend(results[
|
677 |
|
678 |
all_filtered_idxs.extend(filtered_idxs.tolist())
|
679 |
|
@@ -720,7 +752,7 @@ if filez:
|
|
720 |
#=======================================================
|
721 |
|
722 |
dir_str = str(fn1)
|
723 |
-
copy_path = '/content/Output-MIDI-Dataset/'+
|
724 |
if not os.path.exists(copy_path):
|
725 |
os.mkdir(copy_path)
|
726 |
|
|
|
4 |
Automatically generated by Colaboratory.
|
5 |
|
6 |
Original file is located at
|
7 |
+
https://colab.research.google.com/github/asigalov61/Monster-MIDI-Dataset/blob/main/Monster_MIDI_Dataset_GPU_Search_and_Filter.ipynb
|
8 |
|
9 |
+
# Monster MIDI Dataset GPU Search and Filter (ver. 2.0)
|
10 |
|
11 |
***
|
12 |
|
|
|
103 |
print('=' * 70)
|
104 |
# %cd /content/
|
105 |
|
106 |
+
"""# (CREATE MAIN MIDI DATASET FILES LIST)"""
|
107 |
|
108 |
#@title Create Monster MIDI Dataset files list
|
109 |
print('=' * 70)
|
|
|
162 |
print('Loading signatures...')
|
163 |
print('=' * 70)
|
164 |
|
165 |
+
signatures_data_full = cp.array(sigs_matrixes)
|
166 |
|
167 |
print('Done!')
|
168 |
print('=' * 70)
|
|
|
189 |
|
190 |
###########
|
191 |
|
192 |
+
search_settings_string = ''
|
193 |
+
|
194 |
+
if match_drums:
|
195 |
+
search_settings_string += 'Chords_Drums'
|
196 |
+
else:
|
197 |
+
search_settings_string += 'Chords'
|
198 |
+
|
199 |
+
if search_matching_type == 'Distances':
|
200 |
+
search_settings_string += '_O_' + str(distances_norm_order)
|
201 |
+
|
202 |
+
search_settings_string += '_W_'
|
203 |
+
search_settings_string += str(match_results_weight) + '_'
|
204 |
+
search_settings_string += str(match_lengths_weight) + '_'
|
205 |
+
search_settings_string += str(match_counts_weight)
|
206 |
+
|
207 |
+
search_settings_string += '_E_' + str(epsilon)
|
208 |
+
|
209 |
+
###########
|
210 |
+
|
211 |
print('Loading MIDI files...')
|
212 |
print('This may take a while on a large dataset in particular.')
|
213 |
|
|
|
230 |
|
231 |
###################
|
232 |
|
233 |
+
if not os.path.exists('/content/Output-MIDI-Dataset/'+search_matching_type+'_'+search_settings_string):
|
234 |
+
os.makedirs('/content/Output-MIDI-Dataset/'+search_matching_type+'_'+search_settings_string)
|
235 |
|
236 |
###################
|
237 |
|
|
|
279 |
for c in cscore:
|
280 |
|
281 |
pitches = sorted(set([p[4] for p in c if p[3] != 9]))
|
282 |
+
drums = sorted(set([p[4]+drums_offset for p in c if p[3] == 9]))
|
283 |
|
284 |
if pitches:
|
285 |
if len(pitches) > 1:
|
|
|
313 |
src_signatures = cp.stack(cp.array(src_sigs))
|
314 |
|
315 |
if not match_drums:
|
316 |
+
src_signatures = src_signatures[:,:drums_offset]
|
317 |
+
signatures_data = signatures_data_full[:,:drums_offset]
|
318 |
+
else:
|
319 |
+
signatures_data = signatures_data_full
|
320 |
|
321 |
#=======================================================
|
322 |
|
|
|
339 |
|
340 |
for target_sig in tqdm(src_signatures):
|
341 |
|
|
|
|
|
|
|
342 |
comps_lengths = cp.vstack((cp.repeat(cp.sum(target_sig != 0), signatures_data.shape[0]), cp.sum(signatures_data != 0, axis=1)))
|
343 |
comps_lengths_ratios = cp.divide(cp.min(comps_lengths, axis=0), cp.max(comps_lengths, axis=0))
|
344 |
|
|
|
385 |
|
386 |
filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]
|
387 |
|
388 |
+
filtered_idxs = cp.nonzero(cp.in1d(results, filtered_means))[0]
|
389 |
|
390 |
+
all_filtered_means.extend(results[filtered_idxs].tolist())
|
391 |
|
392 |
all_filtered_idxs.extend(filtered_idxs.tolist())
|
393 |
|
|
|
434 |
#=======================================================
|
435 |
|
436 |
dir_str = str(fn1)
|
437 |
+
copy_path = '/content/Output-MIDI-Dataset/'+search_matching_type+'_'+search_settings_string+'/'+dir_str
|
438 |
if not os.path.exists(copy_path):
|
439 |
os.mkdir(copy_path)
|
440 |
|
|
|
540 |
|
541 |
number_of_top_matches_MIDIs_to_collect = 30 #@param {type:"slider", min:5, max:50, step:1}
|
542 |
maximum_match_ratio_to_search_for = 1 #@param {type:"slider", min:0, max:1, step:0.001}
|
543 |
+
match_results_weight = 2 # @param {type:"slider", min:0.1, max:3, step:0.1}
|
544 |
+
match_lengths_weight = 1 # @param {type:"slider", min:0.1, max:3, step:0.1}
|
545 |
+
match_counts_weight = 1 # @param {type:"slider", min:0.1, max:3, step:0.1}
|
546 |
epsilon = 0.5 # @param {type:"slider", min:0.001, max:1, step:0.001}
|
547 |
|
548 |
print('=' * 70)
|
|
|
551 |
|
552 |
###########
|
553 |
|
554 |
+
search_settings_string = ''
|
555 |
+
|
556 |
+
search_settings_string += str(search_matching_type).replace('-', '_')
|
557 |
+
|
558 |
+
search_settings_string += '_W_'
|
559 |
+
search_settings_string += str(match_results_weight) + '_'
|
560 |
+
search_settings_string += str(match_lengths_weight) + '_'
|
561 |
+
search_settings_string += str(match_counts_weight)
|
562 |
+
|
563 |
+
search_settings_string += '_E_' + str(epsilon)
|
564 |
+
|
565 |
+
###########
|
566 |
+
|
567 |
print('Loading MIDI files...')
|
568 |
print('This may take a while on a large dataset in particular.')
|
569 |
|
|
|
586 |
|
587 |
###################
|
588 |
|
589 |
+
if not os.path.exists('/content/Output-MIDI-Dataset/'+search_settings_string):
|
590 |
+
os.makedirs('/content/Output-MIDI-Dataset/'+search_settings_string)
|
591 |
|
592 |
###################
|
593 |
|
|
|
703 |
|
704 |
filtered_means = sorted_means[(sorted_means >= lower_threshold) & (sorted_means <= upper_threshold)][:filter_size]
|
705 |
|
706 |
+
filtered_idxs = cp.nonzero(cp.in1d(results, filtered_means))[0]
|
707 |
|
708 |
+
all_filtered_means.extend(results[filtered_idxs].tolist())
|
709 |
|
710 |
all_filtered_idxs.extend(filtered_idxs.tolist())
|
711 |
|
|
|
752 |
#=======================================================
|
753 |
|
754 |
dir_str = str(fn1)
|
755 |
+
copy_path = '/content/Output-MIDI-Dataset/'+search_settings_string+'/'+dir_str
|
756 |
if not os.path.exists(copy_path):
|
757 |
os.mkdir(copy_path)
|
758 |
|