Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
edd18b67
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
edd18b67
编写于
8月 15, 2022
作者:
u010070587
提交者:
GitHub
8月 15, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7206 from andyjpaddle/fix_vl
Fix visionlan predict format
上级
2c1afec3
c9504a94
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
16 addition
and
16 deletion
+16
-16
doc/doc_ch/algorithm_rec_visionlan.md
doc/doc_ch/algorithm_rec_visionlan.md
+2
-2
doc/doc_en/algorithm_rec_visionlan_en.md
doc/doc_en/algorithm_rec_visionlan_en.md
+2
-2
ppocr/losses/__init__.py
ppocr/losses/__init__.py
+1
-1
ppocr/postprocess/rec_postprocess.py
ppocr/postprocess/rec_postprocess.py
+1
-1
tools/program.py
tools/program.py
+10
-10
未找到文件。
doc/doc_ch/algorithm_rec_visionlan.md
浏览文件 @
edd18b67
...
@@ -101,7 +101,7 @@ python3 tools/export_model.py -c configs/rec/rec_r45_visionlan.yml -o Global.pre
...
@@ -101,7 +101,7 @@ python3 tools/export_model.py -c configs/rec/rec_r45_visionlan.yml -o Global.pre
执行如下命令进行模型推理:
执行如下命令进行模型推理:
```
shell
```
shell
python3 tools/infer/predict_rec.py
--image_dir
=
'./doc/imgs_words/en/word_2.png'
--rec_model_dir
=
'./inference/rec_r45_visionlan/'
--rec_algorithm
=
'VisionLAN'
--rec_image_shape
=
'3,64,256'
--rec_char_dict_path
=
'./ppocr/utils/
dict36.txt'
python3 tools/infer/predict_rec.py
--image_dir
=
'./doc/imgs_words/en/word_2.png'
--rec_model_dir
=
'./inference/rec_r45_visionlan/'
--rec_algorithm
=
'VisionLAN'
--rec_image_shape
=
'3,64,256'
--rec_char_dict_path
=
'./ppocr/utils/
ic15_dict.txt'
--use_space_char
=
False
# 预测文件夹下所有图像时,可修改image_dir为文件夹,如 --image_dir='./doc/imgs_words_en/'。
# 预测文件夹下所有图像时,可修改image_dir为文件夹,如 --image_dir='./doc/imgs_words_en/'。
```
```
...
@@ -110,7 +110,7 @@ python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words/en/word_2.png'
...
@@ -110,7 +110,7 @@ python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words/en/word_2.png'
执行命令后,上面图像的预测结果(识别的文本和得分)会打印到屏幕上,示例如下:
执行命令后,上面图像的预测结果(识别的文本和得分)会打印到屏幕上,示例如下:
结果如下:
结果如下:
```
shell
```
shell
Predicts of ./doc/imgs_words/en/word_2.png:
(
'yourself'
, 0.9
7076982
)
Predicts of ./doc/imgs_words/en/word_2.png:
(
'yourself'
, 0.9
999493
)
```
```
**注意**
:
**注意**
:
...
...
doc/doc_en/algorithm_rec_visionlan_en.md
浏览文件 @
edd18b67
...
@@ -90,7 +90,7 @@ After the conversion is successful, there are three files in the directory:
...
@@ -90,7 +90,7 @@ After the conversion is successful, there are three files in the directory:
For VisionLAN text recognition model inference, the following commands can be executed:
For VisionLAN text recognition model inference, the following commands can be executed:
```
```
python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words/en/word_2.png' --rec_model_dir='./inference/rec_r45_visionlan/' --rec_algorithm='VisionLAN' --rec_image_shape='3,64,256' --rec_char_dict_path='./ppocr/utils/
dict36.txt'
python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words/en/word_2.png' --rec_model_dir='./inference/rec_r45_visionlan/' --rec_algorithm='VisionLAN' --rec_image_shape='3,64,256' --rec_char_dict_path='./ppocr/utils/
ic15_dict.txt' --use_space_char=False
```
```
![](
../imgs_words/en/word_2.png
)
![](
../imgs_words/en/word_2.png
)
...
@@ -98,7 +98,7 @@ python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words/en/word_2.png'
...
@@ -98,7 +98,7 @@ python3 tools/infer/predict_rec.py --image_dir='./doc/imgs_words/en/word_2.png'
After executing the command, the prediction result (recognized text and score) of the image above is printed to the screen, an example is as follows:
After executing the command, the prediction result (recognized text and score) of the image above is printed to the screen, an example is as follows:
The result is as follows:
The result is as follows:
```
shell
```
shell
Predicts of ./doc/imgs_words/en/word_2.png:
(
'yourself'
, 0.9
7076982
)
Predicts of ./doc/imgs_words/en/word_2.png:
(
'yourself'
, 0.9
999493
)
```
```
<a
name=
"4-2"
></a>
<a
name=
"4-2"
></a>
...
...
ppocr/losses/__init__.py
浏览文件 @
edd18b67
...
@@ -67,7 +67,7 @@ def build_loss(config):
...
@@ -67,7 +67,7 @@ def build_loss(config):
'ClsLoss'
,
'AttentionLoss'
,
'SRNLoss'
,
'PGLoss'
,
'CombinedLoss'
,
'ClsLoss'
,
'AttentionLoss'
,
'SRNLoss'
,
'PGLoss'
,
'CombinedLoss'
,
'CELoss'
,
'TableAttentionLoss'
,
'SARLoss'
,
'AsterLoss'
,
'SDMGRLoss'
,
'CELoss'
,
'TableAttentionLoss'
,
'SARLoss'
,
'AsterLoss'
,
'SDMGRLoss'
,
'VQASerTokenLayoutLMLoss'
,
'LossFromOutput'
,
'PRENLoss'
,
'MultiLoss'
,
'VQASerTokenLayoutLMLoss'
,
'LossFromOutput'
,
'PRENLoss'
,
'MultiLoss'
,
'TableMasterLoss'
,
'SPINAttentionLoss'
,
'VLLoss'
,
'StrokeFocusLoss'
'TableMasterLoss'
,
'SPINAttentionLoss'
,
'VLLoss'
,
'StrokeFocusLoss'
]
]
config
=
copy
.
deepcopy
(
config
)
config
=
copy
.
deepcopy
(
config
)
module_name
=
config
.
pop
(
'name'
)
module_name
=
config
.
pop
(
'name'
)
...
...
ppocr/postprocess/rec_postprocess.py
浏览文件 @
edd18b67
...
@@ -780,7 +780,7 @@ class VLLabelDecode(BaseRecLabelDecode):
...
@@ -780,7 +780,7 @@ class VLLabelDecode(BaseRecLabelDecode):
)
+
length
[
i
])].
topk
(
1
)[
0
][:,
0
]
)
+
length
[
i
])].
topk
(
1
)[
0
][:,
0
]
preds_prob
=
paddle
.
exp
(
preds_prob
=
paddle
.
exp
(
paddle
.
log
(
preds_prob
).
sum
()
/
(
preds_prob
.
shape
[
0
]
+
1e-6
))
paddle
.
log
(
preds_prob
).
sum
()
/
(
preds_prob
.
shape
[
0
]
+
1e-6
))
text
.
append
((
preds_text
,
preds_prob
))
text
.
append
((
preds_text
,
preds_prob
.
numpy
()[
0
]
))
if
label
is
None
:
if
label
is
None
:
return
text
return
text
label
=
self
.
decode
(
label
)
label
=
self
.
decode
(
label
)
...
...
tools/program.py
浏览文件 @
edd18b67
...
@@ -490,7 +490,7 @@ def eval(model,
...
@@ -490,7 +490,7 @@ def eval(model,
break
break
images
=
batch
[
0
]
images
=
batch
[
0
]
start
=
time
.
time
()
start
=
time
.
time
()
# use amp
# use amp
if
scaler
:
if
scaler
:
with
paddle
.
amp
.
auto_cast
(
level
=
'O2'
):
with
paddle
.
amp
.
auto_cast
(
level
=
'O2'
):
...
@@ -508,10 +508,10 @@ def eval(model,
...
@@ -508,10 +508,10 @@ def eval(model,
1
,
2
,
0
).
astype
(
np
.
uint8
)
1
,
2
,
0
).
astype
(
np
.
uint8
)
fm_lr
=
(
lr_img
[
i
].
numpy
()
*
255
).
transpose
(
fm_lr
=
(
lr_img
[
i
].
numpy
()
*
255
).
transpose
(
1
,
2
,
0
).
astype
(
np
.
uint8
)
1
,
2
,
0
).
astype
(
np
.
uint8
)
cv2
.
imwrite
(
"output/images/{}_{}_sr.jpg"
.
format
(
sum_images
,
cv2
.
imwrite
(
"output/images/{}_{}_sr.jpg"
.
format
(
i
),
fm_sr
)
sum_images
,
i
),
fm_sr
)
cv2
.
imwrite
(
"output/images/{}_{}_lr.jpg"
.
format
(
sum_images
,
cv2
.
imwrite
(
"output/images/{}_{}_lr.jpg"
.
format
(
i
),
fm_lr
)
sum_images
,
i
),
fm_lr
)
else
:
else
:
preds
=
model
(
images
)
preds
=
model
(
images
)
else
:
else
:
...
@@ -529,10 +529,10 @@ def eval(model,
...
@@ -529,10 +529,10 @@ def eval(model,
1
,
2
,
0
).
astype
(
np
.
uint8
)
1
,
2
,
0
).
astype
(
np
.
uint8
)
fm_lr
=
(
lr_img
[
i
].
numpy
()
*
255
).
transpose
(
fm_lr
=
(
lr_img
[
i
].
numpy
()
*
255
).
transpose
(
1
,
2
,
0
).
astype
(
np
.
uint8
)
1
,
2
,
0
).
astype
(
np
.
uint8
)
cv2
.
imwrite
(
"output/images/{}_{}_sr.jpg"
.
format
(
sum_images
,
cv2
.
imwrite
(
"output/images/{}_{}_sr.jpg"
.
format
(
i
),
fm_sr
)
sum_images
,
i
),
fm_sr
)
cv2
.
imwrite
(
"output/images/{}_{}_lr.jpg"
.
format
(
sum_images
,
cv2
.
imwrite
(
"output/images/{}_{}_lr.jpg"
.
format
(
i
),
fm_lr
)
sum_images
,
i
),
fm_lr
)
else
:
else
:
preds
=
model
(
images
)
preds
=
model
(
images
)
...
@@ -652,7 +652,7 @@ def preprocess(is_train=False):
...
@@ -652,7 +652,7 @@ def preprocess(is_train=False):
'EAST'
,
'DB'
,
'SAST'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
,
'SRN'
,
'EAST'
,
'DB'
,
'SAST'
,
'Rosetta'
,
'CRNN'
,
'STARNet'
,
'RARE'
,
'SRN'
,
'CLS'
,
'PGNet'
,
'Distillation'
,
'NRTR'
,
'TableAttn'
,
'SAR'
,
'PSE'
,
'CLS'
,
'PGNet'
,
'Distillation'
,
'NRTR'
,
'TableAttn'
,
'SAR'
,
'PSE'
,
'SEED'
,
'SDMGR'
,
'LayoutXLM'
,
'LayoutLM'
,
'LayoutLMv2'
,
'PREN'
,
'FCE'
,
'SEED'
,
'SDMGR'
,
'LayoutXLM'
,
'LayoutLM'
,
'LayoutLMv2'
,
'PREN'
,
'FCE'
,
'SVTR'
,
'ViTSTR'
,
'ABINet'
,
'DB++'
,
'TableMaster'
,
'SPIN'
,
'VisionLAN'
,
'SVTR'
,
'ViTSTR'
,
'ABINet'
,
'DB++'
,
'TableMaster'
,
'SPIN'
,
'VisionLAN'
,
'Gestalt'
'Gestalt'
]
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录