#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import torch
import torch.nn as nn

from utils.utils import set_seed
from dataset import WaveTestDataset, TestDataLoader
from driver import Tester
from models.dprnn_tasnet import DPRNNTasNet
from criterion.sdr import NegSISDR
from criterion.pit import PIT1d

parser = argparse.ArgumentParser(description="Evaluation of DPRNN-TasNet")

parser.add_argument('--wav_root', type=str, default=None, help='Path for dataset ROOT directory')
parser.add_argument('--test_json_path', type=str, default=None, help='Path for test.json')
parser.add_argument('--sr', type=int, default=10, help='Sampling rate')
parser.add_argument('--n_sources', type=int, default=None, help='# speakers')
parser.add_argument('--criterion', type=str, default='sisdr', choices=['sisdr'], help='Criterion')
parser.add_argument('--out_dir', type=str, default=None, help='Output directory')
parser.add_argument('--model_path', type=str, default='./tmp/model/best.pth', help='Path for model')
parser.add_argument('--use_cuda', type=int, default=1, help='0: Not use cuda, 1: Use cuda')
parser.add_argument('--overwrite', type=int, default=0, help='0: NOT overwrite, 1: FORCE overwrite')
parser.add_argument('--seed', type=int, default=42, help='Random seed')

def main(args):
    set_seed(args.seed)
    
    test_dataset = WaveTestDataset(args.wav_root, args.test_json_path)
    print("Test dataset includes {} samples.".format(len(test_dataset)))
    
    loader = TestDataLoader(test_dataset, batch_size=1, shuffle=False)
    
    model = DPRNNTasNet.build_model(args.model_path)
    print(model)
    print("# Parameters: {}".format(model.num_parameters))
    
    if args.use_cuda:
        if torch.cuda.is_available():
            model.cuda()
            model = nn.DataParallel(model)
            print("Use CUDA", flush=True)
        else:
            raise ValueError("Cannot use CUDA.")
    else:
        print("Does NOT use CUDA", flush=True)
    
    # Criterion
    if args.criterion == 'sisdr':
        criterion = NegSISDR()
    else:
        raise ValueError("Not support criterion {}".format(args.criterion))
    
    pit_criterion = PIT1d(criterion, n_sources=args.n_sources)
    
    tester = Tester(model, loader, pit_criterion, args)
    tester.run()
    
    
if __name__ == '__main__':
    args = parser.parse_args()
    print(args)
    main(args)

d476621e373023713fe0cc03b402e6d305e756fa
<mask token>


def main(args):
    set_seed(args.seed)
    test_dataset = WaveTestDataset(args.wav_root, args.test_json_path)
    print('Test dataset includes {} samples.'.format(len(test_dataset)))
    loader = TestDataLoader(test_dataset, batch_size=1, shuffle=False)
    model = DPRNNTasNet.build_model(args.model_path)
    print(model)
    print('# Parameters: {}'.format(model.num_parameters))
    if args.use_cuda:
        if torch.cuda.is_available():
            model.cuda()
            model = nn.DataParallel(model)
            print('Use CUDA', flush=True)
        else:
            raise ValueError('Cannot use CUDA.')
    else:
        print('Does NOT use CUDA', flush=True)
    if args.criterion == 'sisdr':
        criterion = NegSISDR()
    else:
        raise ValueError('Not support criterion {}'.format(args.criterion))
    pit_criterion = PIT1d(criterion, n_sources=args.n_sources)
    tester = Tester(model, loader, pit_criterion, args)
    tester.run()


<mask token>

<mask token>
parser.add_argument('--wav_root', type=str, default=None, help=
    'Path for dataset ROOT directory')
parser.add_argument('--test_json_path', type=str, default=None, help=
    'Path for test.json')
parser.add_argument('--sr', type=int, default=10, help='Sampling rate')
parser.add_argument('--n_sources', type=int, default=None, help='# speakers')
parser.add_argument('--criterion', type=str, default='sisdr', choices=[
    'sisdr'], help='Criterion')
parser.add_argument('--out_dir', type=str, default=None, help=
    'Output directory')
parser.add_argument('--model_path', type=str, default=
    './tmp/model/best.pth', help='Path for model')
