Unable to use pretrained resnet50 from keras github?

197 views
Skip to first unread message

Samaksh Yadav

unread,
Nov 5, 2016, 8:35:15 AM11/5/16
to Keras-users

I am using the keras version 1.1.1 , and running the demo examples provided on deep learning models repository  at repository.


My file "check.py" is as below


from resnet50 import ResNet50
from keras.preprocessing import image
from imagenet_utils import preprocess_input, decode_predictions
import numpy as np

model = ResNet50(weights='imagenet')

img_path = 'ele.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)

preds = model.predict(x)
print('Predicted:', decode_predictions(preds))



But when I try to run I 'm getting the following error trace while using resnet50 -


IndexError: index 64 is out of bounds for axis 1 with size 64
Apply node that caused the error: AbstractConv2d{border_mode='valid', subsample=(1, 1), filter_flip=True, imshp=(None, None, None, None), kshp=(64, 64, 1, 1)}(DimShuffle{0,3,1,2}.0, DimShuffle{3,2,0,1}.0)
Toposort index: 1894
Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)]
Inputs shapes: [(1L, 112L, 31L, 55L), (64L, 64L, 1L, 1L)]
Inputs strides: [(763840L, 6820L, 220L, 4L), (4L, 256L, 4L, 4L)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[DimShuffle{0,2,3,1}(AbstractConv2d{border_mode='valid', subsample=(1, 1), filter_flip=True, imshp=(None, None, None, None), kshp=(64, 64, 1, 1)}.0)]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
  File "C:/Users/Widow Maker/Virgillos/check.py", line 6, in <module>
    model = ResNet50(weights='imagenet')
  File "resnet50.py", line 170, in ResNet50
    x = conv_block(x, 3, [64, 64, 256], stage=2, block='a', strides=(1, 1))
  File "resnet50.py", line 90, in conv_block
    name=conv_name_base + '2a')(input_tensor)
  File "C:\Users\Widow Maker\Anaconda2\lib\site-packages\keras\engine\topology.py", line 514, in __call__
    self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
  File "C:\Users\Widow Maker\Anaconda2\lib\site-packages\keras\engine\topology.py", line 572, in add_inbound_node
    Node.create_node(self, inbound_layers, node_indices, tensor_indices)
  File "C:\Users\Widow Maker\Anaconda2\lib\site-packages\keras\engine\topology.py", line 149, in create_node
    output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
  File "C:\Users\Widow Maker\Anaconda2\lib\site-packages\keras\layers\convolutional.py", line 466, in call
    filter_shape=self.W_shape)
  File "C:\Users\Widow Maker\Anaconda2\lib\site-packages\keras\backend\theano_backend.py", line 1307, in conv2d
    filter_shape=filter_shape)

What is the cause of this?
Reply all
Reply to author
Forward
0 new messages