Learn practical skills, build real-world projects, and advance your career

1. Use Keras Pretrained Models dataset

Kernels can't use network connection to download pretrained keras model weights. This dataset helps you to apply your favorite pretrained model in the Kaggle Kernel environment. You can find more details here.

We have to copy the pretrained models to the cache directory (~/.keras/models) where keras is looking for them.

!ls ../input/vgg16/
imagenet_class_index.json vgg16_weights_tf_dim_ordering_tf_kernels.h5 vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5
import os
cache_dir = os.path.expanduser(os.path.join('~', '.keras'))
if not os.path.exists(cache_dir):
    os.makedirs(cache_dir)
models_dir = os.path.join(cache_dir, 'models')
if not os.path.exists(models_dir):
    os.makedirs(models_dir)
!cp ../input/vgg16/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5 ~/.keras/models/
print(os.listdir('../input/plant-seedlings-classification/train/'))
['Loose Silky-bent', 'Shepherds Purse', 'Fat Hen', 'Charlock', 'Sugar beet', 'Maize', 'Common wheat', 'Cleavers', 'Black-grass', 'Small-flowered Cranesbill', 'Scentless Mayweed', 'Common Chickweed']