layout-parser
layout-parser copied to clipboard
_pickle.UnpicklingError: invalid load key, '<'.
I am facing error while building the detectron2 base model from the example given in github and I receive the following error. Couldnt find any solution. Is there anyone facing this issue as well?
PLATFORM : Windows 10
model_final.pth: 942kB [00:02, 436kB/s]
Traceback (most recent call last):
File "C:\Users\Alexander\layoutTest\main.py", line 3, in
Process finished with exit code 1
I had this issue, but I fixed it by using the version of detectron2
specified in the dev-requirements.txt
file: git+https://github.com/facebookresearch/[email protected]#egg=detectron2
This version differs with the version specified in the installation.md
file, which uses v0.5
. Fortunately, using that version also works for me.
I'm on linux and not using anaconda, so hopefully this fix will still work for you.
Hey @ashrewdmint , despite the fact that in dev-requirements.txt
is present the fix, I still got the _pickle.UnpicklingError
Hey @Balthus1989 and @ashrewdmint ! This has nothing to do with the version of detectron2
or torch
. Basically, the error occurs because pickle
does not load the model file due to its incorrect format, which in this case is an HTML returned by DropBox in the download attempt made based on the configuration passed to layoutparser
like, for example, lp://PubLayNet/mask_rcnn_X_101_32x8d_FPN_3x/config
.
I recommend you download the desired configuration file at this link and change the Dropbox URL to the address of the model on your computer. And then provide the address of your config.yaml file when initializing the layoutparser
.
Ex.: model = lp.Detectron2LayoutModel( "/Users/[youuser]/Downloads/config.yaml", label_map={ 0: "Text", 1: "Title", 2: "List", 3: "Table", 4: "Figure", })
Hey @pedrohavay , unfortunately this method still doesn't work for me.
Edit: installing detectron2==0.5 solved the issue. Using detectron2==0.6 always fails.
@junxi-liu is it possible to install an older version from source?
like python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
but with version 0.5 instead of the latest version? Else it doesn't match my torch version.
Edit: I found it out by myself.
Download the zip file (https://github.com/facebookresearch/detectron2/releases), unzip it and then run python -m pip install detectron2-0.5/
in the given directory.
@junxi-liu is it possible to install an older version from source? like
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
but with version 0.5 instead of the latest version? Else it doesn't match my torch version.Edit: I found it out by myself. Download the zip file (https://github.com/facebookresearch/detectron2/releases), unzip it and then run
python -m pip install detectron2-0.5/
in the given directory.
Really appreciate the help!