Merge pull request #723 from PaddlePaddle/autolog

fix autolog install; only autolog in test, or will hangup
pull/728/head
Hui Zhang 3 years ago committed by GitHub
commit 8ad915a907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
.gitignore vendored

@ -16,3 +16,5 @@ tools/kenlm
tools/sox-14.4.2 tools/sox-14.4.2
tools/soxbindings tools/soxbindings
tools/Montreal-Forced-Aligner/ tools/Montreal-Forced-Aligner/
*output/

@ -34,9 +34,8 @@ from deepspeech.training.trainer import Trainer
from deepspeech.utils import error_rate from deepspeech.utils import error_rate
from deepspeech.utils import layer_tools from deepspeech.utils import layer_tools
from deepspeech.utils import mp_tools from deepspeech.utils import mp_tools
from deepspeech.utils.log import Log
from deepspeech.utils.log import Autolog from deepspeech.utils.log import Autolog
from deepspeech.utils.log import Log
logger = Log(__name__).getlog() logger = Log(__name__).getlog()
@ -226,7 +225,6 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
def __init__(self, config, args): def __init__(self, config, args):
super().__init__(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): def ordid2token(self, texts, texts_len):
""" ord() id to chr() chr """ """ ord() id to chr() chr """
@ -294,6 +292,10 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
@paddle.no_grad() @paddle.no_grad()
def test(self): def test(self):
logger.info(f"Test Total Examples: {len(self.test_loader.dataset)}") logger.info(f"Test Total Examples: {len(self.test_loader.dataset)}")
self.autolog = Autolog(
batch_size=self.config.decoding.batch_size,
model_name="deepspeech2",
model_precision="fp32").getlog()
self.model.eval() self.model.eval()
cfg = self.config cfg = self.config
error_rate_type = None error_rate_type = None

@ -18,11 +18,8 @@ import socket
import sys import sys
import auto_log import auto_log
import os
from paddle import inference from paddle import inference
FORMAT_STR = '[%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s' FORMAT_STR = '[%(levelname)s %(asctime)s %(filename)s:%(lineno)d] %(message)s'
DATE_FMT_STR = '%Y/%m/%d %H:%M:%S' DATE_FMT_STR = '%Y/%m/%d %H:%M:%S'
@ -153,9 +150,12 @@ class Log():
def getlog(self): def getlog(self):
return self.logger return self.logger
class Autolog:
def __init__(self, batch_size, model_name = "DeepSpeech", model_precision = "fp32"): class Autolog:
def __init__(self,
batch_size,
model_name="DeepSpeech",
model_precision="fp32"):
pid = os.getpid() pid = os.getpid()
gpu_id = int(os.environ['CUDA_VISIBLE_DEVICES'].split(',')[0]) gpu_id = int(os.environ['CUDA_VISIBLE_DEVICES'].split(',')[0])
infer_config = inference.Config() infer_config = inference.Config()
@ -170,9 +170,7 @@ class Autolog:
pids=pid, pids=pid,
process_name=None, process_name=None,
gpu_ids=gpu_id, gpu_ids=gpu_id,
time_keys=[ time_keys=['preprocess_time', 'inference_time', 'postprocess_time'],
'preprocess_time', 'inference_time', 'postprocess_time'
],
warmup=0) warmup=0)
self.autolog = autolog self.autolog = autolog

@ -99,9 +99,7 @@ def main():
if args.src_dir.startswith('~'): if args.src_dir.startswith('~'):
args.src_dir = os.path.expanduser(args.src_dir) args.src_dir = os.path.expanduser(args.src_dir)
prepare_dataset( prepare_dataset(src_dir=args.src_dir, manifest_path=args.manifest_prefix)
src_dir=args.src_dir,
manifest_path=args.manifest_prefix)
print("manifest prepare done!") print("manifest prepare done!")

@ -44,18 +44,17 @@ if [ $? != 0 ]; then
fi fi
#install auto-log #install auto-log
python3 -c "import auto_log" python -c "import auto_log"
if [ $? != 0 ]; then if [ $? != 0 ]; then
info_msg "Install auto_log into default system path" info_msg "Install auto_log into default system path"
git clone https://github.com/LDOUBLEV/AutoLog test -d AutoLog || git clone https://github.com/LDOUBLEV/AutoLog
if [ $? != 0 ]; then if [ $? != 0 ]; then
error_msg "Download auto_log failed !!!" error_msg "Download auto_log failed !!!"
exit 1 exit 1
fi fi
cd AutoLog cd AutoLog
pip3 install -r requirements.txt pip install -r requirements.txt
python3 setup.py bdist_wheel python setup.py install
pip3 install ./dist/[Aa]uto*.whl
cd .. cd ..
rm -rf AutoLog rm -rf AutoLog
fi fi

Loading…
Cancel
Save