caffe_scope.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:DAVIS-2016-Chanllege-Solution 作者: tangyuhao 项目源码 文件源码
def load(self, filename, bgr_to_rgb=True):
        """Load weights from a .caffemodel file and initialize counters.

        Params:
          filename: caffemodel file.
        """
        print('Loading Caffe file:', filename)
        caffemodel_params = caffe_pb2.NetParameter()
        caffemodel_str = open(filename, 'rb').read()
        caffemodel_params.ParseFromString(caffemodel_str)
        self.caffe_layers = caffemodel_params.layer

        # Layers collection.
        self.layers['convolution'] = [i for i, l in enumerate(self.caffe_layers)
                                      if l.type == 'Convolution']
        self.layers['l2_normalization'] = [i for i, l in enumerate(self.caffe_layers)
                                           if l.type == 'Normalize']
        # BGR to RGB convertion. Tries to find the first convolution with 3
        # and exchange parameters.
        if bgr_to_rgb:
            self.bgr_to_rgb = 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号