本文整理汇总了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