[wekws] rename kws to wekws (#76)

* [wekws] rename kws to wekws

* fix lint
This commit is contained in:
Binbin Zhang 2022-08-27 11:57:44 +08:00 committed by GitHub
parent 51f0fe6dc3
commit c9a262866f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 54 additions and 52 deletions

View File

@ -1 +0,0 @@
../../../kws

View File

@ -68,7 +68,7 @@ if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
$norm_var && cmvn_opts="$cmvn_opts --norm_var" $norm_var && cmvn_opts="$cmvn_opts --norm_var"
num_gpus=$(echo $gpus | awk -F ',' '{print NF}') num_gpus=$(echo $gpus | awk -F ',' '{print NF}')
torchrun --standalone --nnodes=1 --nproc_per_node=$num_gpus \ torchrun --standalone --nnodes=1 --nproc_per_node=$num_gpus \
kws/bin/train.py --gpus $gpus \ wekws/bin/train.py --gpus $gpus \
--config $config \ --config $config \
--train_data data/train/data.list \ --train_data data/train/data.list \
--cv_data data/dev/data.list \ --cv_data data/dev/data.list \
@ -83,14 +83,14 @@ fi
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
echo "Do model average, Compute FRR/FAR ..." echo "Do model average, Compute FRR/FAR ..."
python kws/bin/average_model.py \ python wekws/bin/average_model.py \
--dst_model $score_checkpoint \ --dst_model $score_checkpoint \
--src_path $dir \ --src_path $dir \
--num ${num_average} \ --num ${num_average} \
--val_best --val_best
result_dir=$dir/test_$(basename $score_checkpoint) result_dir=$dir/test_$(basename $score_checkpoint)
mkdir -p $result_dir mkdir -p $result_dir
python kws/bin/score.py \ python wekws/bin/score.py \
--config $dir/config.yaml \ --config $dir/config.yaml \
--test_data data/test/data.list \ --test_data data/test/data.list \
--batch_size 256 \ --batch_size 256 \
@ -100,13 +100,13 @@ if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
first_keyword=0 first_keyword=0
last_keyword=$(($num_keywords+$first_keyword-1)) last_keyword=$(($num_keywords+$first_keyword-1))
for keyword in $(seq $first_keyword $last_keyword); do for keyword in $(seq $first_keyword $last_keyword); do
python kws/bin/compute_det.py \ python wekws/bin/compute_det.py \
--keyword $keyword \ --keyword $keyword \
--test_data data/test/data.list \ --test_data data/test/data.list \
--score_file $result_dir/score.txt \ --score_file $result_dir/score.txt \
--stats_file $result_dir/stats.${keyword}.txt --stats_file $result_dir/stats.${keyword}.txt
done done
python kws/bin/plot_det_curve.py \ python wekws/bin/plot_det_curve.py \
--keywords_dict dict/words.txt \ --keywords_dict dict/words.txt \
--stats_dir $result_dir \ --stats_dir $result_dir \
--figure_file $result_dir/det.png \ --figure_file $result_dir/det.png \
@ -118,7 +118,7 @@ fi
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
python kws/bin/export_jit.py --config $dir/config.yaml \ python wekws/bin/export_jit.py --config $dir/config.yaml \
--checkpoint $score_checkpoint \ --checkpoint $score_checkpoint \
--output_file $dir/final.zip \ --output_file $dir/final.zip \
--output_quant_file $dir/final.quant.zip --output_quant_file $dir/final.quant.zip

1
examples/hey_snips/s0/wekws Symbolic link
View File

@ -0,0 +1 @@
../../../wekws

View File

@ -1 +0,0 @@
../../../kws

View File

@ -73,7 +73,7 @@ if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
$norm_var && cmvn_opts="$cmvn_opts --norm_var" $norm_var && cmvn_opts="$cmvn_opts --norm_var"
num_gpus=$(echo $gpus | awk -F ',' '{print NF}') num_gpus=$(echo $gpus | awk -F ',' '{print NF}')
torchrun --standalone --nnodes=1 --nproc_per_node=$num_gpus \ torchrun --standalone --nnodes=1 --nproc_per_node=$num_gpus \
kws/bin/train.py --gpus $gpus \ wekws/bin/train.py --gpus $gpus \
--config $config \ --config $config \
--train_data data/train/data.list \ --train_data data/train/data.list \
--cv_data data/dev/data.list \ --cv_data data/dev/data.list \
@ -88,14 +88,14 @@ fi
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
echo "Do model average, Compute FRR/FAR ..." echo "Do model average, Compute FRR/FAR ..."
python kws/bin/average_model.py \ python wekws/bin/average_model.py \
--dst_model $score_checkpoint \ --dst_model $score_checkpoint \
--src_path $dir \ --src_path $dir \
--num ${num_average} \ --num ${num_average} \
--val_best --val_best
result_dir=$dir/test_$(basename $score_checkpoint) result_dir=$dir/test_$(basename $score_checkpoint)
mkdir -p $result_dir mkdir -p $result_dir
python kws/bin/score.py \ python wekws/bin/score.py \
--config $dir/config.yaml \ --config $dir/config.yaml \
--test_data data/test/data.list \ --test_data data/test/data.list \
--batch_size 256 \ --batch_size 256 \
@ -104,7 +104,7 @@ if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
--num_workers 8 --num_workers 8
for keyword in 0 1; do for keyword in 0 1; do
python kws/bin/compute_det.py \ python wekws/bin/compute_det.py \
--keyword $keyword \ --keyword $keyword \
--test_data data/test/data.list \ --test_data data/test/data.list \
--window_shift $window_shift \ --window_shift $window_shift \
@ -120,7 +120,7 @@ if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
quantize_score_checkpoint=$(basename $score_checkpoint | sed -e 's:.pt$:.quant.zip:g') quantize_score_checkpoint=$(basename $score_checkpoint | sed -e 's:.pt$:.quant.zip:g')
cat data/train/data.list | python tools/shuffle_list.py --seed 777 | \ cat data/train/data.list | python tools/shuffle_list.py --seed 777 | \
head -n 10000 > $dir/calibration.list head -n 10000 > $dir/calibration.list
python kws/bin/static_quantize.py \ python wekws/bin/static_quantize.py \
--config $dir/config.yaml \ --config $dir/config.yaml \
--test_data $dir/calibration.list \ --test_data $dir/calibration.list \
--checkpoint $score_checkpoint \ --checkpoint $score_checkpoint \
@ -129,7 +129,7 @@ if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
result_dir=$dir/test_$(basename $quantize_score_checkpoint) result_dir=$dir/test_$(basename $quantize_score_checkpoint)
mkdir -p $result_dir mkdir -p $result_dir
python kws/bin/score.py \ python wekws/bin/score.py \
--config $dir/config.yaml \ --config $dir/config.yaml \
--test_data data/test/data.list \ --test_data data/test/data.list \
--batch_size 256 \ --batch_size 256 \
@ -138,7 +138,7 @@ if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
--score_file $result_dir/score.txt \ --score_file $result_dir/score.txt \
--num_workers 8 --num_workers 8
for keyword in 0 1; do for keyword in 0 1; do
python kws/bin/compute_det.py \ python wekws/bin/compute_det.py \
--keyword $keyword \ --keyword $keyword \
--test_data data/test/data.list \ --test_data data/test/data.list \
--score_file $result_dir/score.txt \ --score_file $result_dir/score.txt \
@ -150,12 +150,12 @@ fi
if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then if [ ${stage} -le 5 ] && [ ${stop_stage} -ge 5 ]; then
jit_model=$(basename $score_checkpoint | sed -e 's:.pt$:.zip:g') jit_model=$(basename $score_checkpoint | sed -e 's:.pt$:.zip:g')
onnx_model=$(basename $score_checkpoint | sed -e 's:.pt$:.onnx:g') onnx_model=$(basename $score_checkpoint | sed -e 's:.pt$:.onnx:g')
python kws/bin/export_jit.py \ python wekws/bin/export_jit.py \
--config $dir/config.yaml \ --config $dir/config.yaml \
--checkpoint $score_checkpoint \ --checkpoint $score_checkpoint \
--jit_model $dir/$jit_model --jit_model $dir/$jit_model
python kws/bin/export_onnx.py \ python wekws/bin/export_onnx.py \
--config $dir/config.yaml \ --config $dir/config.yaml \
--checkpoint $score_checkpoint \ --checkpoint $score_checkpoint \
--onnx_model $dir/$onnx_model --onnx_model $dir/$onnx_model
fi fi

View File

@ -0,0 +1 @@
../../../wekws

View File

@ -1 +0,0 @@
../../../kws

View File

@ -68,7 +68,7 @@ if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
$norm_var && cmvn_opts="$cmvn_opts --norm_var" $norm_var && cmvn_opts="$cmvn_opts --norm_var"
num_gpus=$(echo $gpus | awk -F ',' '{print NF}') num_gpus=$(echo $gpus | awk -F ',' '{print NF}')
torchrun --standalone --nnodes=1 --nproc_per_node=$num_gpus \ torchrun --standalone --nnodes=1 --nproc_per_node=$num_gpus \
kws/bin/train.py --gpus $gpus \ wekws/bin/train.py --gpus $gpus \
--config $config \ --config $config \
--train_data data/train/data.list \ --train_data data/train/data.list \
--cv_data data/valid/data.list \ --cv_data data/valid/data.list \
@ -82,7 +82,7 @@ fi
if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
# Do model average # Do model average
python kws/bin/average_model.py \ python wekws/bin/average_model.py \
--dst_model $score_checkpoint \ --dst_model $score_checkpoint \
--src_path $dir \ --src_path $dir \
--num ${num_average} \ --num ${num_average} \
@ -91,7 +91,7 @@ if [ ${stage} -le 3 ] && [ ${stop_stage} -ge 3 ]; then
# Testing # Testing
result_dir=$dir/test_$(basename $score_checkpoint) result_dir=$dir/test_$(basename $score_checkpoint)
mkdir -p $result_dir mkdir -p $result_dir
python kws/bin/compute_accuracy.py --gpu 3 \ python wekws/bin/compute_accuracy.py --gpu 3 \
--config $dir/config.yaml \ --config $dir/config.yaml \
--test_data data/test/data.list \ --test_data data/test/data.list \
--batch_size 256 \ --batch_size 256 \
@ -101,7 +101,7 @@ fi
if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then if [ ${stage} -le 4 ] && [ ${stop_stage} -ge 4 ]; then
python kws/bin/export_jit.py --config $dir/config.yaml \ python wekws/bin/export_jit.py --config $dir/config.yaml \
--checkpoint $score_checkpoint \ --checkpoint $score_checkpoint \
--output_file $dir/final.zip \ --output_file $dir/final.zip \
--output_quant_file $dir/final.quant.zip --output_quant_file $dir/final.quant.zip

View File

@ -0,0 +1 @@
../../../wekws

View File

@ -23,10 +23,10 @@ import torch
import yaml import yaml
from torch.utils.data import DataLoader from torch.utils.data import DataLoader
from kws.dataset.dataset import Dataset from wekws.dataset.dataset import Dataset
from kws.model.kws_model import init_model from wekws.model.kws_model import init_model
from kws.utils.checkpoint import load_checkpoint from wekws.utils.checkpoint import load_checkpoint
from kws.utils.executor import Executor from wekws.utils.executor import Executor
def get_args(): def get_args():

View File

@ -20,8 +20,8 @@ import os
import torch import torch
import yaml import yaml
from kws.model.kws_model import init_model from wekws.model.kws_model import init_model
from kws.utils.checkpoint import load_checkpoint from wekws.utils.checkpoint import load_checkpoint
def get_args(): def get_args():

View File

@ -18,8 +18,8 @@ import torch
import yaml import yaml
import onnxruntime as ort import onnxruntime as ort
from kws.model.kws_model import init_model from wekws.model.kws_model import init_model
from kws.utils.checkpoint import load_checkpoint from wekws.utils.checkpoint import load_checkpoint
def get_args(): def get_args():

View File

@ -25,9 +25,9 @@ import torch
import yaml import yaml
from torch.utils.data import DataLoader from torch.utils.data import DataLoader
from kws.dataset.dataset import Dataset from wekws.dataset.dataset import Dataset
from kws.model.kws_model import init_model from wekws.model.kws_model import init_model
from kws.utils.checkpoint import load_checkpoint from wekws.utils.checkpoint import load_checkpoint
def get_args(): def get_args():

View File

@ -24,9 +24,9 @@ import torch
import yaml import yaml
from torch.utils.data import DataLoader from torch.utils.data import DataLoader
from kws.dataset.dataset import Dataset from wekws.dataset.dataset import Dataset
from kws.model.kws_model import init_model from wekws.model.kws_model import init_model
from kws.utils.checkpoint import load_checkpoint from wekws.utils.checkpoint import load_checkpoint
def get_args(): def get_args():

View File

@ -26,11 +26,11 @@ import yaml
from tensorboardX import SummaryWriter from tensorboardX import SummaryWriter
from torch.utils.data import DataLoader from torch.utils.data import DataLoader
from kws.dataset.dataset import Dataset from wekws.dataset.dataset import Dataset
from kws.utils.checkpoint import load_checkpoint, save_checkpoint from wekws.utils.checkpoint import load_checkpoint, save_checkpoint
from kws.model.kws_model import init_model from wekws.model.kws_model import init_model
from kws.utils.executor import Executor from wekws.utils.executor import Executor
from kws.utils.train_utils import count_parameters, set_mannul_seed from wekws.utils.train_utils import count_parameters, set_mannul_seed
def get_args(): def get_args():

View File

@ -18,8 +18,8 @@ import torch
import torch.distributed as dist import torch.distributed as dist
from torch.utils.data import IterableDataset from torch.utils.data import IterableDataset
import kws.dataset.processor as processor import wekws.dataset.processor as processor
from kws.utils.file_utils import read_lists from wekws.utils.file_utils import read_lists
class Processor(IterableDataset): class Processor(IterableDataset):

View File

@ -18,12 +18,14 @@ from typing import Optional
import torch import torch
import torch.nn as nn import torch.nn as nn
from kws.model.cmvn import GlobalCMVN from wekws.model.cmvn import GlobalCMVN
from kws.model.classifier import GlobalClassifier, LastClassifier, LinearClassifier from wekws.model.classifier import (GlobalClassifier, LastClassifier,
from kws.model.subsampling import LinearSubsampling1, Conv1dSubsampling1, NoSubsampling LinearClassifier)
from kws.model.tcn import TCN, CnnBlock, DsCnnBlock from wekws.model.subsampling import (LinearSubsampling1, Conv1dSubsampling1,
from kws.model.mdtc import MDTC NoSubsampling)
from kws.utils.cmvn import load_cmvn from wekws.model.tcn import TCN, CnnBlock, DsCnnBlock
from wekws.model.mdtc import MDTC
from wekws.utils.cmvn import load_cmvn
class KWSModel(nn.Module): class KWSModel(nn.Module):

View File

@ -15,7 +15,7 @@
import torch import torch
import torch.nn.functional as F import torch.nn.functional as F
from kws.utils.mask import padding_mask from wekws.utils.mask import padding_mask
def max_pooling_loss(logits: torch.Tensor, def max_pooling_loss(logits: torch.Tensor,

View File

@ -17,7 +17,7 @@ import logging
import torch import torch
from torch.nn.utils import clip_grad_norm_ from torch.nn.utils import clip_grad_norm_
from kws.model.loss import criterion from wekws.model.loss import criterion
class Executor: class Executor: