MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / __init__

Method __init__

detectron2/export/caffe2_inference.py:26–46  ·  view source on GitHub ↗
(self, predict_net, init_net)

Source from the content-addressed store, hash-verified

24 _ids = count(0)
25
26 def __init__(self, predict_net, init_net):
27 logger.info(f"Initializing ProtobufModel for: {predict_net.name} ...")
28 super().__init__()
29 assert isinstance(predict_net, caffe2_pb2.NetDef)
30 assert isinstance(init_net, caffe2_pb2.NetDef)
31 # create unique temporary workspace for each instance
32 self.ws_name = "__tmp_ProtobufModel_{}__".format(next(self._ids))
33 self.net = core.Net(predict_net)
34
35 logger.info("Running init_net once to fill the parameters ...")
36 with ScopedWS(self.ws_name, is_reset=True, is_cleanup=False) as ws:
37 ws.RunNetOnce(init_net)
38 uninitialized_external_input = []
39 for blob in self.net.Proto().external_input:
40 if blob not in ws.Blobs():
41 uninitialized_external_input.append(blob)
42 ws.CreateBlob(blob)
43 ws.CreateNet(self.net)
44
45 self._error_msgs = set()
46 self._input_blobs = uninitialized_external_input
47
48 def _infer_output_devices(self, inputs):
49 """

Callers 1

__init__Method · 0.45

Calls 1

ScopedWSClass · 0.85

Tested by

no test coverage detected