ai-forever / ru-clip

CLIP implementation for Russian language
Apache License 2.0
137 stars 36 forks source link

проблема с загрузкой модели в VQGAN+Clip #2

Open nomomon opened 3 years ago

nomomon commented 3 years ago

Я пробовал подключить ru-clip ViT-B32-small.pt модель в notebook VQGAN+Clip используя API clip от OpenAI, но выходит ошибка.

скачал модель с huggingface

!git lfs install
!git clone https://huggingface.co/sberbank-ai/ru-clip

указал путь Clip модели

args = argparse.Namespace(
    ...
    clip_model='/content/ru-clip/ViT-B32-small.pt',
    ...
)

подключение модели (тут и происходит ошибка)

perceptor = clip.load(args.clip_model, jit=False)[0].eval().requires_grad_(False).to(device)

ошибка

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/content/CLIP/clip/clip.py in load(name, device, jit, download_root)
    121     try:
--> 122         # loading JIT archive
    123         model = torch.jit.load(model_path, map_location=device if jit else "cpu").eval()

4 frames
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

During handling of the above exception, another exception occurred:

UnpicklingError                           Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
    775             "functionality.")
    776 
--> 777     magic_number = pickle_module.load(f, **pickle_load_args)
    778     if magic_number != MAGIC_NUMBER:
    779         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, 'v'.