From 05afc903d890fb1ed93df4d078b6e826dd473f59 Mon Sep 17 00:00:00 2001 From: Ishant Mrinal Haloi Date: Fri, 15 Jan 2016 11:14:13 +0800 Subject: [PATCH 1/2] Update io.py --- 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 14942bed542..bc1a895f977 100644 --- a/python/caffe/io.py +++ b/python/caffe/io.py @@ -255,7 +255,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): From bef4098ea488dcd0c0df80c20159238a6c701c0b Mon Sep 17 00:00:00 2001 From: Ishant Mrinal Haloi Date: Fri, 15 Jan 2016 11:31:35 +0800 Subject: [PATCH 2/2] Update io.py --- python/caffe/io.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/caffe/io.py b/python/caffe/io.py index bc1a895f977..c3179dc1f5b 100644 --- a/python/caffe/io.py +++ b/python/caffe/io.py @@ -256,10 +256,10 @@ def set_mean(self, in_, mean): raise ValueError('Mean shape invalid') 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 = 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.')