Search code examples
kaggleresnet

Resnet cannot be loaded


I have trying to import resnet34 and resent50 into a Kaggle Kernal with no success. When I run:

from keras.applications.resnet50 import ResNet50 as resnet50
resnet = ResNet50(weights='imagenet')
learn = ConvLearner.pretrained(resnet, data, precompute=True) 

It starts downloading : 'Downloading: "https://download.pytorch.org/models/resnet34-333f7ec4.pth" to /tmp/.torch/models/resnet34-333f7ec4.pth'

but says "URL fetch failure on https://github.com/fchollet/deep-learning-models/releases/download/v0.2/resnet50_weights_tf_dim_ordering_tf_kernels.h5: None -- [Errno -2] Name or service not known"

and with resnet34:

 arch=resnet34
 learn = ConvLearner.pretrained(arch, data, precompute=True) 

I get: URLError: <urlopen error [Errno -2] Name or service not known>

Others seem to be importing using these same line.


Solution

  • You're getting this error because Kaggle kernels don't (currently) have internet access, so you're not able to fetch things via URL.

    You can add these models to your kernel by adding the relevent datasets (linked below) and then reading them in as you would any other file from the file path "../input/[name_of_dataset]/[name_of_file]". (You should replace [name_of_dataset] and [name_of_file] with the actual names of your dataset and desired file, of course. :)

    Hope that helps!