facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.56k stars 7.49k forks source link

Pickling error while loading dump file generated by DensePose #4884

Open maheboobp opened 1 year ago

maheboobp commented 1 year ago

Instructions To Reproduce the Issue:

I am trying to use DensePose on Google Colab. Specifically i am trying to run below command and load resulting dump file with pickle.

bwlo command works fine

python apply_net.py dump configs/densepose_rcnn_R_50_FPN_s1x.yaml \ https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/165712039/model_final_162be9.pkl \ images --output dump.pkl -v

command i am using to load file is

import pickle f = open('dump.pk', 'rb') pickle.load(f)

i m getting below error

UnpicklingError: A load persistent id instruction was encountered, but no persistent_load function was specified.

Expected behavior:

Expecting pickle to load file without error.

Environment:

Paste the output of the following command:

wget -nc -nv https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py

sys.platform linux Python 3.9.16 (main, Dec 7 2022, 01:11:51) [GCC 9.4.0] numpy 1.22.4 detectron2 0.6 @/usr/local/lib/python3.9/dist-packages/detectron2 Compiler GCC 9.4 CUDA compiler CUDA 11.8 detectron2 arch flags 7.5 DETECTRON2_ENV_MODULE PyTorch 2.0.0+cu117 @/usr/local/lib/python3.9/dist-packages/torch PyTorch debug build False torch._C._GLIBCXX_USE_CXX11_ABI False GPU available Yes GPU 0 Tesla T4 (arch=7.5) Driver version 525.85.12 CUDA_HOME /usr/local/cuda Pillow 8.4.0 torchvision 0.15.1+cu117 @/usr/local/lib/python3.9/dist-packages/torchvision torchvision arch flags 3.5, 5.0, 6.0, 7.0, 7.5, 8.0, 8.6 fvcore 0.1.5.post20221221 iopath 0.1.9 cv2 4.7.0


PyTorch built with:

maheboobp commented 1 year ago

I believe i have an idea on how this is broken , and potential fix. Please let me know if you want me to fix it.

Thnx Maheboob

Reschivon commented 1 year ago

I have the same issue. Any luck?

Reschivon commented 1 year ago

I made the simple mistake of using pickle.load() instead of torch.load()

skthtu commented 1 year ago

Hi @maheboobp ,

There is already a pull request addressing this issue. Please refer to pull request #4841 . Also, it would be greatly appreciated if you could review it.

Thanks. skthtu

maheboobp commented 1 year ago

Hi @maheboobp ,

There is already a pull request addressing this issue. Please refer to pull request #4841 . Also, it would be greatly appreciated if you could review it.

Thanks. skthtu

Thanks. looks good to me.