deepdream.py 文件源码

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

项目:DeepArt 作者: jiriroz 项目源码 文件源码
def __init__(self):
        """Loading DNN model."""
        model_path = '/home/jiri/caffe/models/bvlc_googlenet/'
        net_fn   = model_path + 'deploy.prototxt'
        param_fn = model_path + 'bvlc_googlenet.caffemodel'
        #model_path = '/home/jiri/caffe/models/oxford102/'
        #net_fn   = model_path + 'deploy.prototxt'
        #param_fn = model_path + 'oxford102.caffemodel'

        # Patching model to be able to compute gradients.
        # Note that you can also manually add "force_backward: true" line
        #to "deploy.prototxt".
        model = caffe.io.caffe_pb2.NetParameter()
        text_format.Merge(open(net_fn).read(), model)
        model.force_backward = True
        open('tmp.prototxt', 'w').write(str(model))

        # ImageNet mean, training set dependent
        mean =  np.float32([104.0, 116.0, 122.0])
        # the reference model has channels in BGR order instead of RGB
        chann_sw = (2,1,0)
        self.net = caffe.Classifier('tmp.prototxt', param_fn, mean=mean, channel_swap=chann_sw)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号