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

enforce_cpu not working #44

Closed lkluo closed 3 years ago

lkluo commented 3 years ago

When setting enforce_cpu true, still using CUDA instead of CPU. I think it is due to this https://github.com/Layout-Parser/layout-parser/blob/e035fc8f952addc620670e5b47864fe213db0e10/src/layoutparser/models/layoutmodel.py#L120

Possible fix could be cfg.MODEL.DEVICE = "cuda" if torch.cuda.is_available() and (not enforce_cpu) else "cpu"

karndeepsingh commented 3 years ago

Please help me out to execute the below command I am unable to run it! it throws an error!

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

lolipopshock commented 3 years ago

@lkluo Thanks! Would you like to open a PR and have it fixed?

lolipopshock commented 3 years ago

odel_PLN_a = lp.Detectron2LayoutModel( config

Hey @karndeepsingh - could you specify what the error is?

karndeepsingh commented 3 years ago

I am unable to run above code in my local but when I run it on colab it download weights and config files of the model. How I can do the same on my local device?

lolipopshock commented 3 years ago

Should be fixed in #69 -- now we use device instead of enforce_cpu for specifying devices.