From f622c55b046cf3b000a23c636f1620456a42deda Mon Sep 17 00:00:00 2001 From: Menglong Xu <32296227+mlxu995@users.noreply.github.com> Date: Fri, 17 Dec 2021 20:52:45 +0800 Subject: [PATCH] [kws] update parameter for plotting det curve (#54) --- examples/hey_snips/s0/run.sh | 2 +- kws/bin/plot_det_curve.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/hey_snips/s0/run.sh b/examples/hey_snips/s0/run.sh index 58f300a..8aeb782 100755 --- a/examples/hey_snips/s0/run.sh +++ b/examples/hey_snips/s0/run.sh @@ -107,7 +107,7 @@ if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then --stats_file $result_dir/stats.${keyword}.txt done python kws/bin/plot_det_curve.py \ - --keywords 'Hey_Snips' \ + --keywords_dict dict/words.txt \ --stats_dir $result_dir \ --figure_file $result_dir/det.png \ --xlim 10 \ diff --git a/kws/bin/plot_det_curve.py b/kws/bin/plot_det_curve.py index fc935e3..62b77f7 100644 --- a/kws/bin/plot_det_curve.py +++ b/kws/bin/plot_det_curve.py @@ -62,11 +62,9 @@ def plot_det_curve( if __name__ == '__main__': parser = argparse.ArgumentParser(description='plot det curve') parser.add_argument( - '--keywords', + '--keywords_dict', required=True, - help=('keywords, must in the same order as in "dict/words.txt", ' + - 'separated by ", "') - ) + help='path to the dictionary of keywords') parser.add_argument('--stats_dir', required=True, help='dir of stats files') parser.add_argument( '--figure_file', @@ -87,7 +85,13 @@ if __name__ == '__main__': args = parser.parse_args() - keywords = args.keywords.strip().split(', ') + keywords = [] + with open(args.keywords_dict, 'r', encoding='utf8') as fin: + for line in fin: + keyword, index = line.strip().split() + if int(index) > -1: + keywords.append(keyword) + plot_det_curve( keywords, args.stats_dir,