UnstructuredDetectronModel Initialization TypeError

99 views Asked by At

I am attempting to use a pre-trained model from the model zoo with UnstructuredDetectronModel in Python and encountering a TypeError during the initialization process. I was following this guide where it mentions that UnstructuredDetectronModel is a light wrapper around layoutparser.models.Detectron2LayoutModel and can utilize various pre-trained models from the model zoo. Below is the code snippet that is causing the error:

from unstructured_inference.models.detectron2 import UnstructuredDetectronModel
import layoutparser as lp

model = UnstructuredDetectronModel(
    config_path='lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config',
    label_map={0: "Text", 1: "Title", 2: "List", 3: "Table", 4: "Figure"},
    extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],
)

The error message I receive is: TypeError: init() got an unexpected keyword argument 'config_path'

I am following the documentation and passing the config_path as a string, but it seems like UnstructuredDetectronModel does not accept it as a valid argument. How to properly initialize UnstructuredDetectronModel with a config_path? Any help would be greatly appreciated!

1

There are 1 answers

0
الرحمن الرحیم On

use this changes how you can load a Detectron2LayoutModel directly with a configuration file:

import layoutparser as lp

model = lp.Detectron2LayoutModel(
    config_path='lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config',
    label_map={0: "Text", 1: "Title", 2: "List", 3: "Table", 4: "Figure"},
    extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],
)