Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
DeepSpeech
提交
d55e6b5a
D
DeepSpeech
项目概览
PaddlePaddle
/
DeepSpeech
大约 1 年 前同步成功
通知
207
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d55e6b5a
编写于
6月 23, 2021
作者:
H
Haoxin Ma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revise from_pretrained function
上级
3652b87f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
29 addition
and
13 deletion
+29
-13
deepspeech/exps/deepspeech2/bin/deploy/runtime.py
deepspeech/exps/deepspeech2/bin/deploy/runtime.py
+9
-1
deepspeech/exps/deepspeech2/bin/deploy/server.py
deepspeech/exps/deepspeech2/bin/deploy/server.py
+9
-1
deepspeech/exps/deepspeech2/bin/tune.py
deepspeech/exps/deepspeech2/bin/tune.py
+1
-1
deepspeech/exps/deepspeech2/model.py
deepspeech/exps/deepspeech2/model.py
+1
-1
deepspeech/exps/u2/model.py
deepspeech/exps/u2/model.py
+1
-1
deepspeech/models/deepspeech2.py
deepspeech/models/deepspeech2.py
+4
-4
deepspeech/models/u2.py
deepspeech/models/u2.py
+4
-4
未找到文件。
deepspeech/exps/deepspeech2/bin/deploy/runtime.py
浏览文件 @
d55e6b5a
...
...
@@ -29,6 +29,9 @@ from deepspeech.utils.socket_server import warm_up_test
from
deepspeech.utils.utility
import
add_arguments
from
deepspeech.utils.utility
import
print_arguments
from
paddle.io
import
DataLoader
from
deepspeech.io.collator
import
SpeechCollator
def
init_predictor
(
args
):
if
args
.
model_dir
is
not
None
:
...
...
@@ -83,7 +86,12 @@ def start_server(config, args):
config
.
data
.
keep_transcription_text
=
True
dataset
=
ManifestDataset
.
from_config
(
config
)
model
=
DeepSpeech2Model
.
from_pretrained
(
dataset
,
config
,
config
.
collator
.
batch_size
=
1
config
.
collator
.
num_workers
=
0
collate_fn
=
SpeechCollator
.
from_config
(
config
)
test_loader
=
DataLoader
(
dataset_dataset
,
collate_fn
=
collate_fn
,
num_workers
=
0
)
model
=
DeepSpeech2Model
.
from_pretrained
(
test_loader
,
config
,
args
.
checkpoint_path
)
model
.
eval
()
...
...
deepspeech/exps/deepspeech2/bin/deploy/server.py
浏览文件 @
d55e6b5a
...
...
@@ -28,6 +28,9 @@ from deepspeech.utils.utility import add_arguments
from
deepspeech.utils.utility
import
print_arguments
from
paddle.io
import
DataLoader
from
deepspeech.io.collator
import
SpeechCollator
def
start_server
(
config
,
args
):
"""Start the ASR server"""
config
.
defrost
()
...
...
@@ -36,7 +39,12 @@ def start_server(config, args):
config
.
data
.
keep_transcription_text
=
True
dataset
=
ManifestDataset
.
from_config
(
config
)
model
=
DeepSpeech2Model
.
from_pretrained
(
dataset
,
config
,
config
.
collator
.
batch_size
=
1
config
.
collator
.
num_workers
=
0
collate_fn
=
SpeechCollator
.
from_config
(
config
)
test_loader
=
DataLoader
(
dataset_dataset
,
collate_fn
=
collate_fn
,
num_workers
=
0
)
model
=
DeepSpeech2Model
.
from_pretrained
(
test_loader
,
config
,
args
.
checkpoint_path
)
model
.
eval
()
...
...
deepspeech/exps/deepspeech2/bin/tune.py
浏览文件 @
d55e6b5a
...
...
@@ -47,7 +47,7 @@ def tune(config, args):
drop_last
=
False
,
collate_fn
=
SpeechCollator
(
keep_transcription_text
=
True
))
model
=
DeepSpeech2Model
.
from_pretrained
(
dev_dataset
,
config
,
model
=
DeepSpeech2Model
.
from_pretrained
(
valid_loader
,
config
,
args
.
checkpoint_path
)
model
.
eval
()
...
...
deepspeech/exps/deepspeech2/model.py
浏览文件 @
d55e6b5a
...
...
@@ -318,7 +318,7 @@ class DeepSpeech2Tester(DeepSpeech2Trainer):
def
export
(
self
):
infer_model
=
DeepSpeech2InferModel
.
from_pretrained
(
self
.
test_loader
.
dataset
,
self
.
config
,
self
.
args
.
checkpoint_path
)
self
.
test_loader
,
self
.
config
,
self
.
args
.
checkpoint_path
)
infer_model
.
eval
()
feat_dim
=
self
.
test_loader
.
collate_fn
.
feature_size
static_model
=
paddle
.
jit
.
to_static
(
...
...
deepspeech/exps/u2/model.py
浏览文件 @
d55e6b5a
...
...
@@ -506,7 +506,7 @@ class U2Tester(U2Trainer):
List[paddle.static.InputSpec]: input spec.
"""
from
deepspeech.models.u2
import
U2InferModel
infer_model
=
U2InferModel
.
from_pretrained
(
self
.
test_loader
.
dataset
,
infer_model
=
U2InferModel
.
from_pretrained
(
self
.
test_loader
,
self
.
config
.
model
.
clone
(),
self
.
args
.
checkpoint_path
)
feat_dim
=
self
.
test_loader
.
collate_fn
.
feature_size
...
...
deepspeech/models/deepspeech2.py
浏览文件 @
d55e6b5a
...
...
@@ -198,11 +198,11 @@ class DeepSpeech2Model(nn.Layer):
cutoff_top_n
,
num_processes
)
@
classmethod
def
from_pretrained
(
cls
,
data
set
,
config
,
checkpoint_path
):
def
from_pretrained
(
cls
,
data
loader
,
config
,
checkpoint_path
):
"""Build a DeepSpeech2Model model from a pretrained model.
Parameters
----------
data
set: paddle.io.Dataset
data
loader: paddle.io.DataLoader
config: yacs.config.CfgNode
model configs
...
...
@@ -215,8 +215,8 @@ class DeepSpeech2Model(nn.Layer):
DeepSpeech2Model
The model built from pretrained result.
"""
model
=
cls
(
feat_size
=
data
set
.
feature_size
,
dict_size
=
data
set
.
vocab_size
,
model
=
cls
(
feat_size
=
data
loader
.
collate_fn
.
feature_size
,
dict_size
=
data
loader
.
collate_fn
.
vocab_size
,
num_conv_layers
=
config
.
model
.
num_conv_layers
,
num_rnn_layers
=
config
.
model
.
num_rnn_layers
,
rnn_size
=
config
.
model
.
rnn_layer_size
,
...
...
deepspeech/models/u2.py
浏览文件 @
d55e6b5a
...
...
@@ -876,11 +876,11 @@ class U2Model(U2BaseModel):
return
model
@
classmethod
def
from_pretrained
(
cls
,
data
set
,
config
,
checkpoint_path
):
def
from_pretrained
(
cls
,
data
loader
,
config
,
checkpoint_path
):
"""Build a DeepSpeech2Model model from a pretrained model.
Args:
data
set (paddle.io.Dataset
): not used.
data
loader (paddle.io.DataLoader
): not used.
config (yacs.config.CfgNode): model configs
checkpoint_path (Path or str): the path of pretrained model checkpoint, without extension name
...
...
@@ -888,8 +888,8 @@ class U2Model(U2BaseModel):
DeepSpeech2Model: The model built from pretrained result.
"""
config
.
defrost
()
config
.
input_dim
=
data
set
.
feature_size
config
.
output_dim
=
data
set
.
vocab_size
config
.
input_dim
=
data
loader
.
collate_fn
.
feature_size
config
.
output_dim
=
data
loader
.
collate_fn
.
vocab_size
config
.
freeze
()
model
=
cls
.
from_config
(
config
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录