ChenDelong1999 / RemoteCLIP

🛰️ Official repository of paper "RemoteCLIP: A Vision Language Foundation Model for Remote Sensing" (IEEE TGRS)
https://arxiv.org/abs/2306.11029
Apache License 2.0
228 stars 13 forks source link

Expected state_dict to be dict-like, got <class 'torch.jit._script.RecursiveScriptModule'>. #8

Closed kungkook closed 10 months ago

kungkook commented 10 months ago

`import torch, open_clip from PIL import Image from IPython.display import display

modelname = 'RN50' # 'RN50' or 'ViT-B-32' or 'ViT-L-14' model, , preprocess = open_clip.create_model_and_transforms(model_name) tokenizer = open_clip.get_tokenizer(model_name)

path_to_your_checkpoints = 'checkpoints'

ckpt = torch.load(f"{path_to_your_checkpoints}/{model_name}.pt", map_location="cpu") message = model.load_state_dict(ckpt) print(message) model = model.cuda().eval() i run the code , and then: n Module.load_state_dict(self, state_dict, strict) 1971 r"""Copies parameters and buffers from :attr:state_dict into 1972 this module and its descendants. If :attr:strict is True, then 1973 the keys of :attr:state_dict must exactly match the keys returned (...) 1991 RuntimeError. 1992 """ 1993 if not isinstance(state_dict, Mapping): -> 1994 raise TypeError("Expected state_dict to be dict-like, got {}.".format(type(state_dict))) 1996 missing_keys: List[str] = [] 1997 unexpected_keys: List[str] = []

TypeError: Expected state_dict to be dict-like, got <class 'torch.jit._script.RecursiveScriptModule'>.`

ChenDelong1999 commented 10 months ago

Hi, could you please confirm that the RemoteCILP checkpoint is properly downloaded, and the path_to_your_checkpoints variable is correctly set, such that f"{path_to_your_checkpoints}/{model_name}.pt" could successfully point to the checkpoint file?

kungkook commented 10 months ago

Hi, could you please confirm that the RemoteCILP checkpoint is properly downloaded, and the path_to_your_checkpoints variable is correctly set, such that f"{path_to_your_checkpoints}/{model_name}.pt" could successfully point to the checkpoint file?

It's settled, thank you