Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
61e39dac
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 2 年 前同步成功
通知
210
Star
8425
Fork
1598
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
245
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DeepSpeech
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
245
Issue
245
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
61e39dac
编写于
12月 07, 2021
作者:
K
KP
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize model init.
上级
528c70e5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
4 deletion
+12
-4
paddlespeech/cli/asr/infer.py
paddlespeech/cli/asr/infer.py
+4
-0
paddlespeech/cli/cls/infer.py
paddlespeech/cli/cls/infer.py
+8
-4
未找到文件。
paddlespeech/cli/asr/infer.py
浏览文件 @
61e39dac
...
@@ -137,6 +137,10 @@ class ASRExecutor(BaseExecutor):
...
@@ -137,6 +137,10 @@ class ASRExecutor(BaseExecutor):
"""
"""
Init model and other resources from a specific path.
Init model and other resources from a specific path.
"""
"""
if
hasattr
(
self
,
'model'
):
logger
.
info
(
'Model had been initialized.'
)
return
if
cfg_path
is
None
or
ckpt_path
is
None
:
if
cfg_path
is
None
or
ckpt_path
is
None
:
sample_rate_str
=
'16k'
if
sample_rate
==
16000
else
'8k'
sample_rate_str
=
'16k'
if
sample_rate
==
16000
else
'8k'
tag
=
model_type
+
'_'
+
lang
+
'_'
+
sample_rate_str
tag
=
model_type
+
'_'
+
lang
+
'_'
+
sample_rate_str
...
...
paddlespeech/cli/cls/infer.py
浏览文件 @
61e39dac
...
@@ -128,6 +128,10 @@ class CLSExecutor(BaseExecutor):
...
@@ -128,6 +128,10 @@ class CLSExecutor(BaseExecutor):
"""
"""
Init model and other resources from a specific path.
Init model and other resources from a specific path.
"""
"""
if
hasattr
(
self
,
'model'
):
logger
.
info
(
'Model had been initialized.'
)
return
if
label_file
is
None
or
ckpt_path
is
None
:
if
label_file
is
None
or
ckpt_path
is
None
:
self
.
res_path
=
self
.
_get_pretrained_path
(
model_type
)
# panns_cnn14
self
.
res_path
=
self
.
_get_pretrained_path
(
model_type
)
# panns_cnn14
self
.
cfg_path
=
os
.
path
.
join
(
self
.
cfg_path
=
os
.
path
.
join
(
...
@@ -154,9 +158,9 @@ class CLSExecutor(BaseExecutor):
...
@@ -154,9 +158,9 @@ class CLSExecutor(BaseExecutor):
# model
# model
model_class
=
dynamic_import
(
model_type
,
model_alias
)
model_class
=
dynamic_import
(
model_type
,
model_alias
)
model_dict
=
paddle
.
load
(
self
.
ckpt_path
)
model_dict
=
paddle
.
load
(
self
.
ckpt_path
)
self
.
_
model
=
model_class
(
extract_embedding
=
False
)
self
.
model
=
model_class
(
extract_embedding
=
False
)
self
.
_
model
.
set_state_dict
(
model_dict
)
self
.
model
.
set_state_dict
(
model_dict
)
self
.
_
model
.
eval
()
self
.
model
.
eval
()
def
preprocess
(
self
,
audio_file
:
Union
[
str
,
os
.
PathLike
]):
def
preprocess
(
self
,
audio_file
:
Union
[
str
,
os
.
PathLike
]):
"""
"""
...
@@ -192,7 +196,7 @@ class CLSExecutor(BaseExecutor):
...
@@ -192,7 +196,7 @@ class CLSExecutor(BaseExecutor):
"""
"""
Model inference and result stored in self.output.
Model inference and result stored in self.output.
"""
"""
self
.
_outputs
[
'logits'
]
=
self
.
_
model
(
self
.
_inputs
[
'feats'
])
self
.
_outputs
[
'logits'
]
=
self
.
model
(
self
.
_inputs
[
'feats'
])
def
_generate_topk_label
(
self
,
result
:
np
.
ndarray
,
topk
:
int
)
->
str
:
def
_generate_topk_label
(
self
,
result
:
np
.
ndarray
,
topk
:
int
)
->
str
:
assert
topk
<=
len
(
assert
topk
<=
len
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录