想尝试项目https://github.com/chuanli11/CNNMRF。在通过luarocks克隆和安装loadcaffe之后。然后运行命令:
qlua cnnmrf.lua -content_name master_entrance_portrait
出现此错误:
mkdir: cannot create directory ‘data/result/’: File exists
mkdir: cannot create directory ‘data/result/trans/’: File exists
mkdir: cannot create directory ‘data/result/trans/MRF/’: File exists
mkdir: cannot create directory ‘data/result/trans/MRF/’: File exists
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:505] Reading dangerously large protocol message. If the message turns out to be larger than 1073741824 bytes, parsing will be halted for security reasons. To increase the limit (or to disable these warnings), see CodedInputStream::SetTotalBytesLimit() in google/protobuf/io/coded_stream.h.
[libprotobuf WARNING google/protobuf/io/coded_stream.cc:78] The total number of bytes read was 574671192
Successfully loaded data/models/VGG_ILSVRC_19_layers.caffemodel
qlua: ...torch/install/share/lua/5.1/cudnn/SpatialConvolution.lua:19: nOutputPlane should be divisible by nGroups
stack traceback:
[C]: at 0x7fec4cde29d0
[C]: in function 'assert'
...torch/install/share/lua/5.1/cudnn/SpatialConvolution.lua:19: in function '__init'
...yne/Downloads/torch/install/share/lua/5.1/torch/init.lua:91: in function <...yne/Downloads/torch/install/share/lua/5.1/torch/init.lua:87>
[C]: in function 'SpatialConvolution'
data/models/VGG_ILSVRC_19_layers_deploy.prototxt.lua:3: in main chunk
[C]: in function 'dofile'
...oads/torch/install/share/lua/5.1/loadcaffe/loadcaffe.lua:24: in function 'load'
./transfer_CNNMRF_wrapper.lua:372: in function 'main'
cnnmrf.lua:92: in main chunk
通过loadcaffe将caffe模型转换为火炬模型时出现的一些潜在错误导致猜测。要转换的网络是文件VGG_ILSVRC_19_layers.cafflemodel和VGG_ILSVRC_19_layers_deploy.prototxt中的VGG19。我通过校验和检查了这些文件,它们没问题。但转换后的那个,即VGG_ILSVRC_19_layers_deploy.prototxt.lua就是这样的:
require 'cudnn'
local model = {}
table.insert(model, {'conv1_1', cudnn.SpatialConvolution(0, -1118555060, 4, 1, 0, 0, -47878672, 4, 64)})
table.insert(model, {'relu1_1', cudnn.ReLU(true)})
table.insert(model, {'conv1_2', cudnn.SpatialConvolution(0, 1041742427, 4, 1, 0, 0, -76411872, 4, 64)})
table.insert(model, {'relu1_2', cudnn.ReLU(true)})
table.insert(model, {'pool1', cudnn.SpatialMaxPooling(2, 2, 2, 2, 0, 0):ceil()})
table.insert(model, {'conv2_1', cudnn.SpatialConvolution(0, -1172344618, 4, 1, 0, 0, -76404000, 4, 128)})
table.insert(model, {'relu2_1', cudnn.ReLU(true)})
table.insert(model, {'conv2_2', cudnn.SpatialConvolution(0, -1134797354, 4, 1, 0, 0, -76401184, 4, 128)})
table.insert(model, {'relu2_2', cudnn.ReLU(true)})
table.insert(model, {'pool2', cudnn.SpatialMaxPooling(2, 2, 2, 2, 0, 0):ceil()})
table.insert(model, {'conv3_1', cudnn.SpatialConvolution(0, 32609, 4, 1, 0, 0, -76397968, 4, 256)})
table.insert(model, {'relu3_1', cudnn.ReLU(true)})
table.insert(model, {'conv3_2', cudnn.SpatialConvolution(0, 976600020, 4, 1, 0, 0, -47647424, 4, 256)})
table.insert(model, {'relu3_2', cudnn.ReLU(true)})
table.insert(model, {'conv3_3', cudnn.SpatialConvolution(0, -1193143920, 4, 1, 0, 0, -47644208, 4, 256)})
table.insert(model, {'relu3_3', cudnn.ReLU(true)})
table.insert(model, {'conv3_4', cudnn.SpatialConvolution(0, 965660278, 4, 1, 0, 0, -47640880, 4, 256)})
table.insert(model, {'relu3_4', cudnn.ReLU(true)})
table.insert(model, {'pool3', cudnn.SpatialMaxPooling(2, 2, 2, 2, 0, 0):ceil()})
table.insert(model, {'conv4_1', cudnn.SpatialConvolution(0, 994497290, 4, 1, 0, 0, -47635600, 4, 512)})
table.insert(model, {'relu4_1', cudnn.ReLU(true)})
table.insert(model, {'conv4_2', cudnn.SpatialConvolution(0, 994239873, 4, 1, 0, 0, -47631248, 4, 512)})
table.insert(model, {'relu4_2', cudnn.ReLU(true)})
table.insert(model, {'conv4_3', cudnn.SpatialConvolution(0, -1162151849, 4, 1, 0, 0, -47626896, 4, 512)})
table.insert(model, {'relu4_3', cudnn.ReLU(true)})
table.insert(model, {'conv4_4', cudnn.SpatialConvolution(0, -1161155618, 4, 1, 0, 0, -47622544, 4, 512)})
table.insert(model, {'relu4_4', cudnn.ReLU(true)})
table.insert(model, {'pool4', cudnn.SpatialMaxPooling(2, 2, 2, 2, 0, 0):ceil()})
table.insert(model, {'conv5_1', cudnn.SpatialConvolution(0, 990007184, 4, 1, 0, 0, -47617264, 4, 512)})
table.insert(model, {'relu5_1', cudnn.ReLU(true)})
table.insert(model, {'conv5_2', cudnn.SpatialConvolution(0, -1165327502, 4, 1, 0, 0, -47612912, 4, 512)})
table.insert(model, {'relu5_2', cudnn.ReLU(true)})
table.insert(model, {'conv5_3', cudnn.SpatialConvolution(0, -1173363995, 4, 1, 0, 0, -338687408, 4, 512)})
table.insert(model, {'relu5_3', cudnn.ReLU(true)})
table.insert(model, {'conv5_4', cudnn.SpatialConvolution(0, 980886043, 4, 1, 0, 0, -47608144, 4, 512)})
table.insert(model, {'relu5_4', cudnn.ReLU(true)})
table.insert(model, {'pool5', cudnn.SpatialMaxPooling(2, 2, 2, 2, 0, 0):ceil()})
table.insert(model, {'torch_view', nn.View(-1):setNumInputDims(3)})
table.insert(model, {'fc6', nn.Linear(0, 0)})
table.insert(model, {'relu6', cudnn.ReLU(true)})
table.insert(model, {'drop6', nn.Dropout(0.500000)})
table.insert(model, {'fc7', nn.Linear(0, 0)})
table.insert(model, {'relu7', cudnn.ReLU(true)})
table.insert(model, {'drop7', nn.Dropout(0.500000)})
table.insert(model, {'fc8', nn.Linear(0, 0)})
table.insert(model, {'prob', cudnn.SoftMax()})
return model
发现它在loadcaffe.lua:
C.convertProtoToLua(handle, lua_name, backend)
然后在ffi.lua:
ffi.cdef[[
...
void convertProtoToLua(void** handle, const char* lua_name, const char* cuda_package);
...
]]
这是否意味着在安装之前安装在luarocks中的loadcaffe已损坏?可能是什么原因?提前谢谢!