luca-medeiros/lang-segment-anything

Model loading

Closed this issue · 2 comments

Instructions To Reproduce the 🐛 Bug:

  1. I build the environment same as your repo。

  2. After running running_test.py file, error occues as follows:

Traceback (most recent call last):
  File "/home/hs/sunwenhao/lang-segment-anything/lang_sam/lang_sam.py", line 66, in build_sam
    state_dict = torch.hub.load_state_dict_from_url(checkpoint_url)
  File "/home/hs/miniconda3/envs/grasp-env/lib/python3.9/site-packages/torch/hub.py", line 770, in load_state_dict_from_url
    return torch.load(cached_file, map_location=map_location, weights_only=weights_only)
  File "/home/hs/miniconda3/envs/grasp-env/lib/python3.9/site-packages/torch/serialization.py", line 993, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "/home/hs/miniconda3/envs/grasp-env/lib/python3.9/site-packages/torch/serialization.py", line 447, in __init__
    super().__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/hs/sunwenhao/lang-segment-anything/running_test.py", line 9, in <module>
    model = LangSAM()
  File "/home/hs/sunwenhao/lang-segment-anything/lang_sam/lang_sam.py", line 56, in __init__
    self.build_sam(ckpt_path)
  File "/home/hs/sunwenhao/lang-segment-anything/lang_sam/lang_sam.py", line 69, in build_sam
    raise ValueError(f"Problem loading SAM please make sure you have the right model type: {self.sam_type} \
ValueError: Problem loading SAM please make sure you have the right model type: vit_h                     and a working checkpoint: https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth. Recommend deleting the checkpoint and re-downloading it.
  1. I tried to download ckpt files again but in vain.

looking the stack:
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

Seems you had some issue getting the file.

looking the stack: RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

Seems you had some issue getting the file.

Thanks, Luca! I have solved my problem and you can close thiss essue~