Skip to content

Commit

Permalink
[Feature] Refactor Inferencers (#1608)
Browse files Browse the repository at this point in the history
* tmp commit

* initial

* kie

* update MMOCRInferencer and ocr.py

* fix

* fix bug & add ut

* ut for kie

* part of mmocr inferencer ut

* part of mmocr inferencer ut

* ut

* ut

* docs

* inferencer

* Add TextSpotInferencer

* test

* fix

* textspot

* fix

* test

* test

* fix

* fix
  • Loading branch information
gaotongxiao committed Feb 2, 2023
1 parent 2d743cf commit ad470e3
Show file tree
Hide file tree
Showing 34 changed files with 1,632 additions and 887 deletions.
2 changes: 1 addition & 1 deletion configs/kie/sdmgr/_base_sdmgr_novisual.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
postprocessor=dict(type='SDMGRPostProcessor')),
dictionary=dict(
type='Dictionary',
dict_file='data/kie/wildreceipt/dict.txt',
dict_file='{{ fileDirname }}/../../../dicts/sdmgr_dict.txt',
with_padding=True,
with_unknown=True,
unknown_token=None),
Expand Down
24 changes: 24 additions & 0 deletions configs/kie/sdmgr/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,27 @@ Models:
Metrics:
macro_f1: 0.890
Weights: https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_unet16_60e_wildreceipt/sdmgr_unet16_60e_wildreceipt_20220825_151648-22419f37.pth
- Name: sdmgr_novisual_60e_wildreceipt
In Collection: SDMGR
Config: configs/kie/sdmgr/sdmgr_novisual_60e_wildreceipt.py
Metadata:
Training Data: wildreceipt
Results:
- Task: Key Information Extraction
Dataset: wildreceipt
Metrics:
macro_f1: 0.873
Weights: https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_novisual_60e_wildreceipt/sdmgr_novisual_60e_wildreceipt_20220831_193317-827649d8.pth
- Name: sdmgr_novisual_60e_wildreceipt_openset
In Collection: SDMGR
Config: configs/kie/sdmgr/sdmgr_novisual_60e_wildreceipt-openset.py
Metadata:
Training Data: wildreceipt-openset
Results:
- Task: Key Information Extraction
Dataset: wildreceipt
Metrics:
macro_f1: 0.931
micro_f1: 0.940
edgee_micro_f1: 0.792
Weights: https://download.openmmlab.com/mmocr/kie/sdmgr/sdmgr_novisual_60e_wildreceipt-openset/sdmgr_novisual_60e_wildreceipt-openset_20220831_200807-dedf15ec.pth
2 changes: 1 addition & 1 deletion configs/textdet/dbnet/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Models:
Alias:
- DB_r50
- DBNet
Config: configs/textdet/dbnet/dbnet_resnet50-dcnv2_fpnc_1200e_icdar2015.py
Config: configs/textdet/dbnet/dbnet_resnet50-oclip_1200e_icdar2015.py
Metadata:
Training Data: ICDAR2015
Results:
Expand Down
2 changes: 1 addition & 1 deletion configs/textrecog/crnn/metafile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Collections:
README: configs/textrecog/crnn/README.md

Models:
- Name: crnn_mini-vgg_5e_mj-123
- Name: crnn_mini-vgg_5e_mj
Alias: CRNN
In Collection: CRNN
Config: configs/textrecog/crnn/crnn_mini-vgg_5e_mj.py
Expand Down
91 changes: 91 additions & 0 deletions dicts/sdmgr_dict.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/
\
.
$
£
¥
:
-
,
*
#
(
)
%
@
!
'
&
=
>
+
"
×
?
<
[
]
_
0
1
2
3
4
5
6
7
8
9
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
26 changes: 26 additions & 0 deletions docs/en/api/apis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. role:: hidden
:class: hidden-section

mmocr.apis
===================================

.. contents:: mmocr.apis
:depth: 2
:local:
:backlinks: top

.. currentmodule:: mmocr.apis.inferencers

Inferencers
---------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:
:template: classtemplate.rst

MMOCRInferencer
TextDetInferencer
TextRecInferencer
TextSpotInferencer
KIEInferencer
1 change: 1 addition & 0 deletions docs/en/api/transforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Loading
LoadImageFromLMDB
LoadOCRAnnotations
LoadKIEAnnotations
InferencerLoader


TextDet Transforms
Expand Down
2 changes: 1 addition & 1 deletion docs/en/basic_concepts/structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In the **text detection** task, the detector concentrate on instance-level text

```python
import torch
from mmengine.data import InstanceData
from mmengine.structures import InstanceData

# defining gt_instance for encapsulating the ground truth data
gt_instance = InstanceData()
Expand Down
1 change: 1 addition & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ You can switch between English and Chinese in the lower-left corner of the layou
:maxdepth: 1
:caption: API Reference

mmocr.apis <api/apis>
mmocr.structures <api/structures>
mmocr.datasets <api/datasets>
mmocr.transforms <api/transforms>
Expand Down
26 changes: 26 additions & 0 deletions docs/zh_cn/api/apis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. role:: hidden
:class: hidden-section

mmocr.apis
===================================

.. contents:: mmocr.apis
:depth: 2
:local:
:backlinks: top

.. currentmodule:: mmocr.apis.inferencers

Inferencers
---------------------------------------------

.. autosummary::
:toctree: generated
:nosignatures:
:template: classtemplate.rst

MMOCRInferencer
TextDetInferencer
TextRecInferencer
TextSpotInferencer
KIEInferencer
2 changes: 1 addition & 1 deletion docs/zh_cn/basic_concepts/structures.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MMOCR 基于 {external+mmengine:doc}`MMEngine: 抽象数据接口 <advanced_tuto

```python
import torch
from mmengine.data import InstanceData
from mmengine.structures import InstanceData

# 定义 gt_instance 用于封装边界盒的标注信息
gt_instance = InstanceData()
Expand Down
1 change: 1 addition & 0 deletions docs/zh_cn/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
:maxdepth: 2
:caption: API 文档

mmocr.apis <api/apis>
mmocr.structures <api/structures>
mmocr.datasets <api/datasets>
mmocr.transforms <api/transforms>
Expand Down
3 changes: 2 additions & 1 deletion mmocr/apis/inferencers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from .mmocr_inferencer import MMOCRInferencer
from .textdet_inferencer import TextDetInferencer
from .textrec_inferencer import TextRecInferencer
from .textspot_inferencer import TextSpotInferencer

__all__ = [
'TextDetInferencer', 'TextRecInferencer', 'KIEInferencer',
'MMOCRInferencer'
'MMOCRInferencer', 'TextSpotInferencer'
]
Loading

0 comments on commit ad470e3

Please sign in to comment.