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

Function get_caffe_pb

tensorpack/utils/loadcaffe.py:117–148  ·  view source on GitHub ↗

Get caffe protobuf. Returns: The imported caffe protobuf module.

()

Source from the content-addressed store, hash-verified

115
116
117def get_caffe_pb():
118 """
119 Get caffe protobuf.
120
121 Returns:
122 The imported caffe protobuf module.
123 """
124 dir = get_dataset_path('caffe')
125 caffe_pb_file = os.path.join(dir, 'caffe_pb2.py')
126 if not os.path.isfile(caffe_pb_file):
127 download(CAFFE_PROTO_URL, dir)
128 assert os.path.isfile(os.path.join(dir, 'caffe.proto'))
129
130 cmd = "protoc --version"
131 version, ret = subproc_call(cmd, timeout=3)
132 if ret != 0:
133 sys.exit(1)
134 try:
135 version = version.decode('utf-8')
136 version = float('.'.join(version.split(' ')[1].split('.')[:2]))
137 assert version >= 2.7, "Require protoc>=2.7 for Python3"
138 except Exception:
139 logger.exception("protoc --version gives: " + str(version))
140 raise
141
142 cmd = 'cd {} && protoc caffe.proto --python_out .'.format(dir)
143 ret = os.system(cmd)
144 assert ret == 0, \
145 "Command `{}` failed!".format(cmd)
146 assert os.path.isfile(caffe_pb_file), caffe_pb_file
147 import imp
148 return imp.load_source('caffepb', caffe_pb_file)
149
150
151if __name__ == '__main__':

Callers 2

CaffeLMDBFunction · 0.85
get_per_pixel_meanMethod · 0.85

Calls 5

get_dataset_pathFunction · 0.85
downloadFunction · 0.85
subproc_callFunction · 0.85
joinMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected