Skip to content

Commit

Permalink
Fix: mean shape in compatible with input shape
Browse files Browse the repository at this point in the history
  • Loading branch information
leemgs committed Nov 2, 2017
1 parent 4efdf7e commit bfc638d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/caffe/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ 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.')
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):
Expand Down

0 comments on commit bfc638d

Please sign in to comment.