(self, config_path)
| 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) |
no test coverage detected