| 45 | c2_model(inputs)[0]["instances"] |
| 46 | |
| 47 | def _get_test_image(self): |
| 48 | try: |
| 49 | file_name = DatasetCatalog.get("coco_2017_train")[0]["file_name"] |
| 50 | assert PathManager.exists(file_name) |
| 51 | except Exception: |
| 52 | self.skipTest("COCO dataset not available.") |
| 53 | |
| 54 | with PathManager.open(file_name, "rb") as f: |
| 55 | buf = f.read() |
| 56 | img = cv2.imdecode(np.frombuffer(buf, dtype=np.uint8), cv2.IMREAD_COLOR) |
| 57 | assert img is not None, file_name |
| 58 | return torch.from_numpy(img.transpose(2, 0, 1)) |
| 59 | |
| 60 | def testMaskRCNN(self): |
| 61 | self._test_model("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml") |