MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / load_caffe

Function load_caffe

tensorpack/utils/loadcaffe.py:96–114  ·  view source on GitHub ↗

Load a caffe model. You must be able to ``import caffe`` to use this function. Args: model_desc (str): path to caffe model description file (.prototxt). model_file (str): path to caffe model parameter file (.caffemodel). Returns: dict: the parameters.

(model_desc, model_file)

Source from the content-addressed store, hash-verified

94
95
96def load_caffe(model_desc, model_file):
97 """
98 Load a caffe model. You must be able to ``import caffe`` to use this
99 function.
100
101 Args:
102 model_desc (str): path to caffe model description file (.prototxt).
103 model_file (str): path to caffe model parameter file (.caffemodel).
104 Returns:
105 dict: the parameters.
106 """
107 with change_env('GLOG_minloglevel', '2'):
108 import caffe
109 caffe.set_mode_cpu()
110 net = caffe.Net(model_desc, model_file, caffe.TEST)
111 param_dict = CaffeLayerProcessor(net).process()
112 logger.info("Model loaded from caffe. Params: " +
113 ", ".join(sorted(param_dict.keys())))
114 return param_dict
115
116
117def get_caffe_pb():

Callers 1

loadcaffe.pyFile · 0.85

Calls 4

change_envFunction · 0.85
CaffeLayerProcessorClass · 0.85
joinMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected