From 6fb6f548361c6f97ad30348a3814e10c1dc71574 Mon Sep 17 00:00:00 2001 From: Dwijay Bane Date: Tue, 9 Jan 2018 17:14:15 +0530 Subject: [PATCH] io.py updated --- python/caffe/io.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/caffe/io.py b/python/caffe/io.py index cee5ace2e88..5f933876cc0 100644 --- a/python/caffe/io.py +++ b/python/caffe/io.py @@ -256,7 +256,14 @@ def set_mean(self, in_, mean): if len(ms) != 3: raise ValueError('Mean shape invalid') if ms != self.inputs[in_][1:]: - raise ValueError('Mean shape incompatible with input shape.') + 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.') self.mean[in_] = mean def set_input_scale(self, in_, scale):