Skip to content

Commit f027525

Browse files
authored
Add the MFD Model for detecting mathematic formula regions (#59)
* Add the MFD models in the model catalog * Update new models in the documentation * Add the mfd model config in test
1 parent 262ef0b commit f027525

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

docs/notes/modelzoo.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ model.detect(image)
2828
| [NewspaperNavigator](https://news-navigator.labs.loc.gov/) | [faster_rcnn_R_50_FPN_3x](https://www.dropbox.com/s/wnido8pk4oubyzr/config.yml?dl=1) | lp://NewspaperNavigator/faster_rcnn_R_50_FPN_3x/config | |
2929
| [TableBank](https://doc-analysis.github.io/tablebank-page/index.html) | [faster_rcnn_R_50_FPN_3x](https://www.dropbox.com/s/7cqle02do7ah7k4/config.yaml?dl=1) | lp://TableBank/faster_rcnn_R_50_FPN_3x/config | 89.78 [eval.csv](https://www.dropbox.com/s/1uwnz58hxf96iw2/eval.csv?dl=0) |
3030
| [TableBank](https://doc-analysis.github.io/tablebank-page/index.html) | [faster_rcnn_R_101_FPN_3x](https://www.dropbox.com/s/h63n6nv51kfl923/config.yaml?dl=1) | lp://TableBank/faster_rcnn_R_101_FPN_3x/config | 91.26 [eval.csv](https://www.dropbox.com/s/e1kq8thkj2id1li/eval.csv?dl=0) |
31+
| [Math Formula Detection(MFD)](http://transcriptorium.eu/~htrcontest/MathsICDAR2021/) | [faster_rcnn_R_50_FPN_3x](https://www.dropbox.com/s/ld9izb95f19369w/config.yaml?dl=1) | lp://MFD/faster_rcnn_R_50_FPN_3x/config | 79.68 [eval.csv](https://www.dropbox.com/s/1yvrs29jjybrlpw/eval.csv?dl=0) |
32+
3133

3234
* For PubLayNet models, we suggest using `mask_rcnn_X_101_32x8d_FPN_3x` model as it's trained on the whole training set, while others are only trained on the validation set (the size is only around 1/50). You could expect a 15% AP improvement using the `mask_rcnn_X_101_32x8d_FPN_3x` model.
3335

@@ -39,4 +41,5 @@ model.detect(image)
3941
| [PubLayNet](https://github.com/ibm-aur-nlp/PubLayNet) | `{0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"}` |
4042
| [PrimaLayout](https://www.primaresearch.org/dataset/) | `{1:"TextRegion", 2:"ImageRegion", 3:"TableRegion", 4:"MathsRegion", 5:"SeparatorRegion", 6:"OtherRegion"}` |
4143
| [NewspaperNavigator](https://news-navigator.labs.loc.gov/) | `{0: "Photograph", 1: "Illustration", 2: "Map", 3: "Comics/Cartoon", 4: "Editorial Cartoon", 5: "Headline", 6: "Advertisement"}` |
42-
| [TableBank](https://doc-analysis.github.io/tablebank-page/index.html) | `{0: "Table"}` |
44+
| [TableBank](https://doc-analysis.github.io/tablebank-page/index.html) | `{0: "Table"}` |
45+
| [MFD](http://transcriptorium.eu/~htrcontest/MathsICDAR2021/) | `{1: "Equation"}` |

src/layoutparser/models/detectron2/catalog.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/8v4uqmz1at9v72a/model_final.pth?dl=1",
2424
"faster_rcnn_R_101_FPN_3x": "https://www.dropbox.com/s/6vzfk8lk9xvyitg/model_final.pth?dl=1",
2525
},
26+
"MFD": {
27+
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/7xel0i3iqpm2p8y/model_final.pth?dl=1",
28+
},
2629
}
2730

2831
CONFIG_CATALOG = {
@@ -46,6 +49,9 @@
4649
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/7cqle02do7ah7k4/config.yaml?dl=1",
4750
"faster_rcnn_R_101_FPN_3x": "https://www.dropbox.com/s/h63n6nv51kfl923/config.yaml?dl=1",
4851
},
52+
"MFD": {
53+
"faster_rcnn_R_50_FPN_3x": "https://www.dropbox.com/s/ld9izb95f19369w/config.yaml?dl=1",
54+
},
4955
}
5056

5157
# fmt: off
@@ -85,6 +91,9 @@
8591
"TableBank": {
8692
0: "Table"
8793
},
94+
"MFD": {
95+
1: "Equation"
96+
},
8897
}
8998
# fmt: on
9099

tests/test_model.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from layoutparser.models import *
33
import cv2
44

5-
ALL_CONFIGS = [
5+
ALL_DETECTRON2_MODEL_CONFIGS = [
66
"lp://PrimaLayout/mask_rcnn_R_50_FPN_3x/config",
77
"lp://HJDataset/faster_rcnn_R_50_FPN_3x/config",
88
"lp://HJDataset/mask_rcnn_R_50_FPN_3x/config",
@@ -13,9 +13,10 @@
1313
"lp://NewspaperNavigator/faster_rcnn_R_50_FPN_3x/config",
1414
"lp://TableBank/faster_rcnn_R_50_FPN_3x/config",
1515
"lp://TableBank/faster_rcnn_R_101_FPN_3x/config",
16+
"lp://MFD/faster_rcnn_R_50_FPN_3x/config",
1617
]
1718

18-
ALL_PADDLE_CONFIGS = [
19+
ALL_PADDLEDETECTION_MODEL_CONFIGS = [
1920
"lp://PubLayNet/ppyolov2_r50vd_dcn_365e_publaynet/config",
2021
"lp://TableBank/ppyolov2_r50vd_dcn_365e_tableBank_word/config",
2122
"lp://TableBank/ppyolov2_r50vd_dcn_365e_tableBank_latex/config",
@@ -25,7 +26,7 @@ def test_Detectron2Model(is_large_scale=False):
2526

2627
if is_large_scale:
2728

28-
for config in ALL_CONFIGS:
29+
for config in ALL_DETECTRON2_MODEL_CONFIGS:
2930
model = Detectron2LayoutModel(config)
3031

3132
image = cv2.imread("tests/fixtures/model/test_model_image.jpg")
@@ -58,7 +59,7 @@ def test_PaddleDetectionModel(is_large_scale=False):
5859
""" test PaddleDetection model """
5960
if is_large_scale:
6061

61-
for config in ALL_PADDLE_CONFIGS:
62+
for config in ALL_PADDLEDETECTION_MODEL_CONFIGS:
6263
model = PaddleDetectionLayoutModel(config)
6364

6465
image = cv2.imread("tests/fixtures/model/test_model_image.jpg")

0 commit comments

Comments
 (0)