【报错】本地 Jupyter Notebook 使用 torch.load 调用预训练模型参数时遇到 RuntimeError: PytorchstreamReader failed reading zip archive:failed finding central directoryOutput is truncated. 报错:

【原因】一开始以为是 torch 版本问题 / requiremens 中依赖包的版本问题 / windows 路径问题。后来在本地找到了缓存中下载的 model_base_capfilt_large.pth,发现其下载异常,近 2G 的参数文件只下载了 33M。但因为缓存中可以找到参数文件,因此每次 URL 加载都会直接从缓存中读取,导致读取中断。

【解决办法】重新下载 model_base_capfilt_large.pth,将 URL 加载改为本地路径加载:

# model_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/models/model_base_capfilt_large.pth'

# model = blip_decoder(pretrained=model_url, image_size=image_size, vit='base')

model_path = r"C:\Users\Jackson1125\.cache\torch\hub\checkpoints\model_base_capfilt_large.pth"

model = blip_decoder(pretrained=model_path, image_size=image_size, vit='base')

精彩文章

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: