1

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 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

here is another error:F0508 03:20:57.777287 22515 base_conv_layer.cpp:189] Check failed: bottom[0]->num_axes() == first_spatial_axis + num_spatial_axes_ (3 vs. 4) bottom num_axes may not change. I guess it is because the dim in input_param should be 1,1,224,224,so I change it but meet another error:Cannot copy param 0 weights from layer 'conv1'; shape mismatch. Source param shape is 64 3 7 7 (9408); target param shape is 64 1 7 7 (3136). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer how to solve this problem,please?
btw I'm sure my train and test data are both 8bit gray scale pics.
This 2nd issue is with the number of channels (rgb vs gray). Your train and test both should have same number of channels. So do appropriate conversion based on your need.
thanks a lot.I changed the deploy.prototxt and trainval.prototxt,but still can not solve the first error.I still can not figure out the problem because all pics' channels are the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.