parser.add_argument('--use_cuda', type=int, default=1, help=
    '0: Not use cuda, 1: Use cuda')
parser.add_argument('--overwrite', type=int, default=0, help=
    '0: NOT overwrite, 1: FORCE overwrite')
parser.add_argument('--seed', type=int, default=42, help='Random seed')


def main(args):
    set_seed(args.seed)
    test_dataset = WaveTestDataset(args.wav_root, args.test_json_path)
    print('Test dataset includes {} samples.'.format(len(test_dataset)))
    loader = TestDataLoader(test_dataset, batch_size=1, shuffle=False)
    model = DPRNNTasNet.build_model(args.model_path)
    print(model)
    print('# Parameters: {}'.format(model.num_parameters))
    if args.use_cuda:
        if torch.cuda.is_available():
            model.cuda()
            model = nn.DataParallel(model)
            print('Use CUDA', flush=True)
        else:
            raise ValueError('Cannot use CUDA.')
    else:
        print('Does NOT use CUDA', flush=True)
    if args.criterion == 'sisdr':
        criterion = NegSISDR()
    else:
        raise ValueError('Not support criterion {}'.format(args.criterion))
    pit_criterion = PIT1d(criterion, n_sources=args.n_sources)
    tester = Tester(model, loader, pit_criterion, args)
    tester.run()


if __name__ == '__main__':
    args = parser.parse_args()
    print(args)
    main(args)

<mask token>
parser = argparse.ArgumentParser(description='Evaluation of DPRNN-TasNet')
parser.add_argument('--wav_root', type=str, default=None, help=
    'Path for dataset ROOT directory')
parser.add_argument('--test_json_path', type=str, default=None, help=
    'Path for test.json')
parser.add_argument('--sr', type=int, default=10, help='Sampling rate')
parser.add_argument('--n_sources', type=int, default=None, help='# speakers')
parser.add_argument('--criterion', type=str, default='sisdr', choices=[
    'sisdr'], help='Criterion')
parser.add_argument('--out_dir', type=str, default=None, help=
    'Output directory')
parser.add_argument('--model_path', type=str, default=
    './tmp/model/best.pth', help='Path for model')
parser.add_argument('--use_cuda', type=int, default=1, help=
    '0: Not use cuda, 1: Use cuda')
parser.add_argument('--overwrite', type=int, default=0, help=
    '0: NOT overwrite, 1: FORCE overwrite')
parser.add_argument('--seed', type=int, default=42, help='Random seed')


def main(args):
    set_seed(args.seed)
    test_dataset = WaveTestDataset(args.wav_root, args.test_json_path)
    print('Test dataset includes {} samples.'.format(len(test_dataset)))
    loader = TestDataLoader(test_dataset, batch_size=1, shuffle=False)
    model = DPRNNTasNet.build_model(args.model_path)
    print(model)
    print('# Parameters: {}'.format(model.num_parameters))
    if args.use_cuda:
        if torch.cuda.is_available():
            model.cuda()
            model = nn.DataParallel(model)
            print('Use CUDA', flush=True)
        else:
            raise ValueError('Cannot use CUDA.')
    else:
        print('Does NOT use CUDA', flush=True)
    if args.criterion == 'sisdr':
        criterion = NegSISDR()
    else:
        raise ValueError('Not support criterion {}'.format(args.criterion))
    pit_criterion = PIT1d(criterion, n_sources=args.n_sources)
    tester = Tester(model, loader, pit_criterion, args)
    tester.run()


if __name__ == '__main__':
    args = parser.parse_args()
    print(args)
    main(args)

import argparse
import torch
import torch.nn as nn
from utils.utils import set_seed
from dataset import WaveTestDataset, TestDataLoader
from driver import Tester
from models.dprnn_tasnet import DPRNNTasNet
from criterion.sdr import NegSISDR
from criterion.pit import PIT1d
parser = argparse.ArgumentParser(description='Evaluation of DPRNN-TasNet')
parser.add_argument('--wav_root', type=str, default=None, help=
    'Path for dataset ROOT directory')
parser.add_argument('--test_json_path', type=str, default=None, help=
    'Path for test.json')
