Closed chrisrapson closed 3 years ago
Sounds like it's probably a corrupt download because the following code works just fine on Google Colab.
import os
import numpy as np
from vit_keras import vit, utils
# Triggers weight download.
model = vit.vit_l16(
image_size=384,
activation='sigmoid',
pretrained=True,
include_top=True,
pretrained_top=True
)
# Does the file load?
np.load(os.path.expanduser(os.path.join("~", ".keras", "weights", "ViT-L_16_imagenet21k+imagenet2012.npz")), allow_pickle=False)
I suggest downloading the file manually from here and trying again. Realistically, the right way to ensure there's nothing going wrong with the download is to record the SHA hashes and validate them. I just haven't had the chance to get back into this library recently.
I downloaded from the browser and did a diff, which showed the files were identical. Then I tried the line you suggested by itself (np.load(os.path.expanduser...
) and that was fine. Finally I tried running my full script again, and it just worked. So I can't help with troubleshooting the problem, but anyway I'm glad it's working for me now. Thanks :-)
This looks like a really promising resource. Thanks for putting it together.
When I try to use a model (specifically
vit_l16
) it downloads an NPZ file to my.keras/weights
folder. That file is 1,190,422KB. However, that file fails to load:gives one of two errors:
or
Have you seen this before? Is there something obvious I'm doing wrong? The code I am calling is: