if len(d['hash_sequence']) > MIN_SEQUENCE_LENGTH] # Create a big matrix of the embeddings msd_embeddings = np.concatenate( [d['embedding'] for d in msd_embedding_datas], axis=0) # Construct paths to each feature file msd_feature_paths = [ os.path.join(DATA_PATH, 'msd', 'h5', d['path']) + '.h5' for d in msd_sequence_datas] # Extract all sequences msd_sequences = [d['hash_sequence'] for d in msd_sequence_datas] # Extract all IDs msd_ids = [d['id'] for d in msd_sequence_datas] # Get a list of valid MIDI-MSD match pairs midi_msd_mapping = experiment_utils.get_valid_matches( os.path.join(RESULTS_PATH, '{}_pairs.csv'.format(SPLIT)), SCORE_THRESHOLD, os.path.join(RESULTS_PATH, 'clean_midi_aligned', 'h5')) # Collect a list of valid MIDI entries in the provided mapping valid_midi_list = [] for midi_md5 in midi_msd_mapping: midi_entry = [entry for entry in midi_list if entry['id'] == midi_md5] # Edge case - no entry in the MIDI list for this md5 if len(midi_entry) == 0: continue else: valid_midi_list.append(midi_entry[0]) # Load all pre-computed MIDI CQTs midi_grams = [deepdish.io.load(os.path.join(DATA_PATH, 'clean_midi', 'h5', entry['path'] + '.h5'))['gram']
# Create a big matrix of the embeddings msd_embeddings = np.concatenate( [d['embedding'] for d in msd_embedding_datas], axis=0) # Construct paths to each feature file msd_feature_paths = [ os.path.join(DATA_PATH, 'msd', 'h5', d['path']) + '.h5' for d in msd_sequence_datas ] # Extract all sequences msd_sequences = [d['hash_sequence'] for d in msd_sequence_datas] # Extract all IDs msd_ids = [d['id'] for d in msd_sequence_datas] # Get a list of valid MIDI-MSD match pairs midi_msd_mapping = experiment_utils.get_valid_matches( os.path.join(RESULTS_PATH, '{}_pairs.csv'.format(SPLIT)), SCORE_THRESHOLD, os.path.join(RESULTS_PATH, 'clean_midi_aligned', 'h5')) # Collect a list of valid MIDI entries in the provided mapping valid_midi_list = [] for midi_md5 in midi_msd_mapping: midi_entry = [entry for entry in midi_list if entry['id'] == midi_md5] # Edge case - no entry in the MIDI list for this md5 if len(midi_entry) == 0: continue else: valid_midi_list.append(midi_entry[0]) # Load all pre-computed MIDI CQTs midi_grams = [ deepdish.io.load(