Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hey so I have taken the pull of the repository I want to use different model in for layouting or drawing bounding box that is from LayoutParser TableBank for table purposes so how I can add that in deepdoctection. And I want to set in config file like USE_TABLE_DETECTOR=True something like this.

You must be logged in to vote

Sorry for late reply.

If you register the model first and then instantiate the analyzer with config changes then it will work.

E.G.

import deepdoctection as dd



if __name__ == "__main__":

    dd.ModelCatalog.register("layoutparser/publaynet/model_final.pth", dd.ModelProfile(
        name="layoutparser/publaynet/model_final.pth",
        description="Add some infos regarding the model",
        config="layoutparser/publaynet/config.yml",
        tp_model=False,
        size=[],
        categories={
            1: dd.LayoutType.TEXT,
            2: dd.LayoutType.TITLE,
            3: dd.LayoutType.LIST,
            4: dd.LayoutType.TABLE,
            5: dd.LayoutType.FIGURE,
        },
 …

Replies: 1 comment · 3 replies

Comment options

There is a tutorial for this here.

If there are more questions I am happy to answer them.

You must be logged in to vote
3 replies
@adinath1233
Comment options

There is a tutorial for this here.

If there are more questions I am happy to answer them.

Hi @JaMe76,
Thanks for replying appreciated. The only doubt I have is that if I am making changes in a config file and registering in a pulled or cloned repository will the analyzer work with that?

@JaMe76
Comment options

Sorry for late reply.

If you register the model first and then instantiate the analyzer with config changes then it will work.

E.G.

import deepdoctection as dd



if __name__ == "__main__":

    dd.ModelCatalog.register("layoutparser/publaynet/model_final.pth", dd.ModelProfile(
        name="layoutparser/publaynet/model_final.pth",
        description="Add some infos regarding the model",
        config="layoutparser/publaynet/config.yml",
        tp_model=False,
        size=[],
        categories={
            1: dd.LayoutType.TEXT,
            2: dd.LayoutType.TITLE,
            3: dd.LayoutType.LIST,
            4: dd.LayoutType.TABLE,
            5: dd.LayoutType.FIGURE,
        },
        model_wrapper="D2FrcnnDetector",
    ))

    # you must store layoutparser config file and weights as returned from the following statement
    print(dd.ModelCatalog.get_full_path_weights("layoutparser/publaynet/model_final.pth"))  
    print(dd.ModelCatalog.get_full_path_configs("layoutparser/publaynet/model_final.pth"))


    path = "/path/to/your/pdf/file.pdf"

    # replace the default layout model with the new registered layoutparser model
    analyzer = dd.get_dd_analyzer(config_overwrite=["PT.LAYOUT.WEIGHTS=layoutparser/publaynet/model_final.pth",])
    df = analyzer.analyze(path=path)

    df.reset_state()

    for dp in df:
        dp.viz(interactive=True)
Answer selected by adinath1233
@adinath1233
Comment options

Hey, thank you for the reply I got it how it works appreciated it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.