targetDrummers = ['drummer1', 'drummer2', 'drummer3'] parentFolder = '../../unlabeledDrumDataset/evaluation_enst/STFT/' saveParentFolder = '../../unlabeledDrumDataset/evaluation_enst/Activations/' # parentFolder = '/Volumes/CW_MBP15/Datasets/unlabeledDrumDataset/evaluation_enst/STFT/' # saveParentFolder = '/Volumes/CW_MBP15/Datasets/unlabeledDrumDataset/evaluation_enst/Activations/' modelpath = './models/dnn_model_1nn_lstm_rc.h5' ''' ==== File IO + testing ''' model = load_model(modelpath) for drummer in targetDrummers: #==== get STFT stftpath = parentFolder + drummer + '/' stftFilePathList = getFilePathList(stftpath, 'mat') saveFolder = saveParentFolder + drummer + '/' for i in range(0, len(stftFilePathList)): print 'test on file %f' % i filename = stftFilePathList[i][-11:-4] savepath = saveFolder + filename tmp = loadmat(stftFilePathList[i]) X = np.ndarray.transpose(tmp['X']) X = np.reshape(X, (X.shape[0], 1, X.shape[1])) ''' ==== Testing ''' Y = model.predict(X, batch_size=64) all = [Y[:, 0], Y[:, 1], Y[:, 2]] np.save(savepath, all)
targetDrummers = ['drummer1', 'drummer2', 'drummer3'] parentFolder = '../../unlabeledDrumDataset/evaluation_enst/CQT/' saveParentFolder = '../../unlabeledDrumDataset/evaluation_enst/Activations/' # parentFolder = '/Volumes/CW_MBP15/Datasets/unlabeledDrumDataset/evaluation_enst/STFT/' # saveParentFolder = '/Volumes/CW_MBP15/Datasets/unlabeledDrumDataset/evaluation_enst/Activations/' modelpath = './models/dnn_model_cqt_rms.h5' ''' ==== File IO + testing ''' model = load_model(modelpath) for drummer in targetDrummers: #==== get STFT cqtpath = parentFolder + drummer + '/' cqtFilePathList = getFilePathList(cqtpath, 'mat') saveFolder = saveParentFolder + drummer + '/' for i in range(0, len(cqtFilePathList)): print 'test on file %f' % i filename = cqtFilePathList[i][-11:-4] savepath = saveFolder + filename tmp = loadmat(cqtFilePathList[i]) X = np.ndarray.transpose(tmp['Xcqt']) ''' ==== Testing ''' X_diff = np.diff(X, axis=0) finalRow = np.zeros((1, np.size(X, 1))) X_diff = np.concatenate((X_diff, finalRow), axis=0) X_all = np.concatenate((X, X_diff), axis=1)
histogram_freq=0, write_graph=True, write_images=True) # earlyStopCallBack = EarlyStopping(monitor='loss', min_delta=1e-6, patience=5) ''' ==== File IO + file concatenation ''' X = np.ndarray((0, 121)) Y = np.ndarray((0, 3)) for method in targetPseudoLabels: for genre in targetGenres: #==== get STFT & pseudo label cqtpath = parentFolder + 'CQT/' + genre + '/' cqtFilePathList = getFilePathList(cqtpath, 'mat') pseudoLabelPath = parentFolder + method + '/' + genre + '/' pseudoLabelFilePathList = getFilePathList(pseudoLabelPath, 'mat') for i in range(0, 200): #len(stftFilePathList)): tmp = loadmat(cqtFilePathList[i]) X_song = np.ndarray.transpose(tmp['Xcqt']) tmp = loadmat(pseudoLabelFilePathList[i]) Y_song = np.ndarray.transpose(tmp['HD']) assert (len(X_song) == len(Y_song) ), 'dimensionality mismatch between CQT and Pseudo-Labels!' ''' ==== Concatenating matrices ''' X = np.concatenate((X, X_song), axis=0) Y = np.concatenate((Y, Y_song), axis=0)
'drummer2', 'drummer3'] parentFolder = '../../unlabeledDrumDataset/evaluation_enst/200drums/' parentFolder2 = '../../unlabeledDrumDataset/evaluation_enst/enst/' parentFolder3 = '../../unlabeledDrumDataset/evaluation_enst/smt/' saveParentFolder = '../../unlabeledDrumDataset/evaluation_enst/Activations/' # parentFolder = '/Volumes/CW_MBP15/Datasets/unlabeledDrumDataset/evaluation_enst/STFT/' # saveParentFolder = '/Volumes/CW_MBP15/Datasets/unlabeledDrumDataset/evaluation_enst/Activations/' ''' ==== File IO + testing ''' for drummer in targetDrummers: #==== get STFT stftpath = parentFolder + drummer + '/' stftFilePathList = getFilePathList(stftpath, 'mat') stftpath2 = parentFolder2 + drummer + '/' stftFilePathList2 = getFilePathList(stftpath2, 'mat') stftpath3 = parentFolder3 + drummer + '/' stftFilePathList3 = getFilePathList(stftpath3, 'mat') saveFolder = saveParentFolder + drummer + '/' for i in range(0, len(stftFilePathList)): print 'test on file %f' % i filename = stftFilePathList[i][-11:-4] savepath = saveFolder + filename tmp = loadmat(stftFilePathList[i]) Y1 = np.ndarray.transpose(tmp['HD']) filename2 = stftFilePathList2[i][-11:-4]
model.add(Dropout(0.25)) model.add(Dense(units = 3)) model.add(Activation('sigmoid')) model.compile(optimizer = 'rmsprop', loss='mse', metrics = ['mae']) return model model = createModel() ''' ==== File IO + training ''' for method in targetPseudoLabels: for genre in targetGenres: #==== get STFT & pseudo label stftpath = parentFolder + 'STFT/' + genre + '/' stftFilePathList = getFilePathList(stftpath, 'mat') pseudoLabelPath = parentFolder + method + '/' + genre + '/' pseudoLabelFilePathList = getFilePathList(pseudoLabelPath, 'mat') for i in range(0, len(stftFilePathList)): tmp = loadmat(stftFilePathList[i]) X = np.ndarray.transpose(tmp['X']) tmp = loadmat(pseudoLabelFilePathList[i]) Y = np.ndarray.transpose(tmp['HD']) assert (len(X) == len(Y)), 'dimensionality mismatch between STFT and Pseudo-Labels!' ''' ==== Training ''' [y_hh_scaled, dump, dump] = scaleData(Y[:, 0]) [y_kd_scaled, dump, dump] = scaleData(Y[:, 1])
hopSize = 512.00 fs = 44100.00 order = round(0.1 / (hopSize / fs)) offset = 0.12 ''' ==== File IO + testing ''' hh_all_results = [] bd_all_results = [] sd_all_results = [] for drummer in targetDrummers: #==== get STFT activpath = parentFolder + drummer + '/' annpath = annotationFolder + drummer + '/' activFilePathList = getFilePathList(activpath, 'npy') annFilePathList = getFilePathList(annpath, 'mat') for i in range(0, len(activFilePathList)): print 'evaluate file %f' % i filename = activFilePathList[i] all = np.load(filename) filename_ann = annFilePathList[i] ann = loadmat(filename_ann) drums_ann = ann['drums'] onsets_ann = ann['onsets'] ref_hh, ref_bd, ref_sd = getIndividualOnset(onsets_ann, drums_ann) #==== load activation functions activ_hh = all[0] activ_bd = all[1] activ_sd = all[2]