In [1]:
from keras.optimizers import SGD
from convnetskeras.convnets import preprocess_image_batch, convnet

im = preprocess_image_batch(['examples/dog.jpg'],img_size=(256,256), crop_size=(227,227), color_mode="rgb")

sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model = convnet('alexnet',weights_path="weights/alexnet_weights.h5", heatmap=False)
model.compile(optimizer=sgd, loss='mse')

out = model.predict(im)


Using Theano backend.
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-1-8eeda6cea3a9> in <module>()
      5 
      6 sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
----> 7 model = convnet('alexnet',weights_path="weights/alexnet_weights.h5", heatmap=False)
      8 model.compile(optimizer=sgd, loss='mse')
      9 

/media/rahul/3828C55728C51532/Cell Classification/convnets-keras/convnetskeras/convnets.py in convnet(network, weights_path, heatmap, trainable)
     63     elif network == 'alexnet':
     64         convnet_init = AlexNet
---> 65     convnet = convnet_init(weights_path, heatmap=False)
     66 
     67     if not heatmap:

/media/rahul/3828C55728C51532/Cell Classification/convnets-keras/convnetskeras/convnets.py in AlexNet(weights_path, heatmap)
    274 
    275     if weights_path:
--> 276         model.load_weights(weights_path)
    277 
    278     return model

/home/rahul/Desktop/CNN_Architecture/keras-master/keras/engine/topology.pyc in load_weights(self, filepath)
   2474         '''
   2475         import h5py
-> 2476         f = h5py.File(filepath, mode='r')
   2477         if 'layer_names' not in f.attrs and 'model_weights' in f:
   2478             f = f['model_weights']

/home/rahul/anaconda2/lib/python2.7/site-packages/h5py/_hl/files.pyc in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
    270 
    271                 fapl = make_fapl(driver, libver, **kwds)
--> 272                 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
    273 
    274                 if swmr_support:

/home/rahul/anaconda2/lib/python2.7/site-packages/h5py/_hl/files.pyc in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
     90         if swmr and swmr_support:
     91             flags |= h5f.ACC_SWMR_READ
---> 92         fid = h5f.open(name, flags, fapl=fapl)
     93     elif mode == 'r+':
     94         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2582)()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper (-------src-dir-------/h5py/_objects.c:2541)()

h5py/h5f.pyx in h5py.h5f.open (-------src-dir-------/h5py/h5f.c:1816)()

IOError: Unable to open file (Unable to open file: name = 'weights/alexnet_weights.h5', errno = 2, error message = 'no such file or directory', flags = 0, o_flags = 0)