summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrzemysław Dolata <snowball91b@gmail.com>2017-11-06 15:42:07 +0100
committerGitHub <noreply@github.com>2017-11-06 15:42:07 +0100
commit613e13bef77d4f9ecda21f33b7c66a4758e1c5c9 (patch)
tree526acc8927fd51187aa925c75cfbf94f298fe257
parentbe6a5c42c4a55b918aa1bedc68e9238014c2b5dd (diff)
parentbfc638d502b8b991e6ef5aaaa1946049312e6336 (diff)
downloadcaffe-613e13bef77d4f9ecda21f33b7c66a4758e1c5c9.tar.gz
caffe-613e13bef77d4f9ecda21f33b7c66a4758e1c5c9.tar.bz2
caffe-613e13bef77d4f9ecda21f33b7c66a4758e1c5c9.zip
Merge pull request #5719 from leemgs/upstream-issue5718
Fix: mean shape incompatible with input shape
-rw-r--r--python/caffe/io.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/caffe/io.py b/python/caffe/io.py
index d61f765b..ed4b3bef 100644
--- a/python/caffe/io.py
+++ b/python/caffe/io.py
@@ -256,7 +256,12 @@ class Transformer:
if len(ms) != 3:
raise ValueError('Mean shape invalid')
if ms != self.inputs[in_][1:]:
- raise ValueError('Mean shape incompatible with input shape.')
+ 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
self.mean[in_] = mean
def set_input_scale(self, in_, scale):