本文整理匯總了Python中museval.eval_mus_track方法的典型用法代碼示例。如果您正苦於以下問題:Python museval.eval_mus_track方法的具體用法?Python museval.eval_mus_track怎麽用?Python museval.eval_mus_track使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類museval
的用法示例。
在下文中一共展示了museval.eval_mus_track方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_aggregate
# 需要導入模塊: import museval [as 別名]
# 或者: from museval import eval_mus_track [as 別名]
def test_aggregate(reference):
track, _ = reference
np.random.seed(0)
random_voc = np.random.random(track.audio.shape)
random_acc = np.random.random(track.audio.shape)
# create a silly regression test
estimates = {
'vocals': random_voc,
'accompaniment': random_acc
}
scores = museval.eval_mus_track(
track, estimates
)
print(scores.df)
results = museval.EvalStore()
results.add_track(scores)
agg = results.agg_frames_scores()
print(results)
示例2: test_random_estimate
# 需要導入模塊: import museval [as 別名]
# 或者: from museval import eval_mus_track [as 別名]
def test_random_estimate(reference):
track, _ = reference
np.random.seed(0)
random_voc = np.random.random(track.audio.shape)
random_acc = np.random.random(track.audio.shape)
# create a silly regression test
estimates = {
'vocals': random_voc,
'accompaniment': random_acc
}
scores = museval.eval_mus_track(
track, estimates
)
# save json
with open(
os.path.join('.', track.name) + '.json', 'w+'
) as f:
f.write(scores.json)
# validate json
assert scores.validate() is None
示例3: test_one_estimate
# 需要導入模塊: import museval [as 別名]
# 或者: from museval import eval_mus_track [as 別名]
def test_one_estimate(reference):
track, _ = reference
np.random.seed(0)
random_voc = np.random.random(track.audio.shape)
estimates = {
'vocals': random_voc
}
with pytest.warns(UserWarning):
est_scores = museval.eval_mus_track(
track, estimates
)
est_json = json.loads(est_scores.json)
assert len(est_json['targets']) == 0
示例4: oracle
# 需要導入模塊: import museval [as 別名]
# 或者: from museval import eval_mus_track [as 別名]
def oracle(track, separation_fn):
# compute the mixture complex tf transform
x = stft(track.audio)
v = []
for name, value in track.sources.items():
v_j = np.sum(np.abs(stft(value.audio))**2,
axis=-1, keepdims=True)
v += [np.squeeze(v_j)]
v = np.moveaxis(np.array(v), 0, 2)
y = separation_fn(v, x)
estimates = {}
for j, (name, value) in enumerate(track.sources.items()):
audio_hat = istft(y[..., j])
estimates[name] = audio_hat
# Evaluate using museval
scores = museval.eval_mus_track(
track, estimates, output_dir=None
)
print(scores)
return estimates
示例5: test_track_scores
# 需要導入模塊: import museval [as 別名]
# 或者: from museval import eval_mus_track [as 別名]
def test_track_scores(reference):
track, ref_scores = reference
np.random.seed(0)
random_voc = np.random.random(track.audio.shape)
random_acc = np.random.random(track.audio.shape)
# create a silly regression test
estimates = {
'vocals': random_voc,
'accompaniment': random_acc
}
scores = museval.eval_mus_track(
track, estimates
)
est_scores = json.loads(scores.json)
for target in ref_scores['targets']:
for metric in ['SDR', 'SIR', 'SAR', 'ISR']:
ref = np.array([d['metrics'][metric] for d in target['frames']])
idx = [t['name']
for t in est_scores['targets']].index(target['name'])
est = np.array(
[
d['metrics'][metric]
for d in est_scores['targets'][idx]['frames']
]
)
assert np.allclose(ref, est, atol=1e-02, equal_nan=True)
示例6: separate_and_evaluate
# 需要導入模塊: import museval [as 別名]
# 或者: from museval import eval_mus_track [as 別名]
def separate_and_evaluate(
track,
targets,
model_name,
niter,
alpha,
softmask,
output_dir,
eval_dir,
device='cpu'
):
estimates = test.separate(
audio=track.audio,
targets=targets,
model_name=model_name,
niter=niter,
alpha=alpha,
softmask=softmask,
device=device
)
if output_dir:
mus.save_estimates(estimates, track, output_dir)
scores = museval.eval_mus_track(
track, estimates, output_dir=eval_dir
)
return scores