Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
a11fbc0f
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a11fbc0f
编写于
1月 05, 2022
作者:
A
andyjpaddle
提交者:
GitHub
1月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5166 from tink2123/fix_save_load
fix save load, update det pretrain
上级
f78168a0
3647c318
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
15 addition
and
12 deletion
+15
-12
doc/doc_ch/detection.md
doc/doc_ch/detection.md
+3
-3
doc/doc_en/detection_en.md
doc/doc_en/detection_en.md
+3
-3
ppocr/utils/save_load.py
ppocr/utils/save_load.py
+9
-6
未找到文件。
doc/doc_ch/detection.md
浏览文件 @
a11fbc0f
...
...
@@ -78,11 +78,11 @@ json.dumps编码前的图像标注信息是包含多个字典的list,字典中
cd
PaddleOCR/
# 根据backbone的不同选择下载对应的预训练模型
# 下载MobileNetV3的预训练模型
wget
-P
./pretrain_models/ https://paddle
-imagenet-models-name.bj.bcebos.com/dygraph
/MobileNetV3_large_x0_5_pretrained.pdparams
wget
-P
./pretrain_models/ https://paddle
ocr.bj.bcebos.com/pretrained
/MobileNetV3_large_x0_5_pretrained.pdparams
# 或,下载ResNet18_vd的预训练模型
wget
-P
./pretrain_models/ https://paddle
-imagenet-models-name.bj.bcebos.com/dygraph
/ResNet18_vd_pretrained.pdparams
wget
-P
./pretrain_models/ https://paddle
ocr.bj.bcebos.com/pretrained
/ResNet18_vd_pretrained.pdparams
# 或,下载ResNet50_vd的预训练模型
wget
-P
./pretrain_models/ https://paddle
-imagenet-models-name.bj.bcebos.com/dygraph
/ResNet50_vd_ssld_pretrained.pdparams
wget
-P
./pretrain_models/ https://paddle
ocr.bj.bcebos.com/pretrained
/ResNet50_vd_ssld_pretrained.pdparams
```
<a
name=
"2-----"
></a>
...
...
doc/doc_en/detection_en.md
浏览文件 @
a11fbc0f
...
...
@@ -67,11 +67,11 @@ And the responding download link of backbone pretrain weights can be found in (h
```
shell
cd
PaddleOCR/
# Download the pre-trained model of MobileNetV3
wget
-P
./pretrain_models/ https://paddle
-imagenet-models-name.bj.bcebos.com/dygraph
/MobileNetV3_large_x0_5_pretrained.pdparams
wget
-P
./pretrain_models/ https://paddle
ocr.bj.bcebos.com/pretrained
/MobileNetV3_large_x0_5_pretrained.pdparams
# or, download the pre-trained model of ResNet18_vd
wget
-P
./pretrain_models/ https://paddle
-imagenet-models-name.bj.bcebos.com/dygraph
/ResNet18_vd_pretrained.pdparams
wget
-P
./pretrain_models/ https://paddle
ocr.bj.bcebos.com/pretrained
/ResNet18_vd_pretrained.pdparams
# or, download the pre-trained model of ResNet50_vd
wget
-P
./pretrain_models/ https://paddle
-imagenet-models-name.bj.bcebos.com/dygraph
/ResNet50_vd_ssld_pretrained.pdparams
wget
-P
./pretrain_models/ https://paddle
ocr.bj.bcebos.com/pretrained
/ResNet50_vd_ssld_pretrained.pdparams
```
...
...
ppocr/utils/save_load.py
浏览文件 @
a11fbc0f
...
...
@@ -111,13 +111,16 @@ def load_pretrained_params(model, path):
params
=
paddle
.
load
(
path
+
'.pdparams'
)
state_dict
=
model
.
state_dict
()
new_state_dict
=
{}
for
k1
,
k2
in
zip
(
state_dict
.
keys
(),
params
.
keys
()
):
if
list
(
state_dict
[
k1
].
shape
)
==
list
(
params
[
k2
].
shape
):
new_state_dict
[
k1
]
=
params
[
k2
]
for
k1
in
params
.
keys
(
):
if
k1
not
in
state_dict
.
keys
(
):
logger
.
warning
(
"The pretrained params {} not in model"
.
format
(
k1
))
else
:
logger
.
warning
(
"The shape of model params {} {} not matched with loaded params {} {} !"
.
format
(
k1
,
state_dict
[
k1
].
shape
,
k2
,
params
[
k2
].
shape
))
if
list
(
state_dict
[
k1
].
shape
)
==
list
(
params
[
k1
].
shape
):
new_state_dict
[
k1
]
=
params
[
k1
]
else
:
logger
.
warning
(
"The shape of model params {} {} not matched with loaded params {} {} !"
.
format
(
k1
,
state_dict
[
k1
].
shape
,
k1
,
params
[
k1
].
shape
))
model
.
set_state_dict
(
new_state_dict
)
logger
.
info
(
"load pretrain successful from {}"
.
format
(
path
))
return
model
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录