解决方法参考http://stackoverflow.com/questions/29842935/mean-shape-incompatible-with-input-shape-caffe-classification-error-in-io-py
在运行caffe的python例子时,命令行输入
python classify.py cat.jpg foo
报错
ValueError: Mean shape incompatible with input shape.
原因是‘mean’与‘input’的尺寸不同造成的。
参考前面的文章,修改了 ./python/caffe/io.py 文件
将:
if ms != self.inputs[in_][1:]: raise ValueError('Mean shape incompatible with input shape.')
修改为:
if ms != self.inputs[in_][1:]: print(self.inputs[in_]) in_shape = self.inputs[in_][1:] m_min, m_max = mean.min(), mean.max() normal_mean = (mean - m_min) / (m_max - m_min) mean = resize_image(normal_mean.transpose((1,2,0)), in_shape[1:]).transpose((2,0,1)) * \ (m_max - m_min) + m_min #raise ValueError('Mean shape incompatible with input shape.')