Mercurial > hg > segmentation
comparison SegEval.py @ 18:b4bf37f94e92
prepared to add another annotation
author | mitian |
---|---|
date | Wed, 09 Dec 2015 16:27:10 +0000 |
parents | 6dae41887406 |
children |
comparison
equal
deleted
inserted
replaced
17:c01fcb752221 | 18:b4bf37f94e92 |
---|---|
14 from itertools import combinations | 14 from itertools import combinations |
15 from os.path import join, isdir, isfile, abspath, dirname, basename, split, splitext | 15 from os.path import join, isdir, isfile, abspath, dirname, basename, split, splitext |
16 from copy import copy | 16 from copy import copy |
17 | 17 |
18 import matplotlib | 18 import matplotlib |
19 # matplotlib.use('Agg') | 19 matplotlib.use('Agg') |
20 import matplotlib.pyplot as plt | 20 import matplotlib.pyplot as plt |
21 import matplotlib.gridspec as gridspec | 21 import matplotlib.gridspec as gridspec |
22 import numpy as np | 22 import numpy as np |
23 import scipy as sp | 23 import scipy as sp |
24 from scipy.signal import correlate2d, convolve2d, filtfilt, resample | 24 from scipy.signal import correlate2d, convolve2d, filtfilt, resample |
27 from sklearn.cluster import KMeans | 27 from sklearn.cluster import KMeans |
28 from sklearn.preprocessing import normalize | 28 from sklearn.preprocessing import normalize |
29 from sklearn.metrics.pairwise import pairwise_distances | 29 from sklearn.metrics.pairwise import pairwise_distances |
30 | 30 |
31 # Load dependencies | 31 # Load dependencies |
32 from utils.SegUtil import getMean, getStd, getDelta, getSSM, reduceSSM, upSample, normaliseFeature | 32 from utils.SegUtil import getMean, getStd, getDelta, getSSM, reduceSSM, upSample, normaliseFeature, normaliseArray |
33 from utils.PeakPickerUtil import PeakPicker | 33 from utils.PeakPickerUtil import PeakPicker |
34 from utils.gmmdist import * | 34 from utils.gmmdist import * |
35 from utils.GmmMetrics import GmmDistance | 35 from utils.GmmMetrics import GmmDistance |
36 from utils.RankClustering import rClustering | 36 from utils.RankClustering import rClustering |
37 from utils.kmeans import Kmeans | 37 from utils.kmeans import Kmeans |
38 from utils.PathTracker import PathTracker | 38 # from utils.PathTracker import PathTracker |
39 from utils.OnsetPlotProc import onset_plot, plot_on | 39 from utils.OnsetPlotProc import onset_plot, plot_on |
40 | 40 |
41 # Load bourdary retrieval utilities | 41 # Load bourdary retrieval utilities |
42 import cnmf as cnmf_S | 42 import cnmf as cnmf_S |
43 import foote as foote_S | 43 import foote as foote_S |
44 import sf as sf_S | 44 import sf as sf_S |
45 import fmc2d as fmc2d_S | 45 import fmc2d as fmc2d_S |
46 import novelty as novelty_S | 46 import novelty as novelty_S |
47 | 47 |
48 # Algorithm params | 48 # Algorithm params |
49 # cnmf | |
49 h = 8 # Size of median filter for features in C-NMF | 50 h = 8 # Size of median filter for features in C-NMF |
50 R = 15 # Size of the median filter for the activation matrix C-NMF | 51 R = 12 # Size of the median filter for the activation matrix C-NMF |
51 rank = 3 # Rank of decomposition for the boundaries | 52 rank = 4 # Rank of decomposition for the boundaries |
52 rank_labels = 16 # Rank of decomposition for the labels | 53 rank_labels = 16 # Rank of decomposition for the labels |
53 R_labels = 4 # Size of the median filter for the labels | 54 R_labels = 4 # Size of the median filter for the labels |
54 # Foote | 55 # Foote |
55 M = 2 # Median filter for the audio features (in beats) | 56 M = 2 # Median filter for the audio features (in beats) |
56 Mg = 32 # Gaussian kernel size | 57 Mg = 32 # Gaussian kernel size |
64 op = optparse.OptionParser() | 65 op = optparse.OptionParser() |
65 # IO options | 66 # IO options |
66 op.add_option('-g', '--gammatonegram-features', action="store", dest="GF", default='/Volumes/c4dm-03/people/mit/features/gammatonegram/qupujicheng/2048', type="str", help="Loading gammatone features from.." ) | 67 op.add_option('-g', '--gammatonegram-features', action="store", dest="GF", default='/Volumes/c4dm-03/people/mit/features/gammatonegram/qupujicheng/2048', type="str", help="Loading gammatone features from.." ) |
67 op.add_option('-s', '--spectrogram-features', action="store", dest="SF", default='/Volumes/c4dm-03/people/mit/features/spectrogram/qupujicheng/2048', type="str", help="Loading spectral features from.." ) | 68 op.add_option('-s', '--spectrogram-features', action="store", dest="SF", default='/Volumes/c4dm-03/people/mit/features/spectrogram/qupujicheng/2048', type="str", help="Loading spectral features from.." ) |
68 op.add_option('-t', '--tempogram-features', action="store", dest="TF", default='/Volumes/c4dm-03/people/mit/features/tempogram/qupujicheng/tempo_features_6s', type="str", help="Loading tempogram features from.." ) | 69 op.add_option('-t', '--tempogram-features', action="store", dest="TF", default='/Volumes/c4dm-03/people/mit/features/tempogram/qupujicheng/tempo_features_6s', type="str", help="Loading tempogram features from.." ) |
69 op.add_option('-f', '--featureset', action="store", dest="FEATURES", default='[0, 1, 2, 3]', type="str", help="Choose feature subsets (input a list of integers) used for segmentation -- gammtone, chroma, timbre, tempo -- 0, 1, 2, 3." ) | |
70 op.add_option('-a', '--annotations', action="store", dest="GT", default='/Volumes/c4dm-03/people/mit/annotation/qupujicheng/lowercase', type="str", help="Loading annotation files from.. ") | 70 op.add_option('-a', '--annotations', action="store", dest="GT", default='/Volumes/c4dm-03/people/mit/annotation/qupujicheng/lowercase', type="str", help="Loading annotation files from.. ") |
71 op.add_option('-o', '--ouput', action="store", dest="OUTPUT", default='/Volumes/c4dm-03/people/mit/segmentation/gammatone/qupujicheng', type="str", help="Write segmentation results to ") | 71 op.add_option('-o', '--ouput', action="store", dest="OUTPUT", default='/Volumes/c4dm-03/people/mit/segmentation/gammatone/qupujicheng', type="str", help="Write segmentation results to ") |
72 | 72 op.add_option('-d', '--dataset', action="store", dest="DATASET", default='qupujicheng', type="str", help="Specify datasets") |
73 # boundary retrieval options | 73 |
74 # parameterization options | |
74 op.add_option('-b', '--bounrary-method', action="store", dest="BOUNDARY", type='choice', choices=['novelty', 'cnmf', 'foote', 'sf'], default='novelty', help="Choose boundary retrieval algorithm ('novelty', 'cnmf', 'sf', 'fmc2d')." ) | 75 op.add_option('-b', '--bounrary-method', action="store", dest="BOUNDARY", type='choice', choices=['novelty', 'cnmf', 'foote', 'sf'], default='novelty', help="Choose boundary retrieval algorithm ('novelty', 'cnmf', 'sf', 'fmc2d')." ) |
75 op.add_option('-l', '--labeling-method', action="store", dest="LABEL", type='choice', choices=['cnmf', 'fmc2d'], default='cnmf', help="Choose boundary labeling algorithm ('cnmf', 'fmc2d')." ) | 76 op.add_option('-l', '--labeling-method', action="store", dest="LABEL", type='choice', choices=['cnmf', 'fmc2d'], default='cnmf', help="Choose boundary labeling algorithm ('cnmf', 'fmc2d')." ) |
77 op.add_option('-x', '--experiment', action="store", dest="EXPERIMENT", type='choice', choices=['all', 'individual', 'fuse_feature', 'fuse_ssm', 'fuse_novelty', 'fuse_bounds'], default='all', help="Specify experiment to execute." ) | |
76 | 78 |
77 # Plot/print/mode options | 79 # Plot/print/mode options |
78 op.add_option('-p', '--plot', action="store_true", dest="PLOT", default=False, help="Save plots") | 80 op.add_option('-p', '--plot', action="store_true", dest="PLOT", default=False, help="Save plots") |
79 op.add_option('-e', '--test-mode', action="store_true", dest="TEST", default=False, help="Test mode") | 81 op.add_option('-e', '--test-mode', action="store_true", dest="TEST", default=False, help="Test mode") |
80 op.add_option('-v', '--verbose-mode', action="store_true", dest="VERBOSE", default=False, help="Print results in verbose mode.") | 82 op.add_option('-v', '--verbose-mode', action="store_true", dest="VERBOSE", default=False, help="Print results in verbose mode.") |
81 | 83 |
82 return op.parse_args() | 84 return op.parse_args() |
83 options, args = parse_args() | 85 options, args = parse_args() |
84 | 86 |
85 class FeatureObj() : | 87 class FeatureObj() : |
86 __slots__ = ['key', 'audio', 'timestamps', 'gammatone_features', 'tempo_features', 'timbre_features', 'harmonic_features', 'gammatone_ssm', 'tempo_ssm', 'timbre_features', 'harmonic_ssm', 'ssm_timestamps'] | 88 __slots__ = ['key', 'audio', 'timestamps', 'gammatone_features', 'tempo_features', 'timbre_features', 'harmonic_features', 'gammatone_ssm', 'tempo_ssm', 'timbre_features', 'harmonic_ssm', 'ssm_timestamps'] |
87 | 89 |
88 class AudioObj(): | 90 class AudioObj(): |
89 __slots__ = ['name', 'feature_list', 'gt', 'label', 'gammatone_features', 'tempo_features', 'timbre_features', 'harmonic_features', 'combined_features',\ | 91 __slots__ = ['name', 'feature_list', 'gt', 'label', 'gammatone_features', 'tempo_features', 'timbre_features', 'harmonic_features', 'combined_features',\ |
90 'gammatone_ssm', 'tempo_ssm', 'timbre_ssm', 'harmonic_ssm', 'combined_ssm', 'ssm', 'ssm_timestamps', 'tempo_timestamps'] | 92 'gammatone_ssm', 'tempo_ssm', 'timbre_ssm', 'harmonic_ssm', 'combined_ssm', 'ssm', 'ssm_timestamps', 'timestamps'] |
91 | 93 |
92 class EvalObj(): | 94 class EvalObj(): |
93 __slots__ = ['TP', 'FP', 'FN', 'P', 'R', 'F', 'AD', 'DA'] | 95 __slots__ = ['TP', 'FP', 'FN', 'P', 'R', 'F', 'AD', 'DA', 'detection'] |
94 | 96 |
95 | 97 |
96 class SSMseg(object): | 98 class SSMseg(object): |
97 '''The main segmentation object''' | 99 '''The main segmentation object''' |
98 def __init__(self): | 100 def __init__(self): |
99 self.SampleRate = 44100 | 101 self.SampleRate = 44100.0 |
100 self.NqHz = self.SampleRate/2 | 102 self.NqHz = self.SampleRate/2 |
101 self.timestamp = [] | |
102 self.previousSample = 0.0 | 103 self.previousSample = 0.0 |
103 self.featureWindow = 6.0 | 104 self.featureWindow = 6.0 |
104 self.featureStep = 3.0 | 105 self.featureStep = 3.0 |
105 self.kernel_size = 64 # Adjust this param according to the feature resolution.pq | 106 self.kernel_size = 100 # Adjust this param according to the feature resolution.pq |
106 self.blockSize = 2048 | 107 self.blockSize = 2048.0 |
107 self.stepSize = 1024 | 108 self.stepSize = 1024.0 |
108 | 109 |
109 '''NOTE: Match the following params with those used for feature extraction!''' | 110 '''NOTE: Match the following params with those used for feature extraction!''' |
110 | 111 |
111 '''NOTE: Unlike spectrogram ones, Gammatone features are extracted without taking an FFT. The windowing is done under the purpose of chunking | 112 '''NOTE: Unlike spectrogram ones, Gammatone features are extracted without taking an FFT. The windowing is done under the purpose of chunking |
112 the audio to facilitate the gammatone filtering with the specified blockSize and stepSize. The resulting gammatonegram is aggregated every | 113 the audio to facilitate the gammatone filtering with the specified blockSize and stepSize. The resulting gammatonegram is aggregated every |
120 '''Settings for extracting tempogram features.''' | 121 '''Settings for extracting tempogram features.''' |
121 self.tempoWindow = 6.0 | 122 self.tempoWindow = 6.0 |
122 self.bpmBands = [30, 45, 60, 80, 100, 120, 180, 240, 400, 600] | 123 self.bpmBands = [30, 45, 60, 80, 100, 120, 180, 240, 400, 600] |
123 | 124 |
124 '''Peak picking settings for novelty based method''' | 125 '''Peak picking settings for novelty based method''' |
125 self.threshold = 30 | 126 self.threshold = 10 |
126 self.confidence_threshold = 0.5 | 127 self.confidence_threshold = 0.4 |
127 self.delta_threshold = 0.0 | 128 self.delta_threshold = 0.0 |
128 self.backtracking_threshold = 1.9 | 129 self.backtracking_threshold = 1.9 |
129 self.polyfitting_on = True | 130 self.polyfitting_on = True |
130 self.medfilter_on = True | 131 self.medfilter_on = True |
131 self.LPfilter_on = True | 132 self.LPfilter_on = True |
132 self.whitening_on = False | 133 self.whitening_on = True |
133 self.aCoeffs = [1.0000, -0.5949, 0.2348] | 134 self.aCoeffs = [1.0000, -0.5949, 0.2348] |
134 self.bCoeffs = [0.1600, 0.3200, 0.1600] | 135 self.bCoeffs = [0.1600, 0.3200, 0.1600] |
135 self.cutoff = 0.34 | 136 self.cutoff = 0.34 |
136 self.medianWin = 7 | 137 self.medianWin = 10 |
137 | 138 self.lin = 0.5 |
138 if plot_on : onset_plot.reset() | 139 if plot_on : onset_plot.reset() |
139 | 140 |
140 def pairwiseF(self, annotation, detection, tolerance=3.0, combine=1.0, idx2time=None): | 141 def pairwiseF(self, annotation, detection, tolerance=3.0, combine=1.0, idx2time=None): |
141 '''Pairwise F measure evaluation of detection rates.''' | 142 '''Pairwise F measure evaluation of detection rates.''' |
142 | 143 |
146 res.AD, res.DA = 0.0, 0.0 | 147 res.AD, res.DA = 0.0, 0.0 |
147 | 148 |
148 if len(detection) == 0: | 149 if len(detection) == 0: |
149 return res | 150 return res |
150 | 151 |
152 if idx2time != None: | |
153 # Map detected idxs to real time | |
154 detection.sort() | |
155 if detection[-1] >= len(idx2time): | |
156 detection = detection[:-len(np.array(detection)[np.array(detection)-len(idx2time)>=0])] | |
157 detection = [idx2time[int(i)] for i in detection] | |
158 detection = np.append(detection, annotation[-1]) | |
159 res.detection = detection | |
160 | |
151 gt = len(annotation) # Total number of ground truth data points | 161 gt = len(annotation) # Total number of ground truth data points |
152 dt = len(detection) # Total number of experimental data points | 162 dt = len(detection) # Total number of experimental data points |
153 foundIdx = [] | 163 foundIdx = [] |
154 D_AD = np.zeros(gt) | 164 D_AD = np.zeros(gt) |
155 D_DA = np.zeros(dt) | 165 D_DA = np.zeros(dt) |
156 | 166 |
157 if idx2time != None: | |
158 # Map detected idxs to real time | |
159 detection = [idx2time[int(np.rint(i))] for i in detection] + [annotation[-1]] | |
160 # print 'detection', detection | |
161 detection = np.append(detection, annotation[-1]) | |
162 | |
163 for dtIdx in xrange(dt): | 167 for dtIdx in xrange(dt): |
164 D_DA[dtIdx] = np.min(abs(detection[dtIdx] - annotation)) | 168 D_DA[dtIdx] = np.min(abs(detection[dtIdx] - annotation)) |
169 | |
165 for gtIdx in xrange(gt): | 170 for gtIdx in xrange(gt): |
166 D_AD[gtIdx] = np.min(abs(annotation[gtIdx] - detection)) | 171 D_AD[gtIdx] = np.min(abs(annotation[gtIdx] - detection)) |
167 for dtIdx in xrange(dt): | 172 for dtIdx in xrange(dt): |
168 if (annotation[gtIdx] >= detection[dtIdx] - tolerance/2.0) and (annotation[gtIdx] <= detection[dtIdx] + tolerance/2.0): | 173 if (annotation[gtIdx] >= detection[dtIdx] - tolerance/2.0) and (annotation[gtIdx] <= detection[dtIdx] + tolerance/2.0): |
169 res.TP = res.TP + 1.0 | |
170 foundIdx.append(gtIdx) | 174 foundIdx.append(gtIdx) |
175 continue | |
171 foundIdx = list(set(foundIdx)) | 176 foundIdx = list(set(foundIdx)) |
172 res.TP = len(foundIdx) | 177 res.TP = len(foundIdx) |
178 # res.FP = dt - res.TP | |
173 res.FP = max(0, dt - res.TP) | 179 res.FP = max(0, dt - res.TP) |
174 res.FN = max(0, gt - res.TP) | 180 res.FN = gt - res.TP |
175 | 181 |
176 res.AD = np.mean(D_AD) | 182 res.AD = np.mean(D_AD) |
177 res.DA = np.mean(D_DA) | 183 res.DA = np.mean(D_DA) |
178 | |
179 | 184 |
180 if res.TP == 0: | 185 if res.TP == 0: |
181 return res | 186 return res |
182 | 187 |
183 res.P = res.TP / float(dt) | 188 res.P = res.TP / float(res.TP+res.FP) |
184 res.R = res.TP / float(gt) | 189 res.R = res.TP / float(res.TP+res.FN) |
185 res.F = 2 * res.P * res.R / (res.P + res.R) | 190 res.F = 2 * res.P * res.R / (res.P + res.R) |
186 return res | 191 return res |
187 | 192 |
188 def writeIndividualHeader(self, filename): | 193 def writeIndividualHeader(self, filename): |
189 '''Write header of output files for individual features.''' | 194 '''Write header of output files for individual features.''' |
190 | 195 |
191 with open(filename, 'a') as f: | 196 with open(filename, 'a') as f: |
192 csvwriter = csv.writer(f, delimiter=',') | 197 csvwriter = csv.writer(f, delimiter=',') |
193 csvwriter.writerow(['audio', 'gammatone_tp_05', 'gammatone_fp_05', 'gammatone_fn_05', 'gammatone_P_05', 'gammatone_R_05', 'gammatone_F_05', 'gammatone_AD_05', 'gammatone_DA_05', 'gammatone_tp_3', \ | 198 csvwriter.writerow(['audio', 'harmonic_tp_05', 'harmonic_fp_05', 'harmonic_fn_05', 'harmonic_P_05', \ |
194 'gammatone_fp_3', 'gammatone_fn_3', 'gammatone_P_3', 'gammatone_R_3', 'gammatone_F_3', 'gammatone_AD_3', 'gammatone_DA_3', 'harmonic_tp_05', 'harmonic_fp_05', 'harmonic_fn_05', 'harmonic_P_05', \ | |
195 'harmonic_R_05', 'harmonic_F_05', 'harmonic_AD_05', 'harmonic_DA_05', 'harmonic_tp_3', 'harmonic_fp_3', 'harmonic_fn_3', 'harmonic_P_3', 'harmonic_R_3', 'harmonic_F_3', 'harmonic_AD_3', 'harmonic_DA_3', \ | 199 'harmonic_R_05', 'harmonic_F_05', 'harmonic_AD_05', 'harmonic_DA_05', 'harmonic_tp_3', 'harmonic_fp_3', 'harmonic_fn_3', 'harmonic_P_3', 'harmonic_R_3', 'harmonic_F_3', 'harmonic_AD_3', 'harmonic_DA_3', \ |
196 'timbre_tp_05', 'timbre_fp_05', 'timbre_fn_05', 'timbre_P_05', 'timbre_R_05', 'timbre_F_05', 'timbre_AD_05', 'timbre_DA_05', 'timbre_tp_3', 'timbre_fp_3', 'timbre_fn_3', 'timbre_P_3', 'timbre_R_3', \ | 200 'timbre_tp_05', 'timbre_fp_05', 'timbre_fn_05', 'timbre_P_05', 'timbre_R_05', 'timbre_F_05', 'timbre_AD_05', 'timbre_DA_05', 'timbre_tp_3', 'timbre_fp_3', 'timbre_fn_3', 'timbre_P_3', 'timbre_R_3', \ |
197 'timbre_F_3', 'timbre_AD_3', 'timbre_DA_3', 'tempo_tp_05', 'tempo_fp_05', 'tempo_fn_05', 'tempo_P_05', 'tempo_R_05', 'tempo_F_05', 'tempo_AD_05', 'tempo_DA_05', \ | 201 'timbre_F_3', 'timbre_AD_3', 'timbre_DA_3', 'tempo_tp_05', 'tempo_fp_05', 'tempo_fn_05', 'tempo_P_05', 'tempo_R_05', 'tempo_F_05', 'tempo_AD_05', 'tempo_DA_05', \ |
198 'tempo_tp_3', 'tempo_fp_3', 'tempo_fn_3', 'tempo_P_3', 'tempo_R_3', 'tempo_F_3', 'tempo_AD_3', 'tempo_DA_3']) | 202 'tempo_tp_3', 'tempo_fp_3', 'tempo_fn_3', 'tempo_P_3', 'tempo_R_3', 'tempo_F_3', 'tempo_AD_3', 'tempo_DA_3']) |
199 | 203 |
200 def writeIndividualRes(self, filename, ao_name, gt_res_05, gt_res_3, harmonic_res_05, harmonic_res_3, timbre_res_05, timbre_res_3, tempo_res_05, tempo_res_3): | 204 def writeIndividualRes(self, filename, ao_name, harmonic_res_05, harmonic_res_3, timbre_res_05, timbre_res_3, tempo_res_05, tempo_res_3): |
201 '''Write result of single detection for individual features.''' | 205 '''Write result of single detection for individual features.''' |
202 | 206 |
203 with open(filename, 'a') as f: | 207 with open(filename, 'a') as f: |
204 csvwriter = csv.writer(f, delimiter=',') | 208 csvwriter = csv.writer(f, delimiter=',') |
205 csvwriter.writerow([ao_name, gt_res_05.TP, gt_res_05.FP, gt_res_05.FN, gt_res_05.P, gt_res_05.R, gt_res_05.F, gt_res_05.AD, gt_res_05.DA, gt_res_3.TP, gt_res_3.FP, gt_res_3.FN, gt_res_3.P, \ | 209 csvwriter.writerow([ao_name, harmonic_res_05.TP, harmonic_res_05.FP, harmonic_res_05.FN, harmonic_res_05.P, harmonic_res_05.R, harmonic_res_05.F, harmonic_res_05.AD, harmonic_res_05.DA, \ |
206 gt_res_3.R, gt_res_3.F, gt_res_3.AD, gt_res_3.DA, harmonic_res_05.TP, harmonic_res_05.FP, harmonic_res_05.FN, harmonic_res_05.P, harmonic_res_05.R, harmonic_res_05.F, harmonic_res_05.AD, harmonic_res_05.DA, \ | |
207 harmonic_res_3.TP, harmonic_res_3.FP, harmonic_res_3.FN, harmonic_res_3.P, harmonic_res_3.R, harmonic_res_3.F, harmonic_res_3.AD, harmonic_res_3.DA, timbre_res_05.TP, timbre_res_05.FP, \ | 210 harmonic_res_3.TP, harmonic_res_3.FP, harmonic_res_3.FN, harmonic_res_3.P, harmonic_res_3.R, harmonic_res_3.F, harmonic_res_3.AD, harmonic_res_3.DA, timbre_res_05.TP, timbre_res_05.FP, \ |
208 timbre_res_05.FN, timbre_res_05.P, timbre_res_05.R, timbre_res_05.F, timbre_res_05.AD, timbre_res_05.DA, timbre_res_3.TP, timbre_res_3.FP, timbre_res_3.FN, timbre_res_3.P, timbre_res_3.R, timbre_res_3.F, \ | 211 timbre_res_05.FN, timbre_res_05.P, timbre_res_05.R, timbre_res_05.F, timbre_res_05.AD, timbre_res_05.DA, timbre_res_3.TP, timbre_res_3.FP, timbre_res_3.FN, timbre_res_3.P, timbre_res_3.R, timbre_res_3.F, \ |
209 timbre_res_3.AD, timbre_res_3.DA, tempo_res_05.TP, tempo_res_05.FP, tempo_res_05.FN, tempo_res_05.P, tempo_res_05.R, tempo_res_05.F, tempo_res_05.AD, tempo_res_05.DA, tempo_res_3.TP, tempo_res_3.FP, \ | 212 timbre_res_3.AD, timbre_res_3.DA, tempo_res_05.TP, tempo_res_05.FP, tempo_res_05.FN, tempo_res_05.P, tempo_res_05.R, tempo_res_05.F, tempo_res_05.AD, tempo_res_05.DA, tempo_res_3.TP, tempo_res_3.FP, \ |
210 tempo_res_3.FN, tempo_res_3.P, tempo_res_3.R, tempo_res_3.F, tempo_res_3.AD, tempo_res_3.DA]) | 213 tempo_res_3.FN, tempo_res_3.P, tempo_res_3.R, tempo_res_3.F, tempo_res_3.AD, tempo_res_3.DA]) |
211 | 214 |
212 def writeCombinedHeader(self, filename): | 215 def writeCombinedHeader(self, filename): |
213 '''Write header of output files for combined features.''' | 216 '''Write header of output files for combined features.''' |
214 | 217 |
215 with open(filename, 'a') as f: | 218 with open(filename, 'a') as f: |
216 csvwriter = csv.writer(f, delimiter=',') | 219 csvwriter = csv.writer(f, delimiter=',') |
217 csvwriter.writerow(['audio', 'gt_tb_P_0.5', 'gt_tb_R_0.5', 'gt_tb_F_0.5', 'gt_tb_P_3', 'gt_tb_R_3', 'gt_tb_F_3', 'gt_tp_P_0.5', 'gt_tp_R_0.5', 'gt_tp_F_0.5', 'gt_tp_P_3', 'gt_tp_R_3', 'gt_tp_F_3',\ | 220 csvwriter.writerow(['audio', 'hm_tb_P_0.5', 'hm_tb_R_0.5', 'hm_tb_F_0.5', 'hm_tb_P_3', 'hm_tb_R_3', 'hm_tb_F_3', 'hm_tp_P_0.5', 'hm_tp_R_0.5',\ |
218 'gt_hm_P_0.5', 'gt_hm_R_0.5', 'gt_hm_F_0.5', 'gt_hm_P_3', 'gt_hm_R_3', 'gt_hm_F_3', 'tb_tp_P_0.5', 'tb_tp_R_0.5', 'tb_tp_F_0.5', 'tb_tp_P_3', 'tb_tp_R_3', 'tb_tp_F_3', 'hm_tb_P_0.5', 'hm_tb_R_0.5', 'hm_tb_F_0.5', \ | 221 'hm_tp_F_0.5', 'hm_tp_P_3', 'hm_tp_R_3', 'hm_tp_F_3', 'tb_tp_P_0.5', 'tb_tp_R_0.5', 'tb_tp_F_0.5', 'tb_tp_P_3', 'tb_tp_R_3', 'tb_tp_F_3',\ |
219 'hm_tb_P_3', 'hm_tb_R_3', 'hm_tb_F_3', 'hm_tp_P_0.5', 'hm_tp_R_0.5', 'hm_tp_F_0.5', 'hm_tp_P_3', 'hm_tp_R_3', 'hm_tp_F_3', 'gt_tb_tp_P_0.5', 'gt_tb_tp_R_0.5', 'gt_tb_tp_F_0.5', 'gt_tb_tp_P_3', 'gt_tb_tp_R_3', \ | 222 'hm_tb_tp_P_0.5', 'hm_tb_tp_R_0.5', 'hm_tb_tp_F_0.5', 'hm_tb_tp_P_3', 'hm_tb_tp_R_3', 'hm_tb_tp_F_3']) |
220 'gt_tb_tp_F_3', 'gt_hm_tb_P_0.5', 'gt_hm_tb_R_0.5', 'gt_hm_tb_F_0.5', 'gt_hm_tb_P_3', 'gt_hm_tb_R_3', 'gt_hm_tb_F_3', 'gt_hm_tp_P_0.5', 'gt_hm_tp_R_0.5', 'gt_hm_tp_F_0.5', 'gt_hm_tp_P_3', 'gt_hm_tp_R_3', 'gt_hm_tp_F_3', \ | 223 |
221 'hm_tb_tp_P_0.5', 'hm_tb_tp_R_0.5', 'hm_tb_tp_F_0.5', 'hm_tb_tp_P_3', 'hm_tb_tp_R_3', 'hm_tb_tp_F_3', 'gt_hm_tb_tp_P_0.5', 'gt_hm_tb_tp_R_0.5', 'gt_hm_tb_tp_F_0.5', 'gt_hm_tb_tp_P_3', 'gt_hm_tb_tp_R_3', 'gt_hm_tb_tp_F_3']) | 224 def writeCombinedRes(self, filename, ao_name, hm_tb_res_05, hm_tb_res_3, hm_tp_res_05, hm_tp_res_3, tb_tp_res_05, tb_tp_res_3, hm_tb_tp_res_05, hm_tb_tp_res_3): |
222 | |
223 def writeCombinedRes(self, filename, ao_name, gt_hm_res_05, gt_hm_res_3, gt_tb_res_05, gt_tb_res_3, gt_tp_res_05, gt_tp_res_3, hm_tb_res_05, hm_tb_res_3, hm_tp_res_05, hm_tp_res_3, \ | |
224 tb_tp_res_05, tb_tp_res_3, gt_hm_tb_res_05, gt_hm_tb_res_3, gt_hm_tp_res_05, gt_hm_tp_res_3, gt_tb_tp_res_05, gt_tb_tp_res_3, hm_tb_tp_res_05, hm_tb_tp_res_3, gt_hm_tb_tp_res_05, gt_hm_tb_tp_res_3): | |
225 '''Write result of single detection for combined features.''' | 225 '''Write result of single detection for combined features.''' |
226 | 226 |
227 with open(filename, 'a') as f: | 227 with open(filename, 'a') as f: |
228 csvwriter = csv.writer(f, delimiter=',') | 228 csvwriter = csv.writer(f, delimiter=',') |
229 csvwriter.writerow([ao_name, gt_tb_res_05.P, gt_tb_res_05.R, gt_tb_res_05.F, gt_tb_res_3.P, gt_tb_res_3.R, gt_tb_res_3.F, gt_tp_res_05.P, gt_tp_res_05.R, gt_tp_res_05.F, gt_tp_res_3.P, gt_tp_res_3.R, gt_tp_res_3.F, \ | 229 csvwriter.writerow([ao_name, hm_tb_res_05.P, hm_tb_res_05.R, hm_tb_res_05.F, hm_tb_res_3.P, hm_tb_res_3.R, hm_tb_res_3.F,\ |
230 gt_hm_res_05.P, gt_hm_res_05.R, gt_hm_res_05.F, gt_hm_res_3.P, gt_hm_res_3.R, gt_hm_res_3.F, tb_tp_res_05.P, tb_tp_res_05.R, tb_tp_res_05.F, tb_tp_res_3.P, tb_tp_res_3.R, tb_tp_res_3.F, \ | 230 hm_tp_res_05.P, hm_tp_res_05.R, hm_tp_res_05.F, hm_tp_res_3.P, hm_tp_res_3.R, hm_tp_res_3.F, tb_tp_res_05.P, tb_tp_res_05.R, tb_tp_res_05.F, tb_tp_res_3.P, tb_tp_res_3.R, tb_tp_res_3.F, \ |
231 hm_tb_res_05.P, hm_tb_res_05.R, hm_tb_res_05.F, hm_tb_res_3.P, hm_tb_res_3.R, hm_tb_res_3.F, hm_tp_res_05.P, hm_tp_res_05.R, hm_tp_res_05.F, hm_tp_res_3.P, hm_tp_res_3.R, hm_tp_res_3.F, \ | 231 hm_tb_tp_res_05.P, hm_tb_tp_res_05.R, hm_tb_tp_res_05.F, hm_tb_tp_res_3.P, hm_tb_tp_res_3.R, hm_tb_tp_res_3.F]) |
232 gt_tb_tp_res_05.P, gt_tb_tp_res_05.R, gt_tb_tp_res_05.F, gt_tb_tp_res_3.P, gt_tb_tp_res_3.R, gt_tb_tp_res_3.F, gt_hm_tb_res_05.P, gt_hm_tb_res_05.R, gt_hm_tb_res_05.F, gt_hm_tb_res_3.P, gt_hm_tb_res_3.R, gt_hm_tb_res_3.F, \ | 232 |
233 gt_hm_tp_res_05.P, gt_hm_tp_res_05.R, gt_hm_tp_res_05.F, gt_hm_tp_res_3.P, gt_hm_tp_res_3.R, gt_hm_tp_res_3.F, hm_tb_tp_res_05.P, hm_tb_tp_res_05.R, hm_tb_tp_res_05.F, hm_tb_tp_res_3.P, hm_tb_tp_res_3.R, hm_tb_tp_res_3.F, \ | 233 def removeDuplicates(self, bounds, tol=1.0): |
234 gt_hm_tb_tp_res_05.P, gt_hm_tb_tp_res_05.R, gt_hm_tb_tp_res_05.F, gt_hm_tb_tp_res_3.P, gt_hm_tb_tp_res_3.R, gt_hm_tb_tp_res_3.F]) | 234 '''Remove duplicates by averaging boundaries located in the tolerance window.''' |
235 | 235 new_bounds = [] |
236 def writeMergedHeader(self, filename): | 236 bounds = list(set(bounds)) |
237 '''Write header of output files merging individual detections.''' | 237 bounds.sort() |
238 with open(filename, 'a') as f: | 238 tol_win = int(tol * self.SampleRate / self.stepSize) |
239 csvwriter = csv.writer(f, delimiter=',') | 239 |
240 csvwriter.writerow(['audio', 'merged_tp_05', 'merged_fp_05', 'merged_fn_05', 'merged_P_05', 'merged_R_05', 'merged_F_05', 'merged_AD_05', 'merged_DA_05', 'merged_tp_3', \ | 240 bound_idx = 0 |
241 'merged_fp_3', 'merged_fn_3', 'merged_P_3', 'merged_R_3', 'merged_F_3', 'merged_AD_3', 'merged_DA_3']) | 241 nBounds = len(bounds) |
242 | 242 |
243 def writeMergedRes(self, filename, ao_name, merged_res_05, merged_res_3): | 243 while bound_idx < nBounds: |
244 '''Write results by merging individual detections.''' | 244 start = bounds[bound_idx] |
245 with open(filename, 'a') as f: | 245 cnt = 1 |
246 csvwriter = csv.writer(f, delimiter=',') | 246 temp = [start] |
247 csvwriter.writerow([ao_name, merged_res_05.TP, merged_res_05.FP, merged_res_05.FN, merged_res_05.P, merged_res_05.R, merged_res_05.F, merged_res_05.AD, merged_res_05.DA, \ | 247 while (bound_idx+cnt < nBounds and (bounds[bound_idx+cnt] - start <= tol_win)): |
248 merged_res_3.TP, merged_res_3.FP, merged_res_3.FN, merged_res_3.P, merged_res_3.R, merged_res_3.F, merged_res_3.AD, merged_res_3.DA]) | 248 temp.append(bounds[bound_idx+cnt]) |
249 | 249 cnt += 1 |
250 | |
251 new_bounds.append(int(np.mean(temp))) | |
252 bound_idx += cnt | |
253 | |
254 # print 'new_bounds', nBounds, len(new_bounds) | |
255 return new_bounds | |
256 | |
257 def selectBounds(self, nc, bounds, thresh=0.5): | |
258 '''Select bounds with nc value above thresh.''' | |
259 # return list(np.array(bounds)[np.where(np.array(nc)>thresh)[0]]) | |
260 bounds_keep = [] | |
261 nc = normaliseArray(nc) | |
262 for i, x in enumerate(bounds): | |
263 if nc[x] >= thresh: | |
264 bounds_keep.append(x) | |
265 # print 'bounds_keep', len(bounds), len(bounds_keep) | |
266 return bounds_keep | |
250 | 267 |
251 def process(self): | 268 def process(self): |
252 '''For the aggregated input features, discard a propertion each time as the pairwise distances within the feature space descending. | 269 '''For the aggregated input features, discard a propertion each time as the pairwise distances within the feature space descending. |
253 In the meanwhile evaluate the segmentation result and track the trend of perfomance changing by measuring the feature selection | 270 In the meanwhile evaluate the segmentation result and track the trend of perfomance changing by measuring the feature selection |
254 threshold - segmentation f measure curve. | 271 threshold - segmentation f measure curve. |
285 gammatone_feature_list = [i for i in os.listdir(options.GF) if not i.startswith('.')] | 302 gammatone_feature_list = [i for i in os.listdir(options.GF) if not i.startswith('.')] |
286 gammatone_feature_list = ['contrast6', 'rolloff4', 'dct'] | 303 gammatone_feature_list = ['contrast6', 'rolloff4', 'dct'] |
287 tempo_feature_list = [i for i in os.listdir(options.TF) if not i.startswith('.')] | 304 tempo_feature_list = [i for i in os.listdir(options.TF) if not i.startswith('.')] |
288 tempo_feature_list = ['ti', 'tir'] | 305 tempo_feature_list = ['ti', 'tir'] |
289 timbre_feature_list = ['mfcc_harmonic'] | 306 timbre_feature_list = ['mfcc_harmonic'] |
290 harmonic_feature_list = ['chromagram'] | 307 harmonic_feature_list = ['chromagram_harmonic'] |
291 | 308 |
292 gammatone_feature_list = [join(options.GF, f) for f in gammatone_feature_list] | 309 gammatone_feature_list = [join(options.GF, f) for f in gammatone_feature_list] |
293 timbre_feature_list = [join(options.SF, f) for f in timbre_feature_list] | 310 timbre_feature_list = [join(options.SF, f) for f in timbre_feature_list] |
294 tempo_feature_list = [join(options.TF, f) for f in tempo_feature_list] | 311 tempo_feature_list = [join(options.TF, f) for f in tempo_feature_list] |
295 harmonic_feature_list = [join(options.SF, f) for f in harmonic_feature_list] | 312 harmonic_feature_list = [join(options.SF, f) for f in harmonic_feature_list] |
296 | 313 |
297 fobj_list = [] | 314 |
298 | 315 # Prepare output files. |
316 outfile1 = join(options.OUTPUT, 'individual_novelty.csv') | |
317 outfile2 = join(options.OUTPUT, 'individual_cnmf.csv') | |
318 outfile3 = join(options.OUTPUT, 'individual_sf.csv') | |
319 | |
320 outfile4 = join(options.OUTPUT, 'combinedFeatures_novelty.csv') | |
321 outfile5 = join(options.OUTPUT, 'combinedFeatures_cnmf.csv') | |
322 outfile6 = join(options.OUTPUT, 'combinedFeatures_sf.csv') | |
323 | |
324 # outfile7 = join(options.OUTPUT, 'combinedSSM_novelty.csv') | |
325 # | |
326 # outfile8 = join(options.OUTPUT, 'combinedBounds_novelty.csv') | |
327 # outfile9 = join(options.OUTPUT, 'combinedBounds_sf.csv') | |
328 | |
329 # self.writeIndividualHeader(outfile1) | |
330 # self.writeIndividualHeader(outfile2) | |
331 # self.writeIndividualHeader(outfile3) | |
332 # | |
333 self.writeCombinedHeader(outfile4) | |
334 self.writeCombinedHeader(outfile5) | |
335 self.writeCombinedHeader(outfile6) | |
336 # self.writeCombinedHeader(outfile7) | |
337 # self.writeCombinedHeader(outfile8) | |
338 # self.writeCombinedHeader(outfile9) | |
339 | |
299 # For each audio file, load specific features | 340 # For each audio file, load specific features |
300 for audio in audio_files: | 341 for audio in audio_files: |
301 ao = AudioObj() | 342 ao = AudioObj() |
302 ao.name = splitext(audio)[0] | 343 ao.name = splitext(audio)[0] |
303 annotation_file = join(options.GT, ao.name+'.txt') # iso, salami | 344 |
304 ao.gt = np.genfromtxt(annotation_file, usecols=0) | 345 # Load annotations for specified audio collection. |
305 ao.label = np.genfromtxt(annotation_file, usecols=1, dtype=str) | 346 if options.DATASET == 'qupujicheng': |
306 # annotation_file = join(options.GT, ao.name+'.csv') # qupujicheng | 347 annotation_file = join(options.GT, ao.name+'.csv') # qupujicheng |
307 # ao.gt = np.genfromtxt(annotation_file, usecols=0, delimiter=',') | 348 ao.gt = np.genfromtxt(annotation_file, usecols=0, delimiter=',') |
308 # ao.label = np.genfromtxt(annotation_file, usecols=1, delimiter=',', dtype=str) | 349 ao.label = np.genfromtxt(annotation_file, usecols=1, delimiter=',', dtype=str) |
350 elif options.DATASET == 'salami': | |
351 annotation_file = join(options.GT, ao.name+'.txt') # iso, salami | |
352 ao.gt = np.genfromtxt(annotation_file, usecols=0) | |
353 ao.label = np.genfromtxt(annotation_file, usecols=1, dtype=str) | |
354 else: | |
355 annotation_file = join(options.GT, ao.name+'.lab') # beatles | |
356 ao.gt = np.genfromtxt(annotation_file, usecols=(0,1)) | |
357 ao.gt = np.unique(np.ndarray.flatten(ao.gt)) | |
358 ao.label = np.genfromtxt(annotation_file, usecols=2, dtype=str) | |
309 | 359 |
310 gammatone_featureset, timbre_featureset, tempo_featureset, harmonic_featureset = [], [], [], [] | 360 gammatone_featureset, timbre_featureset, tempo_featureset, harmonic_featureset = [], [], [], [] |
311 for feature in gammatone_feature_list: | |
312 for f in os.listdir(feature): | |
313 if f[:f.find('_vamp')]==ao.name: | |
314 gammatone_featureset.append(np.genfromtxt(join(feature, f), delimiter=',',filling_values=0.0)[:,1:]) | |
315 break | |
316 if len(gammatone_feature_list) > 1: | |
317 n_frame = np.min([x.shape[0] for x in gammatone_featureset]) | |
318 gammatone_featureset = [x[:n_frame,:] for x in gammatone_featureset] | |
319 ao.gammatone_features = np.hstack((gammatone_featureset)) | |
320 else: | |
321 ao.gammatone_features = gammatone_featureset[0] | |
322 | 361 |
323 for feature in timbre_feature_list: | 362 for feature in timbre_feature_list: |
324 for f in os.listdir(feature): | 363 for f in os.listdir(feature): |
325 if f[:f.find('_vamp')]==ao.name: | 364 if f[:f.find('_vamp')]==ao.name: |
326 timbre_featureset.append(np.genfromtxt(join(feature, f), delimiter=',',filling_values=0.0)[:,1:]) | 365 timbre_featureset.append(np.genfromtxt(join(feature, f), delimiter=',',filling_values=0.0)[:,0:14]) |
327 break | 366 break |
328 if len(timbre_feature_list) > 1: | 367 if len(timbre_feature_list) > 1: |
329 n_frame = np.min([x.shape[0] for x in timbre_featureset]) | 368 n_frame = np.min([x.shape[0] for x in timbre_featureset]) |
330 timbre_featureset = [x[:n_frame,:] for x in timbre_featureset] | 369 timbre_featureset = [x[:n_frame,:] for x in timbre_featureset] |
331 ao.timbre_features = np.hstack((timbre_featureset)) | 370 ao.timbre_features = np.hstack((timbre_featureset)) |
354 ao.harmonic_features = np.hstack((harmonic_featureset)) | 393 ao.harmonic_features = np.hstack((harmonic_featureset)) |
355 else: | 394 else: |
356 ao.harmonic_features = harmonic_featureset[0] | 395 ao.harmonic_features = harmonic_featureset[0] |
357 | 396 |
358 # Get aggregated features for computing ssm | 397 # Get aggregated features for computing ssm |
359 aggregation_window, aggregation_step = 1,1 | 398 aggregation_window, aggregation_step = 20,10 |
360 featureRate = float(self.SampleRate) /self.stepSize | 399 featureRate = float(self.SampleRate) / self.stepSize |
361 pca = PCA(n_components=5) | 400 pca = PCA(n_components=6) |
362 | 401 |
363 # Resample and normalise features | 402 # Resample and normalise features |
364 step = ao.tempo_features.shape[0] | 403 # step = ao.tempo_features.shape[0] |
365 ao.gammatone_features = resample(ao.gammatone_features, step) | 404 # ao.timbre_features = resample(ao.timbre_features, step) |
366 ao.gammatone_features = normaliseFeature(ao.gammatone_features) | 405 ao.timbre_features = normaliseFeature(ao.timbre_features) |
406 # ao.harmonic_features = resample(ao.harmonic_features, step) | |
407 ao.harmonic_features = normaliseFeature(ao.harmonic_features) | |
408 nFrames = np.min([ao.timbre_features.shapes[0], ao.harmonic_features.shapes[0]]) | |
409 ao.timbre_features = ao.timbre_features[:nFrames, :] | |
410 ao.harmonic_features = ao.harmonic_features[:nFrames, :] | |
411 ao.tempo_features = normaliseFeature(ao.tempo_features) | |
412 ao.tempo_features = upSample(ao.tempo_features, nFrames) | |
413 ao.timestamps = np.array(map(lambda x: x / featureRate, np.arange(0, nFrames))) | |
414 | |
415 step = nFrames / 10 | |
367 ao.timbre_features = resample(ao.timbre_features, step) | 416 ao.timbre_features = resample(ao.timbre_features, step) |
368 ao.timbre_features = normaliseFeature(ao.timbre_features) | |
369 ao.harmonic_features = resample(ao.harmonic_features, step) | 417 ao.harmonic_features = resample(ao.harmonic_features, step) |
370 ao.harmonic_features = normaliseFeature(ao.harmonic_features) | 418 ao.tempo_features = resample(ao.tempo_features, step) |
371 ao.tempo_features = normaliseFeature(ao.tempo_features) | |
372 | |
373 pca.fit(ao.gammatone_features) | |
374 ao.gammatone_features = pca.transform(ao.gammatone_features) | |
375 ao.gammatone_ssm = getSSM(ao.gammatone_features) | |
376 | 419 |
377 pca.fit(ao.tempo_features) | 420 pca.fit(ao.tempo_features) |
378 ao.tempo_features = pca.transform(ao.tempo_features) | 421 ao.tempo_features = pca.transform(ao.tempo_features) |
379 ao.tempo_ssm = getSSM(ao.tempo_features) | 422 ao.tempo_ssm = getSSM(ao.tempo_features) |
380 | 423 |
384 | 427 |
385 pca.fit(ao.harmonic_features) | 428 pca.fit(ao.harmonic_features) |
386 ao.harmonic_features = pca.transform(ao.harmonic_features) | 429 ao.harmonic_features = pca.transform(ao.harmonic_features) |
387 ao.harmonic_ssm = getSSM(ao.harmonic_features) | 430 ao.harmonic_ssm = getSSM(ao.harmonic_features) |
388 | 431 |
389 ao.ssm_timestamps = np.array(map(lambda x: ao.tempo_timestamps[aggregation_step*x], np.arange(0, ao.gammatone_ssm.shape[0]))) | 432 |
390 | |
391 audio_list.append(ao) | |
392 | |
393 # Prepare output files. | |
394 outfile1 = join(options.OUTPUT, 'individual_novelty.csv') | |
395 outfile2 = join(options.OUTPUT, 'individual_foote.csv') | |
396 outfile3 = join(options.OUTPUT, 'individual_sf.csv') | |
397 outfile4 = join(options.OUTPUT, 'individual_cnmf.csv') | |
398 | |
399 outfile5 = join(options.OUTPUT, 'combined_novelty.csv') | |
400 outfile6 = join(options.OUTPUT, 'combined_foote.csv') | |
401 outfile7 = join(options.OUTPUT, 'combined_sf.csv') | |
402 outfile8 = join(options.OUTPUT, 'combined_cnmf.csv') | |
403 | |
404 outfile9 = join(options.OUTPUT, 'individual_merged.csv') | |
405 | |
406 self.writeIndividualHeader(outfile1) | |
407 self.writeIndividualHeader(outfile2) | |
408 self.writeIndividualHeader(outfile3) | |
409 self.writeIndividualHeader(outfile4) | |
410 | |
411 # self.writeCombinedHeader(outfile5) | |
412 # self.writeCombinedHeader(outfile6) | |
413 self.writeCombinedHeader(outfile7) | |
414 self.writeCombinedHeader(outfile8) | |
415 | |
416 self.writeMergedHeader(outfile9) | |
417 | |
418 print 'Segmenting using %s method' %options.BOUNDARY | |
419 for i,ao in enumerate(audio_list): | |
420 print 'processing: %s' %ao.name | |
421 | 433 |
422 ############################################################################################################################################ | 434 ############################################################################################################################################ |
423 # Experiment 1: segmentation using individual features. | 435 # Experiment 1: segmentation using individual features. |
424 | 436 |
425 gammatone_novelty, smoothed_gammatone_novelty, gammatone_novelty_idxs = novelty_S.process(ao.gammatone_ssm, self.kernel_size, peak_picker) | 437 timbre_novelty, smoothed_timbre_novelty, timbre_novelty_idxs = novelty_S.process(ao.timbre_ssm, peak_picker, self.kernel_size) |
426 timbre_novelty, smoothed_timbre_novelty, timbre_novelty_idxs = novelty_S.process(ao.timbre_ssm, self.kernel_size, peak_picker) | 438 tempo_novelty, smoothed_tempo_novelty, tempo_novelty_idxs = novelty_S.process(ao.tempo_ssm, peak_picker, self.kernel_size) |
427 tempo_novelty, smoothed_tempo_novelty, tempo_novelty_idxs = novelty_S.process(ao.tempo_ssm, self.kernel_size, peak_picker) | 439 harmonic_novelty, smoothed_harmonic_novelty, harmonic_novelty_idxs = novelty_S.process(ao.harmonic_ssm, peak_picker, self.kernel_size) |
428 harmonic_novelty, smoothed_harmonic_novelty, harmonic_novelty_idxs = novelty_S.process(ao.harmonic_ssm, self.kernel_size, peak_picker) | |
429 | 440 |
430 gammatone_cnmf_idxs = cnmf_S.segmentation(ao.gammatone_features, rank=rank, R=R, h=h, niter=300) | 441 timbre_cnmf_idxs = cnmf_S.segmentation(ao.timbre_features, rank=rank, R=R, h=h, niter=300)[-1] |
431 timbre_cnmf_idxs = cnmf_S.segmentation(ao.timbre_features, rank=rank, R=R, h=h, niter=300) | 442 tempo_cnmf_idxs = cnmf_S.segmentation(ao.tempo_features, rank=rank, R=R, h=h, niter=300)[-1] |
432 tempo_cnmf_idxs = cnmf_S.segmentation(ao.tempo_features, rank=rank, R=R, h=h, niter=300) | 443 harmonic_cnmf_idxs = cnmf_S.segmentation(ao.harmonic_features, rank=rank, R=R, h=h, niter=300)[-1] |
433 harmonic_cnmf_idxs = cnmf_S.segmentation(ao.harmonic_features, rank=rank, R=R, h=h, niter=300) | 444 |
434 | 445 timbre_sf_nc, timbre_sf_idxs = sf_S.segmentation(ao.timbre_features) |
435 gammatone_foote_idxs = foote_S.segmentation(ao.gammatone_features, M=M, Mg=Mg, L=L) | 446 tempo_sf_nc, tempo_sf_idxs = sf_S.segmentation(ao.tempo_features) |
436 timbre_foote_idxs = foote_S.segmentation(ao.timbre_features, M=M, Mg=Mg, L=L) | 447 harmonic_sf_nc, harmonic_sf_idxs = sf_S.segmentation(ao.harmonic_features) |
437 tempo_foote_idxs = foote_S.segmentation(ao.tempo_features, M=M, Mg=Mg, L=L) | |
438 harmonic_foote_idxs = foote_S.segmentation(ao.harmonic_features, M=M, Mg=Mg, L=L) | |
439 | |
440 gammatone_sf_idxs = sf_S.segmentation(ao.gammatone_features) | |
441 timbre_sf_idxs = sf_S.segmentation(ao.timbre_features) | |
442 tempo_sf_idxs = sf_S.segmentation(ao.tempo_features) | |
443 harmonic_sf_idxs = sf_S.segmentation(ao.harmonic_features) | |
444 | 448 |
445 # Evaluate and write results. | 449 # Evaluate and write results. |
446 gt_novelty_05 = self.pairwiseF(ao.gt, gammatone_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
447 gt_novelty_3 = self.pairwiseF(ao.gt, gammatone_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
448 harmonic_novelty_05 = self.pairwiseF(ao.gt, harmonic_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 450 harmonic_novelty_05 = self.pairwiseF(ao.gt, harmonic_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
449 harmonic_novelty_3 = self.pairwiseF(ao.gt, harmonic_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 451 harmonic_novelty_3 = self.pairwiseF(ao.gt, harmonic_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
450 tempo_novelty_05 = self.pairwiseF(ao.gt, tempo_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 452 tempo_novelty_05 = self.pairwiseF(ao.gt, tempo_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
451 tempo_novelty_3 = self.pairwiseF(ao.gt, tempo_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 453 tempo_novelty_3 = self.pairwiseF(ao.gt, tempo_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
452 timbre_novelty_05 = self.pairwiseF(ao.gt, timbre_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 454 timbre_novelty_05 = self.pairwiseF(ao.gt, timbre_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
453 timbre_novelty_3 = self.pairwiseF(ao.gt, timbre_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 455 timbre_novelty_3 = self.pairwiseF(ao.gt, timbre_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
454 | 456 |
455 gt_cnmf_05 = self.pairwiseF(ao.gt, gammatone_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
456 gt_cnmf_3 = self.pairwiseF(ao.gt, gammatone_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
457 harmonic_cnmf_05 = self.pairwiseF(ao.gt, harmonic_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 457 harmonic_cnmf_05 = self.pairwiseF(ao.gt, harmonic_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
458 harmonic_cnmf_3 = self.pairwiseF(ao.gt, harmonic_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 458 harmonic_cnmf_3 = self.pairwiseF(ao.gt, harmonic_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
459 tempo_cnmf_05 = self.pairwiseF(ao.gt, tempo_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 459 tempo_cnmf_05 = self.pairwiseF(ao.gt, tempo_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
460 tempo_cnmf_3 = self.pairwiseF(ao.gt, tempo_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 460 tempo_cnmf_3 = self.pairwiseF(ao.gt, tempo_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
461 timbre_cnmf_05 = self.pairwiseF(ao.gt, timbre_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 461 timbre_cnmf_05 = self.pairwiseF(ao.gt, timbre_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
462 timbre_cnmf_3 = self.pairwiseF(ao.gt, timbre_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 462 timbre_cnmf_3 = self.pairwiseF(ao.gt, timbre_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
463 | 463 |
464 gt_sf_05 = self.pairwiseF(ao.gt, gammatone_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
465 gt_sf_3 = self.pairwiseF(ao.gt, gammatone_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
466 harmonic_sf_05 = self.pairwiseF(ao.gt, harmonic_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 464 harmonic_sf_05 = self.pairwiseF(ao.gt, harmonic_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
467 harmonic_sf_3 = self.pairwiseF(ao.gt, harmonic_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 465 harmonic_sf_3 = self.pairwiseF(ao.gt, harmonic_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
468 tempo_sf_05 = self.pairwiseF(ao.gt, tempo_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 466 tempo_sf_05 = self.pairwiseF(ao.gt, tempo_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
469 tempo_sf_3 = self.pairwiseF(ao.gt, tempo_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 467 tempo_sf_3 = self.pairwiseF(ao.gt, tempo_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
470 timbre_sf_05 = self.pairwiseF(ao.gt, timbre_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 468 timbre_sf_05 = self.pairwiseF(ao.gt, timbre_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
471 timbre_sf_3 = self.pairwiseF(ao.gt, timbre_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 469 timbre_sf_3 = self.pairwiseF(ao.gt, timbre_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
472 | 470 |
473 gt_foote_05 = self.pairwiseF(ao.gt, gammatone_foote_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 471 self.writeIndividualRes(outfile1, ao.name, harmonic_novelty_05, harmonic_novelty_3, tempo_novelty_05, tempo_novelty_3, timbre_novelty_05, timbre_novelty_3) |
474 gt_foote_3 = self.pairwiseF(ao.gt, gammatone_foote_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 472 self.writeIndividualRes(outfile2, ao.name, harmonic_cnmf_05, harmonic_cnmf_3, tempo_cnmf_05, tempo_cnmf_3, timbre_cnmf_05, timbre_cnmf_3) |
475 harmonic_foote_05 = self.pairwiseF(ao.gt, harmonic_foote_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 473 self.writeIndividualRes(outfile3, ao.name, harmonic_sf_05, harmonic_sf_3, tempo_sf_05, tempo_sf_3, timbre_sf_05, timbre_sf_3) |
476 harmonic_foote_3 = self.pairwiseF(ao.gt, harmonic_foote_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
477 tempo_foote_05 = self.pairwiseF(ao.gt, tempo_foote_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
478 tempo_foote_3 = self.pairwiseF(ao.gt, tempo_foote_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
479 timbre_foote_05 = self.pairwiseF(ao.gt, timbre_foote_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
480 timbre_foote_3 = self.pairwiseF(ao.gt, timbre_foote_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
481 | |
482 self.writeIndividualRes(outfile1, ao.name, gt_novelty_05, gt_novelty_3, harmonic_novelty_05, harmonic_novelty_3, tempo_novelty_05, tempo_novelty_3, timbre_novelty_05, timbre_novelty_3) | |
483 self.writeIndividualRes(outfile2, ao.name, gt_cnmf_05, gt_cnmf_3, harmonic_cnmf_05, harmonic_cnmf_3, tempo_cnmf_05, tempo_cnmf_3, timbre_cnmf_05, timbre_cnmf_3) | |
484 self.writeIndividualRes(outfile3, ao.name, gt_sf_05, gt_sf_3, harmonic_sf_05, harmonic_sf_3, tempo_sf_05, tempo_sf_3, timbre_sf_05, timbre_sf_3) | |
485 self.writeIndividualRes(outfile4, ao.name, gt_foote_05, gt_foote_3, harmonic_foote_05, harmonic_foote_3, tempo_foote_05, tempo_foote_3, timbre_foote_05, timbre_foote_3) | |
486 | 474 |
487 | 475 |
488 ############################################################################################################################################ | 476 ############################################################################################################################################ |
489 # Experiment 2: segmentation using combined features. | 477 # Experiment 2: segmentation using combined features. |
490 | 478 |
491 # Dumping features. | 479 # Dumping features. |
492 gt_hm = np.hstack([ao.gammatone_features, ao.harmonic_features]) | |
493 gt_tb = np.hstack([ao.gammatone_features, ao.timbre_features]) | |
494 gt_tp = np.hstack([ao.gammatone_features, ao.tempo_features]) | |
495 hm_tb = np.hstack([ao.harmonic_features, ao.timbre_features]) | 480 hm_tb = np.hstack([ao.harmonic_features, ao.timbre_features]) |
496 hm_tp = np.hstack([ao.harmonic_features, ao.tempo_features]) | 481 hm_tp = np.hstack([ao.harmonic_features, ao.tempo_features]) |
497 tb_tp = np.hstack([ao.timbre_features, ao.tempo_features]) | 482 tb_tp = np.hstack([ao.timbre_features, ao.tempo_features]) |
498 gt_hm_tb = np.hstack([ao.gammatone_features, ao.harmonic_features, ao.timbre_features]) | |
499 gt_hm_tp = np.hstack([ao.gammatone_features, ao.harmonic_features, ao.tempo_features]) | |
500 gt_tb_tp = np.hstack([ao.gammatone_features, ao.timbre_features, ao.tempo_features]) | |
501 hm_tb_tp = np.hstack([ao.harmonic_features, ao.timbre_features, ao.tempo_features]) | 483 hm_tb_tp = np.hstack([ao.harmonic_features, ao.timbre_features, ao.tempo_features]) |
502 gt_hm_tb_tp = np.hstack([ao.gammatone_features, ao.harmonic_features, ao.timbre_features, ao.tempo_features]) | 484 |
485 hm_tb_feature_ssm = getSSM(hm_tb) | |
486 hm_tp_feature_ssm = getSSM(hm_tp) | |
487 tb_tp_feature_ssm = getSSM(tb_tp) | |
488 hm_tb_tp_feature_ssm = getSSM(hm_tb_tp) | |
503 | 489 |
504 # Evaluting and writing results. | 490 # Evaluting and writing results. |
505 gt_hm_sf_idxs = sf_S.segmentation(gt_hm) | 491 hm_tb_novelty_idxs = novelty_S.process(hm_tb_feature_ssm)[-1] |
506 gt_tb_sf_idxs = sf_S.segmentation(gt_tb) | 492 hm_tp_novelty_idxs = novelty_S.process(hm_tp_feature_ssm)[-1] |
507 gt_tp_sf_idxs = sf_S.segmentation(gt_tp) | 493 tb_tp_novelty_idxs = novelty_S.process(tb_tp_feature_ssm)[-1] |
508 hm_tb_sf_idxs = sf_S.segmentation(hm_tb) | 494 hm_tb_tp_novelty_idxs = novelty_S.process(hm_tb_tp_feature_ssm)[-1] |
509 hm_tp_sf_idxs = sf_S.segmentation(hm_tp) | 495 |
510 tb_tp_sf_idxs = sf_S.segmentation(tb_tp) | 496 hm_tb_sf_idxs = sf_S.segmentation(hm_tb)[-1] |
511 gt_hm_tb_sf_idxs = sf_S.segmentation(gt_hm_tb) | 497 hm_tp_sf_idxs = sf_S.segmentation(hm_tp)[-1] |
512 gt_hm_tp_sf_idxs = sf_S.segmentation(gt_hm_tp) | 498 tb_tp_sf_idxs = sf_S.segmentation(tb_tp)[-1] |
513 gt_tb_tp_sf_idxs = sf_S.segmentation(gt_tb_tp) | 499 hm_tb_tp_sf_idxs = sf_S.segmentation(hm_tb_tp)[-1] |
514 hm_tb_tp_sf_idxs = sf_S.segmentation(hm_tb_tp) | 500 |
515 gt_hm_tb_tp_sf_idxs = sf_S.segmentation(gt_hm_tb_tp) | 501 hm_tb_cnmf_idxs = cnmf_S.segmentation(hm_tb, rank=4, R=R, h=h, niter=300)[-1] |
516 | 502 hm_tp_cnmf_idxs = cnmf_S.segmentation(hm_tp, rank=4, R=R, h=h, niter=300)[-1] |
517 gt_hm_cnmf_idxs = cnmf_S.segmentation(gt_hm, rank=4, R=R, h=h, niter=300) | 503 tb_tp_cnmf_idxs = cnmf_S.segmentation(tb_tp, rank=4, R=R, h=h, niter=300)[-1] |
518 gt_tb_cnmf_idxs = cnmf_S.segmentation(gt_tb, rank=4, R=R, h=h, niter=300) | 504 hm_tb_tp_cnmf_idxs = cnmf_S.segmentation(hm_tb_tp, rank=6, R=R, h=h, niter=300)[-1] |
519 gt_tp_cnmf_idxs = cnmf_S.segmentation(gt_tp, rank=4, R=R, h=h, niter=300) | 505 |
520 hm_tb_cnmf_idxs = cnmf_S.segmentation(hm_tb, rank=4, R=R, h=h, niter=300) | 506 hm_tb_novelty_05 = self.pairwiseF(ao.gt, hm_tb_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
521 hm_tp_cnmf_idxs = cnmf_S.segmentation(hm_tp, rank=4, R=R, h=h, niter=300) | 507 hm_tp_novelty_05 = self.pairwiseF(ao.gt, hm_tp_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
522 tb_tp_cnmf_idxs = cnmf_S.segmentation(tb_tp, rank=4, R=R, h=h, niter=300) | 508 tb_tp_novelty_05 = self.pairwiseF(ao.gt, tb_tp_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
523 gt_hm_tb_cnmf_idxs = cnmf_S.segmentation(gt_hm_tb, rank=6, R=R, h=h, niter=300) | 509 hm_tb_tp_novelty_05 = self.pairwiseF(ao.gt, hm_tb_tp_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
524 gt_hm_tp_cnmf_idxs = cnmf_S.segmentation(gt_hm_tp, rank=6, R=R, h=h, niter=300) | 510 |
525 gt_tb_tp_cnmf_idxs = cnmf_S.segmentation(gt_tb_tp, rank=6, R=R, h=h, niter=300) | 511 hm_tb_novelty_3 = self.pairwiseF(ao.gt, hm_tb_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
526 hm_tb_tp_cnmf_idxs = cnmf_S.segmentation(hm_tb_tp, rank=6, R=R, h=h, niter=300) | 512 hm_tp_novelty_3 = self.pairwiseF(ao.gt, hm_tp_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
527 gt_hm_tb_tp_cnmf_idxs = cnmf_S.segmentation(gt_hm_tb_tp, rank=8, R=R, h=h, niter=300) | 513 tb_tp_novelty_3 = self.pairwiseF(ao.gt, tb_tp_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
528 | 514 hm_tb_tp_novelty_3 = self.pairwiseF(ao.gt, hm_tb_tp_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
529 gt_hm_sf_05 = self.pairwiseF(ao.gt, gt_hm_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 515 |
530 gt_tb_sf_05 = self.pairwiseF(ao.gt, gt_tb_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
531 gt_tp_sf_05 = self.pairwiseF(ao.gt, gt_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
532 hm_tb_sf_05 = self.pairwiseF(ao.gt, hm_tb_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 516 hm_tb_sf_05 = self.pairwiseF(ao.gt, hm_tb_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
533 hm_tp_sf_05 = self.pairwiseF(ao.gt, hm_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 517 hm_tp_sf_05 = self.pairwiseF(ao.gt, hm_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
534 tb_tp_sf_05 = self.pairwiseF(ao.gt, tb_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 518 tb_tp_sf_05 = self.pairwiseF(ao.gt, tb_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
535 gt_hm_tb_sf_05 = self.pairwiseF(ao.gt, gt_hm_tb_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
536 gt_hm_tp_sf_05 = self.pairwiseF(ao.gt, gt_hm_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
537 gt_tb_tp_sf_05 = self.pairwiseF(ao.gt, gt_tb_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
538 hm_tb_tp_sf_05 = self.pairwiseF(ao.gt, hm_tb_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 519 hm_tb_tp_sf_05 = self.pairwiseF(ao.gt, hm_tb_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
539 gt_hm_tb_tp_sf_05 = self.pairwiseF(ao.gt, gt_hm_tb_tp_sf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 520 |
540 | |
541 gt_hm_sf_3 = self.pairwiseF(ao.gt, gt_hm_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
542 gt_tb_sf_3 = self.pairwiseF(ao.gt, gt_tb_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
543 gt_tp_sf_3 = self.pairwiseF(ao.gt, gt_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
544 hm_tb_sf_3 = self.pairwiseF(ao.gt, hm_tb_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 521 hm_tb_sf_3 = self.pairwiseF(ao.gt, hm_tb_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
545 hm_tp_sf_3 = self.pairwiseF(ao.gt, hm_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 522 hm_tp_sf_3 = self.pairwiseF(ao.gt, hm_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
546 tb_tp_sf_3 = self.pairwiseF(ao.gt, tb_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 523 tb_tp_sf_3 = self.pairwiseF(ao.gt, tb_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
547 gt_hm_tb_sf_3 = self.pairwiseF(ao.gt, gt_hm_tb_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
548 gt_hm_tp_sf_3 = self.pairwiseF(ao.gt, gt_hm_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
549 gt_tb_tp_sf_3 = self.pairwiseF(ao.gt, gt_tb_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
550 hm_tb_tp_sf_3 = self.pairwiseF(ao.gt, hm_tb_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 524 hm_tb_tp_sf_3 = self.pairwiseF(ao.gt, hm_tb_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
551 gt_hm_tb_tp_sf_3 = self.pairwiseF(ao.gt, gt_hm_tb_tp_sf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 525 |
552 | |
553 gt_hm_cnmf_05 = self.pairwiseF(ao.gt, gt_hm_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
554 gt_tb_cnmf_05 = self.pairwiseF(ao.gt, gt_tb_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
555 gt_tp_cnmf_05 = self.pairwiseF(ao.gt, gt_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
556 hm_tb_cnmf_05 = self.pairwiseF(ao.gt, hm_tb_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 526 hm_tb_cnmf_05 = self.pairwiseF(ao.gt, hm_tb_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
557 hm_tp_cnmf_05 = self.pairwiseF(ao.gt, hm_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 527 hm_tp_cnmf_05 = self.pairwiseF(ao.gt, hm_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
558 tb_tp_cnmf_05 = self.pairwiseF(ao.gt, tb_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 528 tb_tp_cnmf_05 = self.pairwiseF(ao.gt, tb_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
559 gt_hm_tb_cnmf_05 = self.pairwiseF(ao.gt, gt_hm_tb_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
560 gt_hm_tp_cnmf_05 = self.pairwiseF(ao.gt, gt_hm_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
561 gt_tb_tp_cnmf_05 = self.pairwiseF(ao.gt, gt_tb_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | |
562 hm_tb_tp_cnmf_05 = self.pairwiseF(ao.gt, hm_tb_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 529 hm_tb_tp_cnmf_05 = self.pairwiseF(ao.gt, hm_tb_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
563 gt_hm_tb_tp_cnmf_05 = self.pairwiseF(ao.gt, gt_hm_tb_tp_cnmf_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 530 |
564 | |
565 gt_hm_cnmf_3 = self.pairwiseF(ao.gt, gt_hm_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
566 gt_tb_cnmf_3 = self.pairwiseF(ao.gt, gt_tb_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
567 gt_tp_cnmf_3 = self.pairwiseF(ao.gt, gt_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
568 hm_tb_cnmf_3 = self.pairwiseF(ao.gt, hm_tb_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 531 hm_tb_cnmf_3 = self.pairwiseF(ao.gt, hm_tb_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
569 hm_tp_cnmf_3 = self.pairwiseF(ao.gt, hm_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 532 hm_tp_cnmf_3 = self.pairwiseF(ao.gt, hm_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
570 tb_tp_cnmf_3 = self.pairwiseF(ao.gt, tb_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 533 tb_tp_cnmf_3 = self.pairwiseF(ao.gt, tb_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
571 gt_hm_tb_cnmf_3 = self.pairwiseF(ao.gt, gt_hm_tb_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
572 gt_hm_tp_cnmf_3 = self.pairwiseF(ao.gt, gt_hm_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
573 gt_tb_tp_cnmf_3 = self.pairwiseF(ao.gt, gt_tb_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
574 hm_tb_tp_cnmf_3 = self.pairwiseF(ao.gt, hm_tb_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 534 hm_tb_tp_cnmf_3 = self.pairwiseF(ao.gt, hm_tb_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
575 gt_hm_tb_tp_cnmf_3 = self.pairwiseF(ao.gt, gt_hm_tb_tp_cnmf_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | |
576 | 535 |
577 self.writeCombinedRes(outfile7, ao.name, gt_hm_sf_05, gt_hm_sf_3, gt_tb_sf_05, gt_tb_sf_3, gt_tp_sf_05, gt_tp_sf_3, hm_tb_sf_05, hm_tb_sf_3, hm_tp_sf_05, hm_tp_sf_3, tb_tp_sf_05, tb_tp_sf_3,\ | 536 |
578 gt_hm_tb_sf_05, gt_hm_tb_sf_3, gt_hm_tp_sf_05, gt_hm_tp_sf_3, gt_tb_tp_sf_05, gt_tb_tp_sf_3, hm_tb_tp_sf_05, hm_tb_tp_sf_3, gt_hm_tb_tp_sf_05, gt_hm_tb_tp_sf_3) | 537 self.writeCombinedRes(outfile4, ao.name, hm_tb_novelty_05, hm_tb_novelty_3, hm_tp_novelty_05, hm_tp_novelty_3, tb_tp_novelty_05, tb_tp_novelty_3, hm_tb_tp_novelty_05, hm_tb_tp_novelty_3) |
579 | 538 self.writeCombinedRes(outfile5, ao.name, hm_tb_cnmf_05, hm_tb_cnmf_3, hm_tp_cnmf_05, hm_tp_cnmf_3, tb_tp_cnmf_05, tb_tp_cnmf_3, hm_tb_tp_cnmf_05, hm_tb_tp_cnmf_3) |
580 self.writeCombinedRes(outfile8, ao.name, gt_hm_cnmf_05, gt_hm_cnmf_3, gt_tb_cnmf_05, gt_tb_cnmf_3, gt_tp_cnmf_05, gt_tp_cnmf_3, hm_tb_cnmf_05, hm_tb_cnmf_3, hm_tp_cnmf_05, hm_tp_cnmf_3, tb_tp_cnmf_05, tb_tp_cnmf_3,\ | 539 self.writeCombinedRes(outfile6, ao.name, hm_tb_sf_05, hm_tb_sf_3, hm_tp_sf_05, hm_tp_sf_3, tb_tp_sf_05, tb_tp_sf_3, hm_tb_tp_sf_05, hm_tb_tp_sf_3) |
581 gt_hm_tb_cnmf_05, gt_hm_tb_cnmf_3, gt_hm_tp_cnmf_05, gt_hm_tp_cnmf_3, gt_tb_tp_cnmf_05, gt_tb_tp_cnmf_3, hm_tb_tp_cnmf_05, hm_tb_tp_cnmf_3, gt_hm_tb_tp_cnmf_05, gt_hm_tb_tp_cnmf_3) | 540 |
582 | 541 |
583 ############################################################################################################################################ | 542 # ############################################################################################################################################ |
584 # Experiment 3: Pruning boundaries detected by individual boundary algorithms. | 543 # # Experiment 3: late fusion -- segmentation using combined ssms. |
585 | 544 # |
586 # Use different boundary methods for different features | 545 # hm_tb_ssm = self.lin * ao.harmonic_ssm + (1-self.lin) * ao.timbre_ssm |
587 gammatone_idxs, harmonic_idxs, timbre_idxs, tempo_idxs = gammatone_sf_idxs, harmonic_sf_idxs, timbre_sf_idxs, tempo_sf_idxs | 546 # hm_tp_ssm = self.lin * ao.harmonic_ssm + (1-self.lin) * ao.tempo_ssm |
588 bound_candidates = list(gammatone_idxs) + list(harmonic_idxs) + list(timbre_idxs) + list(tempo_idxs) | 547 # tb_tp_ssm = self.lin * ao.timbre_ssm + (1-self.lin) * ao.tempo_ssm |
589 bound_candidates.sort() | 548 # hm_tb_tp_ssm = (ao.harmonic_ssm + ao.timbre_ssm + ao.tempo_ssm) / 3.0 |
590 | 549 # |
591 nBounds = len(bound_candidates) | 550 # hm_tb_ssm_novelty_idxs = novelty_S.process(hm_tb_ssm)[-1] |
592 final_idxs = [] | 551 # hm_tp_ssm_novelty_idxs = novelty_S.process(hm_tp_ssm)[-1] |
593 idx = 0 | 552 # tb_tp_ssm_novelty_idxs = novelty_S.process(tb_tp_ssm)[-1] |
594 tol = 10 # tolerance window of merging boundary scores | 553 # hm_tb_tp_ssm_novelty_idxs = novelty_S.process(hm_tb_tp_ssm)[-1] |
595 while idx < nBounds: | 554 # |
596 temp = [bound_candidates[idx]] | 555 # hm_tb_ssm_novelty_05 = self.pairwiseF(ao.gt, hm_tb_ssm_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
597 pos = [idx] | 556 # hm_tp_ssm_novelty_05 = self.pairwiseF(ao.gt, hm_tp_ssm_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
598 idx += 1 | 557 # tb_tp_ssm_novelty_05 = self.pairwiseF(ao.gt, tb_tp_ssm_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
599 while (idx + tol < nBounds and np.max(bound_candidates[idx: idx+tol]) > 0): | 558 # hm_tb_tp_ssm_novelty_05 = self.pairwiseF(ao.gt, hm_tb_tp_ssm_novelty_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
600 temp += [bound_candidates[idx+delta] for delta in xrange(tol) if (bound_candidates[idx]+delta in bound_candidates)] | 559 # |
601 pos += [idx+delta for delta in xrange(tol) if (bound_candidates[idx]+delta in bound_candidates)] | 560 # hm_tb_ssm_novelty_3 = self.pairwiseF(ao.gt, hm_tb_ssm_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
602 idx += tol | 561 # hm_tp_ssm_novelty_3 = self.pairwiseF(ao.gt, hm_tp_ssm_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
603 if len(temp) == 1: | 562 # tb_tp_ssm_novelty_3 = self.pairwiseF(ao.gt, tb_tp_ssm_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
604 final_idxs.append(temp[0]) | 563 # hm_tb_tp_ssm_novelty_3 = self.pairwiseF(ao.gt, hm_tb_tp_ssm_novelty_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
605 else: | 564 # |
606 final_idxs.append(int(np.rint(np.mean(temp)))) | 565 # self.writeCombinedRes(outfile7, ao.name, hm_tb_ssm_novelty_05, hm_tb_ssm_novelty_3, hm_tp_ssm_novelty_05, hm_tp_ssm_novelty_3, tb_tp_ssm_novelty_05, tb_tp_ssm_novelty_3, hm_tb_tp_ssm_novelty_05, hm_tb_tp_ssm_novelty_3) |
607 | 566 |
608 merged_05 = self.pairwiseF(ao.gt, final_idxs, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) | 567 # ############################################################################################################################################ |
609 merged_3 = self.pairwiseF(ao.gt, final_idxs, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) | 568 # # Experiment 4: late fusion -- segmentation using combined boundaries. |
610 | 569 # hm_novelty_bounds = self.selectBounds(smoothed_harmonic_novelty, harmonic_novelty_idxs, self.confidence_threshold) |
611 self.writeMergedRes(outfile9, ao.name, merged_05, merged_3) | 570 # tb_novelty_bounds = self.selectBounds(smoothed_timbre_novelty, timbre_novelty_idxs, self.confidence_threshold) |
612 | 571 # tp_novelty_bounds = self.selectBounds(smoothed_tempo_novelty, timbre_novelty_idxs, self.confidence_threshold) |
613 # if options.BOUNDARY == 'novelty': | 572 # |
614 # gammatone_novelty, smoothed_gammatone_novelty, gammatone_bound_idxs = novelty_S.process(ao.gammatone_ssm, self.kernel_size, peak_picker) | 573 # hm_tb_novelty_bounds = hm_novelty_bounds + tb_novelty_bounds |
615 # timbre_novelty, smoothed_timbre_novelty, timbre_bound_idxs = novelty_S.process(ao.timbre_ssm, self.kernel_size, peak_picker) | 574 # hm_tp_novelty_bounds = hm_novelty_bounds + tp_novelty_bounds |
616 # tempo_novelty, smoothed_harmonic_novelty, tempo_bound_idxs = novelty_S.process(ao.tempo_ssm, self.kernel_size, peak_picker) | 575 # tb_tp_novelty_bounds = tb_novelty_bounds + tp_novelty_bounds |
617 # harmonic_novelty, smoothed_tempo_novelty, harmonic_bound_idxs = novelty_S.process(ao.harmonic_ssm, self.kernel_size, peak_picker) | 576 # hm_tb_tp_novelty_bounds = hm_novelty_bounds + tb_novelty_bounds + tp_novelty_bounds |
618 # | 577 # |
619 # if options.BOUNDARY == 'cnmf': | 578 # hm_tb_novelty_bounds = self.removeDuplicates(hm_tb_novelty_bounds, tol=1.0) |
620 # gammatone_cnmf_idxs = cnmf_S.segmentation(ao.gammatone_features, rank=rank, R=R, h=8, niter=300) | 579 # hm_tp_novelty_bounds = self.removeDuplicates(hm_tp_novelty_bounds, tol=1.0) |
621 # timbre_cnmf_idxs = cnmf_S.segmentation(ao.timbre_features, rank=rank, R=R, h=h, niter=300) | 580 # tb_tp_novelty_bounds = self.removeDuplicates(tb_tp_novelty_bounds, tol=1.0) |
622 # tempo_cnmf_idxs = cnmf_S.segmentation(ao.tempo_features, rank=rank, R=R, h=h, niter=300) | 581 # hm_tb_tp_novelty_bounds = self.removeDuplicates(hm_tb_tp_novelty_bounds, tol=1.0) |
623 # harmonic_cnmf_idxs = cnmf_S.segmentation(ao.harmonic_features, rank=rank, R=R, h=h, niter=300) | 582 # |
624 # | 583 # hm_sf_bounds = self.selectBounds(harmonic_sf_nc, harmonic_sf_idxs, self.confidence_threshold) |
625 # if options.BOUNDARY == 'foote': | 584 # tb_sf_bounds = self.selectBounds(timbre_sf_nc, timbre_sf_idxs, self.confidence_threshold) |
626 # gammatone_foote_idxs = foote_S.segmentation(ao.gammatone_features, M=M, Mg=Mg, L=L) | 585 # tp_sf_bounds = self.selectBounds(tempo_sf_nc, tempo_sf_idxs, self.confidence_threshold) |
627 # timbre_foote_idxs = foote_S.segmentation(ao.timbre_features, M=M, Mg=Mg, L=L) | 586 # |
628 # tempo_foote_idxs = foote_S.segmentation(ao.tempo_features, M=M, Mg=Mg, L=L) | 587 # hm_tb_sf_bounds = hm_sf_bounds + tb_sf_bounds |
629 # harmonic_foote_idxs = foote_S.segmentation(ao.harmonic_features, M=M, Mg=Mg, L=L) | 588 # hm_tp_sf_bounds = hm_sf_bounds + tp_sf_bounds |
630 # | 589 # tb_tp_sf_bounds = tb_sf_bounds + tp_sf_bounds |
631 # if options.BOUNDARY == 'sf': | 590 # hm_tb_tp_sf_bounds = hm_sf_bounds + tb_sf_bounds + tp_sf_bounds |
632 # gammatone_sf_idxs = sf_S.segmentation(ao.gammatone_features) | 591 # |
633 # timbre_sf_idxs = sf_S.segmentation(ao.timbre_features) | 592 # hm_tb_sf_bounds = self.removeDuplicates(hm_tb_sf_bounds, tol=1.0) |
634 # tempo_sf_idxs = sf_S.segmentation(ao.tempo_features) | 593 # hm_tp_sf_bounds = self.removeDuplicates(hm_tp_sf_bounds, tol=1.0) |
635 # harmonic_sf_idxs = sf_S.segmentation(ao.harmonic_features) | 594 # tb_tp_sf_bounds = self.removeDuplicates(tb_tp_sf_bounds, tol=1.0) |
636 # | 595 # hm_tb_tp_sf_bounds = self.removeDuplicates(hm_tb_tp_sf_bounds, tol=1.0) |
637 # gammatone_novelty_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in gammatone_novelty_peaks] | 596 # |
638 # timbre_novelty_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in timbre_novelty_peaks] | 597 # |
639 # harmonic_novelty_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in harmonic_novelty_peaks] | 598 # hm_tb_novelty_bounds_05 = self.pairwiseF(ao.gt, hm_tb_novelty_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
640 # tempo_novelty_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in tempo_novelty_peaks] | 599 # hm_tp_novelty_bounds_05 = self.pairwiseF(ao.gt, hm_tp_novelty_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
641 # | 600 # tb_tp_novelty_bounds_05 = self.pairwiseF(ao.gt, tb_tp_novelty_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
642 # gammatone_cnmf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in gammatone_cnmf_peaks] | 601 # hm_tb_tp_novelty_bounds_05 = self.pairwiseF(ao.gt, hm_tb_tp_novelty_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
643 # timbre_cnmf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in timbre_cnmf_peaks] | 602 # |
644 # harmonic_cnmf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in harmonic_cnmf_peaks] | 603 # hm_tb_sf_bounds_05 = self.pairwiseF(ao.gt, hm_tb_sf_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
645 # tempo_cnmf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in tempo_cnmf_peaks] | 604 # hm_tp_sf_bounds_05 = self.pairwiseF(ao.gt, hm_tp_sf_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
646 # | 605 # tb_tp_sf_bounds_05 = self.pairwiseF(ao.gt, tb_tp_sf_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
647 # gammatone_sf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in gammatone_sf_peaks] | 606 # hm_tb_tp_sf_bounds_05 = self.pairwiseF(ao.gt, hm_tb_tp_sf_bounds, tolerance=0.5, combine=1.0, idx2time=ao.ssm_timestamps) |
648 # timbre_sf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in timbre_sf_peaks] | 607 # |
649 # harmonic_sf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in harmonic_sf_peaks] | 608 # hm_tb_novelty_bounds_3 = self.pairwiseF(ao.gt, hm_tb_novelty_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
650 # tempo_sf_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in tempo_sf_peaks] | 609 # hm_tp_novelty_bounds_3 = self.pairwiseF(ao.gt, hm_tp_novelty_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
651 # | 610 # tb_tp_novelty_bounds_3 = self.pairwiseF(ao.gt, tb_tp_novelty_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
652 # gammatone_foote_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in gammatone_foote_peaks] | 611 # hm_tb_tp_novelty_bounds_3 = self.pairwiseF(ao.gt, hm_tb_tp_novelty_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
653 # timbre_foote_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in timbre_foote_peaks] | 612 # |
654 # harmonic_foote_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in harmonic_foote_peaks] | 613 # hm_tb_sf_bounds_3 = self.pairwiseF(ao.gt, hm_tb_sf_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
655 # tempo_foote_detection = [0.0] + [ao.ssm_timestamps[int(np.rint(i))] for i in tempo_foote_peaks] | 614 # hm_tp_sf_bounds_3 = self.pairwiseF(ao.gt, hm_tp_sf_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
656 # | 615 # tb_tp_sf_bounds_3 = self.pairwiseF(ao.gt, tb_tp_sf_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
657 # # Experiment 2: Trying combined features using the best boundary retrieval method | 616 # hm_tb_tp_sf_bounds_3 = self.pairwiseF(ao.gt, hm_tb_tp_sf_bounds, tolerance=3, combine=1.0, idx2time=ao.ssm_timestamps) |
658 # ao_featureset = [ao.gammatone_features, ao.harmonic_features, ao.timbre_features, ao.tempo_features] | 617 # |
659 # feature_sel = [int(x) for x in options.FEATURES if x.isdigit()] | 618 # self.writeCombinedRes(outfile8, ao.name, hm_tb_novelty_bounds_05, hm_tb_novelty_bounds_3, hm_tp_novelty_bounds_05, hm_tp_novelty_bounds_3, tb_tp_novelty_bounds_05, tb_tp_novelty_bounds_3, hm_tb_tp_novelty_bounds_05, hm_tb_tp_novelty_bounds_3) |
660 # fused_featureset = [ao_featureset[i] for i in feature_sel] | 619 # self.writeCombinedRes(outfile9, ao.name, hm_tb_sf_bounds_05, hm_tb_sf_bounds_3, hm_tp_sf_bounds_05, hm_tp_sf_bounds_3, tb_tp_sf_bounds_05, tb_tp_sf_bounds_3, hm_tb_tp_sf_bounds_05, hm_tb_tp_sf_bounds_3) |
661 | 620 |
662 # if options.LABEL == 'fmc2d': | |
663 # gammatone_fmc2d_labels = fmc2d_S.compute_similarity(gammatone_bound_idxs, xmeans=True, N=N) | |
664 # timbre_fmc2d_labels = fmc2d_S.compute_similarity(timbre_bound_idxs, xmeans=True, N=N) | |
665 # tempo_fmc2d_labels = fmc2d_S.compute_similarity(tempo_bound_idxs, xmeans=True, N=N) | |
666 # harmonic_fmc2d_labels = fmc2d_S.compute_similarity(harmonic_bound_idxs, xmeans=True, N=N) | |
667 # | |
668 # if options.LABEL == 'cnmf': | |
669 # gammatone_cnmf_labels = cnmf_S.compute_labels(gammatone_bound_idxs, est_bound_idxs, nFrames) | |
670 # timbre_cnmf_labels = cnmf_S.compute_labels(timbre_bound_idxs, est_bound_idxs, nFrames) | |
671 # tempo_cnmf_labels = cnmf_S.compute_labels(tempo_bound_idxs, est_bound_idxs, nFrames) | |
672 # harmonic_cnmf_labels = cnmf_S.compute_labels(harmonic_bound_idxs, est_bound_idxs, nFrames) | |
673 # | |
674 # | |
675 | |
676 | 621 |
677 | 622 |
678 def main(): | 623 def main(): |
679 | 624 |
680 segmenter = SSMseg() | 625 segmenter = SSMseg() |