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
29.3k stars 7.32k forks source link

UnpicklingError: invalid load key, '\xef'. #5263

Open sebastianfernandezgarcia opened 2 months ago

sebastianfernandezgarcia commented 2 months ago

3 days ago my code was working cloning the repo and using:

from detectron2.config import CfgNode as CN
from detectron2.config import get_cfg
from detectron2.utils.visualizer import ColorMode, Visualizer
from detectron2.data import MetadataCatalog
from detectron2.engine import DefaultPredictor

cfg = get_cfg()
add_vit_config(cfg)
cfg.merge_from_file("cascade_dit_base.yml")
cfg.MODEL.WEIGHTS = "publaynet_dit-b_cascade.pth"

predictor = DefaultPredictor(cfg)

After the last commit in the repo, gives me this error:

---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
[<ipython-input-4-ffffa6d6dad1>](https://localhost:8080/#) in <cell line: 20>()
     18 
     19 # Step 4: define model
---> 20 predictor = DefaultPredictor(cfg)
     21 
     22 def analyze_image(img):

7 frames
[/usr/local/lib/python3.10/dist-packages/torch/serialization.py](https://localhost:8080/#) in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
    918             "functionality.")
    919 
--> 920     magic_number = pickle_module.load(f, **pickle_load_args)
    921     if magic_number != MAGIC_NUMBER:
    922         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '\xef'.

"Instructions To Reproduce the Issue and Full Logs"; Clone repo and use cfg in colab

"Your Environment"; Google colab

github-actions[bot] commented 2 months ago

You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template. The following information is missing: "Instructions To Reproduce the Issue and Full Logs"; "Your Environment";

sebastianfernandezgarcia commented 2 months ago

The error is beacause there is a missing file when downloading some utils.

This file: os.system("curl -LJ -o publaynet_dit-b_cascade.pth 'https://layoutlm.blob.core.windows.net/dit/dit-fts/publaynet_dit-b_cascade.pth?sv=2022-11-02&ss=b&srt=o&sp=r&se=2033-06-08T16:48:15Z&st=2023-06-08T08:48:15Z&spr=https&sig=a9VXrihTzbWyVfaIDlIT1Z0FoR1073VB0RLQUMuudD4%3D'")