Layout-Parser / layout-parser

A Unified Toolkit for Deep Learning Based Document Image Analysis
https://layout-parser.github.io/
Apache License 2.0
4.78k stars 459 forks source link

How can I use the model and config from local path #51

Closed gaohuan2015 closed 3 years ago

gaohuan2015 commented 3 years ago

Hi

I am trying to use layout-parser to parse the data from PDF. Because some network issue, I can't download the config from 'lp://PubLayNet/faster_rcnn_R_50_FPN_3x/config'. But I can down load the model_final.pth and config.yaml through my browser. After that I use following code to set up the config path and model path. However, Nothing can be parsed. Is there any thing wrong when I use local path? model = lp.Detectron2LayoutModel(''config.yaml', "model_final.pth", extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8], label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

lolipopshock commented 3 years ago
  1. Can you confirm you have both files config.yaml and model_final.pth in the same directory as the python script?
  2. If it still doesn't work, you might want to add ./ before the paths:
    model = lp.Detectron2LayoutModel("./config.yaml", "./model_final.pth",
    extra_config=["MODEL.ROI_HEADS.SCORE_THRESH_TEST", 0.8],
    label_map={0: "Text", 1: "Title", 2: "List", 3:"Table", 4:"Figure"})

    . If not, please attach your error message in the next post. Thanks.

gaohuan2015 commented 3 years ago

Thanks very much for your help. The problem is resolved and we can close the issue

zhongguogu commented 2 years ago

Thanks very much, it helps me a lot.

zhepherd commented 1 year ago

where to download config and model @gaohuan2015 @lolipopshock