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

Method _test_model

tests/test_export_caffe2.py:26–45  ·  view source on GitHub ↗
(self, config_path, device="cpu")

Source from the content-addressed store, hash-verified

24 setup_logger()
25
26 def _test_model(self, config_path, device="cpu"):
27 # requires extra dependencies
28 from detectron2.export import Caffe2Model, add_export_config, export_caffe2_model
29
30 cfg = get_cfg()
31 cfg.merge_from_file(model_zoo.get_config_file(config_path))
32 cfg = add_export_config(cfg)
33 cfg.MODEL.DEVICE = device
34
35 model = build_model(cfg)
36 DetectionCheckpointer(model).load(model_zoo.get_checkpoint_url(config_path))
37
38 inputs = [{"image": self._get_test_image()}]
39 c2_model = export_caffe2_model(cfg, model, copy.deepcopy(inputs))
40
41 with tempfile.TemporaryDirectory(prefix="detectron2_unittest") as d:
42 c2_model.save_protobuf(d)
43 c2_model.save_graph(os.path.join(d, "test.svg"), inputs=copy.deepcopy(inputs))
44 c2_model = Caffe2Model.load_protobuf(d)
45 c2_model(inputs)[0]["instances"]
46
47 def _get_test_image(self):
48 try:

Callers 4

testMaskRCNNMethod · 0.95
testMaskRCNNGPUMethod · 0.95
testRetinaNetMethod · 0.95
testPanopticFPNMethod · 0.95

Calls 11

_get_test_imageMethod · 0.95
get_cfgFunction · 0.90
add_export_configFunction · 0.90
build_modelFunction · 0.90
export_caffe2_modelFunction · 0.90
merge_from_fileMethod · 0.80
loadMethod · 0.80
save_protobufMethod · 0.80
save_graphMethod · 0.80
load_protobufMethod · 0.80

Tested by

no test coverage detected