KaimingHe / deep-residual-networks

Deep Residual Learning for Image Recognition
MIT License
6.43k stars 2.22k forks source link

Error loading ResNet in Torch #18

Open pasxalinamed opened 8 years ago

pasxalinamed commented 8 years ago

I am trying to load ResNet model in torch using loadcaffe


require 'loadcaffe'

model = loadcaffe.load('ResNet-50-deploy.prototxt ', 'ResNet-50-model.caffemodel')`

the output in terminal is this

Successfully loaded ResNet-50-model.caffemodel

warning: module 'bn_conv1 [type BatchNorm]' not found

warning: module 'scale_conv1 [type Scale]' not found

warning: module 'pool1_pool1_0_split [type Split]' not found

warning: module 'res2a [type Eltwise]' not found`

.
.
.
`conv1: 64 3 7 7

res2a_branch1: 256 64 1 1

Segmentation fault (core dumped)`

and the resulting ResNet-50-deploy.prototxt.lua is

`require 'nn'

local model = {}

table.insert(model, {'conv1', nn.SpatialConvolution(3, 64, 7, 7, 2, 2, 3, 3)})

-- warning: module 'bn_conv1 [type BatchNorm]' not found

-- warning: module 'scale_conv1 [type Scale]' not found

table.insert(model, {'conv1_relu', nn.ReLU(true)})

table.insert(model, {'pool1', nn.SpatialMaxPooling(3, 3, 2, 2, 0, 0):ceil()})

-- warning: module 'pool1_pool1_0_split [type Split]' not found`
.
.
.
`
--warning: module 'res5c [type Eltwise]' not found

table.insert(model, {'res5c_relu', nn.ReLU(true)})

table.insert(model, {'pool5', nn.SpatialAveragePooling(7, 7, 1, 1, 0, 0):ceil()})

table.insert(model, {'fc1000', nn.Linear(2048, 1000)})

return model`

Probably some layers cannot be recognized by Torch. Has anyone managed to resolve this issue?

Thanks, Lina

Hiyorimi commented 8 years ago

I believe you have outdated caffe version.

nhynes commented 8 years ago

Unfortunately, loadcaffe doesn't support non-linear architectures. It's also missing a few modules like Scale and BatchNorm. Fortunately, however, I just finished caffegraph, which loads the pre-trained ResNets just fine.

xpchen0 commented 7 years ago

I have the same problem, do anyone have the solution?