def __init__(self, l_in, bgr_mean=np.array([103.939, 116.779, 123.68]),
data_format='bc01', **kwargs):
"""A Layer to normalize and convert images from RGB to BGR
This layer converts images from RGB to BGR to adapt to Caffe
that uses OpenCV, which uses BGR. It also subtracts the
per-pixel mean. From:
https://github.com/fvisin/reseg/blob/variable_size_images/vgg16.py
Parameters
----------
l_in : :class:``lasagne.layers.Layer``
The incoming layer, typically an
:class:``lasagne.layers.InputLayer``
bgr_mean : iterable of 3 ints
The mean of each channel. By default, the ImageNet
mean values are used.
data_format : str
The format of l_in, either `b01c` (batch, rows, cols,
channels) or `bc01` (batch, channels, rows, cols)
"""
super(RGBtoBGRLayer, self).__init__(l_in, **kwargs)
assert data_format in ['bc01', 'b01c']
self.l_in = l_in
floatX = theano.config.floatX
self.bgr_mean = bgr_mean.astype(floatX)
self.data_format = data_format
评论列表
文章目录