Datasets:
Upload monster_search_and_filter.py
Browse files- monster_search_and_filter.py +15 -8
monster_search_and_filter.py
CHANGED
|
@@ -1700,7 +1700,7 @@ def advanced_score_processor(raw_score,
|
|
| 1700 |
|
| 1701 |
###################################################################################
|
| 1702 |
|
| 1703 |
-
def load_signatures(signatures_data,
|
| 1704 |
|
| 1705 |
sigs_dicts = []
|
| 1706 |
|
|
@@ -1709,7 +1709,7 @@ def load_signatures(signatures_data, covert_counts_to_ratios=True, omit_drums=Tr
|
|
| 1709 |
if omit_drums:
|
| 1710 |
sig = [sig[0], [s for s in sig[1] if s[0] < 449]]
|
| 1711 |
|
| 1712 |
-
if
|
| 1713 |
tcount = sum([s[1] for s in sig[1]])
|
| 1714 |
sig = [sig[0], [[s[0], s[1] / tcount] for s in sig[1]]]
|
| 1715 |
|
|
@@ -1815,7 +1815,7 @@ def get_distances_np(trg_signature_dictionary,
|
|
| 1815 |
|
| 1816 |
def get_MIDI_signature(path_to_MIDI_file,
|
| 1817 |
transpose_factor=0,
|
| 1818 |
-
|
| 1819 |
omit_drums=True
|
| 1820 |
):
|
| 1821 |
|
|
@@ -1893,7 +1893,7 @@ def get_MIDI_signature(path_to_MIDI_file,
|
|
| 1893 |
for item in sig+dsig:
|
| 1894 |
sig_p[item] += 1
|
| 1895 |
|
| 1896 |
-
if
|
| 1897 |
tcount = sum([s[1] for s in sig_p.items()])
|
| 1898 |
sig_p = dict([[s[0], s[1] / tcount] for s in sig_p.items()])
|
| 1899 |
|
|
@@ -1941,7 +1941,7 @@ def search_and_filter(sigs_dicts,
|
|
| 1941 |
output_dir = './Output-MIDI-Dataset/',
|
| 1942 |
number_of_top_matches_to_copy = 30,
|
| 1943 |
transpose_factor=6,
|
| 1944 |
-
|
| 1945 |
omit_drums=True
|
| 1946 |
):
|
| 1947 |
|
|
@@ -1971,8 +1971,10 @@ def search_and_filter(sigs_dicts,
|
|
| 1971 |
|
| 1972 |
trg_sigs = get_MIDI_signature(midi,
|
| 1973 |
transpose_factor=transpose_factor,
|
| 1974 |
-
|
| 1975 |
-
omit_drums=omit_drums
|
|
|
|
|
|
|
| 1976 |
)
|
| 1977 |
|
| 1978 |
tv = list(range(tsidx, teidx))
|
|
@@ -1982,7 +1984,12 @@ def search_and_filter(sigs_dicts,
|
|
| 1982 |
|
| 1983 |
for i in tqdm.tqdm(range(len(trg_sigs))):
|
| 1984 |
|
| 1985 |
-
dists = get_distances_np(trg_sigs[i],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1986 |
|
| 1987 |
sorted_indices = np.argsort(dists).tolist()
|
| 1988 |
|
|
|
|
| 1700 |
|
| 1701 |
###################################################################################
|
| 1702 |
|
| 1703 |
+
def load_signatures(signatures_data, convert_counts_to_ratios=True, omit_drums=True):
|
| 1704 |
|
| 1705 |
sigs_dicts = []
|
| 1706 |
|
|
|
|
| 1709 |
if omit_drums:
|
| 1710 |
sig = [sig[0], [s for s in sig[1] if s[0] < 449]]
|
| 1711 |
|
| 1712 |
+
if convert_counts_to_ratios:
|
| 1713 |
tcount = sum([s[1] for s in sig[1]])
|
| 1714 |
sig = [sig[0], [[s[0], s[1] / tcount] for s in sig[1]]]
|
| 1715 |
|
|
|
|
| 1815 |
|
| 1816 |
def get_MIDI_signature(path_to_MIDI_file,
|
| 1817 |
transpose_factor=0,
|
| 1818 |
+
convert_counts_to_ratios=True,
|
| 1819 |
omit_drums=True
|
| 1820 |
):
|
| 1821 |
|
|
|
|
| 1893 |
for item in sig+dsig:
|
| 1894 |
sig_p[item] += 1
|
| 1895 |
|
| 1896 |
+
if convert_counts_to_ratios:
|
| 1897 |
tcount = sum([s[1] for s in sig_p.items()])
|
| 1898 |
sig_p = dict([[s[0], s[1] / tcount] for s in sig_p.items()])
|
| 1899 |
|
|
|
|
| 1941 |
output_dir = './Output-MIDI-Dataset/',
|
| 1942 |
number_of_top_matches_to_copy = 30,
|
| 1943 |
transpose_factor=6,
|
| 1944 |
+
convert_counts_to_ratios=True,
|
| 1945 |
omit_drums=True
|
| 1946 |
):
|
| 1947 |
|
|
|
|
| 1971 |
|
| 1972 |
trg_sigs = get_MIDI_signature(midi,
|
| 1973 |
transpose_factor=transpose_factor,
|
| 1974 |
+
convert_counts_to_ratios=convert_counts_to_ratios,
|
| 1975 |
+
omit_drums=omit_drums,
|
| 1976 |
+
mismatch_penalty=10,
|
| 1977 |
+
p=3
|
| 1978 |
)
|
| 1979 |
|
| 1980 |
tv = list(range(tsidx, teidx))
|
|
|
|
| 1984 |
|
| 1985 |
for i in tqdm.tqdm(range(len(trg_sigs))):
|
| 1986 |
|
| 1987 |
+
dists = get_distances_np(trg_sigs[i],
|
| 1988 |
+
X,
|
| 1989 |
+
global_union,
|
| 1990 |
+
mismatch_penalty=mismatch_penalty,
|
| 1991 |
+
p=p
|
| 1992 |
+
)
|
| 1993 |
|
| 1994 |
sorted_indices = np.argsort(dists).tolist()
|
| 1995 |
|