Skip to content

Commit e303955

Browse files
committed
Improve the documentation for layout models
1 parent ca187f4 commit e303955

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

docs/api_doc/models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DL Layout Model
1+
Layout Detection Models
22
================================
33

44

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Welcome to Layout Parser's documentation!
1919

2020
api_doc/elements
2121
api_doc/ocr
22-
api_doc/visualization
2322
api_doc/models
23+
api_doc/visualization
2424

2525
Indices and tables
2626
==================

src/layoutparser/models/layoutmodel.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,32 @@ def detect(self): pass
1717

1818

1919
class Detectron2LayoutModel(BaseLayoutModel):
20-
20+
"""Create a Detectron2-based Layout Detection Model
21+
22+
Args:
23+
config_path (:obj:`str`):
24+
The path to the configuration file.
25+
model_path (:obj:`str`, None):
26+
The path to the saved weights of the model.
27+
If set, overwrite the weights in the configuration file.
28+
Defaults to `None`.
29+
label_map (:obj:`dict`, optional):
30+
The map from the model prediction (ids) to real
31+
word labels (strings).
32+
Defaults to `None`.
33+
extra_config (:obj:`list`, optional):
34+
Extra configuration passed to the Detectron2 model
35+
configuration. The argument will be used in the `merge_from_list
36+
<https://detectron2.readthedocs.io/modules/config.html
37+
#detectron2.config.CfgNode.merge_from_list>`_ function.
38+
Defaults to `[]`.
39+
40+
Examples::
41+
>>> import layoutparser as lp
42+
>>> model = lp.models.Detectron2LayoutModel('lp://HJDataset/faster_rcnn_R_50_FPN_3x/config')
43+
>>> model.detect(image)
44+
45+
"""
2146
def __init__(self, config_path,
2247
model_path = None,
2348
label_map = None,
@@ -63,7 +88,14 @@ def _create_model(self):
6388
self.model = DefaultPredictor(self.cfg)
6489

6590
def detect(self, image):
91+
"""Detect the layout of a given image.
92+
93+
Args:
94+
image (:obj:`np.ndarray`): The input image to detect.
6695
96+
Returns:
97+
:obj:`~layoutparser.Layout`: The detected layout of the input image
98+
"""
6799
outputs = self.model(image)
68100
layout = self.gather_output(outputs)
69101
return layout

0 commit comments

Comments
 (0)