Layout Detection Models¶
-
class
layoutparser.models.
Detectron2LayoutModel
(config_path, model_path=None, label_map=None, extra_config=None, enforce_cpu=None, device=None)[source]¶ Bases:
layoutparser.models.base_layoutmodel.BaseLayoutModel
Create a Detectron2-based Layout Detection Model
- Parameters
config_path (
str
) – The path to the configuration file.model_path (
str
, None) – The path to the saved weights of the model. If set, overwrite the weights in the configuration file. Defaults to None.label_map (
dict
, optional) – The map from the model prediction (ids) to real word labels (strings). If the config is from one of the supported datasets, Layout Parser will automatically initialize the label_map. Defaults to None.device (
str
, optional) – Whether to use cuda or cpu devices. If not set, LayoutParser will automatically determine the device to initialize the models on.extra_config (
list
, optional) – Extra configuration passed to the Detectron2 model configuration. The argument will be used in the merge_from_list function. Defaults to [].
- Examples::
>>> import layoutparser as lp >>> model = lp.Detectron2LayoutModel('lp://HJDataset/faster_rcnn_R_50_FPN_3x/config') >>> model.detect(image)
-
DEPENDENCIES
= ['detectron2']¶
-
DETECTOR_NAME
= 'detectron2'¶
-
MODEL_CATALOG
= {'HJDataset': {'faster_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/6icw6at8m28a2ho/model_final.pth?dl=1', 'mask_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/893paxpy5suvlx9/model_final.pth?dl=1', 'retinanet_R_50_FPN_3x': 'https://www.dropbox.com/s/yxsloxu3djt456i/model_final.pth?dl=1'}, 'MFD': {'faster_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/7xel0i3iqpm2p8y/model_final.pth?dl=1'}, 'NewspaperNavigator': {'faster_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/6ewh6g8rqt2ev3a/model_final.pth?dl=1'}, 'PrimaLayout': {'mask_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/h7th27jfv19rxiy/model_final.pth?dl=1'}, 'PubLayNet': {'faster_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/dgy9c10wykk4lq4/model_final.pth?dl=1', 'mask_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/d9fc9tahfzyl6df/model_final.pth?dl=1', 'mask_rcnn_X_101_32x8d_FPN_3x': 'https://www.dropbox.com/s/57zjbwv6gh3srry/model_final.pth?dl=1'}, 'TableBank': {'faster_rcnn_R_101_FPN_3x': 'https://www.dropbox.com/s/6vzfk8lk9xvyitg/model_final.pth?dl=1', 'faster_rcnn_R_50_FPN_3x': 'https://www.dropbox.com/s/8v4uqmz1at9v72a/model_final.pth?dl=1'}}¶