From 97136fe97f15f408ca759a060210365512bb6f2a Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Wed, 20 Oct 2021 02:56:30 +0000 Subject: [PATCH] trainer eval when not train --- deepspeech/exps/deepspeech2/bin/export.py | 5 +++-- deepspeech/exps/deepspeech2/bin/test.py | 5 +++-- deepspeech/exps/deepspeech2/bin/test_export.py | 5 +++-- deepspeech/exps/deepspeech2/bin/test_hub.py | 5 +++-- deepspeech/exps/u2/bin/alignment.py | 5 +++-- deepspeech/exps/u2/bin/export.py | 5 +++-- deepspeech/exps/u2/bin/test.py | 5 +++-- deepspeech/exps/u2_kaldi/bin/test.py | 16 ++++++++-------- deepspeech/exps/u2_st/bin/export.py | 5 +++-- deepspeech/exps/u2_st/bin/test.py | 5 +++-- 10 files changed, 35 insertions(+), 26 deletions(-) diff --git a/deepspeech/exps/deepspeech2/bin/export.py b/deepspeech/exps/deepspeech2/bin/export.py index ab5251d55..5f89e9042 100644 --- a/deepspeech/exps/deepspeech2/bin/export.py +++ b/deepspeech/exps/deepspeech2/bin/export.py @@ -20,8 +20,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_export() + with exp.eval(): + exp.setup() + exp.run_export() def main(config, args): diff --git a/deepspeech/exps/deepspeech2/bin/test.py b/deepspeech/exps/deepspeech2/bin/test.py index 7fbdab451..6181ff902 100644 --- a/deepspeech/exps/deepspeech2/bin/test.py +++ b/deepspeech/exps/deepspeech2/bin/test.py @@ -20,8 +20,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_test() + with exp.eval(): + exp.setup() + exp.run_test() def main(config, args): diff --git a/deepspeech/exps/deepspeech2/bin/test_export.py b/deepspeech/exps/deepspeech2/bin/test_export.py index be1a8479a..77bb0025a 100644 --- a/deepspeech/exps/deepspeech2/bin/test_export.py +++ b/deepspeech/exps/deepspeech2/bin/test_export.py @@ -20,8 +20,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = ExportTester(config, args) - exp.setup() - exp.run_test() + with exp.eval(): + exp.setup() + exp.run_test() def main(config, args): diff --git a/deepspeech/exps/deepspeech2/bin/test_hub.py b/deepspeech/exps/deepspeech2/bin/test_hub.py index 1cf24bb03..7d98e0b15 100644 --- a/deepspeech/exps/deepspeech2/bin/test_hub.py +++ b/deepspeech/exps/deepspeech2/bin/test_hub.py @@ -167,8 +167,9 @@ def check(audio_file): def main_sp(config, args): exp = DeepSpeech2Tester_hub(config, args) - exp.setup() - exp.run_test() + with exp.eval(): + exp.setup() + exp.run_test() def main(config, args): diff --git a/deepspeech/exps/u2/bin/alignment.py b/deepspeech/exps/u2/bin/alignment.py index cef9d1ab9..91aac1a8c 100644 --- a/deepspeech/exps/u2/bin/alignment.py +++ b/deepspeech/exps/u2/bin/alignment.py @@ -20,8 +20,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_align() + with exp.eval(): + exp.setup() + exp.run_align() def main(config, args): diff --git a/deepspeech/exps/u2/bin/export.py b/deepspeech/exps/u2/bin/export.py index 3dc41b706..89acbf70d 100644 --- a/deepspeech/exps/u2/bin/export.py +++ b/deepspeech/exps/u2/bin/export.py @@ -20,8 +20,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_export() + with exp.eval(): + exp.setup() + exp.run_export() def main(config, args): diff --git a/deepspeech/exps/u2/bin/test.py b/deepspeech/exps/u2/bin/test.py index f6127675e..3068f1c7a 100644 --- a/deepspeech/exps/u2/bin/test.py +++ b/deepspeech/exps/u2/bin/test.py @@ -24,8 +24,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_test() + with exp.eval(): + exp.setup() + exp.run_test() def main(config, args): diff --git a/deepspeech/exps/u2_kaldi/bin/test.py b/deepspeech/exps/u2_kaldi/bin/test.py index 93a29ab15..eb7b0280b 100644 --- a/deepspeech/exps/u2_kaldi/bin/test.py +++ b/deepspeech/exps/u2_kaldi/bin/test.py @@ -29,14 +29,14 @@ model_test_alias = { def main_sp(config, args): class_obj = dynamic_import(args.model_name, model_test_alias) exp = class_obj(config, args) - exp.setup() - - if args.run_mode == 'test': - exp.run_test() - elif args.run_mode == 'export': - exp.run_export() - elif args.run_mode == 'align': - exp.run_align() + with exp.eval(): + exp.setup() + if args.run_mode == 'test': + exp.run_test() + elif args.run_mode == 'export': + exp.run_export() + elif args.run_mode == 'align': + exp.run_align() def main(config, args): diff --git a/deepspeech/exps/u2_st/bin/export.py b/deepspeech/exps/u2_st/bin/export.py index c7eb5d03b..2486f4c22 100644 --- a/deepspeech/exps/u2_st/bin/export.py +++ b/deepspeech/exps/u2_st/bin/export.py @@ -20,8 +20,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_export() + with exp.eval(): + exp.setup() + exp.run_export() def main(config, args): diff --git a/deepspeech/exps/u2_st/bin/test.py b/deepspeech/exps/u2_st/bin/test.py index 81197decf..3d51b60e0 100644 --- a/deepspeech/exps/u2_st/bin/test.py +++ b/deepspeech/exps/u2_st/bin/test.py @@ -24,8 +24,9 @@ from deepspeech.utils.utility import print_arguments def main_sp(config, args): exp = Tester(config, args) - exp.setup() - exp.run_test() + with exp.eval(): + exp.setup() + exp.run_test() def main(config, args):