MCPcopy
hub / github.com/hustvl/Vim / _test_rcnn_model

Method _test_rcnn_model

det/tests/test_export_torchscript.py:53–75  ·  view source on GitHub ↗
(self, config_path)

Source from the content-addressed store, hash-verified

51 self._test_retinanet_model("COCO-Detection/retinanet_R_50_FPN_3x.yaml")
52
53 def _test_rcnn_model(self, config_path):
54 model = model_zoo.get(config_path, trained=True)
55 model.eval()
56
57 fields = {
58 "proposal_boxes": Boxes,
59 "objectness_logits": Tensor,
60 "pred_boxes": Boxes,
61 "scores": Tensor,
62 "pred_classes": Tensor,
63 "pred_masks": Tensor,
64 }
65 script_model = scripting_with_instances(model, fields)
66 script_model = reload_script_model(script_model)
67
68 # Test that batch inference with different shapes are supported
69 image = get_sample_coco_image()
70 small_image = nn.functional.interpolate(image, scale_factor=0.5)
71 inputs = [{"image": image}, {"image": small_image}]
72 with torch.no_grad():
73 instance = model.inference(inputs, do_postprocess=False)[0]
74 scripted_instance = script_model.inference(inputs, do_postprocess=False)[0]
75 assert_instances_allclose(instance, scripted_instance)
76
77 def _test_retinanet_model(self, config_path):
78 model = model_zoo.get(config_path, trained=True)

Callers 2

testMaskRCNNFPNMethod · 0.95
testMaskRCNNC4Method · 0.95

Calls 6

scripting_with_instancesFunction · 0.90
reload_script_modelFunction · 0.90
get_sample_coco_imageFunction · 0.90
getMethod · 0.45
inferenceMethod · 0.45

Tested by

no test coverage detected