-
Notifications
You must be signed in to change notification settings - Fork 6
/
evaluate.py
54 lines (41 loc) · 1.29 KB
/
evaluate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import argparse
from pathlib import Path
import torch
from data.musdb18hq import MUSDB18HQ
from train import get_model, validate
def evaluate(args):
model_name = args.model_name
checkpoint_path = args.checkpoint_path
clip_duration = args.clip_duration
batch_size = args.batch_size
evaluate_num = None
root = "/datasets/musdb18hq"
split = "test"
sr = 44100
device = "cuda"
source_types = MUSDB18HQ.source_types
model = get_model(model_name)
model.load_state_dict(torch.load(checkpoint_path))
model.to(device)
sdr = validate(
root=root,
split=split,
sr=sr,
clip_duration=clip_duration,
source_types=source_types,
target_source_type="vocals",
batch_size=batch_size,
model=model,
evaluate_num=evaluate_num,
verbose=True
)
print("--- Median SDR ---")
print("{:.2f} dB".format(sdr))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--model_name', type=str, default="UNet")
parser.add_argument('--checkpoint_path', type=str, required=True)
parser.add_argument('--clip_duration', type=float, required=True)
parser.add_argument('--batch_size', type=int, default=16)
args = parser.parse_args()
evaluate(args)