Merge pull request #720 from Jackwaterveg/develop

增加autoLog
pull/723/head
Hui Zhang 3 years ago committed by GitHub
commit 601938e9b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -35,6 +35,9 @@ from deepspeech.utils import error_rate
from deepspeech.utils import layer_tools
from deepspeech.utils import mp_tools
from deepspeech.utils.log import Log
from deepspeech.utils.log import Autolog
logger = Log(__name__).getlog()
@ -223,7 +226,8 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
def __init__(self, config, args):
super().__init__(config, args)
self.autolog = Autolog(batch_size = config.decoding.batch_size, model_name = "deepspeech2", model_precision = "fp32").getlog()
def ordid2token(self, texts, texts_len):
""" ord() id to chr() chr """
trans = []
@ -248,6 +252,8 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
vocab_list = self.test_loader.collate_fn.vocab_list
target_transcripts = self.ordid2token(texts, texts_len)
self.autolog.times.start()
self.autolog.times.stamp()
result_transcripts = self.model.decode(
audio,
audio_len,
@ -260,6 +266,9 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
cutoff_prob=cfg.cutoff_prob,
cutoff_top_n=cfg.cutoff_top_n,
num_processes=cfg.num_proc_bsearch)
self.autolog.times.stamp()
self.autolog.times.stamp()
self.autolog.times.end()
for utt, target, result in zip(utts, target_transcripts,
result_transcripts):
@ -308,6 +317,7 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
msg += "Final error rate [%s] (%d/%d) = %f" % (
error_rate_type, num_ins, num_ins, errors_sum / len_refs)
logger.info(msg)
self.autolog.report()
def run_test(self):
self.resume_or_scratch()

@ -17,6 +17,12 @@ import os
import socket
import sys
import auto_log
import os
from paddle import inference
FORMAT_STR = '[%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s'
DATE_FMT_STR = '%Y/%m/%d %H:%M:%S'
@ -146,3 +152,29 @@ class Log():
def getlog(self):
return self.logger
class Autolog:
def __init__(self, batch_size, model_name = "DeepSpeech", model_precision = "fp32"):
pid = os.getpid()
gpu_id = int(os.environ['CUDA_VISIBLE_DEVICES'].split(',')[0])
infer_config = inference.Config()
infer_config.enable_use_gpu(100, gpu_id)
autolog = auto_log.AutoLogger(
model_name = model_name,
model_precision = model_precision,
batch_size = batch_size,
data_shape="dynamic",
save_path="./output/auto_log.lpg",
inference_config = infer_config,
pids = pid,
process_name = None,
gpu_ids = gpu_id,
time_keys=[
'preprocess_time', 'inference_time', 'postprocess_time'
],
warmup=0)
self.autolog = autolog
def getlog(self):
return self.autolog

@ -43,6 +43,23 @@ if [ $? != 0 ]; then
rm libsndfile-1.0.28.tar.gz
fi
#install auto-log
python3 -c "import auto_log"
if [ $? != 0 ]; then
info_msg "Install auto_log into default system path"
git clone https://github.com/LDOUBLEV/AutoLog
if [ $? != 0 ]; then
error_msg "Download auto_log failed !!!"
exit 1
fi
cd AutoLog
pip3 install -r requirements.txt
python3 setup.py bdist_wheel
pip3 install ./dist/[Aa]uto*.whl
cd ..
rm -rf AutoLog
fi
# install decoders
python3 -c "import pkg_resources; pkg_resources.require(\"swig_decoders==1.1\")"
if [ $? != 0 ]; then
@ -66,4 +83,5 @@ if [ $? != 0 ]; then
fi
popd
info_msg "Install all dependencies successfully."

Loading…
Cancel
Save