caffe:Check failed: target_blobs.size() == source_layer.blobs_size() (2 vs. 1) Incompatible number of blobs for layer conv1

…衆ロ難τιáo~ 提交于 2019-12-11 06:14:15

问题


I modify the FCN net and design a new net,in which I use two ImageData Layer as input param and hope the net produces a picture as output. here is the train_val.prototxt and the deploy.prototxt

the original picture and the label are both gray scale pics and sizes are 224*224. I've trained a caffemodel and use infer.py to use the caffemodel to do a segmentation,but meet the error:

 F0505 06:15:08.072602 30713 net.cpp:767] Check failed: target_blobs.size() == source_layer.blobs_size() (2 vs. 1) Incompatible number of blobs for layer conv1

here is the infer.py file:

import numpy as np
from PIL import Image
caffe_root = '/home/zhaimo/' 
import sys
sys.path.insert(0, caffe_root + 'caffe-master/python')

import caffe
im = Image.open('/home/zhaimo/fcn-master/data/vessel/test/13.png')
in_ = np.array(im, dtype=np.float32)
#in_ = in_[:,:,::-1]
#in_ -= np.array((104.00698793,116.66876762,122.67891434))
#in_ = in_.transpose((2,0,1))


net = caffe.Net('/home/zhaimo/fcn-master/mo/deploy.prototxt', '/home/zhaimo/fcn-master/mo/snapshot/train/_iter_200000.caffemodel', caffe.TEST)
net.blobs['data'].reshape(1, *in_.shape)
net.blobs['data'].data[...] = in_
net.forward()
out = net.blobs['score'].data[0].argmax(axis=0)

plt.axis('off')
plt.savefig('/home/zhaimo/fcn-master/mo/result/13.png')

how to solve this problem?


回答1:


The problem is with your bias term in conv1. In your train.prototxt it is set to false. But in your deploy.prototxt it is not and by default that is true. That is why weight loader is looking for two blobs.



来源:https://stackoverflow.com/questions/43816249/caffecheck-failed-target-blobs-size-source-layer-blobs-size-2-vs-1-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!