pytorchconfigtorchdetectronlayout-parser

Running Detectron2 locally - windows - [Pytorch Config error]


I am trying to run this code locally: https://gist.github.com/shashank524/74d8f46d5de633b84e2265fcc34774de#file-tabledetection-ipynb

After installing required packages, when I am trying to run this line:

import layoutparser as lp

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

I receive this error:

OSError: [Errno 22] Invalid argument: 'C:\\Users\\username/.torch/iopath_cache\\s/f3b12qc4hc0yh4m\\config.yml?dl=1.lock'

I looked into the directory and there was no config file available. I tried to download the config file from here (https://layout-parser.readthedocs.io/en/latest/notes/modelzoo.html) and put it in the directory but it didn't solve the issue!


Solution

  • Even I got a similar error. I tried out manually some work around in Windows.

    I am using your case as example: OSError: [Errno 22] Invalid argument: 'C:\Users\username/.torch/iopath_cache\s/f3b12qc4hc0yh4m\config.yml?dl=1.lock'

    Please follow the following process.

    1. Navigate to C:\Users\username/.torch/iopath_cache\s/f3b12qc4hc0yh4m\config.yml Open that config.yaml file

    2. Scroll down to WEIGHTS: https://www.dropbox.com/s/h7th27jfv19rxiy/model_final.pth?dl=1 should be around 265 line.

    3. Copy that link and paste it in your browser, a 'model_final.pth' will be downloaded. Copy this file to your desired folder.

    4. Now replace the path to WEIGHTS: your_desired_folder\model_final.pth

    5. Save it and run the code it works!

    But there is a small work around I think before you do this (if you have not done) iopath work around

    https://github.com/Layout-Parser/layout-parser/issues/15 (Github link to the issue)

    Hope this helps!