Im trying to run a keras model,trying to use pre-trained VGGnet-
When i run this Command
base_model = applications.VGG16(weights='imagenet', include_top=False, input_shape=(img_rows, img_cols, img_channel))
I get this error:
JavaScript
x
28
28
1
``------------------------------------------------------------------
2
---------
3
ImportError Traceback (most recent call
4
last)
5
<ipython-input-79-9b18deb3bc0f> in <module>()
6
1
7
----> 2 base_model = applications.VGG16(weights='imagenet',
8
include_top=False, input_shape=(img_rows, img_cols, img_channel))
9
10
/usr/local/lib/python3.5/dist-packages/keras/applications/vgg16.py in
11
VGG16(include_top, weights, input_tensor, input_shape, pooling,
12
classes)
13
167 WEIGHTS_PATH_NO_TOP,
14
168 cache_subdir='models')
15
--> 169 model.load_weights(weights_path)
16
170 if K.backend() == 'theano':
17
171 layer_utils.convert_all_kernels_in_model(model)
18
19
/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py in
20
load_weights(self, filepath, by_name)
21
2563 """
22
2564 if h5py is None:
23
-> 2565 raise ImportError('`load_weights` requires h5py.')
24
2566 f = h5py.File(filepath, mode='r')
25
2567 if 'layer_names' not in f.attrs and 'model_weights' in f:
26
27
ImportError: `load_weights` requires h5py.``
28
I went through some github issues page where a relevant question was asked,but no solutions were given. Any suggestions?
Advertisement
Answer
Install h5py:
JavaScript
1
2
1
pip install h5py
2
Or if using conda:
JavaScript
1
2
1
conda install h5py
2