【问题标题】:Caffe - GoogLeNet Ignoring source layerCaffe - GoogLeNet 忽略源层
【发布时间】:2018-02-27 00:35:27
【问题描述】:

我在docker 容器内运行Caffe 框架(CPU),代码如下:

model_path = 'models/bvlc_googlenet/' # substitute your path here
net_fn   = model_path + 'deploy.prototxt'
param_fn = model_path + 'bvlc_googlenet.caffemodel'

# Patching model to be able to compute gradients.
# Note that you can also manually add "force_backward: true" line to "deploy.prototxt".
model = caffe.io.caffe_pb2.NetParameter()
text_format.Merge(open(net_fn).read(), model)
model.force_backward = True
open('models/bvlc_googlenet/tmp.prototxt', 'w').write(str(model))


net = caffe.Classifier('tmp.prototxt', param_fn,
                       mean = np.float32([104.0, 116.0, 122.0]), # ImageNet mean, training set dependent
                       channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB

但是,在忽略所有模型层之后,我得到以下回溯:

libdc1394 error: Failed to initialize libdc1394
WARNING: Logging before InitGoogleLogging() is written to STDERR
I0227 00:08:49.033560   122 net.cpp:49] Initializing net from parameters: 
force_backward: true
state {
  phase: TEST
}
I0227 00:08:49.033826   122 net.cpp:274] Network initialization done.
I0227 00:08:49.316442   122 upgrade_proto.cpp:52] Attempting to upgrade input file specified using deprecated V1LayerParameter: models/bvlc_googlenet/bvlc_googlenet.caffemodel
I0227 00:08:49.370679   122 upgrade_proto.cpp:60] Successfully upgraded file specified using deprecated V1LayerParameter
I0227 00:08:49.374241   122 net.cpp:752] Ignoring source layer data
I0227 00:08:49.374426   122 net.cpp:752] Ignoring source layer label_data_1_split
I0227 00:08:49.374480   122 net.cpp:752] Ignoring source layer conv1/7x7_s2
I0227 00:08:49.374514   122 net.cpp:752] Ignoring source layer conv1/relu_7x7
I0227 00:08:49.374563   122 net.cpp:752] Ignoring source layer pool1/3x3_s2
I0227 00:08:49.374616   122 net.cpp:752] Ignoring source layer pool1/norm1
I0227 00:08:49.374683   122 net.cpp:752] Ignoring source layer conv2/3x3_reduce
(for all layers)
Traceback (most recent call last):
  File "dream.py", line 40, in <module>
    channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB
  File "/root/caffe/python/caffe/classifier.py", line 29, in __init__
    in_ = self.inputs[0]
IndexError: list index out of range

谁能指点我正确的方向?

【问题讨论】:

    标签: python caffe


    【解决方案1】:

    这行得通:

    model_name = "GoogLeNet"
    model_path = 'models/bvlc_googlenet/'
    net_fn   = 'models/bvlc_googlenet/deploy_googlenet_updated.prototxt'
    param_fn = model_path + 'bvlc_googlenet.caffemodel'
    mean = np.float32([104.0, 117.0, 123.0])
    
    net = caffe.Classifier(net_fn, param_fn,
                           mean = mean, # ImageNet mean, training set dependent
                           channel_swap = (2,1,0)) # the reference model has channels in BGR order instead of RGB
    

    【讨论】:

      猜你喜欢
      • 2019-01-06
      • 2015-08-29
      • 2016-11-13
      • 1970-01-01
      • 2017-10-30
      • 2018-05-17
      • 1970-01-01
      • 2017-02-15
      • 2017-05-08
      相关资源
      最近更新 更多