parser.add_argument('--sr', type=int, default=10, help='Sampling rate')
parser.add_argument('--n_sources', type=int, default=None, help='# speakers')
parser.add_argument('--criterion', type=str, default='sisdr', choices=[
    'sisdr'], help='Criterion')
parser.add_argument('--out_dir', type=str, default=None, help=
    'Output directory')
parser.add_argument('--model_path', type=str, default=
    './tmp/model/best.pth', help='Path for model')
parser.add_argument('--use_cuda', type=int, default=1, help=
    '0: Not use cuda, 1: Use cuda')
parser.add_argument('--overwrite', type=int, default=0, help=
    '0: NOT overwrite, 1: FORCE overwrite')
parser.add_argument('--seed', type=int, default=42, help='Random seed')


def main(args):
    set_seed(args.seed)
    test_dataset = WaveTestDataset(args.wav_root, args.test_json_path)
    print('Test dataset includes {} samples.'.format(len(test_dataset)))
    loader = TestDataLoader(test_dataset, batch_size=1, shuffle=False)
    model = DPRNNTasNet.build_model(args.model_path)
    print(model)
    print('# Parameters: {}'.format(model.num_parameters))
    if args.use_cuda:
        if torch.cuda.is_available():
            model.cuda()
            model = nn.DataParallel(model)
            print('Use CUDA', flush=True)
        else:
            raise ValueError('Cannot use CUDA.')
    else:
        print('Does NOT use CUDA', flush=True)
    if args.criterion == 'sisdr':
        criterion = NegSISDR()
    else:
        raise ValueError('Not support criterion {}'.format(args.criterion))
    pit_criterion = PIT1d(criterion, n_sources=args.n_sources)
    tester = Tester(model, loader, pit_criterion, args)
    tester.run()


if __name__ == '__main__':
    args = parser.parse_args()
    print(args)
    main(args)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import torch
import torch.nn as nn

from utils.utils import set_seed
from dataset import WaveTestDataset, TestDataLoader
from driver import Tester
from models.dprnn_tasnet import DPRNNTasNet
from criterion.sdr import NegSISDR
from criterion.pit import PIT1d

parser = argparse.ArgumentParser(description="Evaluation of DPRNN-TasNet")

parser.add_argument('--wav_root', type=str, default=None, help='Path for dataset ROOT directory')
parser.add_argument('--test_json_path', type=str, default=None, help='Path for test.json')
parser.add_argument('--sr', type=int, default=10, help='Sampling rate')
parser.add_argument('--n_sources', type=int, default=None, help='# speakers')
parser.add_argument('--criterion', type=str, default='sisdr', choices=['sisdr'], help='Criterion')
parser.add_argument('--out_dir', type=str, default=None, help='Output directory')
parser.add_argument('--model_path', type=str, default='./tmp/model/best.pth', help='Path for model')
parser.add_argument('--use_cuda', type=int, default=1, help='0: Not use cuda, 1: Use cuda')
parser.add_argument('--overwrite', type=int, default=0, help='0: NOT overwrite, 1: FORCE overwrite')
parser.add_argument('--seed', type=int, default=42, help='Random seed')

def main(args):
    set_seed(args.seed)
    
    test_dataset = WaveTestDataset(args.wav_root, args.test_json_path)
    print("Test dataset includes {} samples.".format(len(test_dataset)))
    
    loader = TestDataLoader(test_dataset, batch_size=1, shuffle=False)
    
    model = DPRNNTasNet.build_model(args.model_path)
    print(model)
    print("# Parameters: {}".format(model.num_parameters))
    
    if args.use_cuda:
        if torch.cuda.is_available():
            model.cuda()
            model = nn.DataParallel(model)
            print("Use CUDA", flush=True)
        else:
            raise ValueError("Cannot use CUDA.")
    else:
        print("Does NOT use CUDA", flush=True)
    
    # Criterion
    if args.criterion == 'sisdr':
        criterion = NegSISDR()
    else:
        raise ValueError("Not support criterion {}".format(args.criterion))
    
    pit_criterion = PIT1d(criterion, n_sources=args.n_sources)
    
    tester = Tester(model, loader, pit_criterion, args)
    tester.run()
    
    
if __name__ == '__main__':
    args = parser.parse_args()
    print(args)
    main(args)
